add functionality to move between start button/options button
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
signature TITLE_TYPE =
|
signature TITLE_TYPE =
|
||||||
sig
|
sig
|
||||||
datatype focus = START_BUTTON
|
datatype focus = START_BUTTON | OPTIONS_BUTTON
|
||||||
|
|
||||||
type title_type = {focus: focus}
|
type title_type = {focus: focus}
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ end
|
|||||||
|
|
||||||
structure TitleType :> TITLE_TYPE =
|
structure TitleType :> TITLE_TYPE =
|
||||||
struct
|
struct
|
||||||
datatype focus = START_BUTTON
|
datatype focus = START_BUTTON | OPTIONS_BUTTON
|
||||||
|
|
||||||
type title_type = {focus: focus}
|
type title_type = {focus: focus}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,34 @@ struct
|
|||||||
if #attackHeld input orelse #jumpHeld input then
|
if #attackHeld input orelse #jumpHeld input then
|
||||||
GameType.LEVEL LevelType.initial
|
GameType.LEVEL LevelType.initial
|
||||||
else
|
else
|
||||||
|
let
|
||||||
|
val titleState =
|
||||||
|
if #downHeld input then
|
||||||
|
{focus = OPTIONS_BUTTON}
|
||||||
|
else
|
||||||
|
titleState
|
||||||
|
in
|
||||||
GameType.TITLE titleState
|
GameType.TITLE titleState
|
||||||
|
end
|
||||||
|
in
|
||||||
|
{mode = mode, userKeys = userKeys}
|
||||||
|
end
|
||||||
|
| OPTIONS_BUTTON =>
|
||||||
|
let
|
||||||
|
val mode =
|
||||||
|
if #attackHeld input orelse #jumpHeld input then
|
||||||
|
(* placeholder: go to configure screen instead once that is implemented *)
|
||||||
|
GameType.TITLE titleState
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val titleState =
|
||||||
|
if #upHeld input then
|
||||||
|
{focus = START_BUTTON}
|
||||||
|
else
|
||||||
|
titleState
|
||||||
|
in
|
||||||
|
GameType.TITLE titleState
|
||||||
|
end
|
||||||
in
|
in
|
||||||
{mode = mode, userKeys = userKeys}
|
{mode = mode, userKeys = userKeys}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ struct
|
|||||||
, b
|
, b
|
||||||
) =
|
) =
|
||||||
if pos = String.size str then
|
if pos = String.size str then
|
||||||
Vector.concat acc
|
acc
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val chr = String.sub (str, pos)
|
val chr = String.sub (str, pos)
|
||||||
@@ -51,7 +51,7 @@ struct
|
|||||||
in (Constants.worldWidth - textWidth) div 2
|
in (Constants.worldWidth - textWidth) div 2
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getTextVec (x, y, width, height, str, r, g, b) =
|
fun getTextVec (x, y, width, height, str, r, g, b, acc) =
|
||||||
let
|
let
|
||||||
val wratio = width / Constants.worldWidthReal
|
val wratio = width / Constants.worldWidthReal
|
||||||
val hratio = height / Constants.worldHeightReal
|
val hratio = height / Constants.worldHeightReal
|
||||||
@@ -76,7 +76,7 @@ struct
|
|||||||
val fontSpace = Real32.toInt IEEEReal.TO_NEAREST fontSpace
|
val fontSpace = Real32.toInt IEEEReal.TO_NEAREST fontSpace
|
||||||
in
|
in
|
||||||
helpGetTextVec
|
helpGetTextVec
|
||||||
(x, y, fontSize, fontSpace, width, height, 0, str, [], r, g, b)
|
(x, y, fontSize, fontSpace, width, height, 0, str, acc, r, g, b)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -98,14 +98,34 @@ struct
|
|||||||
val fontSpace = Real32.toInt IEEEReal.TO_NEAREST fontSpace
|
val fontSpace = Real32.toInt IEEEReal.TO_NEAREST fontSpace
|
||||||
in
|
in
|
||||||
helpGetTextVec
|
helpGetTextVec
|
||||||
(x, y, fontSize, fontSpace, width, height, 0, str, [], r, g, b)
|
(x, y, fontSize, fontSpace, width, height, 0, str, acc, r, g, b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getDrawVec (title: TitleType.title_type, width, height) =
|
fun getDrawVec (title: TitleType.title_type, width, height) =
|
||||||
case #focus title of
|
case #focus title of
|
||||||
START_BUTTON =>
|
START_BUTTON =>
|
||||||
let val playX = getTextCentreX "Play game"
|
let
|
||||||
in getTextVec (playX, 500, width, height, "Play game", 0.0, 0.0, 0.0)
|
val playX = getTextCentreX "Play game"
|
||||||
|
val acc =
|
||||||
|
getTextVec (playX, 500, width, height, "Play game", 0.3, 0.3, 0.7, [])
|
||||||
|
|
||||||
|
val optionsX = getTextCentreX "Options"
|
||||||
|
val acc =
|
||||||
|
getTextVec (optionsX, 600, width, height, "Options", 0.0, 0.0, 0.0, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
|
end
|
||||||
|
| OPTIONS_BUTTON =>
|
||||||
|
let
|
||||||
|
val playX = getTextCentreX "Play game"
|
||||||
|
val acc =
|
||||||
|
getTextVec (playX, 500, width, height, "Play game", 0.0, 0.0, 0.0, [])
|
||||||
|
|
||||||
|
val optionsX = getTextCentreX "Options"
|
||||||
|
val acc =
|
||||||
|
getTextVec (optionsX, 600, width, height, "Options", 0.3, 0.3, 0.7, acc)
|
||||||
|
in
|
||||||
|
Vector.concat acc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user