done with saving updated keybindings, both saving to application's RAM memory and to disk

This commit is contained in:
2025-02-21 20:31:26 +00:00
parent edb9b300c3
commit 1bab4d89d7
2 changed files with 32 additions and 2 deletions

View File

@@ -139,6 +139,7 @@ sig
val keyFromString: string -> key_code option
val keyToString: key_code -> string
val userKeysToString: user_key -> string
val containsKey: key_code * key_code list -> bool
val containsAttack: user_key * key_code list -> bool
@@ -531,6 +532,28 @@ struct
| KEY_RIGHT_SUPER => "KEY_RIGHT_SUPER"
| KEY_MENU => "KEY_MENU"
fun userKeysToString {left, right, up, down, jump, attack, escape = _} =
String.concat
[ "ACTION_LEFT:"
, keyToString left
, "\n"
, "ACTION_RIGHT:"
, keyToString right
, "\n"
, "ACTION_UP:"
, keyToString up
, "\n"
, "ACTION_DOWN:"
, keyToString down
, "\n"
, "ACTION_JUMP:"
, keyToString jump
, "\n"
, "ACTION_ATTACK:"
, keyToString attack
, "\n"
]
fun containsKey (searchKey, lst) =
case lst of
hd :: tl => hd = searchKey orelse containsKey (searchKey, tl)

View File

@@ -287,8 +287,15 @@ struct
end
fun saveKeys game =
let val () = InputState.setControls (#userKeys game)
in ()
let
val newKeys = #userKeys game
val () = InputState.setControls newKeys
val io = TextIO.openOut "controls.config"
val () = TextIO.output (io, CoreKey.userKeysToString newKeys)
val () = TextIO.closeOut io
in
()
end
fun runEffects game =