Choice of palette when creating a new level
* In the "New Level" dialog, a "Palette:" option shows a MenuButton drop-down with options: Default, Colored Pencil, and Blueprint. These control the set of colors the new level starts with.
This commit is contained in:
parent
be47dc21c7
commit
3d8eedce35
7
debug-af.sh
Executable file
7
debug-af.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export DEBUG_CHUNK_COLOR=FFFF0066
|
||||||
|
export DEBUG_CANVAS_LABEL=1
|
||||||
|
export DEBUG_CHUNK_COLOR=00FF00AA
|
||||||
|
export DEBUG_CANVAS_BORDER=0FF
|
||||||
|
go run cmd/doodle/main.go --experimental --debug
|
|
@ -3,13 +3,16 @@ package balance
|
||||||
// Feature Flags to turn on/off experimental content.
|
// Feature Flags to turn on/off experimental content.
|
||||||
var Feature = feature{
|
var Feature = feature{
|
||||||
Zoom: false,
|
Zoom: false,
|
||||||
|
ChangePalette: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeaturesOn turns on all feature flags, from CLI --experimental option.
|
// FeaturesOn turns on all feature flags, from CLI --experimental option.
|
||||||
func FeaturesOn() {
|
func FeaturesOn() {
|
||||||
Feature.Zoom = true
|
Feature.Zoom = true
|
||||||
|
Feature.ChangePalette = true
|
||||||
}
|
}
|
||||||
|
|
||||||
type feature struct {
|
type feature struct {
|
||||||
Zoom bool
|
Zoom bool
|
||||||
|
ChangePalette bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ package branding
|
||||||
const (
|
const (
|
||||||
AppName = "Sketchy Maze"
|
AppName = "Sketchy Maze"
|
||||||
Summary = "A drawing-based maze game"
|
Summary = "A drawing-based maze game"
|
||||||
Version = "0.5.0-alpha"
|
Version = "0.6.0-alpha"
|
||||||
Website = "https://www.sketchymaze.com"
|
Website = "https://www.sketchymaze.com"
|
||||||
Copyright = "2021 Noah Petherbridge"
|
Copyright = "2021 Noah Petherbridge"
|
||||||
|
|
||||||
|
|
99
pkg/level/palette_defaults.go
Normal file
99
pkg/level/palette_defaults.go
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
package level
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.kirsle.net/go/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Some choice of palettes.
|
||||||
|
var (
|
||||||
|
DefaultPaletteNames = []string{
|
||||||
|
"Default",
|
||||||
|
"Colored Pencil",
|
||||||
|
"Blueprint",
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultPalettes = map[string]*Palette{
|
||||||
|
"Default": &Palette{
|
||||||
|
Swatches: []*Swatch{
|
||||||
|
&Swatch{
|
||||||
|
Name: "solid",
|
||||||
|
Color: render.Black,
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "decoration",
|
||||||
|
Color: render.Grey,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "fire",
|
||||||
|
Color: render.Red,
|
||||||
|
Fire: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "water",
|
||||||
|
Color: render.RGBA(0, 0, 255, 180),
|
||||||
|
Water: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"Colored Pencil": &Palette{
|
||||||
|
Swatches: []*Swatch{
|
||||||
|
&Swatch{
|
||||||
|
Name: "grass",
|
||||||
|
Color: render.DarkGreen,
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "dirt",
|
||||||
|
Color: render.RGBA(100, 64, 0, 255),
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "stone",
|
||||||
|
Color: render.DarkGrey,
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "fire",
|
||||||
|
Color: render.Red,
|
||||||
|
Fire: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "water",
|
||||||
|
Color: render.RGBA(0, 153, 255, 255),
|
||||||
|
Water: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"Blueprint": &Palette{
|
||||||
|
Swatches: []*Swatch{
|
||||||
|
&Swatch{
|
||||||
|
Name: "solid",
|
||||||
|
Color: render.RGBA(254, 254, 254, 255),
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "decoration",
|
||||||
|
Color: render.Grey,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "fire",
|
||||||
|
Color: render.RGBA(255, 80, 0, 255),
|
||||||
|
Fire: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "water",
|
||||||
|
Color: render.RGBA(0, 153, 255, 255),
|
||||||
|
Water: true,
|
||||||
|
},
|
||||||
|
&Swatch{
|
||||||
|
Name: "electric",
|
||||||
|
Color: render.RGBA(255, 255, 0, 255),
|
||||||
|
Solid: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
|
@ -43,6 +43,11 @@ func (s *MenuScene) Name() string {
|
||||||
return "Menu"
|
return "Menu"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DebugGetWindow surfaces the underlying private window.
|
||||||
|
func (s *MenuScene) DebugGetWindow() *ui.Window {
|
||||||
|
return s.window
|
||||||
|
}
|
||||||
|
|
||||||
// GotoNewMenu loads the MenuScene and shows the "New" window.
|
// GotoNewMenu loads the MenuScene and shows the "New" window.
|
||||||
func (d *Doodle) GotoNewMenu() {
|
func (d *Doodle) GotoNewMenu() {
|
||||||
log.Info("Loading the MenuScene to the New window")
|
log.Info("Loading the MenuScene to the New window")
|
||||||
|
|
|
@ -3,6 +3,7 @@ package windows
|
||||||
import (
|
import (
|
||||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||||
"git.kirsle.net/apps/doodle/pkg/level"
|
"git.kirsle.net/apps/doodle/pkg/level"
|
||||||
|
"git.kirsle.net/apps/doodle/pkg/modal"
|
||||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||||
"git.kirsle.net/go/render"
|
"git.kirsle.net/go/render"
|
||||||
"git.kirsle.net/go/ui"
|
"git.kirsle.net/go/ui"
|
||||||
|
@ -28,14 +29,18 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window {
|
||||||
var (
|
var (
|
||||||
newPageType = level.Bounded.String()
|
newPageType = level.Bounded.String()
|
||||||
newWallpaper = "notebook.png"
|
newWallpaper = "notebook.png"
|
||||||
|
paletteName = level.DefaultPaletteNames[0]
|
||||||
isNewLevel = config.EditLevel == nil
|
isNewLevel = config.EditLevel == nil
|
||||||
title = "New Drawing"
|
title = "New Drawing"
|
||||||
|
|
||||||
|
textCurrentPalette = "Keep current palette"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Given a level to edit?
|
// Given a level to edit?
|
||||||
if config.EditLevel != nil {
|
if config.EditLevel != nil {
|
||||||
newPageType = config.EditLevel.PageType.String()
|
newPageType = config.EditLevel.PageType.String()
|
||||||
newWallpaper = config.EditLevel.Wallpaper
|
newWallpaper = config.EditLevel.Wallpaper
|
||||||
|
paletteName = textCurrentPalette
|
||||||
title = "Page Settings"
|
title = "Page Settings"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +133,14 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window {
|
||||||
frame.Pack(label2, ui.Pack{
|
frame.Pack(label2, ui.Pack{
|
||||||
Side: ui.N,
|
Side: ui.N,
|
||||||
FillX: true,
|
FillX: true,
|
||||||
|
PadY: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
wpFrame := ui.NewFrame("Wallpaper Frame")
|
wpFrame := ui.NewFrame("Wallpaper Frame")
|
||||||
frame.Pack(wpFrame, ui.Pack{
|
frame.Pack(wpFrame, ui.Pack{
|
||||||
Side: ui.N,
|
Side: ui.N,
|
||||||
FillX: true,
|
FillX: true,
|
||||||
|
PadY: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
type wallpaperObj struct {
|
type wallpaperObj struct {
|
||||||
|
@ -164,9 +171,69 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window {
|
||||||
Side: ui.W,
|
Side: ui.W,
|
||||||
PadX: 4,
|
PadX: 4,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// If a new level, the Blueprint button has a tooltip
|
||||||
|
// hinting to pick the Blueprint palette to match.
|
||||||
|
if config.EditLevel == nil && t.Name == "Blueprint" {
|
||||||
|
ui.NewTooltip(radio, ui.Tooltip{
|
||||||
|
Text: "Dark theme! Make sure to also\npick a Blueprint color palette!",
|
||||||
|
Edge: ui.Top,
|
||||||
|
})
|
||||||
|
}
|
||||||
}(t)
|
}(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************
|
||||||
|
* Frame for picking a default color palette.
|
||||||
|
******************/
|
||||||
|
|
||||||
|
// For new level or --experimental only.
|
||||||
|
if config.EditLevel == nil || balance.Feature.ChangePalette {
|
||||||
|
palFrame := ui.NewFrame("Palette Frame")
|
||||||
|
frame.Pack(palFrame, ui.Pack{
|
||||||
|
Side: ui.N,
|
||||||
|
FillX: true,
|
||||||
|
PadY: 4,
|
||||||
|
})
|
||||||
|
|
||||||
|
label3 := ui.NewLabel(ui.Label{
|
||||||
|
Text: "Palette: ",
|
||||||
|
Font: balance.LabelFont,
|
||||||
|
})
|
||||||
|
palFrame.Pack(label3, ui.Pack{
|
||||||
|
Side: ui.W,
|
||||||
|
})
|
||||||
|
|
||||||
|
palBtn := ui.NewMenuButton("Palette Button", ui.NewLabel(ui.Label{
|
||||||
|
TextVariable: &paletteName,
|
||||||
|
Font: balance.MenuFont,
|
||||||
|
}))
|
||||||
|
|
||||||
|
palFrame.Pack(palBtn, ui.Pack{
|
||||||
|
Side: ui.W,
|
||||||
|
// FillX: true,
|
||||||
|
Expand: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
if config.EditLevel != nil {
|
||||||
|
palBtn.AddItem(paletteName, func() {
|
||||||
|
paletteName = textCurrentPalette
|
||||||
|
})
|
||||||
|
palBtn.AddSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, palName := range level.DefaultPaletteNames {
|
||||||
|
palName := palName
|
||||||
|
// palette := level.DefaultPalettes[palName]
|
||||||
|
palBtn.AddItem(palName, func() {
|
||||||
|
paletteName = palName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
config.Supervisor.Add(palBtn)
|
||||||
|
palBtn.Supervise(config.Supervisor)
|
||||||
|
}
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
* Frame for giving the level a title.
|
* Frame for giving the level a title.
|
||||||
******************/
|
******************/
|
||||||
|
@ -258,15 +325,10 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
lvl := level.New()
|
lvl := level.New()
|
||||||
lvl.Palette = level.DefaultPalette()
|
lvl.Palette = level.DefaultPalettes[paletteName]
|
||||||
lvl.Wallpaper = newWallpaper
|
lvl.Wallpaper = newWallpaper
|
||||||
lvl.PageType = pageType
|
lvl.PageType = pageType
|
||||||
|
|
||||||
// Blueprint theme palette for the dark wallpaper color.
|
|
||||||
if lvl.Wallpaper == "blueprint.png" {
|
|
||||||
lvl.Palette = level.NewBlueprintPalette()
|
|
||||||
}
|
|
||||||
|
|
||||||
config.OnCreateNewLevel(lvl)
|
config.OnCreateNewLevel(lvl)
|
||||||
return nil
|
return nil
|
||||||
}},
|
}},
|
||||||
|
@ -278,6 +340,19 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window {
|
||||||
|
|
||||||
// OK button is for editing an existing level.
|
// OK button is for editing an existing level.
|
||||||
{"OK", func(ed ui.EventData) error {
|
{"OK", func(ed ui.EventData) error {
|
||||||
|
// If we're editing a level, did we select a new palette?
|
||||||
|
if paletteName != textCurrentPalette {
|
||||||
|
modal.Confirm(
|
||||||
|
"Are you sure you want to change the level palette?\n"+
|
||||||
|
"Existing pixels drawn on your level may change, and\n"+
|
||||||
|
"if the new palette is smaller, some pixels may be\n"+
|
||||||
|
"lost from your level. OK to continue?",
|
||||||
|
).WithTitle("Change Level Palette").Then(func() {
|
||||||
|
config.OnCancel();
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
config.OnCancel()
|
config.OnCancel()
|
||||||
return nil
|
return nil
|
||||||
}},
|
}},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user