From 35cc84767113f925c3531d77bfde90df304726f5 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 10 Feb 2024 00:01:24 -0600 Subject: [PATCH] Add in shoulder button navigation to consumables window. Fix down navigation when reaching a partially filled row in the inventory consumables window. Added arrows navigation input helper icon. --- .../AdventuresInLestoria.cpp | 1 + .../InventoryConsumableWindow.cpp | 24 +++++++++++++++--- Adventures in Lestoria/Key.cpp | 1 + Adventures in Lestoria/State_MainMenu.cpp | 1 - Adventures in Lestoria/Version.h | 2 +- .../assets/config/gfx/gfx.txt | 1 + .../assets/themes/button_arrows.png | Bin 0 -> 9983 bytes Adventures in Lestoria/olcPixelGameEngine.h | 1 + 8 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 Adventures in Lestoria/assets/themes/button_arrows.png diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 3493afbc..ae944ef7 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2524,6 +2524,7 @@ void AiL::InitializeDefaultKeybinds(){ KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast(GPAxes::RY)}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::LX)}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast(GPAxes::RX)}); + KEY_SCROLL.AddKeybind({KEY,ARROWS}); KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::ALL)}); KEY_SHOULDER.AddKeybind({KEY,SHOULDER}); diff --git a/Adventures in Lestoria/InventoryConsumableWindow.cpp b/Adventures in Lestoria/InventoryConsumableWindow.cpp index 00675c36..3bb20fa8 100644 --- a/Adventures in Lestoria/InventoryConsumableWindow.cpp +++ b/Adventures in Lestoria/InventoryConsumableWindow.cpp @@ -111,7 +111,18 @@ void Menu::InitializeConsumableInventoryWindow(){ {game->KEY_BACK,{"Back",[](MenuType type){ Menu::CloseMenu(); }}}, - {{game->KEY_SCROLLVERT,Analog},{"Scroll",[](MenuType type){}}}, + {{game->KEY_SCROLL,Analog},{"Scroll",[](MenuType type){}}}, + {{game->KEY_SHOULDER,Pressed},{"Scroll",[](MenuType type){}}}, + {{game->KEY_FASTSCROLLDOWN,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){ + auto itemsWindow=Component(type,"inventory"); + int invWidth=int((itemsWindow->rect.size.x-12)/(float(itemsWindow->options.size.x)+itemsWindow->options.padding)); + itemsWindow->IncreaseSelectionIndex(invWidth*3.f); + }}}, + {{game->KEY_FASTSCROLLUP,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){ + auto itemsWindow=Component(type,"inventory"); + int invWidth=int((itemsWindow->rect.size.x-12)/(float(itemsWindow->options.size.x)+itemsWindow->options.padding)); + itemsWindow->IncreaseSelectionIndex(invWidth*-3.f); + }}}, } ,{ //Button Navigation Rules {"OK Button",{ @@ -183,9 +194,14 @@ void Menu::InitializeConsumableInventoryWindow(){ std::weak_ptrselectedButton=DYNAMIC_POINTER_CAST(*component); int newRowIndex=selectedButton.lock()->inventoryIndex+invWidth; //Moving down moves the cursor down an entire row. if(newRowIndex>=itemsList.size()){ - //This means we have to wrap around. - returnData="OK Button"; - return; + int currentRow=newRowIndex/invWidth; + //The logic here is, if we clamp this row index to the last possible index and we're still on the same row, it means there is at least an item on this row. So we go to that instead. + newRowIndex=std::clamp(newRowIndex,0,int(itemsList.size()-1)); + int newRow=newRowIndex/invWidth; + if(currentRow!=newRow){ //This means we are on a different row, so the row we went down on didn't have any items. Simply drop down to the OK Button. + returnData="OK Button"; + return; + } } if(newRowIndex<0||newRowIndex>=itemsList.size())ERR(std::format("New Row Index ended up out-of-bounds! newRowIndex={}. THIS SHOULD NOT BE HAPPENING!",newRowIndex)); //Select the component that matches this new number. diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp index 02ce1a89..d434499d 100644 --- a/Adventures in Lestoria/Key.cpp +++ b/Adventures in Lestoria/Key.cpp @@ -482,6 +482,7 @@ std::map,GenericKey::KeyInfo> GenericKey::keyLiteral={ {{KEY, CAPS_LOCK},{"CAP LK"}}, {{KEY, olc::ENUM_END},{""}}, {{KEY, SHOULDER},{"Q-E","themes/button_qe.png"}}, + {{KEY, ARROWS},{"Arrow Keys","themes/button_arrows.png"}}, {{MOUSE, Mouse::LEFT},{"L.MOUSE"}}, {{MOUSE, Mouse::RIGHT},{"R.MOUSE"}}, {{MOUSE, Mouse::MIDDLE},{"M.MOUSE"}}, diff --git a/Adventures in Lestoria/State_MainMenu.cpp b/Adventures in Lestoria/State_MainMenu.cpp index f8a8bf8a..b6d2e7ee 100644 --- a/Adventures in Lestoria/State_MainMenu.cpp +++ b/Adventures in Lestoria/State_MainMenu.cpp @@ -56,5 +56,4 @@ void State_MainMenu::OnUserUpdate(AiL*game){ }; void State_MainMenu::Draw(AiL*game){ TitleScreen::Draw(); - game->DrawOGStringDecal({0,0},"DOWN: "+std::to_string(game->KEY_SCROLLVERT.Analog())); }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 65dca823..64756e3d 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 6936 +#define VERSION_BUILD 6939 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/gfx/gfx.txt b/Adventures in Lestoria/assets/config/gfx/gfx.txt index e8a7b797..71069820 100644 --- a/Adventures in Lestoria/assets/config/gfx/gfx.txt +++ b/Adventures in Lestoria/assets/config/gfx/gfx.txt @@ -63,6 +63,7 @@ Images GFX_Button_SHOULDER_QE = themes/button_qe.png GFX_Button_SHOULDER_L1R1 = themes/button_r1l1.png GFX_Button_AnalogStick = themes/button_analogstick.png + GFX_Button_Arrows = themes/button_arrows.png GFX_Overworld_Arrow = overworld_arrow.png GFX_Exclamation = exclamation.png GFX_Ursule2 = monsters/Ursule Mother of Bears2.png diff --git a/Adventures in Lestoria/assets/themes/button_arrows.png b/Adventures in Lestoria/assets/themes/button_arrows.png new file mode 100644 index 0000000000000000000000000000000000000000..4c4a36fcb70951b7bd5500329e49cffc9f4d7753 GIT binary patch literal 9983 zcmeHrXH-*Lw{}nvDbiGW2~7bBgd`9WdhbX_q)13Y5eOxr7o`d!9Z`Dkh#jJUfC;BPgm^%B`YNW0Jxx` zu53X3Wg{L8=g$$pOFtH5005V%e2s1p3{YM`S9cd%2PZ6$;Nyw~V!a(~0RZpuf>Z}j zw&sM;6ZGX)(w@Bg^`2|)Tk7FKi`((H;H8r1>l;UA+g}d8Z?B>6E}1Ur zAHei7xV#Rw6r-MQeyI<#g43kNb3XkbzbdY`@t$f;T>efn7GJio&G05Luzl(zG{_~7 zt12*K*X0gVZau?yimCOP;03$$`ziAMUa*{L@`Et~H`5NCQls27lp84bdS&hwT2;+3 zTFz>R{~A|p8}ELv^z>~cex0R1npXQE_w=>WIGF!K@vOa0VR!!$V zUB{cqc=eX&c4`-IJL<3VPpMguOXuM%FBrb7+sI(fop}1jlx!r?4*P)_lL9BX`rBmOUy=Q*}wlkNOxbvNlyW=CC#? zQ^YO#dF*QB4WAYDnOtaC<8Rbv~(WBuaHq< zC?6O{@+je!_MlpK)P&Jf^X=r>wE|h6ObKb)l=#R?kjo}rdRNWFu51|EkSWQ8T`~+N z*D5V3$W)3!ETn5O3hpv!!uTIrXqFT_v{H%|AFOyk_~Fub|lYGXm|PLWmtU9X`9LU{GV zD{+$xe&&hNj#GYbs_W&_04KgT!ac_nq71HsS37<&pfa*hb1-pR7+E zvWhpk8R}EurFR?oWz?H_NJ8~(8UoDgn4l83JbIc8C#5`c+WDmHd0QV$-7uyRyeFv} z9hqOq88nZWk3Xt+k7Mbxs~+!iTdTFLuQ{I!#dE%kSsA?|+9E@f9B21iQ(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a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -654,6 +654,7 @@ namespace olc //UNREACHABLE ITEMS BELOW: SHOULDER, + ARROWS, }; namespace Mouse