Shareware Build Flags
* Build the app with -tags="shareware" to compile the free/shareware build of the game. * `make build-free` compiles both binaries to the bin/ folder in shareware mode. * The constant balance.FreeVersion is true in the shareware build and all functionality related to the Doodad Editor UI mode is disabled in this build mode.
This commit is contained in:
parent
52a2545692
commit
693664db6c
7
Makefile
7
Makefile
|
@ -20,6 +20,13 @@ build:
|
|||
go build $(LDFLAGS) -i -o bin/doodle cmd/doodle/main.go
|
||||
go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/main.go
|
||||
|
||||
# `make build-free` to build the binary in free mode.
|
||||
.PHONY: build-free
|
||||
build-free:
|
||||
gofmt -w .
|
||||
go build $(LDFLAGS) -tags="shareware" -i -o bin/doodle cmd/doodle/main.go
|
||||
go build $(LDFLAGS) -tags="shareware" -i -o bin/doodad cmd/doodad/main.go
|
||||
|
||||
# `make mingw` to cross-compile a Windows binary with mingw.
|
||||
.PHONY: mingw
|
||||
mingw:
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
|
||||
doodle "git.kirsle.net/apps/doodle/pkg"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -29,9 +30,16 @@ func main() {
|
|||
app := cli.NewApp()
|
||||
app.Name = "doodad"
|
||||
app.Usage = "command line interface for Doodle"
|
||||
app.Version = fmt.Sprintf("%s build %s. Built on %s",
|
||||
|
||||
var freeLabel string
|
||||
if balance.FreeVersion {
|
||||
freeLabel = " (shareware)"
|
||||
}
|
||||
|
||||
app.Version = fmt.Sprintf("%s build %s%s. Built on %s",
|
||||
doodle.Version,
|
||||
Build,
|
||||
freeLabel,
|
||||
BuildDate,
|
||||
)
|
||||
|
||||
|
|
|
@ -34,9 +34,16 @@ func main() {
|
|||
app := cli.NewApp()
|
||||
app.Name = "doodle"
|
||||
app.Usage = "command line interface for Doodle"
|
||||
app.Version = fmt.Sprintf("%s build %s. Built on %s",
|
||||
|
||||
var freeLabel string
|
||||
if balance.FreeVersion {
|
||||
freeLabel = " (shareware)"
|
||||
}
|
||||
|
||||
app.Version = fmt.Sprintf("%s build %s%s. Built on %s",
|
||||
doodle.Version,
|
||||
Build,
|
||||
freeLabel,
|
||||
BuildDate,
|
||||
)
|
||||
|
||||
|
|
29
docs/Release Modes.md
Normal file
29
docs/Release Modes.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Release Modes
|
||||
|
||||
Verifying your release mode:
|
||||
|
||||
```bash
|
||||
# Full release version
|
||||
$ doodle -version
|
||||
doodle version 0.0.7 build 52a2545. Built on 2019-04-19T17:16:19-07:00
|
||||
|
||||
# Shareware version includes the word "(shareware)" after the build number.
|
||||
$ doodle -version
|
||||
doodle version 0.0.7 build 52a2545 (shareware). Built on 2019-04-19T17:16:19-07:00
|
||||
```
|
||||
|
||||
## Shareware
|
||||
|
||||
* `make build-free` to build the shareware binaries to the bin/ folder.
|
||||
|
||||
The shareware (free) version of the game has the following restrictions:
|
||||
|
||||
* No Doodad Editor Mode available.
|
||||
* "New Doodad" button hidden from UI
|
||||
* d.NewDoodad() function errors out
|
||||
* The dev console `edit <file>` command won't edit a doodad.
|
||||
|
||||
## Full Version
|
||||
|
||||
The full release of the game has no restrictions and includes the Doodad Editor
|
||||
Mode.
|
6
pkg/balance/flag_free.go
Normal file
6
pkg/balance/flag_free.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
// +build shareware
|
||||
|
||||
package balance
|
||||
|
||||
// FreeVersion is true in the free version of the game.
|
||||
const FreeVersion = true
|
6
pkg/balance/flag_paid.go
Normal file
6
pkg/balance/flag_paid.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
// +build !shareware
|
||||
|
||||
package balance
|
||||
|
||||
// FreeVersion is true in the free version of the game.
|
||||
const FreeVersion = false
|
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
// Command is a parsed shell command.
|
||||
|
@ -60,7 +61,7 @@ func (c Command) Run(d *Doodle) error {
|
|||
return nil
|
||||
case "eval":
|
||||
case "$":
|
||||
out, err := d.shell.js.Run(c.ArgsLiteral)
|
||||
out, err := c.RunScript(d, c.ArgsLiteral)
|
||||
d.Flash("%+v", out)
|
||||
return err
|
||||
case "repl":
|
||||
|
@ -163,8 +164,7 @@ func (c Command) Edit(d *Doodle) error {
|
|||
|
||||
filename := c.Args[0]
|
||||
d.shell.Write("Editing file: " + filename)
|
||||
d.EditFile(filename)
|
||||
return nil
|
||||
return d.EditFile(filename)
|
||||
}
|
||||
|
||||
// Play a map.
|
||||
|
@ -220,6 +220,17 @@ func (c Command) BoolProp(d *Doodle) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RunScript evaluates some JavaScript code safely.
|
||||
func (c Command) RunScript(d *Doodle, code interface{}) (otto.Value, error) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
d.Flash("Panic: %s", err)
|
||||
}
|
||||
}()
|
||||
out, err := d.shell.js.Run(code)
|
||||
return out, err
|
||||
}
|
||||
|
||||
// Default command.
|
||||
func (c Command) Default() error {
|
||||
return fmt.Errorf("%s: command not found. Try `help` for help",
|
||||
|
|
|
@ -48,7 +48,5 @@ func (d *Doodle) EditFile(filename string) error {
|
|||
}
|
||||
}
|
||||
|
||||
d.EditDrawing(absPath)
|
||||
|
||||
return nil
|
||||
return d.EditDrawing(absPath)
|
||||
}
|
||||
|
|
|
@ -186,6 +186,11 @@ func (d *Doodle) NewMap() {
|
|||
|
||||
// NewDoodad loads a new Doodad in Edit Mode.
|
||||
func (d *Doodle) NewDoodad(size int) {
|
||||
if balance.FreeVersion {
|
||||
d.Flash("Doodad editor is not available in your version of the game.")
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("Starting a new doodad")
|
||||
scene := &EditorScene{
|
||||
DrawingType: enum.DoodadDrawing,
|
||||
|
@ -214,6 +219,9 @@ func (d *Doodle) EditDrawing(filename string) error {
|
|||
log.Info("is a Level type")
|
||||
scene.DrawingType = enum.LevelDrawing
|
||||
case "doodad":
|
||||
if balance.FreeVersion {
|
||||
return fmt.Errorf("Doodad editor not supported in your version of the game")
|
||||
}
|
||||
scene.DrawingType = enum.DoodadDrawing
|
||||
default:
|
||||
return fmt.Errorf("file extension '%s' doesn't indicate its drawing type", ext)
|
||||
|
|
|
@ -399,7 +399,7 @@ func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.Frame {
|
|||
d.Prompt("Open filename>", func(answer string) {
|
||||
if answer != "" {
|
||||
if err := d.EditFile(answer); err != nil {
|
||||
d.Flash("File not found: %s", answer)
|
||||
d.Flash(err.Error())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -408,6 +408,12 @@ func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.Frame {
|
|||
}
|
||||
|
||||
for _, btn := range buttons {
|
||||
if balance.FreeVersion {
|
||||
if btn.Text == "New Doodad" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
w := ui.NewButton(btn.Text, ui.NewLabel(ui.Label{
|
||||
Text: btn.Text,
|
||||
Font: balance.MenuFont,
|
||||
|
|
Loading…
Reference in New Issue
Block a user