Added VSync toggle to Settings windows. Release Build 8464.

mac-build
sigonasr2 11 months ago
parent 9fb5946369
commit 68ed4d2b5d
  1. 4
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 12
      Adventures in Lestoria/GameSettings.cpp
  3. 3
      Adventures in Lestoria/GameSettings.h
  4. 1
      Adventures in Lestoria/SaveFile.cpp
  5. 44
      Adventures in Lestoria/SettingsWindow.cpp
  6. 2
      Adventures in Lestoria/Version.h
  7. 7
      Adventures in Lestoria/olcPixelGameEngine.h
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2713,6 +2713,7 @@ int main()
vi2d windowPosConf={30,30}; vi2d windowPosConf={30,30};
vi2d windowSizeConf=WINDOW_SIZE*4; vi2d windowSizeConf=WINDOW_SIZE*4;
bool fullscreenConf=false; bool fullscreenConf=false;
bool vsyncConf=GameSettings::VSyncEnabled();
if(std::filesystem::exists(loadSystemFilename)){ if(std::filesystem::exists(loadSystemFilename)){
utils::datafile::Read(loadSystemFile,loadSystemFilename); utils::datafile::Read(loadSystemFile,loadSystemFilename);
@ -2733,11 +2734,12 @@ int main()
} }
#endif #endif
if(loadSystemFile.HasProperty("Fullscreen"))fullscreenConf=loadSystemFile["Fullscreen"].GetBool(); if(loadSystemFile.HasProperty("Fullscreen"))fullscreenConf=loadSystemFile["Fullscreen"].GetBool();
if(loadSystemFile.HasProperty("VSync"))vsyncConf=loadSystemFile["VSync"].GetBool();
if(requiredSize>0)fullscreenConf=true; if(requiredSize>0)fullscreenConf=true;
} }
#pragma endregion #pragma endregion
if (demo.Construct(windowPosConf.x, windowPosConf.y, windowSizeConf.x, windowSizeConf.y, WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4, fullscreenConf)) if (demo.Construct(windowPosConf.x, windowPosConf.y, windowSizeConf.x, windowSizeConf.y, WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4, fullscreenConf, vsyncConf))
demo.Start(); demo.Start();
} }

@ -51,6 +51,7 @@ 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;
bool GameSettings::vsync=true;
const bool GameSettings::OVERRIDE=true; 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;
@ -79,6 +80,9 @@ const vi2d GameSettings::GetWindowPos(){
const IconType GameSettings::GetIconType(){ const IconType GameSettings::GetIconType(){
return iconType; return iconType;
} }
const bool GameSettings::VSyncEnabled(){
return vsync;
}
void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){ void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){
showMaxHealth=maxHealthDisplayed; showMaxHealth=maxHealthDisplayed;
@ -105,6 +109,10 @@ void GameSettings::SetIconType(IconType type){
iconType=type; iconType=type;
} }
void GameSettings::SetVSync(const bool vSyncEnabled){
vsync=vSyncEnabled;
}
void GameSettings::Initialize(){ void GameSettings::Initialize(){
utils::datafile loadSystemFile; utils::datafile loadSystemFile;
@ -139,6 +147,10 @@ void GameSettings::Initialize(){
GameSettings::SetKeyboardAutoAim(loadSystemFile["Keyboard Auto-Aim"].GetBool()); GameSettings::SetKeyboardAutoAim(loadSystemFile["Keyboard Auto-Aim"].GetBool());
Component<Checkbox>(SETTINGS,"Keyboard Play Auto-Aim Checkbox")->SetChecked(loadSystemFile["Keyboard Auto-Aim"].GetBool()); Component<Checkbox>(SETTINGS,"Keyboard Play Auto-Aim Checkbox")->SetChecked(loadSystemFile["Keyboard Auto-Aim"].GetBool());
} }
if(loadSystemFile.HasProperty("VSync")){
GameSettings::SetVSync(loadSystemFile["VSync"].GetBool());
Component<Checkbox>(SETTINGS,"VSync Checkbox")->SetChecked(loadSystemFile["VSync"].GetBool());
}
if(loadSystemFile.HasProperty("Controller Icons")){ if(loadSystemFile.HasProperty("Controller Icons")){
const int maxIterations=10; const int maxIterations=10;
int iterationCount=0; int iterationCount=0;

@ -47,6 +47,7 @@ class GameSettings{
static bool rumble; static bool rumble;
static bool terrainCollisionBoxes; static bool terrainCollisionBoxes;
static bool keyboardAutoAim; static bool keyboardAutoAim;
static bool vsync;
static vi2d windowPos; static vi2d windowPos;
static IconType iconType; static IconType iconType;
public: public:
@ -58,6 +59,7 @@ public:
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 bool VSyncEnabled();
static const vi2d GetWindowPos(); static const vi2d GetWindowPos();
static const IconType GetIconType(); static const IconType GetIconType();
static void SetMaxHealthDisplay(bool maxHealthDisplayed); static void SetMaxHealthDisplay(bool maxHealthDisplayed);
@ -68,5 +70,6 @@ public:
static void SetKeyboardAutoAim(bool autoAimEnabled); static void SetKeyboardAutoAim(bool autoAimEnabled);
static void SetWindowPos(vi2d windowPos); static void SetWindowPos(vi2d windowPos);
static void SetIconType(IconType type); static void SetIconType(IconType type);
static void SetVSync(const bool vSyncEnabled);
static void Initialize(); static void Initialize();
}; };

@ -169,6 +169,7 @@ const void SaveFile::SaveGame(){
saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled()); saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled());
saveSystemFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled()); saveSystemFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled());
saveSystemFile["Controller Icons"].SetInt(int(GameSettings::GetIconType())); saveSystemFile["Controller Icons"].SetInt(int(GameSettings::GetIconType()));
saveSystemFile["VSync"].SetBool(GameSettings::VSyncEnabled());
saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().x,0); saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().x,0);
saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().y,1); saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().y,1);

@ -108,18 +108,18 @@ void Menu::InitializeSettingsWindow(){
settingsList->ADD("Show Max HP 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); GameSettings::SetMaxHealthDisplay(data.checked);
return true; return true;
},false)END; },GameSettings::ShowMaxHealth())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 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){ 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); GameSettings::SetMaxManaDisplay(data.checked);
return true; return true;
},false)END; },GameSettings::ShowMaxMana())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("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){ 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; },GameSettings::ScreenShakeEnabled())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("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){ 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)){
@ -132,18 +132,25 @@ void Menu::InitializeSettingsWindow(){
} }
} }
return true; return true;
},true)END; },GameSettings::RumbleEnabled())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("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;
auto vsyncToggle=settingsList->ADD("VSync Checkbox",Checkbox)(geom2d::rect<float>{{4.f,100},{16.f,16.f}},[](ToggleFuncData data){
game->SetVSync(data.checked);
GameSettings::SetVSync(data.checked);
return true;
},GameSettings::VSyncEnabled())END;
auto vsyncToggleLabel=settingsList->ADD("VSync Toggle Label",MenuLabel)(geom2d::rect<float>{{22.f,100},{windowSize.x/2-36.f,16.f}},"VSync",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsList->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,60},{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; },GameSettings::TerrainCollisionBoxesEnabled())END;
settingsList->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,60},{windowSize.x/2-36.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-36.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){ 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; },GameSettings::KeyboardAutoAimEnabled())END;
settingsList->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,80},{windowSize.x/2-36.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-36.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,100},{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){
@ -162,7 +169,7 @@ void Menu::InitializeSettingsWindow(){
fullscreenToggleLabel->Disable(); fullscreenToggleLabel->Disable();
#endif #endif
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){ settingsList->ADD("Button Set Toggle Box",MenuIconButton)(geom2d::rect<float>{{windowSize.x/2.f-windowSize.x/8.f-6.f,120.f},{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);
@ -208,13 +215,13 @@ void Menu::InitializeSettingsWindow(){
}; };
#pragma endregion #pragma endregion
settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,120.f},vf2d{settingsList->rect.size.x-12-56,24}},"Keyboard Bindings",[&](MenuFuncData data){ settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,140.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,148.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){ settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,168.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");
if(SteamInput()){ if(SteamInput()){
@ -275,25 +282,28 @@ void Menu::InitializeSettingsWindow(){
.right="Terrain Collision Boxes Checkbox",}}, .right="Terrain Collision Boxes Checkbox",}},
{"Controller Rumble Checkbox",{ {"Controller Rumble Checkbox",{
.up="Screen Shake Checkbox", .up="Screen Shake Checkbox",
.down="Button Set Toggle Box", .down="VSync Checkbox",
.left="Keyboard Play Auto-Aim Checkbox", .left="Keyboard Play Auto-Aim Checkbox",
.right="Keyboard Play Auto-Aim Checkbox",}}, .right="Keyboard Play Auto-Aim Checkbox",}},
{"Button Set Toggle Box",{ {"VSync Checkbox",{
.up="Controller Rumble Checkbox", .up="Controller Rumble Checkbox",
.down="Keyboard Bindings Button", .down="Button Set Toggle Box",
.left="Fullscreen Toggle Checkbox", .left="Fullscreen Toggle Checkbox",
.right="Fullscreen Toggle Checkbox",}}, .right="Fullscreen Toggle Checkbox",}},
{"Fullscreen Toggle Checkbox",{ {"Fullscreen Toggle Checkbox",{
.up="Keyboard Play Auto-Aim Checkbox", .up="Keyboard Play Auto-Aim Checkbox",
.down="Keyboard Bindings Button", .down="Button Set Toggle Box",
.left="Button Set Toggle Box", .left="VSync Checkbox",
.right="Button Set Toggle Box",}}, .right="VSync Checkbox",}},
{"Keyboard Bindings Button",{ {"Button Set Toggle Box",{
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
.up="Button Set Toggle Box", .up="VSync Checkbox",
#else #else
.up="Fullscreen Toggle Checkbox", .up="Fullscreen Toggle Checkbox",
#endif #endif
.down="Keyboard Bindings Button",}},
{"Keyboard Bindings Button",{
.up="Button Set Toggle Box",
.down="Controller Bindings Button",}}, .down="Controller Bindings Button",}},
{"Controller Bindings Button",{ {"Controller Bindings Button",{
.up="Keyboard Bindings Button", .up="Keyboard Bindings Button",

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

@ -1093,6 +1093,7 @@ namespace olc
void SetWindowPos(vi2d pos); void SetWindowPos(vi2d pos);
void SetWindowSize(vi2d size); void SetWindowSize(vi2d size);
void SetVSync(const bool vSyncEnabled);
public: // CONFIGURATION ROUTINES public: // CONFIGURATION ROUTINES
// Layer targeting functions // Layer targeting functions
@ -4470,6 +4471,10 @@ namespace olc
platform->SetWindowSize(size); platform->SetWindowSize(size);
} }
void PixelGameEngine::SetVSync(const bool vSyncEnabled){
renderer->SetVSync(vSyncEnabled);
}
void PixelGameEngine::TextEntryEnable(const bool bEnable, const std::string& sText) void PixelGameEngine::TextEntryEnable(const bool bEnable, const std::string& sText)
{ {
if (bEnable) if (bEnable)
@ -6918,7 +6923,6 @@ namespace olc
XResizeWindow(olc_Display, olc_Window, size.x, size.y); XResizeWindow(olc_Display, olc_Window, size.x, size.y);
} }
} }
virtual olc::rcode SetWindowTitle(const std::string& s) override virtual olc::rcode SetWindowTitle(const std::string& s) override
{ {
X11::XStoreName(olc_Display, olc_Window, s.c_str()); X11::XStoreName(olc_Display, olc_Window, s.c_str());
@ -7614,7 +7618,6 @@ namespace olc
return olc::rcode::OK; return olc::rcode::OK;
} }
virtual void SetWindowPos(vi2d pos)override{ virtual void SetWindowPos(vi2d pos)override{
} }
virtual void SetWindowSize(vi2d size)override{ virtual void SetWindowSize(vi2d size)override{

Loading…
Cancel
Save