Add in showing of max health/mana display in settings menu. Release Build 8142.

pull/57/head
sigonasr2 9 months ago
parent 4d912ab259
commit 0484908b37
  1. 19
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 22
      Adventures in Lestoria/GameSettings.cpp
  3. 6
      Adventures in Lestoria/GameSettings.h
  4. 2
      Adventures in Lestoria/SaveFile.cpp
  5. 54
      Adventures in Lestoria/SettingsWindow.cpp
  6. 2
      Adventures in Lestoria/Version.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -1700,8 +1700,27 @@ void AiL::RenderHud(){
DrawDecal({2,20},GFX["mana.png"].Decal()); DrawDecal({2,20},GFX["mana.png"].Decal());
std::string text=player->GetHealth()>0?std::to_string(healthCounter.GetDisplayValue()):"X"; std::string text=player->GetHealth()>0?std::to_string(healthCounter.GetDisplayValue()):"X";
std::string text_mana=std::to_string(manaCounter.GetDisplayValue()); std::string text_mana=std::to_string(manaCounter.GetDisplayValue());
DrawShadowStringPropDecal({20,3},text,healthCounter.GetDisplayColor(),BLACK,{2,2},INFINITE); DrawShadowStringPropDecal({20,3},text,healthCounter.GetDisplayColor(),BLACK,{2,2},INFINITE);
DrawShadowStringPropDecal({24,23},text_mana,manaCounter.GetDisplayColor(),BLACK,{1.5f,1.5f},INFINITE); DrawShadowStringPropDecal({24,23},text_mana,manaCounter.GetDisplayColor(),BLACK,{1.5f,1.5f},INFINITE);
#pragma region Show Max Health/Max Mana
if(GameSettings::ShowMaxHealth()){
vf2d healthTextSize=GetTextSizeProp(text)*vf2d{2.f,2.f};
std::string maxHealthText="/"+std::to_string(int(player->GetMaxHealth()));
float maxHealthTextHeight=GetTextSizeProp(maxHealthText).y;
DrawShadowStringPropDecal(vf2d{20,3}+healthTextSize+vf2d{1.f,-maxHealthTextHeight},maxHealthText,{200,200,200,255},BLACK,{1.f,1.f},INFINITE);
}
if(GameSettings::ShowMaxMana()){
vf2d manaTextSize=GetTextSizeProp(text_mana)*vf2d{1.5f,1.5f};
std::string maxManaText="/"+std::to_string(player->GetMaxMana());
float maxManaTextHeight=GetTextSizeProp(maxManaText).y;
DrawShadowStringPropDecal(vf2d{24,23}+manaTextSize+vf2d{1.f,-maxManaTextHeight},maxManaText,{200,200,255,255},BLACK,{1.f,1.f},INFINITE);
}
#pragma endregion
if(player->notEnoughManaDisplay.second>0){ if(player->notEnoughManaDisplay.second>0){
std::string displayText="Not enough mana for "+player->notEnoughManaDisplay.first+"!"; std::string displayText="Not enough mana for "+player->notEnoughManaDisplay.first+"!";
DrawShadowStringPropDecal(vf2d{float(ScreenWidth()/2),float(ScreenHeight()/4)}-GetTextSizeProp(displayText)/2,displayText,DARK_RED,VERY_DARK_RED); DrawShadowStringPropDecal(vf2d{float(ScreenWidth()/2),float(ScreenHeight()/4)}-GetTextSizeProp(displayText)/2,displayText,DARK_RED,VERY_DARK_RED);

@ -46,6 +46,8 @@ All rights reserved.
INCLUDE_DATA INCLUDE_DATA
bool GameSettings::screenShake=true; bool GameSettings::screenShake=true;
bool GameSettings::showMaxHealth=false;
bool GameSettings::showMaxMana=false;
bool GameSettings::rumble=true; bool GameSettings::rumble=true;
bool GameSettings::terrainCollisionBoxes=true; bool GameSettings::terrainCollisionBoxes=true;
bool GameSettings::keyboardAutoAim=false; bool GameSettings::keyboardAutoAim=false;
@ -53,6 +55,12 @@ const bool GameSettings::OVERRIDE=true;
vi2d GameSettings::windowPos{30,30}; vi2d GameSettings::windowPos{30,30};
IconType GameSettings::iconType=IconType::XB; IconType GameSettings::iconType=IconType::XB;
const bool GameSettings::ShowMaxHealth(){
return showMaxHealth;
}
const bool GameSettings::ShowMaxMana(){
return showMaxMana;
}
const bool GameSettings::ScreenShakeEnabled(){ const bool GameSettings::ScreenShakeEnabled(){
return screenShake; return screenShake;
} }
@ -72,6 +80,12 @@ const IconType GameSettings::GetIconType(){
return iconType; return iconType;
} }
void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){
showMaxHealth=maxHealthDisplayed;
}
void GameSettings::SetMaxManaDisplay(bool maxManaDisplayed){
showMaxMana=maxManaDisplayed;
}
void GameSettings::SetScreenShake(bool screenShakeEnabled){ void GameSettings::SetScreenShake(bool screenShakeEnabled){
screenShake=screenShakeEnabled; screenShake=screenShakeEnabled;
} }
@ -101,6 +115,14 @@ void GameSettings::Initialize(){
utils::datafile::Read(loadSystemFile,loadSystemFilename); utils::datafile::Read(loadSystemFile,loadSystemFilename);
} }
if(loadSystemFile.HasProperty("Show Max Health")){
GameSettings::SetMaxHealthDisplay(loadSystemFile["Show Max Health"].GetBool());
Component<Checkbox>(SETTINGS,"Show Max HP Checkbox")->SetChecked(loadSystemFile["Show Max Health"].GetBool());
}
if(loadSystemFile.HasProperty("Show Max Mana")){
GameSettings::SetMaxManaDisplay(loadSystemFile["Show Max Mana"].GetBool());
Component<Checkbox>(SETTINGS,"Show Max Mana Checkbox")->SetChecked(loadSystemFile["Show Max Mana"].GetBool());
}
if(loadSystemFile.HasProperty("Screen Shake")){ if(loadSystemFile.HasProperty("Screen Shake")){
GameSettings::SetScreenShake(loadSystemFile["Screen Shake"].GetBool()); GameSettings::SetScreenShake(loadSystemFile["Screen Shake"].GetBool());
Component<Checkbox>(SETTINGS,"Screen Shake Checkbox")->SetChecked(loadSystemFile["Screen Shake"].GetBool()); Component<Checkbox>(SETTINGS,"Screen Shake Checkbox")->SetChecked(loadSystemFile["Screen Shake"].GetBool());

@ -41,6 +41,8 @@ All rights reserved.
#include "IconType.h" #include "IconType.h"
class GameSettings{ class GameSettings{
static bool showMaxHealth;
static bool showMaxMana;
static bool screenShake; static bool screenShake;
static bool rumble; static bool rumble;
static bool terrainCollisionBoxes; static bool terrainCollisionBoxes;
@ -50,12 +52,16 @@ class GameSettings{
public: public:
static const bool OVERRIDE; static const bool OVERRIDE;
static const bool ShowMaxHealth();
static const bool ShowMaxMana();
static const bool ScreenShakeEnabled(); static const bool ScreenShakeEnabled();
static const bool RumbleEnabled(const bool override=false); static const bool RumbleEnabled(const bool override=false);
static const bool TerrainCollisionBoxesEnabled(); static const bool TerrainCollisionBoxesEnabled();
static const bool KeyboardAutoAimEnabled(); static const bool KeyboardAutoAimEnabled();
static const vi2d GetWindowPos(); static const vi2d GetWindowPos();
static const IconType GetIconType(); static const IconType GetIconType();
static void SetMaxHealthDisplay(bool maxHealthDisplayed);
static void SetMaxManaDisplay(bool maxManaDisplayed);
static void SetScreenShake(bool screenShakeEnabled); static void SetScreenShake(bool screenShakeEnabled);
static void SetRumble(bool rumbleEnabled); static void SetRumble(bool rumbleEnabled);
static void SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled); static void SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled);

@ -164,6 +164,8 @@ const void SaveFile::SaveGame(){
#pragma region Save System Settings #pragma region Save System Settings
saveSystemFile["BGM Level"].SetReal(Audio::GetBGMVolume()); saveSystemFile["BGM Level"].SetReal(Audio::GetBGMVolume());
saveSystemFile["SFX Level"].SetReal(Audio::GetSFXVolume()); saveSystemFile["SFX Level"].SetReal(Audio::GetSFXVolume());
saveSystemFile["Show Max Health"].SetBool(GameSettings::ShowMaxHealth());
saveSystemFile["Show Max Mana"].SetBool(GameSettings::ShowMaxMana());
saveSystemFile["Screen Shake"].SetBool(GameSettings::ScreenShakeEnabled()); saveSystemFile["Screen Shake"].SetBool(GameSettings::ScreenShakeEnabled());
saveSystemFile["Controller Rumble"].SetBool(GameSettings::RumbleEnabled()); saveSystemFile["Controller Rumble"].SetBool(GameSettings::RumbleEnabled());
saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled()); saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled());

@ -97,12 +97,24 @@ void Menu::InitializeSettingsWindow(){
} }
} }
})END; })END;
settingsList->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect<float>{{4.f,40},{16.f,16.f}},[](ToggleFuncData data){
settingsList->ADD("Show Max HP Checkbox",Checkbox)(geom2d::rect<float>{{4.f,40},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetMaxHealthDisplay(data.checked);
return true;
},false)END;
settingsList->ADD("Show Max HP Label",MenuLabel)(geom2d::rect<float>{{22.f,40},{windowSize.x/2-24.f,16.f}},"Show Max Health",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Show Max Mana Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,40},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetMaxManaDisplay(data.checked);
return true;
},false)END;
settingsList->ADD("Show Max Mana Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,40},{windowSize.x/2-24.f,16.f}},"Show Max Mana",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect<float>{{4.f,60},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetScreenShake(data.checked); GameSettings::SetScreenShake(data.checked);
return true; return true;
},true)END; },true)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; settingsList->ADD("Screen Shake Label",MenuLabel)(geom2d::rect<float>{{22.f,60},{windowSize.x/2-24.f,16.f}},"Screen Shake",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect<float>{{4.f,60},{16.f,16.f}},[](ToggleFuncData data){ settingsList->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect<float>{{4.f,80},{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)){
@ -114,20 +126,20 @@ void Menu::InitializeSettingsWindow(){
} }
return true; return true;
},true)END; },true)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; settingsList->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect<float>{{22.f,80},{windowSize.x/2-24.f,16.f}},"Gamepad Rumble",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,40},{16.f,16.f}},[](ToggleFuncData data){ settingsList->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,60},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetTerrainCollisionBoxes(data.checked); GameSettings::SetTerrainCollisionBoxes(data.checked);
return true; return true;
},true)END; },true)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; settingsList->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,60},{windowSize.x/2-24.f,16.f}},"Terrain Collision Boxes",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,60},{16.f,16.f}},[](ToggleFuncData data){ settingsList->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,80},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetKeyboardAutoAim(data.checked); GameSettings::SetKeyboardAutoAim(data.checked);
return true; return true;
},false)END; },false)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; settingsList->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,80},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
auto fullscreenToggle=settingsList->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,80},{16.f,16.f}},[](ToggleFuncData data){ auto fullscreenToggle=settingsList->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,100},{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());
} }
@ -137,13 +149,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=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; auto fullscreenToggleLabel=settingsList->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,100},{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
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){ settingsList->ADD("Button Set Toggle Box",MenuIconButton)(geom2d::rect<float>{{windowSize.x/8.f,100},{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);
@ -189,13 +201,13 @@ void Menu::InitializeSettingsWindow(){
}; };
#pragma endregion #pragma endregion
settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,100.f},vf2d{settingsList->rect.size.x-12-56,24}},"Keyboard Bindings",[&](MenuFuncData data){ settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,120.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;
settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,128.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){ settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,148.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);
@ -224,9 +236,19 @@ void Menu::InitializeSettingsWindow(){
.down="SFX Slider",}}, .down="SFX Slider",}},
{"SFX Slider",{ {"SFX Slider",{
.up="BGM Slider", .up="BGM Slider",
.down="Terrain Collision Boxes Checkbox",}}, .down="Show Max Mana Checkbox",}},
{"Terrain Collision Boxes Checkbox",{ {"Show Max HP Checkbox",{
.up="SFX Slider",
.down="Screen Shake Checkbox",
.left="Show Max Mana Checkbox",
.right="Show Max Mana Checkbox",}},
{"Show Max Mana Checkbox",{
.up="SFX Slider", .up="SFX Slider",
.down="Terrain Collision Boxes Checkbox",
.left="Show Max HP Checkbox",
.right="Show Max HP Checkbox",}},
{"Terrain Collision Boxes Checkbox",{
.up="Show Max Mana Checkbox",
.down="Keyboard Play Auto-Aim Checkbox", .down="Keyboard Play Auto-Aim Checkbox",
.left="Screen Shake Checkbox", .left="Screen Shake Checkbox",
.right="Screen Shake Checkbox",}}, .right="Screen Shake Checkbox",}},
@ -236,7 +258,7 @@ void Menu::InitializeSettingsWindow(){
.left="Controller Rumble Checkbox", .left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}}, .right="Controller Rumble Checkbox",}},
{"Screen Shake Checkbox",{ {"Screen Shake Checkbox",{
.up="SFX Slider", .up="Show Max HP Checkbox",
.down="Controller Rumble Checkbox", .down="Controller Rumble Checkbox",
.left="Terrain Collision Boxes Checkbox", .left="Terrain Collision Boxes Checkbox",
.right="Terrain Collision Boxes Checkbox",}}, .right="Terrain Collision Boxes Checkbox",}},

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 5 #define VERSION_MINOR 5
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 8134 #define VERSION_BUILD 8142
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save