Fixup some developer console commands

This commit is contained in:
Noah 2020-11-20 22:53:38 -08:00
parent fade085695
commit 8eb3ab51d3
2 changed files with 27 additions and 9 deletions

View File

@ -59,6 +59,7 @@ func (c Command) Run(d *Doodle) error {
d.Goto(&GUITestScene{}) d.Goto(&GUITestScene{})
return nil return nil
case "eval": case "eval":
fallthrough
case "$": case "$":
out, err := c.RunScript(d, c.ArgsLiteral) out, err := c.RunScript(d, c.ArgsLiteral)
d.Flash("%+v", out) d.Flash("%+v", out)
@ -90,12 +91,19 @@ func (c Command) Close(d *Doodle) error {
// Help prints the help info. // Help prints the help info.
func (c Command) Help(d *Doodle) error { func (c Command) Help(d *Doodle) error {
if len(c.Args) == 0 { if len(c.Args) == 0 {
d.Flash("Available commands: new save edit play quit echo clear help") d.Flash("Available commands: new save edit play quit echo")
d.Flash(" alert clear help boolProp eval repl")
d.Flash("Type `help` and then the command, like: `help edit`") d.Flash("Type `help` and then the command, like: `help edit`")
return nil return nil
} }
switch c.Args[0] { switch c.Args[0] {
case "echo":
d.Flash("Usage: echo <message>")
d.Flash("Flash a message back to the console")
case "alert":
d.Flash("Usage: alert <message>")
d.Flash("Pop up an Alert box with a custom message")
case "new": case "new":
d.Flash("Usage: new") d.Flash("Usage: new")
d.Flash("Create a new drawing in Edit Mode") d.Flash("Create a new drawing in Edit Mode")
@ -108,18 +116,25 @@ func (c Command) Help(d *Doodle) error {
case "play": case "play":
d.Flash("Usage: play <filename.json>") d.Flash("Usage: play <filename.json>")
d.Flash("Open a map from disk in Play Mode") d.Flash("Open a map from disk in Play Mode")
case "echo":
d.Flash("Usage: echo <message>")
d.Flash("Flash a message back to the console")
case "quit": case "quit":
fallthrough
case "exit": case "exit":
d.Flash("Usage: quit") d.Flash("Usage: quit")
d.Flash("Closes the dev console") d.Flash("Closes the dev console (alias: exit)")
case "clear": case "clear":
d.Flash("Usage: clear") d.Flash("Usage: clear")
d.Flash("Clears the terminal output history") d.Flash("Clears the console output history")
case "eval":
fallthrough
case "$":
d.Flash("Evaluate a line of JavaScript on the in-game interpreter")
case "repl":
d.Flash("Enter a JavaScript shell on the in-game interpreter")
case "boolProp":
d.Flash("Toggle boolean values. `boolProp list` lists available")
case "help": case "help":
d.Flash("Usage: help <command>") d.Flash("Usage: help <command>")
d.Flash("Gets further help on a command")
default: default:
d.Flash("Unknown help topic.") d.Flash("Unknown help topic.")
} }

View File

@ -213,12 +213,15 @@ func (s *EditorScene) Loop(d *Doodle, ev *event.State) error {
} else if keybind.ZoomReset(ev) { } else if keybind.ZoomReset(ev) {
d.Flash("Reset zoom") d.Flash("Reset zoom")
s.UI.Canvas.Zoom = 0 s.UI.Canvas.Zoom = 0
} else if keybind.Origin(ev) {
d.Flash("Scrolled back to level origin (0,0)")
s.UI.Canvas.ScrollTo(render.Origin)
} }
} }
// More keybinds
if keybind.Origin(ev) {
d.Flash("Scrolled back to level origin (0,0)")
s.UI.Canvas.ScrollTo(render.Origin)
}
s.UI.Loop(ev) s.UI.Loop(ev)
// Switching to Play Mode? // Switching to Play Mode?