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.

pull/35/head
sigonasr2 10 months ago
parent 6a5b74b3e6
commit 35cc847671
  1. 1
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 20
      Adventures in Lestoria/InventoryConsumableWindow.cpp
  3. 1
      Adventures in Lestoria/Key.cpp
  4. 1
      Adventures in Lestoria/State_MainMenu.cpp
  5. 2
      Adventures in Lestoria/Version.h
  6. 1
      Adventures in Lestoria/assets/config/gfx/gfx.txt
  7. BIN
      Adventures in Lestoria/assets/themes/button_arrows.png
  8. 1
      Adventures in Lestoria/olcPixelGameEngine.h

@ -2524,6 +2524,7 @@ void AiL::InitializeDefaultKeybinds(){
KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)}); KEY_SCROLLVERT.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::LX)});
KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)}); KEY_SCROLLHORZ.AddKeybind({ANALOG,static_cast<int>(GPAxes::RX)});
KEY_SCROLL.AddKeybind({KEY,ARROWS});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::ALL)}); KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::ALL)});
KEY_SHOULDER.AddKeybind({KEY,SHOULDER}); KEY_SHOULDER.AddKeybind({KEY,SHOULDER});

@ -111,7 +111,18 @@ void Menu::InitializeConsumableInventoryWindow(){
{game->KEY_BACK,{"Back",[](MenuType type){ {game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu(); 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<InventoryScrollableWindowComponent>(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<InventoryScrollableWindowComponent>(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 ,{ //Button Navigation Rules
{"OK Button",{ {"OK Button",{
@ -183,10 +194,15 @@ void Menu::InitializeConsumableInventoryWindow(){
std::weak_ptr<MenuItemButton>selectedButton=DYNAMIC_POINTER_CAST<MenuItemButton>(*component); std::weak_ptr<MenuItemButton>selectedButton=DYNAMIC_POINTER_CAST<MenuItemButton>(*component);
int newRowIndex=selectedButton.lock()->inventoryIndex+invWidth; //Moving down moves the cursor down an entire row. int newRowIndex=selectedButton.lock()->inventoryIndex+invWidth; //Moving down moves the cursor down an entire row.
if(newRowIndex>=itemsList.size()){ if(newRowIndex>=itemsList.size()){
//This means we have to wrap around. 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"; returnData="OK Button";
return; 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)); 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. //Select the component that matches this new number.
auto component=std::find_if(itemsList.begin(),itemsList.end(),[&](auto&comp){return DYNAMIC_POINTER_CAST<MenuItemButton>(comp)->inventoryIndex==newRowIndex;}); auto component=std::find_if(itemsList.begin(),itemsList.end(),[&](auto&comp){return DYNAMIC_POINTER_CAST<MenuItemButton>(comp)->inventoryIndex==newRowIndex;});

@ -482,6 +482,7 @@ std::map<std::pair<InputType,int>,GenericKey::KeyInfo> GenericKey::keyLiteral={
{{KEY, CAPS_LOCK},{"CAP LK"}}, {{KEY, CAPS_LOCK},{"CAP LK"}},
{{KEY, olc::ENUM_END},{""}}, {{KEY, olc::ENUM_END},{""}},
{{KEY, SHOULDER},{"Q-E","themes/button_qe.png"}}, {{KEY, SHOULDER},{"Q-E","themes/button_qe.png"}},
{{KEY, ARROWS},{"Arrow Keys","themes/button_arrows.png"}},
{{MOUSE, Mouse::LEFT},{"L.MOUSE"}}, {{MOUSE, Mouse::LEFT},{"L.MOUSE"}},
{{MOUSE, Mouse::RIGHT},{"R.MOUSE"}}, {{MOUSE, Mouse::RIGHT},{"R.MOUSE"}},
{{MOUSE, Mouse::MIDDLE},{"M.MOUSE"}}, {{MOUSE, Mouse::MIDDLE},{"M.MOUSE"}},

@ -56,5 +56,4 @@ void State_MainMenu::OnUserUpdate(AiL*game){
}; };
void State_MainMenu::Draw(AiL*game){ void State_MainMenu::Draw(AiL*game){
TitleScreen::Draw(); TitleScreen::Draw();
game->DrawOGStringDecal({0,0},"DOWN: "+std::to_string(game->KEY_SCROLLVERT.Analog()));
}; };

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 6936 #define VERSION_BUILD 6939
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -63,6 +63,7 @@ Images
GFX_Button_SHOULDER_QE = themes/button_qe.png GFX_Button_SHOULDER_QE = themes/button_qe.png
GFX_Button_SHOULDER_L1R1 = themes/button_r1l1.png GFX_Button_SHOULDER_L1R1 = themes/button_r1l1.png
GFX_Button_AnalogStick = themes/button_analogstick.png GFX_Button_AnalogStick = themes/button_analogstick.png
GFX_Button_Arrows = themes/button_arrows.png
GFX_Overworld_Arrow = overworld_arrow.png GFX_Overworld_Arrow = overworld_arrow.png
GFX_Exclamation = exclamation.png GFX_Exclamation = exclamation.png
GFX_Ursule2 = monsters/Ursule Mother of Bears2.png GFX_Ursule2 = monsters/Ursule Mother of Bears2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

@ -654,6 +654,7 @@ namespace olc
//UNREACHABLE ITEMS BELOW: //UNREACHABLE ITEMS BELOW:
SHOULDER, SHOULDER,
ARROWS,
}; };
namespace Mouse namespace Mouse

Loading…
Cancel
Save