From c81ca5dcf3e07ffbace216c05b06a30ceafb9b72 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Fri, 21 Feb 2025 06:37:16 +0000 Subject: [PATCH] allow user to press up and down to select different options in options --- fcore/options/options-update.sml | 40 +++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/fcore/options/options-update.sml b/fcore/options/options-update.sml index fe0c3bf..e8b612e 100644 --- a/fcore/options/options-update.sml +++ b/fcore/options/options-update.sml @@ -1,5 +1,43 @@ structure OptionsUpdate = struct - fun update (options, input, userKeys) = + open OptionsType + + fun default (options, userKeys) = {mode = GameType.OPTIONS options, userKeys = userKeys} + + fun withFocus (newFocus, userKeys) = + {mode = GameType.OPTIONS {focus = newFocus}, userKeys = userKeys} + + fun update (options, input: FrameInputType.t, userKeys) = + case #focus options of + LEFT_KEY => + if #downHeld input then withFocus (RIGHT_KEY, userKeys) + else default (options, userKeys) + | RIGHT_KEY => + if #upHeld input then withFocus (LEFT_KEY, userKeys) + else if #downHeld input then withFocus (UP_KEY, userKeys) + else default (options, userKeys) + | UP_KEY => + if #upHeld input then withFocus (RIGHT_KEY, userKeys) + else if #downHeld input then withFocus (DOWN_KEY, userKeys) + else default (options, userKeys) + | DOWN_KEY => + if #upHeld input then withFocus (UP_KEY, userKeys) + else if #downHeld input then withFocus (JUMP_KEY, userKeys) + else default (options, userKeys) + | JUMP_KEY => + if #upHeld input then withFocus (DOWN_KEY, userKeys) + else if #downHeld input then withFocus (ATTACK_KEY, userKeys) + else default (options, userKeys) + | ATTACK_KEY => + if #upHeld input then withFocus (JUMP_KEY, userKeys) + else if #downHeld input then withFocus (SAVE_BUTTON, userKeys) + else default (options, userKeys) + | SAVE_BUTTON => + if #upHeld input then withFocus (ATTACK_KEY, userKeys) + else if #downHeld input then withFocus (CANCEL_BUTTON, userKeys) + else default (options, userKeys) + | CANCEL_BUTTON => + if #upHeld input then withFocus (SAVE_BUTTON, userKeys) + else default (options, userKeys) end