diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index a5870d8a..0d9da714 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2280,7 +2280,28 @@ int main() { { AiL demo; - if (demo.Construct(WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4)) + + #pragma region Load Window Settings + utils::datafile loadSystemFile; + + std::string loadSystemFilename="save_file_path"_S+"system.conf"; + + vi2d windowPosConf={30,30}; + vi2d windowSizeConf=WINDOW_SIZE; + bool fullscreenConf=false; + + if(std::filesystem::exists(loadSystemFilename)){ + utils::datafile::Read(loadSystemFile,loadSystemFilename); + if(loadSystemFile.HasProperty("Window Pos")){ + GameSettings::SetWindowPos({loadSystemFile["Window Pos"].GetInt(0),loadSystemFile["Window Pos"].GetInt(1)}); + windowPosConf={loadSystemFile["Window Pos"].GetInt(0),loadSystemFile["Window Pos"].GetInt(1)}; + } + if(loadSystemFile.HasProperty("Window Size"))windowSizeConf={loadSystemFile["Window Size"].GetInt(0),loadSystemFile["Window Size"].GetInt(1)}; + if(loadSystemFile.HasProperty("Fullscreen"))fullscreenConf=loadSystemFile["Fullscreen"].GetBool(); + } + #pragma endregion + + if (demo.Construct(windowPosConf.x, windowPosConf.y, windowSizeConf.x, windowSizeConf.y, WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4, fullscreenConf)) demo.Start(); } diff --git a/Adventures in Lestoria/GameSettings.cpp b/Adventures in Lestoria/GameSettings.cpp index 14d00c94..4dc1b2b0 100644 --- a/Adventures in Lestoria/GameSettings.cpp +++ b/Adventures in Lestoria/GameSettings.cpp @@ -42,6 +42,7 @@ bool GameSettings::screenShake=true; bool GameSettings::rumble=true; bool GameSettings::terrainCollisionBoxes=true; bool GameSettings::keyboardAutoAim=false; +vi2d GameSettings::windowPos{30,30}; const bool GameSettings::ScreenShakeEnabled(){ return screenShake; @@ -55,6 +56,9 @@ const bool GameSettings::TerrainCollisionBoxesEnabled(){ const bool GameSettings::KeyboardAutoAimEnabled(){ return keyboardAutoAim; } +const vi2d GameSettings::GetWindowPos(){ + return windowPos; +} void GameSettings::SetScreenShake(bool screenShakeEnabled){ screenShake=screenShakeEnabled; @@ -67,4 +71,7 @@ void GameSettings::SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled){ } void GameSettings::SetKeyboardAutoAim(bool autoAimEnabled){ keyboardAutoAim=autoAimEnabled; +} +void GameSettings::SetWindowPos(vi2d windowPos){ + GameSettings::windowPos=windowPos; } \ No newline at end of file diff --git a/Adventures in Lestoria/GameSettings.h b/Adventures in Lestoria/GameSettings.h index 18e6c430..9902861a 100644 --- a/Adventures in Lestoria/GameSettings.h +++ b/Adventures in Lestoria/GameSettings.h @@ -37,18 +37,23 @@ All rights reserved. #pragma endregion #pragma once +#include "olcUTIL_Geometry2D.h" + class GameSettings{ static bool screenShake; static bool rumble; static bool terrainCollisionBoxes; static bool keyboardAutoAim; + static vi2d windowPos; public: static const bool ScreenShakeEnabled(); static const bool RumbleEnabled(); static const bool TerrainCollisionBoxesEnabled(); static const bool KeyboardAutoAimEnabled(); + static const vi2d GetWindowPos(); static void SetScreenShake(bool screenShakeEnabled); static void SetRumble(bool rumbleEnabled); static void SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled); static void SetKeyboardAutoAim(bool autoAimEnabled); + static void SetWindowPos(vi2d windowPos); }; \ No newline at end of file diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index 36625b5e..6c6a54ed 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -129,7 +129,6 @@ const void SaveFile::SaveGame(){ saveFile["Controller Rumble"].SetBool(GameSettings::RumbleEnabled()); saveFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled()); saveFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled()); - saveFile["Fullscreen"].SetBool(game->IsFullscreen()); #pragma region Save Keyboard/Controller mappings //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! @@ -161,6 +160,7 @@ const void SaveFile::SaveGame(){ saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().y,1); saveSystemFile["Window Size"].SetInt(game->GetWindowSize().x,0); saveSystemFile["Window Size"].SetInt(game->GetWindowSize().y,1); + saveSystemFile["Fullscreen"].SetBool(game->IsFullscreen()); #pragma endregion utils::datafile::Write(saveFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); @@ -243,10 +243,8 @@ const void SaveFile::SaveGame(){ void SaveFile::LoadFile(){ utils::datafile loadFile; - utils::datafile loadSystemFile; std::string loadFilename="save_file_path"_S+std::format("save.{:04}",saveFileID); - std::string loadSystemFilename="save_file_path"_S+"system.conf"; if(std::filesystem::exists(loadFilename)){ utils::datafile::Read(loadFile,"save_file_path"_S+std::format("save.{:04}",saveFileID)); @@ -299,7 +297,6 @@ void SaveFile::LoadFile(){ if(loadFile.HasProperty("Controller Rumble"))GameSettings::SetRumble(loadFile["Controller Rumble"].GetBool()); if(loadFile.HasProperty("Terrain Collision Boxes"))GameSettings::SetTerrainCollisionBoxes(loadFile["Terrain Collision Boxes"].GetBool()); if(loadFile.HasProperty("Keyboard Auto-Aim"))GameSettings::SetKeyboardAutoAim(loadFile["Keyboard Auto-Aim"].GetBool()); - if(loadFile.HasProperty("Fullscreen"))game->SetFullscreen(loadFile["Fullscreen"].GetBool(),{}); #pragma region Load Keyboard/Controller mappings //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! @@ -341,14 +338,6 @@ void SaveFile::LoadFile(){ } #pragma endregion - #pragma region Load System Settings - if(std::filesystem::exists(loadSystemFilename)){ - utils::datafile::Read(loadSystemFile,loadSystemFilename); - if(loadSystemFile.HasProperty("Window Pos"))game->SetWindowPos({loadSystemFile["Window Pos"].GetInt(0),loadSystemFile["Window Pos"].GetInt(1)}); - if(loadSystemFile.HasProperty("Window Size"))game->SetWindowSize({loadSystemFile["Window Size"].GetInt(0),loadSystemFile["Window Size"].GetInt(1)}); - } - #pragma endregion - GameState::ChangeState(States::OVERWORLD_MAP,0.5f); }else{ std::cout<ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,104},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; #ifndef __EMSCRIPTEN__ settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,124},{16.f,16.f}},[](ToggleFuncData data){ - game->SetFullscreen(data.checked,{}); + if(data.checked){ //When going to fullscreen mode, the windowed mode positioning needs to be saved to be restored later. + GameSettings::SetWindowPos(game->GetActualWindowPos()); + } + game->SetFullscreen(data.checked,GameSettings::GetWindowPos()); return true; - },false)END; + },game->IsFullscreen())END; settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,124},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; #endif diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 3c1ded4b..d4d7a124 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -7,14 +7,14 @@ January 1st - Track items used during a stage, on death, restore the loadout item quantities used. -- Add screen shake and rumble as a toggle. - -- Fullscreen toggle - > Implement fullscreen capabilities for the PGE. - - Toggle between Playstation / Xbox controller gamepad displays - Rebind FACELEFT/FACERIGHT menu keys (as they are used constantly throughout menus and would need to be rebinded if the player wants). (Or make confirm/back not rebindable) +Open window to the correct position/size at the beginning of the game if possible. + +Input HElper disappearing? (Possibly on loads) +Boss + January 31st ============ @@ -32,8 +32,6 @@ January 31st - Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in. -- Save window position and size - - Condense stage track (loading times) - If you enter the keyboard config menu and press a controller button, it cancels the request. If you enter the controller config menu and press a keyboard/mouse button, it also cancels the request. \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 33311075..67e22696 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7370 +#define VERSION_BUILD 7382 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx index 35876ef9..48cc6299 100644 --- a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx @@ -1,5 +1,5 @@ - + @@ -679,7 +679,6 @@ - diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 3f3ce16d..b314b210 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -990,7 +990,7 @@ namespace olc PixelGameEngine(); virtual ~PixelGameEngine(); public: - olc::rcode Construct(int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, + olc::rcode Construct(int32_t window_x, int32_t window_y, int32_t window_w, int32_t window_h, int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, bool full_screen = false, bool vsync = false, bool cohesion = false); olc::rcode Start(); @@ -2089,13 +2089,14 @@ namespace olc {} - olc::rcode PixelGameEngine::Construct(int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, bool full_screen, bool vsync, bool cohesion) + olc::rcode PixelGameEngine::Construct(int32_t window_x, int32_t window_y, int32_t window_w, int32_t window_h, int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, bool full_screen, bool vsync, bool cohesion) { bPixelCohesion = cohesion; vScreenSize = { screen_w, screen_h }; vInvScreenSize = { 1.0f / float(screen_w), 1.0f / float(screen_h) }; + vWindowPos = {window_x,window_y}; vPixelSize = { pixel_w, pixel_h }; - vWindowSize = vScreenSize * vPixelSize; + vWindowSize = {window_w,window_h}; bFullScreen = full_screen; bEnableVSYNC = vsync; vPixel = 2.0f / vScreenSize; @@ -2128,7 +2129,7 @@ namespace olc if (platform->ApplicationStartUp() != olc::OK) return olc::FAIL; // Construct the window - if (platform->CreateWindowPane({ 30,30 }, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; + if (platform->CreateWindowPane(vWindowPos, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; olc_UpdateWindowSize(vWindowSize.x, vWindowSize.y); // Start the thread @@ -4530,7 +4531,6 @@ namespace olc void PixelGameEngine::olc_UpdateActualWindowPos(int32_t x, int32_t y){ vActualWindowPos = { x, y }; - std::cout<IsFullscreen()){ RECT rWndRect = { 0, 0, ptrPGE->GetWindowSize().x, ptrPGE->GetWindowSize().y }; - DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME; - WINDOWPLACEMENT placement; int width = rWndRect.right - rWndRect.left; int height = rWndRect.bottom - rWndRect.top; MoveWindow(olc_hWnd,pos.x, pos.y, width, height,true); @@ -6580,7 +6577,6 @@ namespace olc X11::XVisualInfo* olc_VisualInfo; X11::Colormap olc_ColourMap; X11::XSetWindowAttributes olc_SetWindowAttribs; - vi2d desiredPos{30,30}; public: virtual olc::rcode ApplicationStartUp() override @@ -7168,7 +7164,7 @@ namespace olc { if (platform->ApplicationStartUp() != olc::OK) return olc::FAIL; // Construct the window - if (platform->CreateWindowPane({ 30,30 }, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; + if (platform->CreateWindowPane(vWindowPos, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; olc_UpdateWindowSize(vWindowSize.x, vWindowSize.y); if (platform->ThreadStartUp() == olc::FAIL) return olc::FAIL; @@ -7633,7 +7629,7 @@ namespace olc if (platform->ApplicationStartUp() != olc::OK) return olc::FAIL; // Construct the window - if (platform->CreateWindowPane({ 30,30 }, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; + if (platform->CreateWindowPane(vWindowPos, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL; olc_UpdateWindowSize(vWindowSize.x, vWindowSize.y); // Some implementations may form an event loop here diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 12abf924..4b2d021c 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ