doodle/pkg/balance/boolprops.go
Noah Petherbridge d6f86487f5 Horizontal Toolbars Option for Editor Mode
On small screen sizes like the Pinephone, the toolbars in the Level
Editor are best made horizontal across the top and bottom of the screen
leaving more room for the drawing.

Enable it with a boolProp for now, and then reopen the level editor:

    boolProp horizontalToolbars true

When launching `doodle -w mobile` it will automatically enable this
option.
2021-06-13 21:23:26 -07:00

69 lines
1.5 KiB
Go

package balance
import (
"errors"
"fmt"
"sort"
"strings"
)
// Fun bool props to wreak havoc in the game.
var (
// Force show hidden doodads in the palette in Editor Mode.
ShowHiddenDoodads bool
// Force ability to edit Locked levels and doodads.
WriteLockOverride bool
// Pretty-print JSON files when writing.
JSONIndent bool
// Temporary debug flag.
TempDebug bool
// Draw horizontal toolbars in Level Editor instead of vertical.
HorizontalToolbars bool
)
// Human friendly names for the boolProps. Not necessarily the long descriptive
// variable names above.
var props = map[string]*bool{
"showAllDoodads": &ShowHiddenDoodads,
"writeLockOverride": &WriteLockOverride,
"prettyJSON": &JSONIndent,
"tempDebug": &TempDebug,
"horizontalToolbars": &HorizontalToolbars,
// WARNING: SLOW!
"disableChunkTextureCache": &DisableChunkTextureCache,
}
// GetBoolProp reads the current value of a boolProp.
// Special value "list" will error out with a list of available props.
func GetBoolProp(name string) (bool, error) {
if name == "list" {
var keys []string
for k := range props {
keys = append(keys, k)
}
sort.Strings(keys)
return false, fmt.Errorf(
"Boolprops: %s",
strings.Join(keys, ", "),
)
}
if prop, ok := props[name]; ok {
return *prop, nil
}
return false, errors.New("no such boolProp")
}
// BoolProp allows easily setting a boolProp by name.
func BoolProp(name string, v bool) error {
if prop, ok := props[name]; ok {
*prop = v
return nil
}
return errors.New("no such boolProp")
}