@ -60,7 +60,7 @@ void Menu::InitializeSettingsWindow(){
vf2d windowSize = WINDOW_SIZE - vf2d { 28 , 28 } ;
Menu * settingsWindow = CreateMenu ( SETTINGS , CENTERED , windowSize ) ;
settingsWindow - > ADD ( " Unlock All Button " , MenuComponent ) ( geom2d : : rect < float > { { 4 , windowSize . y } , { 72 , 12 } } , " Unlock All " , [ ] ( MenuFuncData data ) {
settingsWindow - > ADD ( " Unlock All Button " , MenuComponent ) ( geom2d : : rect < float > { { 4 , windowSize . y - 12 } , { 72 , 12 } } , " Unlock All " , [ ] ( MenuFuncData data ) {
for ( auto & cp : State_OverworldMap : : connections ) {
Unlock : : UnlockArea ( cp . map ) ;
}
@ -68,30 +68,30 @@ void Menu::InitializeSettingsWindow(){
return true ;
} ) END ;
settingsWindow - > ADD ( " Settings Label " , MenuLabel ) ( geom2d : : rect < float > { { 4 , 4 } , vf2d { windowSize . x - 8 , 24 } } , " Game Settings " , 2.f , ComponentAttr : : BACKGROUND | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
settingsWindow - > ADD ( " Settings Label " , MenuLabel ) ( geom2d : : rect < float > { { 4 , 4 } , vf2d { windowSize . x - 20 , 24 } } , " Game Settings " , 2.f , ComponentAttr : : BACKGROUND | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
settingsWindow - > F ( A : : LAST_BGM_VOLUME ) = 1.f ;
settingsWindow - > F ( A : : LAST_SFX_VOLUME ) = 1.f ;
settingsWindow - > ADD ( " BGM Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 44 } , { 172 , 16 } } , " BGM Volume: " , Audio : : GetBGMVolume ( ) , [ ] ( float val ) {
settingsWindow - > ADD ( " BGM Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 32 } , { 172 , 16 } } , " BGM Volume: " , Audio : : GetBGMVolume ( ) , [ ] ( float val ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_BGM_VOLUME ) - val ) > = 0.04f ) {
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
Menu : : menus [ SETTINGS ] - > F ( A : : LAST_BGM_VOLUME ) = val ;
}
Audio : : SetBGMVolume ( val ) ;
} ) END ;
settingsWindow - > ADD ( " SFX Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 64 } , { 172 , 16 } } , " SFX Volume: " , Audio : : GetSFXVolume ( ) , [ ] ( float val ) {
settingsWindow - > ADD ( " SFX Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 52 } , { 172 , 16 } } , " SFX Volume: " , Audio : : GetSFXVolume ( ) , [ ] ( float val ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_SFX_VOLUME ) - val ) > = 0.04f ) {
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
Menu : : menus [ SETTINGS ] - > F ( A : : LAST_SFX_VOLUME ) = val ;
}
} ) END ;
settingsWindow - > ADD ( " Screen Shake Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 84 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsWindow - > ADD ( " Screen Shake Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 72 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetScreenShake ( data . checked ) ;
return true ;
} , true ) END ;
settingsWindow - > ADD ( " Screen Shake Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 84 } , { windowSize . x / 2 - 24.f , 16.f } } , " Screen Shake " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Controller Rumble Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 104 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsWindow - > ADD ( " Screen Shake Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 72 } , { windowSize . x / 2 - 24.f , 16.f } } , " Screen Shake " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Controller Rumble Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 92 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetRumble ( data . checked ) ;
if ( GameSettings : : RumbleEnabled ( ) ) {
Input : : StartVibration ( ) ;
@ -101,27 +101,33 @@ void Menu::InitializeSettingsWindow(){
}
return true ;
} , true ) END ;
settingsWindow - > ADD ( " Controller Rumble Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 104 } , { windowSize . x / 2 - 24.f , 16.f } } , " Gamepad Rumble " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Controller Rumble Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 92 } , { windowSize . x / 2 - 24.f , 16.f } } , " Gamepad Rumble " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Terrain Collision Boxes Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 84 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsWindow - > ADD ( " Terrain Collision Boxes Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 72 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetTerrainCollisionBoxes ( data . checked ) ;
return true ;
} , true ) END ;
settingsWindow - > ADD ( " Terrain Collision Boxes Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 84 } , { windowSize . x / 2 - 24.f , 16.f } } , " Terrain Collision Boxes " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Keyboard Play Auto-Aim Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 104 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsWindow - > ADD ( " Terrain Collision Boxes Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 72 } , { windowSize . x / 2 - 24.f , 16.f } } , " Terrain Collision Boxes " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Keyboard Play Auto-Aim Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 92 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetKeyboardAutoAim ( data . checked ) ;
return true ;
} , false ) END ;
settingsWindow - > ADD ( " Keyboard Play Auto-Aim Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 104 } , { windowSize . x / 2 - 24.f , 16.f } } , " Aim Assist \n (No Mouse Players) " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
# ifndef __EMSCRIPTEN__
settingsWindow - > ADD ( " Fullscreen Toggle Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 124 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
if ( data . checked ) { //When going to fullscreen mode, the windowed mode positioning needs to be saved to be restored later.
GameSettings : : SetWindowPos ( game - > GetActualWindowPos ( ) ) ;
}
game - > SetFullscreen ( data . checked , GameSettings : : GetWindowPos ( ) ) ;
return true ;
} , game - > IsFullscreen ( ) ) END ;
settingsWindow - > ADD ( " Fullscreen Toggle Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 124 } , { windowSize . x / 2 - 24.f , 16.f } } , " Fullscreen " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
settingsWindow - > ADD ( " Keyboard Play Auto-Aim Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 92 } , { windowSize . x / 2 - 24.f , 16.f } } , " Aim Assist \n (No Mouse Players) " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
auto fullscreenToggle = settingsWindow - > ADD ( " Fullscreen Toggle Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 112 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
if ( data . checked ) { //When going to fullscreen mode, the windowed mode positioning needs to be saved to be restored later.
GameSettings : : SetWindowPos ( game - > GetActualWindowPos ( ) ) ;
}
if ( ! Menu : : UsingMouseNavigation ( ) ) { //This prevents the fullscreen toggle from losing focus upon a window resize.
Menu : : IgnoreNextMouseNavigationAttempt ( ) ;
}
game - > SetFullscreen ( data . checked , GameSettings : : GetWindowPos ( ) ) ;
return true ;
} , game - > IsFullscreen ( ) ) END ;
auto fullscreenToggleLabel = settingsWindow - > ADD ( " Fullscreen Toggle Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 112 } , { windowSize . x / 2 - 24.f , 16.f } } , " Fullscreen " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
# ifdef __EMSCRIPTEN__
fullscreenToggle - > Disable ( ) ;
fullscreenToggleLabel - > Disable ( ) ;
# endif
# pragma region Setup all input displays as keyboard controls.
@ -146,21 +152,82 @@ void Menu::InitializeSettingsWindow(){
} ;
# pragma endregion
settingsWindow - > ADD ( " Keyboard Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 144 .f } , vf2d { windowSize . x - 32 , 24 } } , " Keyboard Bindings " , [ & ] ( MenuFuncData data ) {
settingsWindow - > ADD ( " Keyboard Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 132 .f } , vf2d { windowSize . x - 32 , 24 } } , " Keyboard Bindings " , [ & ] ( MenuFuncData data ) {
ChangeKeybindDisplayType ( KEY ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Keyboard Mappings " ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;
return true ;
} , vf2d { 1.5f , 2.f } ) END ;
settingsWindow - > ADD ( " Controller Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 172 .f } , vf2d { windowSize . x - 32 , 24 } } , " Controller Bindings " , [ & ] ( MenuFuncData data ) {
settingsWindow - > ADD ( " Controller Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 160 .f } , vf2d { windowSize . x - 32 , 24 } } , " Controller Bindings " , [ & ] ( MenuFuncData data ) {
ChangeKeybindDisplayType ( CONTROLLER ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Controller Mappings " ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;
return true ;
} , vf2d { 1.5f , 2.f } ) END ;
settingsWindow - > ADD ( " Go Back " , MenuComponent ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2.f , windowSize . y } - vf2d { 36 , 4 } , { 72 , 12 } } , " Go Back " , [ ] ( MenuFuncData data ) {
settingsWindow - > ADD ( " Go Back " , MenuComponent ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2.f , windowSize . y - 12 } - vf2d { 36 , 4 } , { 72 , 12 } } , " Go Back " , [ ] ( MenuFuncData data ) {
Menu : : CloseMenu ( ) ;
return true ;
} ) END ;
settingsWindow - > SetupKeyboardNavigation (
[ ] ( MenuType type , Data & returnData ) { //On Open
returnData = " BGM Slider " ;
} ,
{ //Button Key
{ game - > KEY_SCROLL , { " Navigate " , [ ] ( MenuType type ) { } } } ,
{ game - > KEY_BACK , { " Back " , [ ] ( MenuType type ) {
Menu : : CloseMenu ( ) ;
} } } ,
{ game - > KEY_CONFIRM , { " Select " , [ ] ( MenuType type ) { } } } ,
}
, { //Button Navigation Rules
{ " BGM Slider " , {
. up = " Go Back " ,
. down = " SFX Slider " , } } ,
{ " SFX Slider " , {
. up = " BGM Slider " ,
. down = " Terrain Collision Boxes Checkbox " , } } ,
{ " Terrain Collision Boxes Checkbox " , {
. up = " SFX Slider " ,
. down = " Keyboard Play Auto-Aim Checkbox " ,
. left = " Screen Shake Checkbox " ,
. right = " Screen Shake Checkbox " , } } ,
{ " Keyboard Play Auto-Aim Checkbox " , {
. up = " Terrain Collision Boxes Checkbox " ,
. down = " Fullscreen Toggle Checkbox " ,
. left = " Controller Rumble Checkbox " ,
. right = " Controller Rumble Checkbox " , } } ,
{ " Screen Shake Checkbox " , {
. up = " SFX Slider " ,
. down = " Controller Rumble Checkbox " ,
. left = " Terrain Collision Boxes Checkbox " ,
. right = " Terrain Collision Boxes Checkbox " , } } ,
{ " Controller Rumble Checkbox " , {
. up = " Screen Shake Checkbox " ,
. down = " Fullscreen Toggle Checkbox " ,
. left = " Keyboard Play Auto-Aim Checkbox " ,
. right = " Keyboard Play Auto-Aim Checkbox " , } } ,
{ " Fullscreen Toggle Checkbox " , {
. up = " Keyboard Play Auto-Aim Checkbox " ,
. down = " Keyboard Bindings Button " ,
. left = " Controller Rumble Checkbox " ,
. right = " Controller Rumble Checkbox " , } } ,
{ " Keyboard Bindings Button " , {
. up = " Fullscreen Toggle Checkbox " ,
. down = " Controller Bindings Button " , } } ,
{ " Controller Bindings Button " , {
. up = " Keyboard Bindings Button " ,
. down = " Go Back " , } } ,
{ " Go Back " , {
. up = " Controller Bindings Button " ,
. down = " BGM Slider " ,
. left = " Unlock All Button " ,
. right = " Unlock All Button " , } } ,
{ " Unlock All Button " , {
. up = " Controller Bindings Button " ,
. down = " BGM Slider " ,
. left = " Go Back " ,
. right = " Go Back " , } } ,
} ) ;
}