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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user