add 'tempKeys' field to OptionsType.options_type, so that any key binding changes in the menu do not take immediate effect (requires pressing 'save button' in order for changes to be saved and take effect)
This commit is contained in:
@@ -11,9 +11,14 @@ sig
|
||||
| CANCEL_BUTTON
|
||||
|
||||
type options_type =
|
||||
{focus: focus, isSelected: bool, lastUpPress: real, lastDownPress: real}
|
||||
{ focus: focus
|
||||
, isSelected: bool
|
||||
, lastUpPress: real
|
||||
, lastDownPress: real
|
||||
, tempKeys: CoreKey.user_key
|
||||
}
|
||||
|
||||
val initial: options_type
|
||||
val init: CoreKey.user_key -> options_type
|
||||
end
|
||||
|
||||
structure OptionsType :> OPTIONS_TYPE =
|
||||
@@ -29,12 +34,18 @@ struct
|
||||
| CANCEL_BUTTON
|
||||
|
||||
type options_type =
|
||||
{focus: focus, isSelected: bool, lastUpPress: real, lastDownPress: real}
|
||||
{ focus: focus
|
||||
, isSelected: bool
|
||||
, lastUpPress: real
|
||||
, lastDownPress: real
|
||||
, tempKeys: CoreKey.user_key
|
||||
}
|
||||
|
||||
val initial =
|
||||
fun init userKeys =
|
||||
{ focus = LEFT_KEY
|
||||
, isSelected = false
|
||||
, lastUpPress = 0.0
|
||||
, lastDownPress = 0.0
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ end
|
||||
|
||||
functor MakeUpdateSelectedKey(Fn: MAKE_UPDATE_SELECTED_KEY) =
|
||||
struct
|
||||
fun setNewKeys (options, userKeys, time) =
|
||||
fun setNewKeys (options, tempKeys, userKeys, time) =
|
||||
let
|
||||
val {focus, lastUpPress, lastDownPress, ...} = options
|
||||
val options =
|
||||
@@ -17,6 +17,7 @@ struct
|
||||
, lastUpPress = time
|
||||
, lastDownPress = time
|
||||
, isSelected = false
|
||||
, tempKeys = tempKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
@@ -31,8 +32,8 @@ struct
|
||||
Fn.deselect (options, userKeys)
|
||||
(* what if new key collides with existing key? todo *)
|
||||
else
|
||||
let val userKeys = Fn.updateKeys (key, userKeys)
|
||||
in setNewKeys (options, userKeys, time)
|
||||
let val tempKeys = Fn.updateKeys (key, userKeys)
|
||||
in setNewKeys (options, tempKeys, userKeys, time)
|
||||
end
|
||||
| [] => Fn.default (options, userKeys)
|
||||
end
|
||||
@@ -52,6 +53,7 @@ struct
|
||||
, lastUpPress = 0.0
|
||||
, lastDownPress = 0.0
|
||||
, isSelected = isSelected
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
@@ -69,12 +71,14 @@ struct
|
||||
, lastUpPress = time
|
||||
, lastDownPress = 0.0
|
||||
, isSelected = isSelected
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
else
|
||||
{ focus = focus
|
||||
, lastUpPress = lastUpPress
|
||||
, lastDownPress = 0.0
|
||||
, isSelected = isSelected
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
@@ -90,12 +94,14 @@ struct
|
||||
, lastUpPress = 0.0
|
||||
, lastDownPress = time
|
||||
, isSelected = isSelected
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
else
|
||||
{ focus = focus
|
||||
, lastUpPress = 0.0
|
||||
, lastDownPress = lastDownPress
|
||||
, isSelected = isSelected
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
@@ -109,6 +115,7 @@ struct
|
||||
, lastUpPress = lastUpPress
|
||||
, lastDownPress = lastDownPress
|
||||
, isSelected = true
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
@@ -122,6 +129,7 @@ struct
|
||||
, lastUpPress = lastUpPress
|
||||
, lastDownPress = lastDownPress
|
||||
, isSelected = false
|
||||
, tempKeys = userKeys
|
||||
}
|
||||
in
|
||||
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||
|
||||
Reference in New Issue
Block a user