Send User-Agent of version/os/arch on update check

pull/84/head
Noah 2022-01-16 18:33:27 -08:00
parent 05b97df846
commit d67c1cfcf1
4 changed files with 48 additions and 6 deletions

View File

@ -1,15 +1,34 @@
package branding
import (
"fmt"
"runtime"
)
// Constants for branding and version information.
const (
AppName = "Sketchy Maze"
Summary = "A drawing-based maze game"
Version = "0.10.1"
Version = "0.10.2"
Website = "https://www.sketchymaze.com"
Copyright = "2021 Noah Petherbridge"
Copyright = "2022 Noah Petherbridge"
Byline = "a game by Noah Petherbridge."
// Update check URL
UpdateCheckJSON = "https://download.sketchymaze.com/version.json"
GuidebookURL = "https://www.sketchymaze.com/guidebook/"
)
// UserAgent controls the HTTP User-Agent header when the game checks
// for updates on startup, to collect basic statistics of which game
// versions are out in the wild. Only static data (the --version string)
// about version, architecture, build number is included but no user
// specific data.
func UserAgent() string {
return fmt.Sprintf("%s v%s on %s/%s",
AppName,
Version,
runtime.GOOS,
runtime.GOARCH,
)
}

View File

@ -47,6 +47,7 @@ type MainScene struct {
updateInfo updater.VersionInfo
// Lazy scroll variables. See LoopLazyScroll().
PauseLazyScroll bool // exported for dev console
lazyScrollBounce bool
lazyScrollTrajectory render.Point
lazyScrollLastValue render.Point
@ -379,6 +380,21 @@ func (s *MainScene) Resized(width, height int) {
})
}
// ButtonFrame returns the main button frame.
func (s *MainScene) ButtonFrame() *ui.Frame {
return s.frame
}
// LabelVersion returns the version widget.
func (s *MainScene) LabelVersion() *ui.Label {
return s.labelVersion
}
// LabelHint returns the hint widget.
func (s *MainScene) LabelHint() *ui.Label {
return s.labelHint
}
// Move things into position for the main menu. This function arranges
// the Title, Subtitle, Buttons, etc. into screen relative positions every
// tick. This function sets their 'default' values, but if the window is
@ -459,6 +475,10 @@ func (s *MainScene) positionMenuLandscape(d *Doodle) {
// LoopLazyScroll gently scrolls the title screen demo level, called each Loop.
func (s *MainScene) LoopLazyScroll() {
if s.PauseLazyScroll {
return
}
// The v1 basic sauce algorithm:
// 1. We scroll diagonally downwards and rightwards.
// 2. When we scroll downwards far enough, we change direction.

View File

@ -7,7 +7,6 @@ import (
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/level"
"git.kirsle.net/apps/doodle/pkg/log"
"git.kirsle.net/apps/doodle/pkg/shmem"
"git.kirsle.net/apps/doodle/pkg/uix"
"git.kirsle.net/go/render"
@ -222,7 +221,6 @@ func PreloadAllChunkBitmaps(chunker *level.Chunker) {
for {
remaining := chunker.PrerenderN(10)
log.Debug("Remain: %d", remaining)
// Set the load screen progress % based on number of chunks to render.
if loadChunksTarget > 0 {

View File

@ -72,9 +72,14 @@ func Check() (VersionInfo, error) {
Timeout: 10 * time.Second,
}
log.Debug("Checking for app updates")
req, err := http.NewRequest("GET", branding.UpdateCheckJSON, nil)
if err != nil {
return result, fmt.Errorf("updater.Check: HTTP error getting %s: %s", branding.UpdateCheckJSON, err)
}
req.Header.Add("User-Agent", branding.UserAgent())
resp, err := client.Get(branding.UpdateCheckJSON)
log.Debug("Checking for app updates")
resp, err := client.Do(req)
if err != nil {
return result, fmt.Errorf("updater.Check: HTTP error: %s", err)
}