diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 54a87603..e50628d9 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -86,12 +86,7 @@ (entryWindow.hide) (entryWindow.show)))) - (when (and FlxG.keys.justPressed.SPACE !entryNameText) - (defAndCall method toggleBackgroundColor - (set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#) - (save.flush) - // setModel so the entry text gets remade in inverted/lightened colors when necessary - (refreshModel))) + (#when debug (when FlxG.keys.justPressed.SEMICOLON @@ -262,7 +257,13 @@ (map (m.activeTodoEntries) makeText) (set entryWindow.textColor FlxColor.GRAY) (when m.rewardFiles - (_makeText "[SPACE] Cycle background color" 0)) + (_makeText "{space} Cycle background color" 0 + ->_ + (defAndCall method toggleBackgroundColor + (set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#) + (save.flush) + // setModel so the entry text gets remade in inverted/lightened colors when necessary + (refreshModel)))) (when windowWasShown (entryWindow.show)) diff --git a/projects/kiss-tools/src/kiss_tools/KeyShortcutHandler.kiss b/projects/kiss-tools/src/kiss_tools/KeyShortcutHandler.kiss index 0b8346e7..189b4de6 100644 --- a/projects/kiss-tools/src/kiss_tools/KeyShortcutHandler.kiss +++ b/projects/kiss-tools/src/kiss_tools/KeyShortcutHandler.kiss @@ -47,17 +47,27 @@ (tryCallOrThrow onBadKey "Key $key is not defined in $currentMap and no onBadKey event was given" key currentMap))))) // Extract [k]eyboard [s]hortcuts from a string: -(method extractKeyboardShortcuts [str &opt :Stream stream :String shortcuts] +(method extractKeyboardShortcuts [str &opt :Stream stream :Array shortcuts] (unless stream (set stream (Stream.fromString str))) - (unless shortcuts (set shortcuts "")) - (case (stream.takeUntilAndDrop "[") + (unless shortcuts (set shortcuts [])) + (case (stream.takeUntilOneOf ["[" "{"] false) ((Some _) - (case (stream.takeUntilAndDrop "]") - ((Some newShortcuts) - (extractKeyboardShortcuts str stream (+ shortcuts newShortcuts))) - (otherwise - (tryCallOrThrow onBadShortcut "unclosed [ in $str" str null) - ""))) + (case (stream.takeChars 1) + ((Some "[") + (case (stream.takeUntilAndDrop "]") + ((Some newShortcuts) + (extractKeyboardShortcuts str stream (shortcuts.concat (newShortcuts.split "")))) + (otherwise + (tryCallOrThrow onBadShortcut "unclosed [ in $str" str null) + []))) + ((Some "{") + (case (stream.takeUntilAndDrop "}") + ((Some newShortcut) + (extractKeyboardShortcuts str stream (shortcuts.concat [newShortcut]))) + (otherwise + (tryCallOrThrow onBadShortcut "unclosed { in $str" str null) + []))) + (otherwise (throw "takeUntilOneOf lied")))) (otherwise shortcuts))) @@ -85,4 +95,4 @@ (method :Void registerItem [description :T item] (whenLet [keyboardShortcut (extractKeyboardShortcuts description)] - (registerShortcut (keyboardShortcut.split "") description item))) \ No newline at end of file + (registerShortcut keyboardShortcut description item))) \ No newline at end of file