diff --git a/Adventures in Lestoria/ConsumableCraftItemWindow.cpp b/Adventures in Lestoria/ConsumableCraftItemWindow.cpp index 3d4c2306..79da97f6 100644 --- a/Adventures in Lestoria/ConsumableCraftItemWindow.cpp +++ b/Adventures in Lestoria/ConsumableCraftItemWindow.cpp @@ -102,6 +102,8 @@ void Menu::InitializeConsumableCraftItemWindow(){ } data.component.lock()->SetGrayedOut(!item.lock()->CanEnhanceItem(qty)); + + Menu::CloseMenu(); return true; })END; diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index 501df64a..efd109db 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -51,6 +51,7 @@ INCLUDE_ITEM_CATEGORIES INCLUDE_DATA bool Menu::MOUSE_NAVIGATION=true; +bool Menu::nextMouseNavigationIsIgnored=false; vi2d Menu::lastActiveMousePos{}; std::vectorMenu::stack; std::mapMenu::menus; @@ -159,7 +160,12 @@ void Menu::Update(AiL*game){ } if(!UsingMouseNavigation()&&geom2d::line(lastActiveMousePos,game->GetMousePos()).length()>="ThemeGlobal.MouseActivationDistance"_F){ - SetMouseNavigation(true); + if(!nextMouseNavigationIsIgnored){ + SetMouseNavigation(true); + }else{ //Update the last active mouse position as if we were going to change to mouse navigation mode because we want to ignore this one and not trigger it until we move the mouse on purpose. + lastActiveMousePos=game->GetMousePos(); + nextMouseNavigationIsIgnored=false; + } } for(auto&[key,button]:components){ @@ -760,4 +766,8 @@ void Menu::SetSelection(Data button,const bool reset){ }else{ ERR("WARNING! Specified menu opening function does not hold neither a string nor a pointer to a component to use!"); } +} + +void Menu::IgnoreNextMouseNavigationAttempt(){ + nextMouseNavigationIsIgnored=true; } \ No newline at end of file diff --git a/Adventures in Lestoria/Menu.h b/Adventures in Lestoria/Menu.h index a87123f7..f47103c4 100644 --- a/Adventures in Lestoria/Menu.h +++ b/Adventures in Lestoria/Menu.h @@ -197,6 +197,7 @@ public: void SetSelection(Data button,const bool reset=false); // Use the reset parameter when a window is opening up, as this will cause the window now to scroll to its previous target. const std::weak_ptrGetSelection()const; const std::weak_ptrGetKeySelection()const; + static void IgnoreNextMouseNavigationAttempt(); private: Menu(vf2d pos,vf2d size); static MenuType lastMenuTypeCreated; @@ -230,6 +231,7 @@ private: static bool MOUSE_NAVIGATION; static std::weak_ptrlastHover; + static bool nextMouseNavigationIsIgnored; //This variable will blatantly ignore the next mouse move signal to set mouse navigation to true, useful when toggling between windowed and full screen. bool cover; //A black cover for when a menu pops up to fade out the stuff behind it. }; diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index 2f373ebd..32f04aa8 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -62,7 +62,7 @@ enum MenuType{ SAVE_FILE_NAME, //100% Controller Compatibility LOAD_GAME, //100% Controller Compatibility - Online Mode Tab switching USER_ID, //100% Controller Compatibility - SETTINGS, //0% Controller Compatibility + SETTINGS, //100% Controller Compatibility SHERMAN, //0% Controller Compatibility INPUT_KEY_DISPLAY, //25% Controller Compatibility NEW_INPUT, //100% Controller Compatibility diff --git a/Adventures in Lestoria/SettingsWindow.cpp b/Adventures in Lestoria/SettingsWindow.cpp index 023d67f0..c91b939d 100644 --- a/Adventures in Lestoria/SettingsWindow.cpp +++ b/Adventures in Lestoria/SettingsWindow.cpp @@ -60,7 +60,7 @@ void Menu::InitializeSettingsWindow(){ vf2d windowSize=WINDOW_SIZE-vf2d{28,28}; Menu*settingsWindow=CreateMenu(SETTINGS,CENTERED,windowSize); - settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect{{4,windowSize.y},{72,12}},"Unlock All",[](MenuFuncData data){ + settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect{{4,windowSize.y-12},{72,12}},"Unlock All",[](MenuFuncData data){ for(auto&cp:State_OverworldMap::connections){ Unlock::UnlockArea(cp.map); } @@ -68,30 +68,30 @@ void Menu::InitializeSettingsWindow(){ return true; })END; - settingsWindow->ADD("Settings Label",MenuLabel)(geom2d::rect{{4,4},vf2d{windowSize.x-8,24}},"Game Settings",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END; + settingsWindow->ADD("Settings Label",MenuLabel)(geom2d::rect{{4,4},vf2d{windowSize.x-20,24}},"Game Settings",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END; settingsWindow->F(A::LAST_BGM_VOLUME)=1.f; settingsWindow->F(A::LAST_SFX_VOLUME)=1.f; - settingsWindow->ADD("BGM Slider",Slider)(geom2d::rect{vf2d{windowSize.x/2-64,44},{172,16}},"BGM Volume:",Audio::GetBGMVolume(),[](float val){ + settingsWindow->ADD("BGM Slider",Slider)(geom2d::rect{vf2d{windowSize.x/2-64,32},{172,16}},"BGM Volume:",Audio::GetBGMVolume(),[](float val){ if(abs(Menu::menus[SETTINGS]->F(A::LAST_BGM_VOLUME)-val)>=0.04f){ SoundEffect::PlaySFX("Change Volume",SoundEffect::CENTERED); Menu::menus[SETTINGS]->F(A::LAST_BGM_VOLUME)=val; } Audio::SetBGMVolume(val); })END; - settingsWindow->ADD("SFX Slider",Slider)(geom2d::rect{vf2d{windowSize.x/2-64,64},{172,16}},"SFX Volume:",Audio::GetSFXVolume(),[](float val){ + settingsWindow->ADD("SFX Slider",Slider)(geom2d::rect{vf2d{windowSize.x/2-64,52},{172,16}},"SFX Volume:",Audio::GetSFXVolume(),[](float val){ if(abs(Menu::menus[SETTINGS]->F(A::LAST_SFX_VOLUME)-val)>=0.04f){ SoundEffect::PlaySFX("Change Volume",SoundEffect::CENTERED); Menu::menus[SETTINGS]->F(A::LAST_SFX_VOLUME)=val; } })END; - settingsWindow->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect{{4.f,84},{16.f,16.f}},[](ToggleFuncData data){ + settingsWindow->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect{{4.f,72},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetScreenShake(data.checked); return true; },true)END; - settingsWindow->ADD("Screen Shake Label",MenuLabel)(geom2d::rect{{22.f,84},{windowSize.x/2-24.f,16.f}},"Screen Shake",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; - settingsWindow->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect{{4.f,104},{16.f,16.f}},[](ToggleFuncData data){ + settingsWindow->ADD("Screen Shake Label",MenuLabel)(geom2d::rect{{22.f,72},{windowSize.x/2-24.f,16.f}},"Screen Shake",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + settingsWindow->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect{{4.f,92},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetRumble(data.checked); if(GameSettings::RumbleEnabled()){ Input::StartVibration(); @@ -101,27 +101,33 @@ void Menu::InitializeSettingsWindow(){ } return true; },true)END; - settingsWindow->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect{{22.f,104},{windowSize.x/2-24.f,16.f}},"Gamepad Rumble",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + settingsWindow->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect{{22.f,92},{windowSize.x/2-24.f,16.f}},"Gamepad Rumble",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; - settingsWindow->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,84},{16.f,16.f}},[](ToggleFuncData data){ + settingsWindow->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,72},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetTerrainCollisionBoxes(data.checked); return true; },true)END; - settingsWindow->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,84},{windowSize.x/2-24.f,16.f}},"Terrain Collision Boxes",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; - settingsWindow->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,104},{16.f,16.f}},[](ToggleFuncData data){ + settingsWindow->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,72},{windowSize.x/2-24.f,16.f}},"Terrain Collision Boxes",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + settingsWindow->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,92},{16.f,16.f}},[](ToggleFuncData data){ GameSettings::SetKeyboardAutoAim(data.checked); return true; },false)END; - settingsWindow->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){ - 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; - },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; + settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,92},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + + auto fullscreenToggle=settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect{{windowSize.x/2+4.f,112},{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()); + } + if(!Menu::UsingMouseNavigation()){ //This prevents the fullscreen toggle from losing focus upon a window resize. + Menu::IgnoreNextMouseNavigationAttempt(); + } + game->SetFullscreen(data.checked,GameSettings::GetWindowPos()); + return true; + },game->IsFullscreen())END; + auto fullscreenToggleLabel=settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect{{windowSize.x/2+22.f,112},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + #ifdef __EMSCRIPTEN__ + fullscreenToggle->Disable(); + fullscreenToggleLabel->Disable(); #endif #pragma region Setup all input displays as keyboard controls. @@ -146,21 +152,82 @@ void Menu::InitializeSettingsWindow(){ }; #pragma endregion - settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,144.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",[&](MenuFuncData data){ + settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,132.f},vf2d{windowSize.x-32,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; - settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,172.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){ + settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){ ChangeKeybindDisplayType(CONTROLLER); Component(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings"); Menu::OpenMenu(INPUT_KEY_DISPLAY); return true; },vf2d{1.5f,2.f})END; - settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect{vf2d{windowSize.x/2.f,windowSize.y}-vf2d{36,4},{72,12}},"Go Back",[](MenuFuncData data){ + settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect{vf2d{windowSize.x/2.f,windowSize.y-12}-vf2d{36,4},{72,12}},"Go Back",[](MenuFuncData data){ Menu::CloseMenu(); return true; })END; + + settingsWindow->SetupKeyboardNavigation( + [](MenuType type,Data&returnData){ //On Open + returnData="BGM Slider"; + }, + { //Button Key + {game->KEY_SCROLL,{"Navigate",[](MenuType type){}}}, + {game->KEY_BACK,{"Back",[](MenuType type){ + Menu::CloseMenu(); + }}}, + {game->KEY_CONFIRM,{"Select",[](MenuType type){}}}, + } + ,{ //Button Navigation Rules + {"BGM Slider",{ + .up="Go Back", + .down="SFX Slider",}}, + {"SFX Slider",{ + .up="BGM Slider", + .down="Terrain Collision Boxes Checkbox",}}, + {"Terrain Collision Boxes Checkbox",{ + .up="SFX Slider", + .down="Keyboard Play Auto-Aim Checkbox", + .left="Screen Shake Checkbox", + .right="Screen Shake Checkbox",}}, + {"Keyboard Play Auto-Aim Checkbox",{ + .up="Terrain Collision Boxes Checkbox", + .down="Fullscreen Toggle Checkbox", + .left="Controller Rumble Checkbox", + .right="Controller Rumble Checkbox",}}, + {"Screen Shake Checkbox",{ + .up="SFX Slider", + .down="Controller Rumble Checkbox", + .left="Terrain Collision Boxes Checkbox", + .right="Terrain Collision Boxes Checkbox",}}, + {"Controller Rumble Checkbox",{ + .up="Screen Shake Checkbox", + .down="Fullscreen Toggle Checkbox", + .left="Keyboard Play Auto-Aim Checkbox", + .right="Keyboard Play Auto-Aim Checkbox",}}, + {"Fullscreen Toggle Checkbox",{ + .up="Keyboard Play Auto-Aim Checkbox", + .down="Keyboard Bindings Button", + .left="Controller Rumble Checkbox", + .right="Controller Rumble Checkbox",}}, + {"Keyboard Bindings Button",{ + .up="Fullscreen Toggle Checkbox", + .down="Controller Bindings Button",}}, + {"Controller Bindings Button",{ + .up="Keyboard Bindings Button", + .down="Go Back",}}, + {"Go Back",{ + .up="Controller Bindings Button", + .down="BGM Slider", + .left="Unlock All Button", + .right="Unlock All Button",}}, + {"Unlock All Button",{ + .up="Controller Bindings Button", + .down="BGM Slider", + .left="Go Back", + .right="Go Back",}}, + }); } \ No newline at end of file diff --git a/Adventures in Lestoria/Slider.h b/Adventures in Lestoria/Slider.h index 4cae347c..ac89ccf7 100644 --- a/Adventures in Lestoria/Slider.h +++ b/Adventures in Lestoria/Slider.h @@ -83,7 +83,7 @@ public: dragging=true; } - if(dragging){ + if(dragging||(hovered&&!Menu::UsingMouseNavigation())){ if(Menu::UsingMouseNavigation()){ val=GetSliderVal(game->GetMouseX()-Menu::menus[parentMenu]->pos.x-8); }else{ @@ -93,6 +93,9 @@ public: if(game->KEY_RIGHT.Held()){ val+=1.f*game->GetElapsedTime(); } + if(game->KEY_SCROLLHORZ.Analog()){ + val+=game->KEY_SCROLLHORZ.Analog()*game->GetElapsedTime(); + } } val=std::clamp(val,0.f,1.f); if(abs(prevVal-val)>=0.01f){ diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index d4d7a124..3d109d9b 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -13,7 +13,6 @@ January 1st Open window to the correct position/size at the beginning of the game if possible. Input HElper disappearing? (Possibly on loads) -Boss January 31st ============ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 67e22696..3d60e32b 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 7382 +#define VERSION_BUILD 7391 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 4b2d021c..8badfb56 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ