Moved settings related to the game itself into its own settings save file. Emscripten build also saves a separate system settings file in indexeddb. Added checks to prevent menu sounds from playing when the menu is not currently open, but adjusted in a different location in the game. Implemented different button icon sets and a setting to toggle between them. Removed the double button display (caused more confusion and took up more room). Fixed a bug with iterating through navigation groups when a button was removed/disabled from the list. Removed iconscaling dependency based on MenuIconButton sizes.

This commit is contained in:
2024-02-20 03:47:12 -06:00
parent 0d295021b6
commit 66b0648a59
45 changed files with 459 additions and 155 deletions
+61 -22
View File
@@ -49,6 +49,7 @@ All rights reserved.
#include "Checkbox.h"
#include "InputDisplayComponent.h"
#include "GameSettings.h"
#include "MenuIconButton.h"
INCLUDE_DATA
INCLUDE_game
@@ -60,11 +61,13 @@ 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-12},{72,12}},"Unlock All",[](MenuFuncData data){
for(auto&cp:State_OverworldMap::connections){
Unlock::UnlockArea(cp.map);
settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect<float>{{4,windowSize.y-20},{72,12}},"Unlock All",[](MenuFuncData data){
if(Menu::IsCurrentlyActive(SETTINGS)){
for(auto&cp:State_OverworldMap::connections){
Unlock::UnlockArea(cp.map);
}
SoundEffect::PlaySFX("Buy Item",SoundEffect::CENTERED);
}
SoundEffect::PlaySFX("Buy Item",SoundEffect::CENTERED);
return true;
})END;
@@ -74,16 +77,20 @@ void Menu::InitializeSettingsWindow(){
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){
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;
if(Menu::IsCurrentlyActive(SETTINGS)){
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);
}
Audio::SetBGMVolume(val);
})END;
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;
if(Menu::IsCurrentlyActive(SETTINGS)){
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,72},{16.f,16.f}},[](ToggleFuncData data){
@@ -92,12 +99,14 @@ void Menu::InitializeSettingsWindow(){
},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;
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();
data.component.lock()->F(A::RUMBLE_TIMER)=0.3f;
}else{
Input::StopVibration();
if(Menu::IsCurrentlyActive(SETTINGS)){
GameSettings::SetRumble(data.checked);
if(GameSettings::RumbleEnabled()){
Input::StartVibration();
data.component.lock()->F(A::RUMBLE_TIMER)=0.3f;
}else{
Input::StopVibration();
}
}
return true;
},true)END;
@@ -129,6 +138,27 @@ void Menu::InitializeSettingsWindow(){
fullscreenToggle->Disable();
fullscreenToggleLabel->Disable();
#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){
switch(GameSettings::GetIconType()){
case IconType::XB:{
GameSettings::SetIconType(IconType::PS);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/ps.png"].Decal());
}break;
case IconType::PS:{
GameSettings::SetIconType(IconType::XB_REVERSED);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/xb_reversed.png"].Decal());
}break;
case IconType::XB_REVERSED:{
GameSettings::SetIconType(IconType::XB);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/xb.png"].Decal());
}break;
default:{
ERR(std::format("WARNING! Unhandled icon type {}!",int(GameSettings::GetIconType())));
}
}
return true;
})END;
#pragma region Setup all input displays as keyboard controls.
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
@@ -165,7 +195,7 @@ void Menu::InitializeSettingsWindow(){
return true;
},vf2d{1.5f,2.f})END;
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){
settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect<float>{vf2d{windowSize.x/2.f,windowSize.y-12}-vf2d{36,8},{72,12}},"Go Back",[](MenuFuncData data){
Menu::CloseMenu();
return true;
})END;
@@ -205,16 +235,25 @@ void Menu::InitializeSettingsWindow(){
.right="Terrain Collision Boxes Checkbox",}},
{"Controller Rumble Checkbox",{
.up="Screen Shake Checkbox",
.down="Fullscreen Toggle Checkbox",
.down="Button Set Toggle Box",
.left="Keyboard Play Auto-Aim Checkbox",
.right="Keyboard Play Auto-Aim Checkbox",}},
{"Button Set Toggle Box",{
.up="Controller Rumble Checkbox",
.down="Keyboard Bindings Button",
.left="Fullscreen Toggle Checkbox",
.right="Fullscreen Toggle Checkbox",}},
{"Fullscreen Toggle Checkbox",{
.up="Keyboard Play Auto-Aim Checkbox",
.down="Keyboard Bindings Button",
.left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}},
.left="Button Set Toggle Box",
.right="Button Set Toggle Box",}},
{"Keyboard Bindings Button",{
.up="Fullscreen Toggle Checkbox",
#ifdef __EMSCRIPTEN__
.up="Button Set Toggle Box",
#else
.up="Fullscreen Toggle Checkbox",
#endif
.down="Controller Bindings Button",}},
{"Controller Bindings Button",{
.up="Keyboard Bindings Button",