diff --git a/Crawler/InventoryScrollableWindowComponent.h b/Crawler/InventoryScrollableWindowComponent.h index 14e761ef..b9de1f01 100644 --- a/Crawler/InventoryScrollableWindowComponent.h +++ b/Crawler/InventoryScrollableWindowComponent.h @@ -125,7 +125,7 @@ protected: return true; }; - MenuItemButton*button=NEW MenuItemButton{parentMenu,{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc}; + MenuItemButton*button=NEW MenuItemButton{parentMenu,{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc,parentMenu,"itemName","itemDescription"}; AddComponent(Menu::menus[parentMenu],"item"+std::to_string(itemIndex),button); }else if(components.size()>inv.size()){ //There are empty spots, so let's clean up. diff --git a/Crawler/ItemLoadoutWindow.cpp b/Crawler/ItemLoadoutWindow.cpp index 1fcc4dd5..917e9e47 100644 --- a/Crawler/ItemLoadoutWindow.cpp +++ b/Crawler/ItemLoadoutWindow.cpp @@ -52,13 +52,13 @@ void Menu::InitializeItemLoadoutWindow(){ float buttonBorderPadding=64; - MenuItemItemButton*loadoutItem1=NEW MenuItemItemButton(ITEM_LOADOUT,{{64,120},{48,48}},game->GetLoadoutItem(0),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=0; return true;}); - MenuItemItemButton*loadoutItem2=NEW MenuItemItemButton(ITEM_LOADOUT,{{itemLoadoutWindowWidth/2-24,120},{48,48}},game->GetLoadoutItem(1),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=1;return true;}); - MenuItemItemButton*loadoutItem3=NEW MenuItemItemButton(ITEM_LOADOUT,{{itemLoadoutWindowWidth-48-64,120},{48,48}},game->GetLoadoutItem(2),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=2;return true;}); + MenuItemItemButton*loadoutItem1=NEW MenuItemItemButton(ITEM_LOADOUT,{{64,96},{48,48}},game->GetLoadoutItem(0),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=0; return true;},ITEM_LOADOUT,"Item Name Label","Item Description"); + MenuItemItemButton*loadoutItem2=NEW MenuItemItemButton(ITEM_LOADOUT,{{itemLoadoutWindowWidth/2-24,96},{48,48}},game->GetLoadoutItem(1),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=1;return true;},ITEM_LOADOUT,"Item Name Label","Item Description"); + MenuItemItemButton*loadoutItem3=NEW MenuItemItemButton(ITEM_LOADOUT,{{itemLoadoutWindowWidth-48-64,96},{48,48}},game->GetLoadoutItem(2),INVENTORY,[](MenuFuncData data){Menu::menus.at(INVENTORY)->I(A::LOADOUT_SLOT)=2;return true;},ITEM_LOADOUT,"Item Name Label","Item Description"); //TODO: Make these two do something. - MenuLabel*itemNameLabel=NEW MenuLabel(ITEM_LOADOUT,{{0,182},{itemLoadoutWindowWidth,12}},"",1,ComponentAttr::SHADOW); - MenuLabel*itemDescription=NEW MenuLabel(ITEM_LOADOUT,{{0,194},{itemLoadoutWindowWidth,24}},"",1,ComponentAttr::SHADOW); + MenuLabel*itemNameLabel=NEW MenuLabel(ITEM_LOADOUT,{{0,158},{itemLoadoutWindowWidth,12}},"",1,ComponentAttr::SHADOW); + MenuLabel*itemDescription=NEW MenuLabel(ITEM_LOADOUT,{{0,170},{itemLoadoutWindowWidth,24}},"",1,ComponentAttr::SHADOW); itemLoadoutWindow->AddComponent("Loadout Item 1",loadoutItem1); itemLoadoutWindow->AddComponent("Loadout Item 2",loadoutItem2); diff --git a/Crawler/MenuItemButton.h b/Crawler/MenuItemButton.h index 1e0044e1..5dd71998 100644 --- a/Crawler/MenuItemButton.h +++ b/Crawler/MenuItemButton.h @@ -47,10 +47,13 @@ class MenuItemButton:public MenuIconButton{ private: std::vector&invRef; int inventoryIndex=0; + MenuType itemDescriptionMenu; + std::string itemNameLabelName; + std::string itemDescriptionLabelName; public: int selected=-1; //0-2 representing which loadout slot this item consumes. -1 means not selected. - inline MenuItemButton(MenuType parent,geom2d::rectrect,std::vector&invRef,int invIndex,MenuFunc onClick) - :MenuIconButton(parent,rect,invRef.size()>invIndex?ITEM_DATA.at(invRef[invIndex]).Decal():nullptr,onClick),invRef(invRef),inventoryIndex(invIndex){ + inline MenuItemButton(MenuType parent,geom2d::rectrect,std::vector&invRef,int invIndex,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName) + :MenuIconButton(parent,rect,invRef.size()>invIndex?ITEM_DATA.at(invRef[invIndex]).Decal():nullptr,onClick),invRef(invRef),inventoryIndex(invIndex),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ draggable=false; valid=invRef.size()>invIndex; } @@ -69,26 +72,14 @@ protected: if(valid){ icon=ITEM_DATA.at(invRef[inventoryIndex]).Decal(); if(hovered){ - switch(parentMenu){ - case INVENTORY:{ - //There should be an itemName label to modify. - Component(INVENTORY,"itemName")->label=ITEM_DATA.at(invRef[inventoryIndex]).Name(); - //There should be an itemDescription label to modify. - Component(INVENTORY,"itemDescription")->label=ITEM_DATA.at(invRef[inventoryIndex]).Description(); - }break; - } + Component(itemDescriptionMenu,itemNameLabelName)->label=ITEM_DATA.at(invRef[inventoryIndex]).Name(); + Component(itemDescriptionMenu,itemDescriptionLabelName)->label=ITEM_DATA.at(invRef[inventoryIndex]).Description(); } }else{ icon=nullptr; if(hovered){ - switch(parentMenu){ - case INVENTORY:{ - //There should be an itemName label to modify. - Component(INVENTORY,"itemName")->label=""; - //There should be an itemDescription label to modify. - Component(INVENTORY,"itemDescription")->label=""; - }break; - } + Component(itemDescriptionMenu,itemNameLabelName)->label=""; + Component(itemDescriptionMenu,itemDescriptionLabelName)->label=""; } } } @@ -111,7 +102,7 @@ protected: } inline MenuComponent*PickUpDraggableItem()override final{ if(valid){ - MenuItemButton*pickUp=NEW MenuItemButton(parentMenu,rect,invRef,inventoryIndex,onClick); + MenuItemButton*pickUp=NEW MenuItemButton(parentMenu,rect,invRef,inventoryIndex,onClick,itemDescriptionMenu,itemNameLabelName,itemDescriptionLabelName); valid=false; return pickUp; }else{ diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index 2f542603..6b7775c1 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -46,9 +46,12 @@ INCLUDE_ITEM_DATA class MenuItemItemButton:public MenuIconButton{ private: Item&itemRef; + MenuType itemDescriptionMenu; + std::string itemNameLabelName; + std::string itemDescriptionLabelName; public: - inline MenuItemItemButton(MenuType parent,geom2d::rectrect,Item&itemRef,MenuType menuDest,MenuFunc onClick) - :MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef){ + inline MenuItemItemButton(MenuType parent,geom2d::rectrect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName) + :MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ draggable=false; valid=!itemRef.IsBlank(); } @@ -59,26 +62,14 @@ protected: if(valid){ icon=itemRef.Decal(); if(hovered){ - switch(parentMenu){ - case INVENTORY:{ - //There should be an itemName label to modify. - Component(ITEM_LOADOUT,"Item Name Label")->label=itemRef.Name(); - //There should be an itemDescription label to modify. - Component(ITEM_LOADOUT,"Item Description")->label=itemRef.Description(); - }break; - } + Component(itemDescriptionMenu,itemNameLabelName)->label=itemRef.Name(); + Component(itemDescriptionMenu,itemDescriptionLabelName)->label=itemRef.Description(); } }else{ icon=nullptr; if(hovered){ - switch(parentMenu){ - case INVENTORY:{ - //There should be an itemName label to modify. - Component(ITEM_LOADOUT,"Item Name Label")->label=""; - //There should be an itemDescription label to modify. - Component(ITEM_LOADOUT,"Item Description")->label=""; - }break; - } + Component(itemDescriptionMenu,itemNameLabelName)->label=""; + Component(itemDescriptionMenu,itemDescriptionLabelName)->label=""; } } } diff --git a/Crawler/Version.h b/Crawler/Version.h index 0c310f41..141cb04b 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -33,7 +33,7 @@ SUCH DAMAGE. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 2856 +#define VERSION_BUILD 2860 #define stringify(a) stringify_(a) #define stringify_(a) #a