Add Branding Module for Centralized Game Info

* Moves the game's Title, Summary and Version into pkg/branding where it
  is centrally controlled.
physics
Noah 2019-06-23 17:52:48 -07:00
parent 99eab19c5b
commit 1150d6d3e9
11 changed files with 34 additions and 16 deletions

View File

@ -12,7 +12,7 @@ import (
"image/png"
"git.kirsle.net/apps/doodle/lib/render"
doodle "git.kirsle.net/apps/doodle/pkg"
"git.kirsle.net/apps/doodle/pkg/branding"
"git.kirsle.net/apps/doodle/pkg/doodads"
"git.kirsle.net/apps/doodle/pkg/level"
"git.kirsle.net/apps/doodle/pkg/log"
@ -146,7 +146,7 @@ func imageToDrawing(c *cli.Context, chroma render.Color, inputFiles []string, ou
case extDoodad:
log.Info("Output is a Doodad file (chunk size %d): %s", chunkSize, outputFile)
doodad := doodads.New(chunkSize)
doodad.GameVersion = doodle.Version
doodad.GameVersion = branding.Version
doodad.Title = c.String("title")
if doodad.Title == "" {
doodad.Title = "Converted Doodad"
@ -184,7 +184,7 @@ func imageToDrawing(c *cli.Context, chroma render.Color, inputFiles []string, ou
}
lvl := level.New()
lvl.GameVersion = doodle.Version
lvl.GameVersion = branding.Version
lvl.Title = c.String("title")
if lvl.Title == "" {
lvl.Title = "Converted Level"

View File

@ -9,8 +9,8 @@ import (
"time"
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
doodle "git.kirsle.net/apps/doodle/pkg"
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/branding"
"github.com/urfave/cli"
)
@ -37,7 +37,7 @@ func main() {
}
app.Version = fmt.Sprintf("%s build %s%s. Built on %s",
doodle.Version,
branding.Version,
Build,
freeLabel,
BuildDate,

View File

@ -11,6 +11,7 @@ import (
"git.kirsle.net/apps/doodle/lib/render/sdl"
doodle "git.kirsle.net/apps/doodle/pkg"
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/branding"
"github.com/urfave/cli"
_ "image/png"
@ -37,7 +38,7 @@ func main() {
app := cli.NewApp()
app.Name = "doodle"
app.Usage = "command line interface for Doodle"
app.Usage = fmt.Sprintf("%s - %s", branding.AppName, branding.Summary)
var freeLabel string
if balance.FreeVersion {
@ -45,7 +46,7 @@ func main() {
}
app.Version = fmt.Sprintf("%s build %s%s. Built on %s",
doodle.Version,
branding.Version,
Build,
freeLabel,
BuildDate,
@ -74,7 +75,7 @@ func main() {
// SDL engine.
engine := sdl.New(
"Doodle v"+doodle.Version,
fmt.Sprintf("%s v%s", branding.AppName, branding.Version),
balance.Width,
balance.Height,
)

8
pkg/branding/branding.go Normal file
View File

@ -0,0 +1,8 @@
package branding
// Constants for branding and version information.
const (
AppName = "Project: Doodle"
Summary = "A drawing-based maze game"
Version = "0.0.8-alpha"
)

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"strings"
"git.kirsle.net/apps/doodle/pkg/branding"
"git.kirsle.net/apps/doodle/pkg/enum"
"git.kirsle.net/apps/doodle/pkg/filesystem"
"git.kirsle.net/apps/doodle/pkg/log"
@ -62,6 +63,10 @@ func (d *Doodad) WriteFile(filename string) error {
filename += enum.DoodadExt
}
// Set the version information.
d.Version = 1
d.GameVersion = branding.Version
// bin, err := m.ToBinary()
bin, err := d.ToJSON()
if err != nil {

View File

@ -14,9 +14,6 @@ import (
)
const (
// Version number.
Version = "0.0.7-alpha"
// TargetFPS is the frame rate to cap the game to.
TargetFPS = 1000 / 60 // 60 FPS

View File

@ -257,8 +257,7 @@ func (s *EditorScene) SaveDoodad(filename string) error {
// Save it to their profile directory.
filename = userdir.DoodadPath(filename)
log.Info("Write Doodad: %s", filename)
err := d.WriteJSON(filename)
return err
return d.WriteFile(filename)
}
// Destroy the scene.

View File

@ -9,6 +9,7 @@ import (
"git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/branding"
"git.kirsle.net/apps/doodle/pkg/doodads"
"git.kirsle.net/apps/doodle/pkg/enum"
"git.kirsle.net/apps/doodle/pkg/level"
@ -564,7 +565,7 @@ func (u *EditorUI) SetupStatusBar(d *Doodle) *ui.Frame {
shareware = " (shareware)"
}
extraLabel := ui.NewLabel(ui.Label{
Text: "Doodle v" + Version + shareware,
Text: fmt.Sprintf("%s v%s%s", branding.AppName, branding.Version, shareware),
Font: balance.StatusFont,
})
extraLabel.Configure(ui.Config{

View File

@ -7,6 +7,7 @@ import (
"git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/branding"
"git.kirsle.net/apps/doodle/pkg/log"
)
@ -258,7 +259,7 @@ func (s *GUITestScene) Draw(d *Doodle) error {
d.Engine.Clear(render.White)
label := ui.NewLabel(ui.Label{
Text: "GUITest Doodle v" + Version,
Text: fmt.Sprintf("GUITest %s v%s", branding.AppName, branding.Version),
Font: render.Text{
Size: 26,
Color: render.Pink,

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"strings"
"git.kirsle.net/apps/doodle/pkg/branding"
"git.kirsle.net/apps/doodle/pkg/enum"
"git.kirsle.net/apps/doodle/pkg/filesystem"
"git.kirsle.net/apps/doodle/pkg/log"
@ -47,6 +48,10 @@ func (m *Level) WriteFile(filename string) error {
filename += enum.LevelExt
}
// Set the version information.
m.Version = 1
m.GameVersion = branding.Version
// bin, err := m.ToBinary()
bin, err := m.ToJSON()
if err != nil {

View File

@ -5,6 +5,7 @@ import (
"git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/branding"
)
// MainScene implements the main menu of Doodle.
@ -67,7 +68,7 @@ func (s *MainScene) Draw(d *Doodle) error {
d.Engine.Clear(render.White)
label := ui.NewLabel(ui.Label{
Text: "Doodle v" + Version,
Text: branding.AppName,
Font: render.Text{
Size: 26,
Color: render.Pink,