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.

This commit is contained in:
sigonasr2 2024-02-10 00:01:24 -06:00
parent 6a5b74b3e6
commit 35cc847671
8 changed files with 25 additions and 6 deletions

View File

@ -2524,6 +2524,7 @@ void AiL::InitializeDefaultKeybinds(){
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::RX)});
KEY_SCROLL.AddKeybind({KEY,ARROWS});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::ALL)});
KEY_SHOULDER.AddKeybind({KEY,SHOULDER});

View File

@ -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<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
{"OK Button",{
@ -183,9 +194,14 @@ void Menu::InitializeConsumableInventoryWindow(){
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.
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.

View File

@ -482,6 +482,7 @@ std::map<std::pair<InputType,int>,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"}},

View File

@ -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()));
};

View File

@ -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

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

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