WIP Doodle++ #93
|
@ -155,7 +155,7 @@ func imageToDrawing(c *cli.Context, chroma render.Color, inputFiles []string, ou
|
||||||
if doodad.Title == "" {
|
if doodad.Title == "" {
|
||||||
doodad.Title = "Converted Doodad"
|
doodad.Title = "Converted Doodad"
|
||||||
}
|
}
|
||||||
doodad.Author = native.DefaultAuthor()
|
doodad.Author = native.DefaultAuthor
|
||||||
|
|
||||||
// Write the first layer and gather its palette.
|
// Write the first layer and gather its palette.
|
||||||
log.Info("Converting first layer to drawing and getting the palette")
|
log.Info("Converting first layer to drawing and getting the palette")
|
||||||
|
@ -195,7 +195,7 @@ func imageToDrawing(c *cli.Context, chroma render.Color, inputFiles []string, ou
|
||||||
if lvl.Title == "" {
|
if lvl.Title == "" {
|
||||||
lvl.Title = "Converted Level"
|
lvl.Title = "Converted Level"
|
||||||
}
|
}
|
||||||
lvl.Author = native.DefaultAuthor()
|
lvl.Author = native.DefaultAuthor
|
||||||
palette, chunker := imageToChunker(images[0], chroma, nil, lvl.Chunker.Size)
|
palette, chunker := imageToChunker(images[0], chroma, nil, lvl.Chunker.Size)
|
||||||
lvl.Palette = palette
|
lvl.Palette = palette
|
||||||
lvl.Chunker = chunker
|
lvl.Chunker = chunker
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/plus/bootstrap"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/plus/bootstrap"
|
||||||
|
"git.kirsle.net/SketchyMaze/doodle/pkg/plus/dpp"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sound"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/sound"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sprites"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/sprites"
|
||||||
|
@ -118,6 +119,11 @@ func main() {
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Action = func(c *cli.Context) error {
|
||||||
log.Info("Starting %s %s", app.Name, app.Version)
|
log.Info("Starting %s %s", app.Name, app.Version)
|
||||||
|
|
||||||
|
// Print registration information, + also this sets the DefaultAuthor field.
|
||||||
|
if reg, err := dpp.Driver.GetRegistration(); err == nil {
|
||||||
|
log.Info("Registered to %s", reg.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// --chdir into a different working directory? e.g. for Flatpak especially.
|
// --chdir into a different working directory? e.g. for Flatpak especially.
|
||||||
if doodlePath := c.String("chdir"); doodlePath != "" {
|
if doodlePath := c.String("chdir"); doodlePath != "" {
|
||||||
if err := os.Chdir(doodlePath); err != nil {
|
if err := os.Chdir(doodlePath); err != nil {
|
||||||
|
|
|
@ -539,7 +539,7 @@ func (s *EditorScene) SaveLevel(filename string) error {
|
||||||
m.Title = "Alpha"
|
m.Title = "Alpha"
|
||||||
}
|
}
|
||||||
if m.Author == "" {
|
if m.Author == "" {
|
||||||
m.Author = native.DefaultAuthor()
|
m.Author = native.DefaultAuthor
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Palette = s.UI.Canvas.Palette
|
m.Palette = s.UI.Canvas.Palette
|
||||||
|
@ -641,7 +641,7 @@ func (s *EditorScene) SaveDoodad(filename string) error {
|
||||||
d.Title = "Untitled Doodad"
|
d.Title = "Untitled Doodad"
|
||||||
}
|
}
|
||||||
if d.Author == "" {
|
if d.Author == "" {
|
||||||
d.Author = native.DefaultAuthor()
|
d.Author = native.DefaultAuthor
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: is this copying necessary?
|
// TODO: is this copying necessary?
|
||||||
|
|
|
@ -91,7 +91,7 @@ func New() *Level {
|
||||||
Base: Base{
|
Base: Base{
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Title: "Untitled",
|
Title: "Untitled",
|
||||||
Author: native.DefaultAuthor(),
|
Author: native.DefaultAuthor,
|
||||||
Files: NewFileSystem(),
|
Files: NewFileSystem(),
|
||||||
},
|
},
|
||||||
Chunker: NewChunker(balance.ChunkSize),
|
Chunker: NewChunker(balance.ChunkSize),
|
||||||
|
|
|
@ -2,28 +2,9 @@ package native
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/plus/dpp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var USER string = os.Getenv("USER")
|
var (
|
||||||
|
USER string = os.Getenv("USER")
|
||||||
/*
|
DefaultAuthor = USER
|
||||||
DefaultAuthor will return the local user's name to be the default Author
|
)
|
||||||
for levels and doodads they create.
|
|
||||||
|
|
||||||
If they have registered the game, use the name from their license JWT token.
|
|
||||||
|
|
||||||
Otherwise fall back to their native operating system user.
|
|
||||||
*/
|
|
||||||
func DefaultAuthor() string {
|
|
||||||
// Are we registered? TODO: get from registration
|
|
||||||
if dpp.Driver.IsRegistered() {
|
|
||||||
if reg, err := dpp.Driver.GetRegistration(); err == nil {
|
|
||||||
return reg.Name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return OS username
|
|
||||||
return os.Getenv("USER")
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/filesystem"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/filesystem"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/level"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/level"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/levelpack"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/levelpack"
|
||||||
|
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
||||||
"git.kirsle.net/SketchyMaze/doodle/pkg/plus"
|
"git.kirsle.net/SketchyMaze/doodle/pkg/plus"
|
||||||
"git.kirsle.net/SketchyMaze/dpp/embedding"
|
"git.kirsle.net/SketchyMaze/dpp/embedding"
|
||||||
"git.kirsle.net/SketchyMaze/dpp/license"
|
"git.kirsle.net/SketchyMaze/dpp/license"
|
||||||
|
@ -46,11 +47,19 @@ func (Plugin) UploadLicenseFile(filename string) (plus.Registration, error) {
|
||||||
|
|
||||||
// Hack: to translate JWT token types, easiest is to just encode/decode them (inner jwt.StandardClaims complexity).
|
// Hack: to translate JWT token types, easiest is to just encode/decode them (inner jwt.StandardClaims complexity).
|
||||||
func translateLicenseStruct(reg license.Registration) (plus.Registration, error) {
|
func translateLicenseStruct(reg license.Registration) (plus.Registration, error) {
|
||||||
jsonStr, err := json.Marshal(reg)
|
// Set the DefaultAuthor to the registered user's name.
|
||||||
|
if reg.Name != "" {
|
||||||
|
native.DefaultAuthor = reg.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal to JSON and back to cast the type.
|
||||||
|
var (
|
||||||
|
result plus.Registration
|
||||||
|
jsonStr, err = json.Marshal(reg)
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return plus.Registration{}, err
|
return plus.Registration{}, err
|
||||||
}
|
}
|
||||||
var result plus.Registration
|
|
||||||
err = json.Unmarshal(jsonStr, &result)
|
err = json.Unmarshal(jsonStr, &result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,11 @@ var ErrNotImplemented = errors.New("not implemented")
|
||||||
type Plugin struct{}
|
type Plugin struct{}
|
||||||
|
|
||||||
func (Plugin) LoadFromEmbeddable(filename string, fs filesystem.Embeddable, force bool) (*doodads.Doodad, error) {
|
func (Plugin) LoadFromEmbeddable(filename string, fs filesystem.Embeddable, force bool) (*doodads.Doodad, error) {
|
||||||
return doodads.LoadFile(filename)
|
if result, err := doodads.LoadFile(filename); err != nil {
|
||||||
|
return nil, plus.ErrRegisteredFeature
|
||||||
|
} else {
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Plugin) IsRegistered() bool {
|
func (Plugin) IsRegistered() bool {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user