2020-11-18 02:22:48 +00:00
|
|
|
// Package keybind centralizes the global hotkey bindings.
|
|
|
|
//
|
|
|
|
// Whenever the app would need to query a hotkey like "F3" or "Ctrl-Z"
|
|
|
|
// is held down, it should use a method in this file. It can be
|
|
|
|
// expanded later to allow user customizable bindings or something.
|
|
|
|
//
|
|
|
|
// NOTE: arrow key and gameplay controls not yet ported to here.
|
|
|
|
package keybind
|
|
|
|
|
|
|
|
import "git.kirsle.net/go/render/event"
|
|
|
|
|
|
|
|
// Shutdown (Escape) signals the game to start closing down.
|
|
|
|
func Shutdown(ev *event.State) bool {
|
|
|
|
return ev.Escape
|
|
|
|
}
|
|
|
|
|
|
|
|
// Help (F1) can be checked one time.
|
|
|
|
func Help(ev *event.State) bool {
|
|
|
|
result := ev.KeyDown("F1")
|
|
|
|
ev.SetKeyDown("F1", false)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugOverlay (F3) can be checked one time.
|
|
|
|
func DebugOverlay(ev *event.State) bool {
|
|
|
|
result := ev.KeyDown("F3")
|
|
|
|
ev.SetKeyDown("F3", false)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugCollision (F4) can be checked one time.
|
|
|
|
func DebugCollision(ev *event.State) bool {
|
|
|
|
result := ev.KeyDown("F4")
|
|
|
|
ev.SetKeyDown("F4", false)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undo (Ctrl-Z)
|
|
|
|
func Undo(ev *event.State) bool {
|
|
|
|
return ev.Ctrl && ev.KeyDown("z")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redo (Ctrl-Y)
|
|
|
|
func Redo(ev *event.State) bool {
|
|
|
|
return ev.Ctrl && ev.KeyDown("y")
|
|
|
|
}
|
|
|
|
|
2020-11-20 04:08:38 +00:00
|
|
|
// ZoomIn (+)
|
|
|
|
func ZoomIn(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("=") || ev.KeyDown("+")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ZoomOut (-)
|
|
|
|
func ZoomOut(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("-")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ZoomReset (1)
|
|
|
|
func ZoomReset(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("1")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Origin (0) -- scrolls the canvas back to 0,0 in Editor Mode.
|
|
|
|
func Origin(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("0")
|
|
|
|
}
|
|
|
|
|
2020-11-18 02:22:48 +00:00
|
|
|
// GotoPlay (P) play tests the current level in the editor.
|
|
|
|
func GotoPlay(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("p")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GotoEdit (E) opens the current played level in Edit Mode, if the
|
|
|
|
// player has come from the editor originally.
|
|
|
|
func GotoEdit(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("e")
|
|
|
|
}
|
|
|
|
|
|
|
|
// LineTool (L) selects the Line Tool in the editor.
|
|
|
|
func LineTool(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("l")
|
|
|
|
}
|
|
|
|
|
|
|
|
// PencilTool (F) selects the freehand pencil tool in the editor.
|
|
|
|
// GotoPlay (P) play tests the current level in the editor.
|
|
|
|
func PencilTool(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("f")
|
|
|
|
}
|
|
|
|
|
|
|
|
// RectTool (R) selects the rectangle in the editor.
|
|
|
|
func RectTool(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("r")
|
|
|
|
}
|
|
|
|
|
|
|
|
// EllipseTool (C) selects this tool in the editor.
|
|
|
|
func EllipseTool(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("c")
|
|
|
|
}
|
|
|
|
|
|
|
|
// EraserTool (X) selects this tool in the editor.
|
|
|
|
func EraserTool(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("x")
|
|
|
|
}
|
|
|
|
|
|
|
|
// DoodadDropper (D) opens the doodad dropper in the editor.
|
|
|
|
func DoodadDropper(ev *event.State) bool {
|
|
|
|
return ev.KeyDown("d")
|
|
|
|
}
|
2021-01-03 23:19:21 +00:00
|
|
|
|
WIP Publish Dialog + UI Improvements
* File->Publish Level in the Level Editor opens the Publish window,
where you can embed custom doodads into your level and export a
portable .level file you can share with others.
* Currently does not actually export a level file yet.
* The dialog lists all unique doodad names in use in your level, and
designates which are built-ins and which are custom (paginated).
* A checkbox would let the user embed built-in doodads into their level,
as well, locking it in to those versions and not using updated
versions from future game releases.
UI Improvements:
* Added styling for a "Primary" UI button, rendered in deep blue.
* Pop-up modals (Alert, Confirm) color their Ok button as Primary.
* The Enter key pressed during an Alert or Confirm modal will invoke its
default button and close the modal, corresponding to its Primary
button.
* The developer console is now opened with the tilde/grave key ` instead
of the Enter key, so that the Enter key is free to click through
modals.
* In the "Open/Edit Drawing" window, a "Browse..." button is added to
the level and doodad sections, spawning a native File Open dialog to
pick a .level or .doodad outside the config root.
2021-06-11 05:31:30 +00:00
|
|
|
// ShellKey (`) opens the developer console.
|
|
|
|
func ShellKey(ev *event.State) bool {
|
|
|
|
v := ev.KeyDown("`")
|
|
|
|
ev.SetKeyDown("`", false)
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enter key.
|
|
|
|
func Enter(ev *event.State) bool {
|
|
|
|
v := ev.Enter
|
|
|
|
ev.Enter = false
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2021-01-03 23:19:21 +00:00
|
|
|
// Shift key.
|
|
|
|
func Shift(ev *event.State) bool {
|
|
|
|
return ev.Shift
|
|
|
|
}
|
|
|
|
|
|
|
|
// Left arrow.
|
|
|
|
func Left(ev *event.State) bool {
|
|
|
|
return ev.Left || ev.KeyDown("a")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Right arrow.
|
|
|
|
func Right(ev *event.State) bool {
|
|
|
|
return ev.Right || ev.KeyDown("d")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Up arrow.
|
|
|
|
func Up(ev *event.State) bool {
|
|
|
|
return ev.Up || ev.KeyDown("w")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Down arrow.
|
|
|
|
func Down(ev *event.State) bool {
|
|
|
|
return ev.Down || ev.KeyDown("s")
|
|
|
|
}
|
|
|
|
|
|
|
|
// "Use" button.
|
|
|
|
func Use(ev *event.State) bool {
|
|
|
|
return ev.Space || ev.KeyDown("q")
|
|
|
|
}
|