Diverge Free vs. Paid Features
* Free (shareware) versions of the game will not be able to Publish Levels (attach custom doodads to the level file) and they will not be able to load a level which relies on embedded doodads. * The UI for the Publish Level window is still available, but clicking on the confirm button will just open the Register (License) window. * When loading a level containing embedded doodads: if some can't load because they're embedded and you're using the free version of the game, the error message is customized to reflect that.
This commit is contained in:
parent
0449737607
commit
dce32ea14b
9
go.mod
9
go.mod
|
@ -7,6 +7,7 @@ require (
|
|||
git.kirsle.net/go/log v0.0.0-20200902035305-70ac2848949b
|
||||
git.kirsle.net/go/render v0.0.0-20210104010442-b4a1979a8ba1
|
||||
git.kirsle.net/go/ui v0.0.0-20200710023146-e2a561fbd04c
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/gen2brain/dlgs v0.0.0-20210406143744-f512297a108e
|
||||
github.com/google/uuid v1.1.2
|
||||
|
@ -24,5 +25,13 @@ require (
|
|||
)
|
||||
|
||||
// replace git.kirsle.net/go/render => /home/kirsle/SketchyMaze/deps/render
|
||||
|
||||
// replace git.kirsle.net/go/ui => /home/kirsle/SketchyMaze/deps/ui
|
||||
|
||||
// replace git.kirsle.net/go/audio => /home/kirsle/SketchyMaze/deps/audio
|
||||
|
||||
// replace git.kirsle.net/go/render => /run/build/doodle/deps/render
|
||||
|
||||
// replace git.kirsle.net/go/ui => /run/build/doodle/deps/ui
|
||||
|
||||
// replace git.kirsle.net/go/audio => /run/build/doodle/deps/audio
|
||||
|
|
1
go.sum
1
go.sum
|
@ -37,6 +37,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng
|
|||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
|
|
|
@ -4,7 +4,7 @@ package branding
|
|||
const (
|
||||
AppName = "Sketchy Maze"
|
||||
Summary = "A drawing-based maze game"
|
||||
Version = "0.6.1"
|
||||
Version = "0.7.0"
|
||||
Website = "https://www.sketchymaze.com"
|
||||
Copyright = "2021 Noah Petherbridge"
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"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/license"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/apps/doodle/pkg/wasm"
|
||||
|
@ -118,6 +119,9 @@ func ListBuiltin() ([]string, error) {
|
|||
func LoadFromEmbeddable(filename string, fs filesystem.Embeddable) (*Doodad, error) {
|
||||
if bin, err := fs.GetFile(balance.EmbeddedDoodadsBasePath + filename); err == nil {
|
||||
log.Debug("doodads.LoadFromEmbeddable: found %s", filename)
|
||||
if !license.IsRegistered() {
|
||||
return nil, license.ErrRegisteredFeature
|
||||
}
|
||||
return Deserialize(filename, bin)
|
||||
}
|
||||
return LoadFile(filename)
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/keybind"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/license"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/modal"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
|
@ -279,7 +280,13 @@ func (s *EditorScene) LoadLevel(filename string) error {
|
|||
|
||||
log.Info("Installing %d actors into the drawing", len(level.Actors))
|
||||
if err := s.UI.Canvas.InstallActors(level.Actors); err != nil {
|
||||
modal.Alert("This level references some doodads that were not found:\n\n%s", err).WithTitle("Level Errors")
|
||||
summary := "This level references some doodads that were not found:"
|
||||
if strings.Contains(err.Error(), license.ErrRegisteredFeature.Error()) {
|
||||
summary = "This level contains embedded doodads, but this is not\n" +
|
||||
"available in the free version of the game. The following\n" +
|
||||
"doodads could not be loaded:"
|
||||
}
|
||||
modal.Alert("%s\n\n%s", summary, err).WithTitle("Level Errors")
|
||||
return fmt.Errorf("EditorScene.LoadLevel: InstallActors: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -689,24 +689,6 @@ func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.MenuBar {
|
|||
native.OpenLocalURL(balance.GuidebookPath)
|
||||
})
|
||||
helpMenu.AddItem("Register", func() {
|
||||
if u.licenseWindow == nil {
|
||||
cfg := windows.License{
|
||||
Supervisor: u.Supervisor,
|
||||
Engine: d.Engine,
|
||||
OnCancel: func() {
|
||||
u.licenseWindow.Hide()
|
||||
},
|
||||
}
|
||||
cfg.OnLicensed = func() {
|
||||
// License status has changed, reload the window!
|
||||
if u.licenseWindow != nil {
|
||||
u.licenseWindow.Hide()
|
||||
}
|
||||
u.licenseWindow = windows.MakeLicenseWindow(d.width, d.height, cfg)
|
||||
}
|
||||
|
||||
cfg.OnLicensed()
|
||||
}
|
||||
u.licenseWindow.Show()
|
||||
})
|
||||
helpMenu.AddItem("About", func() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/level/publishing"
|
||||
"git.kirsle.net/apps/doodle/pkg/license"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/modal"
|
||||
"git.kirsle.net/apps/doodle/pkg/windows"
|
||||
|
@ -82,6 +83,27 @@ func (u *EditorUI) SetupPopups(d *Doodle) {
|
|||
window.Hide()
|
||||
}
|
||||
|
||||
// License Registration Window.
|
||||
if u.licenseWindow == nil {
|
||||
cfg := windows.License{
|
||||
Supervisor: u.Supervisor,
|
||||
Engine: d.Engine,
|
||||
OnCancel: func() {
|
||||
u.licenseWindow.Hide()
|
||||
},
|
||||
}
|
||||
cfg.OnLicensed = func() {
|
||||
// License status has changed, reload the window!
|
||||
if u.licenseWindow != nil {
|
||||
u.licenseWindow.Hide()
|
||||
}
|
||||
u.licenseWindow = windows.MakeLicenseWindow(d.width, d.height, cfg)
|
||||
}
|
||||
|
||||
cfg.OnLicensed()
|
||||
u.licenseWindow.Hide()
|
||||
}
|
||||
|
||||
// Doodad Dropper.
|
||||
if u.doodadWindow == nil {
|
||||
u.doodadWindow = windows.NewDoodadDropper(windows.DoodadDropper{
|
||||
|
@ -128,6 +150,19 @@ func (u *EditorUI) SetupPopups(d *Doodle) {
|
|||
Level: scene.Level,
|
||||
|
||||
OnPublish: func(includeBuiltins bool) {
|
||||
// XXX: Paid Version Only.
|
||||
if !license.IsRegistered() {
|
||||
if u.licenseWindow != nil {
|
||||
u.licenseWindow.Show()
|
||||
u.Supervisor.FocusWindow(u.licenseWindow)
|
||||
}
|
||||
d.Flash("Level Publishing is only available in the full version of the game.")
|
||||
// modal.Alert(
|
||||
// "This feature is only available in the full version of the game.",
|
||||
// ).WithTitle("Please register")
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug("OnPublish: include builtins=%+v", includeBuiltins)
|
||||
cwd, _ := os.Getwd()
|
||||
d.Prompt(fmt.Sprintf("File name (relative to %s)> ", cwd), func(answer string) {
|
||||
|
|
|
@ -13,6 +13,11 @@ import (
|
|||
"github.com/dgrijalva/jwt-go"
|
||||
)
|
||||
|
||||
// Errors
|
||||
var (
|
||||
ErrRegisteredFeature = errors.New("feature not available")
|
||||
)
|
||||
|
||||
// Registration object encoded into a license key file.
|
||||
type Registration struct {
|
||||
Name string `json:"name"`
|
||||
|
|
|
@ -2,6 +2,7 @@ package uix
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
|
@ -20,7 +21,7 @@ func (w *Canvas) InstallActors(actors level.ActorMap) error {
|
|||
for id, actor := range actors {
|
||||
doodad, err := doodads.LoadFromEmbeddable(actor.Filename, w.level)
|
||||
if err != nil {
|
||||
errs = append(errs, err.Error())
|
||||
errs = append(errs, fmt.Sprintf("%s: %s", actor.Filename, err.Error()))
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/branding"
|
||||
"git.kirsle.net/apps/doodle/pkg/license"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/modal"
|
||||
"git.kirsle.net/apps/doodle/pkg/native"
|
||||
"git.kirsle.net/go/render"
|
||||
|
@ -66,7 +67,7 @@ func NewLicenseWindow(cfg License) *ui.Window {
|
|||
window.Configure(ui.Config{
|
||||
Width: windowWidth,
|
||||
Height: windowHeight,
|
||||
Background: render.RGBA(200, 200, 255, 255),
|
||||
Background: render.RGBA(255, 200, 255, 255),
|
||||
})
|
||||
|
||||
var rows = []struct {
|
||||
|
@ -127,21 +128,21 @@ func NewLicenseWindow(cfg License) *ui.Window {
|
|||
{
|
||||
IfUnregistered: true,
|
||||
Button: ui.NewButton("Key Browse", ui.NewLabel(ui.Label{
|
||||
Text: "Upload License Key File",
|
||||
Text: "Browse for License Key",
|
||||
Font: balance.UIFont,
|
||||
})),
|
||||
ButtonStyle: &balance.ButtonPrimary,
|
||||
Func: func() {
|
||||
filename, err := native.OpenFile("Select License File", "*.key *.txt")
|
||||
if err != nil {
|
||||
modal.Alert(err.Error())
|
||||
log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Upload and validate the license key.
|
||||
reg, err := license.UploadLicenseFile(filename)
|
||||
if err != nil {
|
||||
modal.Alert(err.Error())
|
||||
modal.Alert("That license key didn't seem quite right.").WithTitle("License Error")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user