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/doodle cmd/doodle/main.go
|
||||||
go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/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.
|
# `make mingw` to cross-compile a Windows binary with mingw.
|
||||||
.PHONY: mingw
|
.PHONY: mingw
|
||||||
mingw:
|
mingw:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
|
"git.kirsle.net/apps/doodle/cmd/doodad/commands"
|
||||||
doodle "git.kirsle.net/apps/doodle/pkg"
|
doodle "git.kirsle.net/apps/doodle/pkg"
|
||||||
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,9 +30,16 @@ func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "doodad"
|
app.Name = "doodad"
|
||||||
app.Usage = "command line interface for 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,
|
doodle.Version,
|
||||||
Build,
|
Build,
|
||||||
|
freeLabel,
|
||||||
BuildDate,
|
BuildDate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,16 @@ func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "doodle"
|
app.Name = "doodle"
|
||||||
app.Usage = "command line interface for 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,
|
doodle.Version,
|
||||||
Build,
|
Build,
|
||||||
|
freeLabel,
|
||||||
BuildDate,
|
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"
|
"strconv"
|
||||||
|
|
||||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||||
|
"github.com/robertkrimen/otto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command is a parsed shell command.
|
// Command is a parsed shell command.
|
||||||
|
@ -60,7 +61,7 @@ func (c Command) Run(d *Doodle) error {
|
||||||
return nil
|
return nil
|
||||||
case "eval":
|
case "eval":
|
||||||
case "$":
|
case "$":
|
||||||
out, err := d.shell.js.Run(c.ArgsLiteral)
|
out, err := c.RunScript(d, c.ArgsLiteral)
|
||||||
d.Flash("%+v", out)
|
d.Flash("%+v", out)
|
||||||
return err
|
return err
|
||||||
case "repl":
|
case "repl":
|
||||||
|
@ -163,8 +164,7 @@ func (c Command) Edit(d *Doodle) error {
|
||||||
|
|
||||||
filename := c.Args[0]
|
filename := c.Args[0]
|
||||||
d.shell.Write("Editing file: " + filename)
|
d.shell.Write("Editing file: " + filename)
|
||||||
d.EditFile(filename)
|
return d.EditFile(filename)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play a map.
|
// Play a map.
|
||||||
|
@ -220,6 +220,17 @@ func (c Command) BoolProp(d *Doodle) error {
|
||||||
return nil
|
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.
|
// Default command.
|
||||||
func (c Command) Default() error {
|
func (c Command) Default() error {
|
||||||
return fmt.Errorf("%s: command not found. Try `help` for help",
|
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 d.EditDrawing(absPath)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,11 @@ func (d *Doodle) NewMap() {
|
||||||
|
|
||||||
// NewDoodad loads a new Doodad in Edit Mode.
|
// NewDoodad loads a new Doodad in Edit Mode.
|
||||||
func (d *Doodle) NewDoodad(size int) {
|
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")
|
log.Info("Starting a new doodad")
|
||||||
scene := &EditorScene{
|
scene := &EditorScene{
|
||||||
DrawingType: enum.DoodadDrawing,
|
DrawingType: enum.DoodadDrawing,
|
||||||
|
@ -214,6 +219,9 @@ func (d *Doodle) EditDrawing(filename string) error {
|
||||||
log.Info("is a Level type")
|
log.Info("is a Level type")
|
||||||
scene.DrawingType = enum.LevelDrawing
|
scene.DrawingType = enum.LevelDrawing
|
||||||
case "doodad":
|
case "doodad":
|
||||||
|
if balance.FreeVersion {
|
||||||
|
return fmt.Errorf("Doodad editor not supported in your version of the game")
|
||||||
|
}
|
||||||
scene.DrawingType = enum.DoodadDrawing
|
scene.DrawingType = enum.DoodadDrawing
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("file extension '%s' doesn't indicate its drawing type", ext)
|
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) {
|
d.Prompt("Open filename>", func(answer string) {
|
||||||
if answer != "" {
|
if answer != "" {
|
||||||
if err := d.EditFile(answer); err != nil {
|
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 {
|
for _, btn := range buttons {
|
||||||
|
if balance.FreeVersion {
|
||||||
|
if btn.Text == "New Doodad" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w := ui.NewButton(btn.Text, ui.NewLabel(ui.Label{
|
w := ui.NewButton(btn.Text, ui.NewLabel(ui.Label{
|
||||||
Text: btn.Text,
|
Text: btn.Text,
|
||||||
Font: balance.MenuFont,
|
Font: balance.MenuFont,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user