draw options screen when that is selected
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
signature GAME_TYPE =
|
signature GAME_TYPE =
|
||||||
sig
|
sig
|
||||||
datatype mode = LEVEL of LevelType.level_type | TITLE of TitleType.title_type
|
datatype mode =
|
||||||
|
LEVEL of LevelType.level_type
|
||||||
|
| TITLE of TitleType.title_type
|
||||||
|
| OPTIONS of OptionsType.options_type
|
||||||
|
|
||||||
type game_type = {userKeys: CoreKey.user_key, mode: mode}
|
type game_type = {userKeys: CoreKey.user_key, mode: mode}
|
||||||
|
|
||||||
@@ -9,7 +12,10 @@ end
|
|||||||
|
|
||||||
structure GameType :> GAME_TYPE =
|
structure GameType :> GAME_TYPE =
|
||||||
struct
|
struct
|
||||||
datatype mode = LEVEL of LevelType.level_type | TITLE of TitleType.title_type
|
datatype mode =
|
||||||
|
LEVEL of LevelType.level_type
|
||||||
|
| TITLE of TitleType.title_type
|
||||||
|
| OPTIONS of OptionsType.options_type
|
||||||
|
|
||||||
type game_type = {userKeys: CoreKey.user_key, mode: mode}
|
type game_type = {userKeys: CoreKey.user_key, mode: mode}
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ struct
|
|||||||
case mode of
|
case mode of
|
||||||
LEVEL level => LevelUpdate.update (level, input, userKeys)
|
LEVEL level => LevelUpdate.update (level, input, userKeys)
|
||||||
| TITLE title => TitleUpdate.update (title, input, userKeys)
|
| TITLE title => TitleUpdate.update (title, input, userKeys)
|
||||||
|
| OPTIONS options => OptionsUpdate.update (options, input, userKeys)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,33 @@
|
|||||||
structure OptionsType =
|
signature OPTIONS_TYPE =
|
||||||
struct
|
sig
|
||||||
datatype focus =
|
datatype focus =
|
||||||
|
LEFT_KEY
|
||||||
|
| RIGHT_KEY
|
||||||
|
| UP_KEY
|
||||||
|
| DOWN_KEY
|
||||||
|
| JUMP_KEY
|
||||||
|
| ATTACK_KEY
|
||||||
|
| SAVE_BUTTON
|
||||||
|
| CANCEL_BUTTON
|
||||||
|
|
||||||
|
type options_type = {focus: focus}
|
||||||
|
|
||||||
|
val initial: options_type
|
||||||
|
end
|
||||||
|
|
||||||
|
structure OptionsType :> OPTIONS_TYPE =
|
||||||
|
struct
|
||||||
|
datatype focus =
|
||||||
|
LEFT_KEY
|
||||||
|
| RIGHT_KEY
|
||||||
|
| UP_KEY
|
||||||
|
| DOWN_KEY
|
||||||
|
| JUMP_KEY
|
||||||
|
| ATTACK_KEY
|
||||||
|
| SAVE_BUTTON
|
||||||
|
| CANCEL_BUTTON
|
||||||
|
|
||||||
|
type options_type = {focus: focus}
|
||||||
|
|
||||||
|
val initial = {focus = LEFT_KEY}
|
||||||
end
|
end
|
||||||
|
|||||||
5
fcore/options/options-update.sml
Normal file
5
fcore/options/options-update.sml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
structure OptionsUpdate =
|
||||||
|
struct
|
||||||
|
fun update (options, input, userKeys) =
|
||||||
|
{mode = GameType.OPTIONS options, userKeys = userKeys}
|
||||||
|
end
|
||||||
250
fcore/options/options-vec.sml
Normal file
250
fcore/options/options-vec.sml
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
structure OptionsVec =
|
||||||
|
struct
|
||||||
|
open OptionsType
|
||||||
|
|
||||||
|
(* There's code duplication here because we want to avoid
|
||||||
|
* branhing if/case expressions per draw-call because of
|
||||||
|
* the branch prediction cost *)
|
||||||
|
fun drawLeftKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.3, 0.3, 0.7, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawRightKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawUpKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawDownKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawJumpKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawAttackKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawSaveKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.3, 0.3, 0.7, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun drawCancelKey (options, width, height) =
|
||||||
|
let
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 35, width, height, "Left key", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 95, width, height, "Right key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 155, width, height, "Up key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 215, width, height, "Down key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 275, width, height, "Jump key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 335, width, height, "Attack key", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 395, width, height, "Save changes", 0.0, 0.0, 0.0, acc)
|
||||||
|
|
||||||
|
val acc = MakeTextVec.make
|
||||||
|
(155, 455, width, height, "Cancel changes", 0.3, 0.3, 0.7, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
|
||||||
|
fun getDrawVec (options: OptionsType.options_type, width, height) =
|
||||||
|
case #focus options of
|
||||||
|
LEFT_KEY => drawLeftKey (options, width, height)
|
||||||
|
| RIGHT_KEY => drawRightKey (options, width, height)
|
||||||
|
| UP_KEY => drawUpKey (options, width, height)
|
||||||
|
| DOWN_KEY => drawDownKey (options, width, height)
|
||||||
|
| JUMP_KEY => drawJumpKey (options, width, height)
|
||||||
|
| ATTACK_KEY => drawAttackKey (options, width, height)
|
||||||
|
| SAVE_BUTTON => drawSaveKey (options, width, height)
|
||||||
|
| CANCEL_BUTTON => drawCancelKey (options, width, height)
|
||||||
|
end
|
||||||
@@ -25,7 +25,7 @@ struct
|
|||||||
val mode =
|
val mode =
|
||||||
if #attackHeld input orelse #jumpHeld input then
|
if #attackHeld input orelse #jumpHeld input then
|
||||||
(* placeholder: go to configure screen instead once that is implemented *)
|
(* placeholder: go to configure screen instead once that is implemented *)
|
||||||
GameType.TITLE titleState
|
GameType.OPTIONS OptionsType.initial
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val titleState =
|
val titleState =
|
||||||
|
|||||||
4
oms.mlb
4
oms.mlb
@@ -42,6 +42,7 @@ fcore/frame-input-type.sml
|
|||||||
fcore/level/player/player-type.sml
|
fcore/level/player/player-type.sml
|
||||||
fcore/level/level-type.sml
|
fcore/level/level-type.sml
|
||||||
fcore/title/title-type.sml
|
fcore/title/title-type.sml
|
||||||
|
fcore/options/options-type.sml
|
||||||
fcore/game-type.sml
|
fcore/game-type.sml
|
||||||
|
|
||||||
fcore/level/player/player-patch.sml
|
fcore/level/player/player-patch.sml
|
||||||
@@ -60,6 +61,9 @@ fcore/level/level-update.sml
|
|||||||
fcore/title/title-update.sml
|
fcore/title/title-update.sml
|
||||||
fcore/title/title-vec.sml
|
fcore/title/title-vec.sml
|
||||||
|
|
||||||
|
fcore/options/options-update.sml
|
||||||
|
fcore/options/options-vec.sml
|
||||||
|
|
||||||
fcore/game-update.sml
|
fcore/game-update.sml
|
||||||
|
|
||||||
(* shell *)
|
(* shell *)
|
||||||
|
|||||||
@@ -263,6 +263,19 @@ struct
|
|||||||
shellState
|
shellState
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun helpDrawOptions shellState = drawPlayer shellState
|
||||||
|
|
||||||
|
fun drawOptions (shellState: t, options) =
|
||||||
|
let
|
||||||
|
val width = InputState.getWidth ()
|
||||||
|
val height = InputState.getHeight ()
|
||||||
|
val vec = OptionsVec.getDrawVec (options, width, height)
|
||||||
|
val shellState = uploadPlayer (shellState, vec)
|
||||||
|
val () = helpDrawOptions shellState
|
||||||
|
in
|
||||||
|
shellState
|
||||||
|
end
|
||||||
|
|
||||||
fun drawMode (shellState: t, game: GameType.game_type) =
|
fun drawMode (shellState: t, game: GameType.game_type) =
|
||||||
let
|
let
|
||||||
open GameType
|
open GameType
|
||||||
@@ -270,6 +283,7 @@ struct
|
|||||||
case #mode game of
|
case #mode game of
|
||||||
LEVEL level => drawLevel (shellState, level)
|
LEVEL level => drawLevel (shellState, level)
|
||||||
| TITLE title => drawTitle (shellState, title)
|
| TITLE title => drawTitle (shellState, title)
|
||||||
|
| OPTIONS options => drawOptions (shellState, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpLoop (shellState as {window, ...}: t, game) =
|
fun helpLoop (shellState as {window, ...}: t, game) =
|
||||||
|
|||||||
Reference in New Issue
Block a user