@ -50,6 +50,7 @@ All rights reserved.
# include "InputDisplayComponent.h"
# include "InputDisplayComponent.h"
# include "GameSettings.h"
# include "GameSettings.h"
# include "MenuIconButton.h"
# include "MenuIconButton.h"
# include "ScrollableWindowComponent.h"
INCLUDE_DATA
INCLUDE_DATA
INCLUDE_game
INCLUDE_game
@ -71,12 +72,15 @@ void Menu::InitializeSettingsWindow(){
return true ;
return true ;
} ) END ;
} ) 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 - > 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 - > F ( A : : LAST_BGM_VOLUME ) = 1.f ;
settingsWindow - > F ( A : : LAST_BGM_VOLUME ) = 1.f ;
settingsWindow - > F ( A : : LAST_SFX_VOLUME ) = 1.f ;
settingsWindow - > F ( A : : LAST_SFX_VOLUME ) = 1.f ;
settingsWindow - > ADD ( " BGM Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 32 } , { 172 , 16 } } , " BGM Volume: " , Audio : : GetBGMVolume ( ) , [ ] ( float val ) {
//windowsize.y-20
auto settingsList = settingsWindow - > ADD ( " Settings Scroll List " , ScrollableWindowComponent ) ( geom2d : : rect < float > { { 4 , 32 } , { windowSize . x - 8 , windowSize . y - 56 } } ) END ;
settingsList - > ADD ( " BGM Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 0 } , { 172 , 16 } } , " BGM Volume: " , Audio : : GetBGMVolume ( ) , [ ] ( float val ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_BGM_VOLUME ) - val ) > = 0.04f ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_BGM_VOLUME ) - val ) > = 0.04f ) {
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
@ -85,7 +89,7 @@ void Menu::InitializeSettingsWindow(){
Audio : : SetBGMVolume ( val ) ;
Audio : : SetBGMVolume ( val ) ;
}
}
} ) END ;
} ) END ;
settingsWindow - > ADD ( " SFX Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 5 2} , { 172 , 16 } } , " SFX Volume: " , Audio : : GetSFXVolume ( ) , [ ] ( float val ) {
settingsList - > ADD ( " SFX Slider " , Slider ) ( geom2d : : rect < float > { vf2d { windowSize . x / 2 - 64 , 20 } , { 172 , 16 } } , " SFX Volume: " , Audio : : GetSFXVolume ( ) , [ ] ( float val ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_SFX_VOLUME ) - val ) > = 0.04f ) {
if ( abs ( Menu : : menus [ SETTINGS ] - > F ( A : : LAST_SFX_VOLUME ) - val ) > = 0.04f ) {
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
SoundEffect : : PlaySFX ( " Change Volume " , SoundEffect : : CENTERED ) ;
@ -93,12 +97,12 @@ void Menu::InitializeSettingsWindow(){
}
}
}
}
} ) END ;
} ) END ;
settingsWindow - > ADD ( " Screen Shake Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 72 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsList - > ADD ( " Screen Shake Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 40 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetScreenShake ( data . checked ) ;
GameSettings : : SetScreenShake ( data . checked ) ;
return true ;
return true ;
} , true ) END ;
} , true ) END ;
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 ;
settingsList - > ADD ( " Screen Shake Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 40 } , { 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 ) {
settingsList - > ADD ( " Controller Rumble Checkbox " , Checkbox ) ( geom2d : : rect < float > { { 4.f , 60 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
if ( Menu : : IsCurrentlyActive ( SETTINGS ) ) {
GameSettings : : SetRumble ( data . checked ) ;
GameSettings : : SetRumble ( data . checked ) ;
if ( GameSettings : : RumbleEnabled ( GameSettings : : OVERRIDE ) ) {
if ( GameSettings : : RumbleEnabled ( GameSettings : : OVERRIDE ) ) {
@ -110,20 +114,20 @@ void Menu::InitializeSettingsWindow(){
}
}
return true ;
return true ;
} , true ) END ;
} , true ) 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 ;
settingsList - > ADD ( " Controller Rumble Label " , MenuLabel ) ( geom2d : : rect < float > { { 22.f , 60 } , { 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 , 72 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
settingsList - > ADD ( " Terrain Collision Boxes Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 40 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetTerrainCollisionBoxes ( data . checked ) ;
GameSettings : : SetTerrainCollisionBoxes ( data . checked ) ;
return true ;
return true ;
} , true ) END ;
} , true ) END ;
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 ;
settingsList - > ADD ( " Terrain Collision Boxes Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 40 } , { 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 ) {
settingsList - > ADD ( " Keyboard Play Auto-Aim Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 60 } , { 16.f , 16.f } } , [ ] ( ToggleFuncData data ) {
GameSettings : : SetKeyboardAutoAim ( data . checked ) ;
GameSettings : : SetKeyboardAutoAim ( data . checked ) ;
return true ;
return true ;
} , false ) END ;
} , false ) 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 ;
settingsList - > ADD ( " Keyboard Play Auto-Aim Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 60 } , { 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 ) {
auto fullscreenToggle = settingsList - > ADD ( " Fullscreen Toggle Checkbox " , Checkbox ) ( geom2d : : rect < float > { { windowSize . x / 2 + 4.f , 80 } , { 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.
if ( data . checked ) { //When going to fullscreen mode, the windowed mode positioning needs to be saved to be restored later.
GameSettings : : SetWindowPos ( game - > GetActualWindowPos ( ) ) ;
GameSettings : : SetWindowPos ( game - > GetActualWindowPos ( ) ) ;
}
}
@ -133,13 +137,13 @@ void Menu::InitializeSettingsWindow(){
game - > SetFullscreen ( data . checked , GameSettings : : GetWindowPos ( ) ) ;
game - > SetFullscreen ( data . checked , GameSettings : : GetWindowPos ( ) ) ;
return true ;
return true ;
} , game - > IsFullscreen ( ) ) END ;
} , 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 ;
auto fullscreenToggleLabel = settingsList - > ADD ( " Fullscreen Toggle Label " , MenuLabel ) ( geom2d : : rect < float > { { windowSize . x / 2 + 22.f , 80 } , { windowSize . x / 2 - 24.f , 16.f } } , " Fullscreen " , 1.f , ComponentAttr : : SHADOW | ComponentAttr : : LEFT_ALIGN ) END ;
# ifdef __EMSCRIPTEN__
# ifdef __EMSCRIPTEN__
fullscreenToggle - > Disable ( ) ;
fullscreenToggle - > Disable ( ) ;
fullscreenToggleLabel - > Disable ( ) ;
fullscreenToggleLabel - > Disable ( ) ;
# endif
# endif
settingsWindow - > ADD ( " Button Set Toggle Box " , MenuIconButton ) ( geom2d : : rect < float > { { windowSize . x / 8.f , 112 } , { windowSize . x / 4.f , 16.f } } , GFX [ " themes/xb.png " ] . Decal ( ) , [ ] ( MenuFuncData data ) {
settingsList - > ADD ( " Button Set Toggle Box " , MenuIconButton ) ( geom2d : : rect < float > { { windowSize . x / 8.f , 80 } , { windowSize . x / 4.f , 16.f } } , GFX [ " themes/xb.png " ] . Decal ( ) , [ ] ( MenuFuncData data ) {
switch ( GameSettings : : GetIconType ( ) ) {
switch ( GameSettings : : GetIconType ( ) ) {
case IconType : : XB : {
case IconType : : XB : {
GameSettings : : SetIconType ( IconType : : PS ) ;
GameSettings : : SetIconType ( IconType : : PS ) ;
@ -185,13 +189,13 @@ void Menu::InitializeSettingsWindow(){
} ;
} ;
# pragma endregion
# pragma endregion
settingsWindow - > ADD ( " Keyboard Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 132 .f } , vf2d { windowSize . x - 32 , 24 } } , " Keyboard Bindings " , [ & ] ( MenuFuncData data ) {
settingsList - > ADD ( " Keyboard Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 100 .f } , vf2d { settingsList - > rect . size . x - 12 - 56 , 24 } } , " Keyboard Bindings " , [ & ] ( MenuFuncData data ) {
ChangeKeybindDisplayType ( KEY ) ;
ChangeKeybindDisplayType ( KEY ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Keyboard Mappings " ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Keyboard Mappings " ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;
return true ;
return true ;
} , vf2d { 1.5f , 2.f } ) END ;
} , vf2d { 1.5f , 2.f } ) END ;
settingsWindow - > ADD ( " Controller Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 160 .f } , vf2d { windowSize . x - 32 , 24 } } , " Controller Bindings " , [ & ] ( MenuFuncData data ) {
settingsList - > ADD ( " Controller Bindings Button " , MenuComponent ) ( geom2d : : rect < float > { { 28 , 128 .f } , vf2d { settingsList - > rect . size . x - 12 - 56 , 24 } } , " Controller Bindings " , [ & ] ( MenuFuncData data ) {
ChangeKeybindDisplayType ( CONTROLLER ) ;
ChangeKeybindDisplayType ( CONTROLLER ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Controller Mappings " ) ;
Component < MenuLabel > ( INPUT_KEY_DISPLAY , " Keyboard Mapping Label " ) - > SetLabel ( " Controller Mappings " ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;
Menu : : OpenMenu ( INPUT_KEY_DISPLAY ) ;