diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 79e7ed05..6d927949 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -4074,10 +4074,4 @@ void AiL::ComputeModeColors(TilesetData&tileset){ #pragma endregion } } -} - -void AiL::OnWindowLoseFocus()const{ - if(!Menu::IsMenuOpen()&&GameState::STATE==GameState::states[States::GAME_RUN]){ - Menu::OpenMenu(MenuType::PAUSE); - } } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 48e41589..3f0aae6f 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -205,7 +205,6 @@ public: bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; bool OnUserDestroy() override; - void OnWindowLoseFocus()const override final; void GetAnyKeyPress(Key key)override final; void GetAnyKeyRelease(Key key)override final; void GetAnyMousePress(int32_t mouseButton)override final; diff --git a/Adventures in Lestoria/Checkbox.h b/Adventures in Lestoria/Checkbox.h index 9fe4a7e2..58207e33 100644 --- a/Adventures in Lestoria/Checkbox.h +++ b/Adventures in Lestoria/Checkbox.h @@ -42,6 +42,7 @@ All rights reserved. #include "SoundEffect.h" INCLUDE_game +INCLUDE_GFX class Checkbox:public MenuComponent{ protected: @@ -76,17 +77,10 @@ public: } inline void DrawDecal(ViewPort&window,bool focused)override{ - geom2d::linecheckmarkLine1=geom2d::line({rect.left().start.x+rect.size.x*0.125f,rect.left().start.y+rect.size.y*0.5f},{rect.top().start.x+rect.size.x*0.375f,rect.top().start.y+rect.size.y*0.875f}); - geom2d::linecheckmarkLine2=geom2d::line(checkmarkLine1.end,{rect.left().start.x+rect.size.x*0.875f,rect.top().start.y+rect.size.y*0.25f}); - MenuComponent::DrawDecal(window,focused); + if(checked){ - for(int y=-1;y<=1;y++){ - for(int x=-1;x<=1;x++){ - window.DrawLineDecal(vf2d{float(x),float(y)}/game->GetScreenPixelSize()+checkmarkLine1.start,vf2d{float(x),float(y)}/game->GetScreenPixelSize()+checkmarkLine1.end); - window.DrawLineDecal(vf2d{float(x),float(y)}/game->GetScreenPixelSize()+checkmarkLine2.start,vf2d{float(x),float(y)}/game->GetScreenPixelSize()+checkmarkLine2.end); - } - } + window.DrawDecal(rect.pos,GFX["checkmark.png"].Decal()); } } }; \ No newline at end of file diff --git a/Adventures in Lestoria/GameSettings.cpp b/Adventures in Lestoria/GameSettings.cpp index a9b4dc78..e8f9e6b2 100644 --- a/Adventures in Lestoria/GameSettings.cpp +++ b/Adventures in Lestoria/GameSettings.cpp @@ -52,6 +52,7 @@ bool GameSettings::rumble=true; bool GameSettings::terrainCollisionBoxes=true; bool GameSettings::keyboardAutoAim=false; bool GameSettings::vsync=true; +bool GameSettings::autopause=true; const bool GameSettings::OVERRIDE=true; vi2d GameSettings::windowPos{30,30}; IconType GameSettings::iconType=IconType::XB; @@ -83,6 +84,9 @@ const IconType GameSettings::GetIconType(){ const bool GameSettings::VSyncEnabled(){ return vsync; } +const bool GameSettings::AutoPauseEnabled(){ + return autopause; +} void GameSettings::SetMaxHealthDisplay(bool maxHealthDisplayed){ showMaxHealth=maxHealthDisplayed; @@ -152,6 +156,10 @@ void GameSettings::Initialize(){ Component(SETTINGS,"VSync Checkbox")->SetChecked(loadSystemFile["VSync"].GetBool()); game->SetVSync(GameSettings::VSyncEnabled()); } + if(loadSystemFile.HasProperty("Auto Pause")){ + GameSettings::SetAutoPause(loadSystemFile["Auto Pause"].GetBool()); + Component(SETTINGS,"Auto Pause Checkbox")->SetChecked(loadSystemFile["Auto Pause"].GetBool()); + } if(loadSystemFile.HasProperty("Controller Icons")){ const int maxIterations=10; int iterationCount=0; @@ -192,4 +200,8 @@ void GameSettings::Initialize(){ } } #pragma endregion +} + +void GameSettings::SetAutoPause(const bool autoPauseEnabled){ + autopause=autoPauseEnabled; } \ No newline at end of file diff --git a/Adventures in Lestoria/GameSettings.h b/Adventures in Lestoria/GameSettings.h index 4073399d..4ce9e713 100644 --- a/Adventures in Lestoria/GameSettings.h +++ b/Adventures in Lestoria/GameSettings.h @@ -48,6 +48,7 @@ class GameSettings{ static bool terrainCollisionBoxes; static bool keyboardAutoAim; static bool vsync; + static bool autopause; static vi2d windowPos; static IconType iconType; public: @@ -60,6 +61,7 @@ public: static const bool TerrainCollisionBoxesEnabled(); static const bool KeyboardAutoAimEnabled(); static const bool VSyncEnabled(); + static const bool AutoPauseEnabled(); static const vi2d GetWindowPos(); static const IconType GetIconType(); static void SetMaxHealthDisplay(bool maxHealthDisplayed); @@ -71,5 +73,6 @@ public: static void SetWindowPos(vi2d windowPos); static void SetIconType(IconType type); static void SetVSync(const bool vSyncEnabled); + static void SetAutoPause(const bool autoPauseEnabled); static void Initialize(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/LoadGameWindow.cpp b/Adventures in Lestoria/LoadGameWindow.cpp index 8bd11efc..6f0cca17 100644 --- a/Adventures in Lestoria/LoadGameWindow.cpp +++ b/Adventures in Lestoria/LoadGameWindow.cpp @@ -101,14 +101,14 @@ void Menu::InitializeLoadGameWindow(){ if(SaveFile::GetSaveFileCount()>0||SaveFile::GetOnlineSaveFileCount()>0){ if(SaveFile::IsOnline()){ if(Component(type,"Online Game Files List")->GetComponents().size()>0){ - Menu::menus[type]->SetSelection(Component(type,"Online Game Files List")->GetComponents()[0],true); + Menu::menus[type]->SetSelection(Component(type,"Online Game Files List")->GetComponents()[0],true,true); returnData=Menu::menus[type]->GetSelection(); }else{ returnData="Go Back Button"; } }else{ if(Component(type,"Game Files List")->GetComponents().size()>0){ - Menu::menus[type]->SetSelection(Component(type,"Game Files List")->GetComponents()[0],true); + Menu::menus[type]->SetSelection(Component(type,"Game Files List")->GetComponents()[0],true,true); returnData=Menu::menus[type]->GetSelection(); }else{ returnData="Go Back Button"; diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index db0b1fb5..c450541a 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -322,7 +322,7 @@ void Menu::OpenMenu(MenuType menu,bool cover){ Data returnData; menus[menu]->onOpenFunc(menu,returnData); menus[menu]->defaultButton=returnData; - if(std::holds_alternative(returnData)&&std::get(returnData).length()>0||std::holds_alternative>(returnData))menus[menu]->SetSelection(returnData,true); + if(std::holds_alternative(returnData)&&std::get(returnData).length()>0||std::holds_alternative>(returnData))menus[menu]->SetSelection(returnData,false); } stack.push_back(menus[menu]); Audio::UpdateBGMVolume(); //If we open the pause menu, it forces the bgm volume to be halved. So we notify the engine that this is happening. @@ -761,17 +761,11 @@ void Menu::SetSelection(std::string_view button,const bool scroll,const bool res keyboardSelection=selection; } - if(!selection.lock()->parentComponent.expired()&&reset){ - auto scrollWindow=selection.lock()->parentComponent.lock(); - scrollWindow->targetScrollOffset.y=0.f; - scrollWindow->scrollOffset.y=0.f; - scrollWindow->selectionIndex=0.f; - } - if(scroll&&!UsingMouseNavigation()&&!selection.lock()->parentComponent.expired()){ auto scrollWindow=selection.lock()->parentComponent.lock(); scrollWindow->HandleOutsideDisabledButtonSelection(Menu::menus[selection.lock()->parentMenu]->components[selection.lock()->GetName()]); scrollWindow->selectionIndex=scrollWindow->GetComponentIndex(selection); + scrollWindow->SetScrollAmount(scrollWindow->GetScrollAmount()-scrollWindow->GetComponents()[scrollWindow->selectionIndex].lock()->GetPos()); } } diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 8855b5e4..4e4a876f 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -802,6 +802,10 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){ if(game->GetPlayer()->GetHealth()GetPlayer()->GetMaxHealth()*0.5f&&!Tutorial::TaskIsComplete(TutorialTaskName::USE_RECOVERY_ITEMS)){ Tutorial::SetNextTask(TutorialTaskName::USE_RECOVERY_ITEMS); } + + if(GameSettings::AutoPauseEnabled()&&!Menu::IsMenuOpen()&&GameState::STATE==GameState::states[States::GAME_RUN]&&!game->IsFocused()){ + Menu::OpenMenu(MenuType::PAUSE); + } return true; } diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index efeee2df..2c5a1106 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -174,6 +174,7 @@ const void SaveFile::SaveGame(){ saveSystemFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled()); saveSystemFile["Controller Icons"].SetInt(int(GameSettings::GetIconType())); saveSystemFile["VSync"].SetBool(GameSettings::VSyncEnabled()); + saveSystemFile["Auto Pause"].SetBool(GameSettings::AutoPauseEnabled()); saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().x,0); saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().y,1); diff --git a/Adventures in Lestoria/ScrollableWindowComponent.h b/Adventures in Lestoria/ScrollableWindowComponent.h index 6cdfc5f5..60123767 100644 --- a/Adventures in Lestoria/ScrollableWindowComponent.h +++ b/Adventures in Lestoria/ScrollableWindowComponent.h @@ -90,6 +90,10 @@ public: LOG("WARNING! Attempted to remove subbuttons from button listing, but not found!"); } } + + targetScrollOffset.y=std::min(targetScrollOffset.y,bounds.bottom().end.y); + scrollOffset.y=std::min(scrollOffset.y,bounds.bottom().end.y); + selectionIndex=std::min(size_t(selectionIndex),components.size()-1); } virtual inline void RemoveButton(std::weak_ptrbutton){ auto componentSearchResults=std::find_if(components.begin(),components.end(),[&](std::weak_ptrptr){return &*ptr.lock()==&*button.lock();}); diff --git a/Adventures in Lestoria/SettingsWindow.cpp b/Adventures in Lestoria/SettingsWindow.cpp index 428a4efb..03be6b2d 100644 --- a/Adventures in Lestoria/SettingsWindow.cpp +++ b/Adventures in Lestoria/SettingsWindow.cpp @@ -141,6 +141,12 @@ void Menu::InitializeSettingsWindow(){ 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; + + auto autoPauseToggle=settingsList->ADD("Auto Pause Checkbox",Checkbox)(geom2d::rect{{4.f,120},{16.f,16.f}},[](ToggleFuncData data){ + GameSettings::SetAutoPause(data.checked); + return true; + },GameSettings::AutoPauseEnabled())END; + auto autoPauseToggleLabel=settingsList->ADD("Auto Pause Toggle Label",MenuLabel)(geom2d::rect{{22.f,120},{windowSize.x/2-36.f,16.f}},"Pause if Hit When\nWindow Unfocused",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); @@ -169,7 +175,7 @@ void Menu::InitializeSettingsWindow(){ fullscreenToggleLabel->Disable(); #endif - 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){ + settingsList->ADD("Button Set Toggle Box",MenuIconButton)(geom2d::rect{{windowSize.x/2.f-windowSize.x/8.f-6.f,140.f},{windowSize.x/4.f,16.f}},GFX["themes/xb.png"].Decal(),[](MenuFuncData data){ switch(GameSettings::GetIconType()){ case IconType::XB:{ GameSettings::SetIconType(IconType::PS); @@ -215,13 +221,13 @@ void Menu::InitializeSettingsWindow(){ }; #pragma endregion - settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,140.f},vf2d{settingsList->rect.size.x-12-56,24}},"Keyboard Bindings",[&](MenuFuncData data){ + settingsList->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,160.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,168.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){ + settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,188.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"); STEAMINPUT( @@ -287,20 +293,19 @@ void Menu::InitializeSettingsWindow(){ .right="Keyboard Play Auto-Aim Checkbox",}}, {"VSync Checkbox",{ .up="Controller Rumble Checkbox", - .down="Button Set Toggle Box", + .down="Auto Pause Checkbox", .left="Fullscreen Toggle Checkbox", .right="Fullscreen Toggle Checkbox",}}, + {"Auto Pause Checkbox",{ + .up="VSync Checkbox", + .down="Button Set Toggle Box",}}, {"Fullscreen Toggle Checkbox",{ .up="Keyboard Play Auto-Aim Checkbox", - .down="Button Set Toggle Box", + .down="Auto Pause Checkbox", .left="VSync Checkbox", .right="VSync Checkbox",}}, {"Button Set Toggle Box",{ - #ifdef __EMSCRIPTEN__ - .up="VSync Checkbox", - #else - .up="Fullscreen Toggle Checkbox", - #endif + .up="Auto Pause Checkbox", .down="Keyboard Bindings Button",}}, {"Keyboard Bindings Button",{ .up="Button Set Toggle Box", diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 15d219c0..550e005c 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -11,25 +11,6 @@ Upon completion of a stage in time trial mode if the player beat their previous For each class and stage combination there will be a "dev time" Settings menu doesn't scroll back up properly while the scrollbar does? -Merchant descriptions have no newlines. -Amount to sell shows total of that accessory you have instead of 1/1. -Bosses can get stuck outside the arena? Traveling merchants of different colors/looks. Steel Weapons appear in the demo for Chapter 2. -Update display counters on the overworld map. -Pressing movement keys that negate each other shouldn't cause a walking animation to occur. - ->As the player navigates around the map, the blank map canvas gets updated based on distance. ->If a chunk has not been explored yet, it gets flagged as explored (probably unlock the chunks around the player as well). - ->When a map is visited later, all visited chunks are revealed again. - -============================================ -Consider a "killed by player" / "marked by player" flag for monsters to determine if a player gets credit for a monster kill (for achievements) -Make another actions config file for the main build (The app # is different) - -Review other games and see what the screen does when the player takes damage. Vignette effect - -Look at green slime remains count for crafting. - -Textured ground tiles \ No newline at end of file +Look into removing OVERRIDE from rumble settings. It looks like it was used to purposefully disable rumble, but looks very unnecessary. \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 74123f8b..6f1adf74 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 1 #define VERSION_PATCH 0 -#define VERSION_BUILD 8879 +#define VERSION_BUILD 8901 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/checkmark.png b/Adventures in Lestoria/assets/checkmark.png new file mode 100644 index 00000000..13281734 Binary files /dev/null and b/Adventures in Lestoria/assets/checkmark.png differ diff --git a/Adventures in Lestoria/assets/config/gfx/gfx.txt b/Adventures in Lestoria/assets/config/gfx/gfx.txt index 68ed9369..935947b0 100644 --- a/Adventures in Lestoria/assets/config/gfx/gfx.txt +++ b/Adventures in Lestoria/assets/config/gfx/gfx.txt @@ -85,6 +85,7 @@ Images GFX_SwordSlash = swordslash.png GFX_CustomFont = font.png GFX_Vignette = vignette.png + GFX_Checkmark = checkmark.png # Ability Icons GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png diff --git a/Adventures in Lestoria/assets/gamepack.pak b/Adventures in Lestoria/assets/gamepack.pak index ad0512d3..5f8758a8 100644 Binary files a/Adventures in Lestoria/assets/gamepack.pak and b/Adventures in Lestoria/assets/gamepack.pak differ diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index dd393502..718db33a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ