diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 0399fe4a..6326d949 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2713,6 +2713,7 @@ int main() vi2d windowPosConf={30,30}; vi2d windowSizeConf=WINDOW_SIZE*4; bool fullscreenConf=false; + bool vsyncConf=GameSettings::VSyncEnabled(); if(std::filesystem::exists(loadSystemFilename)){ utils::datafile::Read(loadSystemFile,loadSystemFilename); @@ -2733,11 +2734,12 @@ int main() } #endif if(loadSystemFile.HasProperty("Fullscreen"))fullscreenConf=loadSystemFile["Fullscreen"].GetBool(); + if(loadSystemFile.HasProperty("VSync"))vsyncConf=loadSystemFile["VSync"].GetBool(); if(requiredSize>0)fullscreenConf=true; } #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(); } diff --git a/Adventures in Lestoria/GameSettings.cpp b/Adventures in Lestoria/GameSettings.cpp index 72ba3c15..ebf1476b 100644 --- a/Adventures in Lestoria/GameSettings.cpp +++ b/Adventures in Lestoria/GameSettings.cpp @@ -51,6 +51,7 @@ bool GameSettings::showMaxMana=false; bool GameSettings::rumble=true; bool GameSettings::terrainCollisionBoxes=true; bool GameSettings::keyboardAutoAim=false; +bool GameSettings::vsync=true; const bool GameSettings::OVERRIDE=true; vi2d GameSettings::windowPos{30,30}; IconType GameSettings::iconType=IconType::XB; @@ -79,6 +80,9 @@ const vi2d GameSettings::GetWindowPos(){ const IconType GameSettings::GetIconType(){ return iconType; } +const bool GameSettings::VSyncEnabled(){ + return vsync; +} void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){ showMaxHealth=maxHealthDisplayed; @@ -105,6 +109,10 @@ void GameSettings::SetIconType(IconType type){ iconType=type; } +void GameSettings::SetVSync(const bool vSyncEnabled){ + vsync=vSyncEnabled; +} + void GameSettings::Initialize(){ utils::datafile loadSystemFile; @@ -139,6 +147,10 @@ void GameSettings::Initialize(){ GameSettings::SetKeyboardAutoAim(loadSystemFile["Keyboard Auto-Aim"].GetBool()); Component(SETTINGS,"Keyboard Play Auto-Aim Checkbox")->SetChecked(loadSystemFile["Keyboard Auto-Aim"].GetBool()); } + if(loadSystemFile.HasProperty("VSync")){ + GameSettings::SetVSync(loadSystemFile["VSync"].GetBool()); + Component(SETTINGS,"VSync Checkbox")->SetChecked(loadSystemFile["VSync"].GetBool()); + } if(loadSystemFile.HasProperty("Controller Icons")){ const int maxIterations=10; int iterationCount=0; diff --git a/Adventures in Lestoria/GameSettings.h b/Adventures in Lestoria/GameSettings.h index 1a89ba91..4073399d 100644 --- a/Adventures in Lestoria/GameSettings.h +++ b/Adventures in Lestoria/GameSettings.h @@ -47,6 +47,7 @@ class GameSettings{ static bool rumble; static bool terrainCollisionBoxes; static bool keyboardAutoAim; + static bool vsync; static vi2d windowPos; static IconType iconType; public: @@ -58,6 +59,7 @@ public: static const bool RumbleEnabled(const bool override=false); static const bool TerrainCollisionBoxesEnabled(); static const bool KeyboardAutoAimEnabled(); + static const bool VSyncEnabled(); static const vi2d GetWindowPos(); static const IconType GetIconType(); static void SetMaxHealthDisplay(bool maxHealthDisplayed); @@ -68,5 +70,6 @@ public: static void SetKeyboardAutoAim(bool autoAimEnabled); static void SetWindowPos(vi2d windowPos); static void SetIconType(IconType type); + static void SetVSync(const bool vSyncEnabled); static void Initialize(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index c2323fb0..a21d5785 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -169,6 +169,7 @@ const void SaveFile::SaveGame(){ saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled()); saveSystemFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled()); 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().y,1); diff --git a/Adventures in Lestoria/SettingsWindow.cpp b/Adventures in Lestoria/SettingsWindow.cpp index 52d55a77..aa9d51aa 100644 --- a/Adventures in Lestoria/SettingsWindow.cpp +++ b/Adventures in Lestoria/SettingsWindow.cpp @@ -108,18 +108,18 @@ void Menu::InitializeSettingsWindow(){ settingsList->ADD("Show Max HP Checkbox",Checkbox)(geom2d::rect{{4.f,40},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetMaxHealthDisplay(data.checked); return true; - },false)END; + },GameSettings::ShowMaxHealth())END; settingsList->ADD("Show Max HP Label",MenuLabel)(geom2d::rect{{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{{windowSize.x/2+4.f,40},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetMaxManaDisplay(data.checked); return true; - },false)END; + },GameSettings::ShowMaxMana())END; settingsList->ADD("Show Max Mana Label",MenuLabel)(geom2d::rect{{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{{4.f,60},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetScreenShake(data.checked); return true; - },true)END; + },GameSettings::ScreenShakeEnabled())END; settingsList->ADD("Screen Shake Label",MenuLabel)(geom2d::rect{{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{{4.f,80},{16.f,16.f}},[](ToggleFuncData data){ if(Menu::IsCurrentlyActive(SETTINGS)){ @@ -132,18 +132,25 @@ void Menu::InitializeSettingsWindow(){ } } return true; - },true)END; + },GameSettings::RumbleEnabled())END; settingsList->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect{{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{{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{{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{{windowSize.x/2+4.f,60},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetTerrainCollisionBoxes(data.checked); return true; - },true)END; + },GameSettings::TerrainCollisionBoxesEnabled())END; settingsList->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect{{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{{windowSize.x/2+4.f,80},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetKeyboardAutoAim(data.checked); return true; - },false)END; + },GameSettings::KeyboardAutoAimEnabled())END; settingsList->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect{{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{{windowSize.x/2+4.f,100},{16.f,16.f}},[](ToggleFuncData data){ @@ -162,7 +169,7 @@ void Menu::InitializeSettingsWindow(){ fullscreenToggleLabel->Disable(); #endif - settingsList->ADD("Button Set Toggle Box",MenuIconButton)(geom2d::rect{{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{{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()){ case IconType::XB:{ GameSettings::SetIconType(IconType::PS); @@ -208,13 +215,13 @@ void Menu::InitializeSettingsWindow(){ }; #pragma endregion - settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,120.f},vf2d{settingsList->rect.size.x-12-56,24}},"Keyboard Bindings",[&](MenuFuncData data){ + settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,140.f},vf2d{settingsList->rect.size.x-12-56,24}},"Keyboard Bindings",[&](MenuFuncData data){ ChangeKeybindDisplayType(KEY); Component(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{{28,148.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){ + settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,168.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){ ChangeKeybindDisplayType(CONTROLLER); Component(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings"); if(SteamInput()){ @@ -275,25 +282,28 @@ void Menu::InitializeSettingsWindow(){ .right="Terrain Collision Boxes Checkbox",}}, {"Controller Rumble Checkbox",{ .up="Screen Shake Checkbox", - .down="Button Set Toggle Box", + .down="VSync Checkbox", .left="Keyboard Play Auto-Aim Checkbox", .right="Keyboard Play Auto-Aim Checkbox",}}, - {"Button Set Toggle Box",{ + {"VSync Checkbox",{ .up="Controller Rumble Checkbox", - .down="Keyboard Bindings Button", + .down="Button Set Toggle Box", .left="Fullscreen Toggle Checkbox", .right="Fullscreen Toggle Checkbox",}}, {"Fullscreen Toggle Checkbox",{ .up="Keyboard Play Auto-Aim Checkbox", - .down="Keyboard Bindings Button", - .left="Button Set Toggle Box", - .right="Button Set Toggle Box",}}, - {"Keyboard Bindings Button",{ + .down="Button Set Toggle Box", + .left="VSync Checkbox", + .right="VSync Checkbox",}}, + {"Button Set Toggle Box",{ #ifdef __EMSCRIPTEN__ - .up="Button Set Toggle Box", + .up="VSync Checkbox", #else .up="Fullscreen Toggle Checkbox", #endif + .down="Keyboard Bindings Button",}}, + {"Keyboard Bindings Button",{ + .up="Button Set Toggle Box", .down="Controller Bindings Button",}}, {"Controller Bindings Button",{ .up="Keyboard Bindings Button", diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index d5595ee9..6d977418 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 0 #define VERSION_PATCH 0 -#define VERSION_BUILD 8457 +#define VERSION_BUILD 8464 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 9ccc16c2..b7db8bfb 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -1093,6 +1093,7 @@ namespace olc void SetWindowPos(vi2d pos); void SetWindowSize(vi2d size); + void SetVSync(const bool vSyncEnabled); public: // CONFIGURATION ROUTINES // Layer targeting functions @@ -4470,6 +4471,10 @@ namespace olc platform->SetWindowSize(size); } + void PixelGameEngine::SetVSync(const bool vSyncEnabled){ + renderer->SetVSync(vSyncEnabled); + } + void PixelGameEngine::TextEntryEnable(const bool bEnable, const std::string& sText) { if (bEnable) @@ -6918,7 +6923,6 @@ namespace olc XResizeWindow(olc_Display, olc_Window, size.x, size.y); } } - virtual olc::rcode SetWindowTitle(const std::string& s) override { X11::XStoreName(olc_Display, olc_Window, s.c_str()); @@ -7614,7 +7618,6 @@ namespace olc return olc::rcode::OK; } virtual void SetWindowPos(vi2d pos)override{ - } virtual void SetWindowSize(vi2d size)override{ diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 564ecdf6..bf4d28c6 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ