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. 24
      Adventures in Lestoria/GameSettings.cpp
  3. 8
      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());
std::string text=player->GetHealth()>0?std::to_string(healthCounter.GetDisplayValue()):"X";
std::string text_mana=std::to_string(manaCounter.GetDisplayValue());
DrawShadowStringPropDecal({20,3},text,healthCounter.GetDisplayColor(),BLACK,{2,2},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){
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);

@ -46,6 +46,8 @@ All rights reserved.
INCLUDE_DATA
bool GameSettings::screenShake=true;
bool GameSettings::showMaxHealth=false;
bool GameSettings::showMaxMana=false;
bool GameSettings::rumble=true;
bool GameSettings::terrainCollisionBoxes=true;
bool GameSettings::keyboardAutoAim=false;
@ -53,6 +55,12 @@ const bool GameSettings::OVERRIDE=true;
vi2d GameSettings::windowPos{30,30};
IconType GameSettings::iconType=IconType::XB;
const bool GameSettings::ShowMaxHealth(){
return showMaxHealth;
}
const bool GameSettings::ShowMaxMana(){
return showMaxMana;
}
const bool GameSettings::ScreenShakeEnabled(){
return screenShake;
}
@ -72,6 +80,12 @@ const IconType GameSettings::GetIconType(){
return iconType;
}
void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){
showMaxHealth=maxHealthDisplayed;
}
void GameSettings::SetMaxManaDisplay(bool maxManaDisplayed){
showMaxMana=maxManaDisplayed;
}
void GameSettings::SetScreenShake(bool screenShakeEnabled){
screenShake=screenShakeEnabled;
}
@ -100,7 +114,15 @@ void GameSettings::Initialize(){
std::cout<<"Reading system data file..."<<std::endl;
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")){
GameSettings::SetScreenShake(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"
class GameSettings{
static bool showMaxHealth;
static bool showMaxMana;
static bool screenShake;
static bool rumble;
static bool terrainCollisionBoxes;
@ -49,13 +51,17 @@ class GameSettings{
static IconType iconType;
public:
static const bool OVERRIDE;
static const bool ShowMaxHealth();
static const bool ShowMaxMana();
static const bool ScreenShakeEnabled();
static const bool RumbleEnabled(const bool override=false);
static const bool TerrainCollisionBoxesEnabled();
static const bool KeyboardAutoAimEnabled();
static const vi2d GetWindowPos();
static const IconType GetIconType();
static void SetMaxHealthDisplay(bool maxHealthDisplayed);
static void SetMaxManaDisplay(bool maxManaDisplayed);
static void SetScreenShake(bool screenShakeEnabled);
static void SetRumble(bool rumbleEnabled);
static void SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled);

@ -164,6 +164,8 @@ const void SaveFile::SaveGame(){
#pragma region Save System Settings
saveSystemFile["BGM Level"].SetReal(Audio::GetBGMVolume());
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["Controller Rumble"].SetBool(GameSettings::RumbleEnabled());
saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled());

@ -97,12 +97,24 @@ void Menu::InitializeSettingsWindow(){
}
}
})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);
return true;
},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("Controller Rumble Checkbox",Checkbox)(geom2d::rect<float>{{4.f,60},{16.f,16.f}},[](ToggleFuncData data){
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,80},{16.f,16.f}},[](ToggleFuncData data){
if(Menu::IsCurrentlyActive(SETTINGS)){
GameSettings::SetRumble(data.checked);
if(GameSettings::RumbleEnabled(GameSettings::OVERRIDE)){
@ -114,20 +126,20 @@ void Menu::InitializeSettingsWindow(){
}
return true;
},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);
return true;
},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("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,60},{16.f,16.f}},[](ToggleFuncData data){
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,80},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetKeyboardAutoAim(data.checked);
return true;
},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.
GameSettings::SetWindowPos(game->GetActualWindowPos());
}
@ -137,13 +149,13 @@ void Menu::InitializeSettingsWindow(){
game->SetFullscreen(data.checked,GameSettings::GetWindowPos());
return true;
},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__
fullscreenToggle->Disable();
fullscreenToggleLabel->Disable();
#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()){
case IconType::XB:{
GameSettings::SetIconType(IconType::PS);
@ -189,13 +201,13 @@ void Menu::InitializeSettingsWindow(){
};
#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);
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Keyboard Mappings");
Menu::OpenMenu(INPUT_KEY_DISPLAY);
return true;
},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);
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
Menu::OpenMenu(INPUT_KEY_DISPLAY);
@ -224,9 +236,19 @@ void Menu::InitializeSettingsWindow(){
.down="SFX Slider",}},
{"SFX Slider",{
.up="BGM Slider",
.down="Terrain Collision Boxes Checkbox",}},
{"Terrain Collision Boxes Checkbox",{
.down="Show Max Mana 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",
.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",
.left="Screen Shake Checkbox",
.right="Screen Shake Checkbox",}},
@ -236,7 +258,7 @@ void Menu::InitializeSettingsWindow(){
.left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}},
{"Screen Shake Checkbox",{
.up="SFX Slider",
.up="Show Max HP Checkbox",
.down="Controller Rumble Checkbox",
.left="Terrain Collision Boxes Checkbox",
.right="Terrain Collision Boxes Checkbox",}},

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

Loading…
Cancel
Save