Add in selection indices that respect menus with multiple columns while scrolling through.
This commit is contained in:
@@ -85,7 +85,19 @@ void Menu::InitializeConsumableInventoryWindow(){
|
||||
inventoryWindow->ADD("itemDescription",MenuLabel)(geom2d::rect<float>(vf2d{2,117.f},{windowSize.x-4,windowSize.y-108}),"",1,ComponentAttr::SHADOW)END;
|
||||
|
||||
auto okButton=inventoryWindow->ADD("OK Button",MenuComponent)(geom2d::rect<float>{{windowSize.x/2-24,173.f},{48,12}},"Ok",[](MenuFuncData data){Menu::CloseMenu();return true;})END;
|
||||
|
||||
|
||||
#pragma region ScrollWindow macro lambda
|
||||
#define ScrollWindow(amount) \
|
||||
[](MenuType type){ \
|
||||
auto scrollWindow=Component<InventoryScrollableWindowComponent>(type,"inventory"); \
|
||||
scrollWindow->Scroll(amount); \
|
||||
int invWidth=int((scrollWindow->rect.size.x-12)/(float(scrollWindow->options.size.x)+scrollWindow->options.padding)); /*The inventory width determines how many items to skip at a time.*/ \
|
||||
scrollWindow->SetSelectionSkipIncrement(invWidth); \
|
||||
float scrollAmt=amount*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F; \
|
||||
scrollWindow->IncreaseSelectionIndex(scrollAmt/24.f); \
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
inventoryWindow->SetupKeyboardNavigation(
|
||||
[](MenuType type,Data&returnData){ //On Open
|
||||
//Try to find the component that matches the loadout item we have on us.
|
||||
@@ -111,6 +123,9 @@ void Menu::InitializeConsumableInventoryWindow(){
|
||||
{game->KEY_BACK,{"Back",[](MenuType type){
|
||||
Menu::CloseMenu();
|
||||
}}},
|
||||
{{game->KEY_SCROLL,Analog},{"Scroll",ScrollWindow(game->KEY_SCROLL.Analog())}},
|
||||
{{game->KEY_SCROLLUP,Held},{"Scroll Up",ScrollWindow(-1.0f)}},
|
||||
{{game->KEY_SCROLLDOWN,Held},{"Scroll Down",ScrollWindow(1.0f)}},
|
||||
}
|
||||
,{ //Button Navigation Rules
|
||||
{"OK Button",{
|
||||
|
||||
Reference in New Issue
Block a user