diff --git a/Crawler/CharacterInfoWindow.cpp b/Crawler/CharacterInfoWindow.cpp index 6bd04345..2e18fc83 100644 --- a/Crawler/CharacterInfoWindow.cpp +++ b/Crawler/CharacterInfoWindow.cpp @@ -45,7 +45,7 @@ All rights reserved. INCLUDE_game INCLUDE_GFX INCLUDE_DATA -typedef Attribute A; +using A=Attribute; void Menu::InitializeClassInfoWindow(){ Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{24,24}); diff --git a/Crawler/CharacterMenuWindow.cpp b/Crawler/CharacterMenuWindow.cpp index e3ff5909..3fe1c459 100644 --- a/Crawler/CharacterMenuWindow.cpp +++ b/Crawler/CharacterMenuWindow.cpp @@ -130,7 +130,50 @@ void Menu::InitializeCharacterMenuWindow(){ MenuItemItemButton*comp=(MenuItemItemButton*)data.component; Inventory::EquipItem(comp->GetItem(),EquipSlot(comp->I(Attribute::EQUIP_TYPE))); return true; - },MenuType::ENUM_END,"",""); + },[&](MenuFuncData data){ + MenuItemItemButton*button=(MenuItemItemButton*)data.component; + Item&buttonItem=button->GetItem(); + const std::arraydisplayAttrs{ + ItemAttribute::health, + ItemAttribute::attack, + ItemAttribute::defense, + ItemAttribute::moveSpdPct, + ItemAttribute::cdrPct, + ItemAttribute::critPct, + ItemAttribute::critDmgPct, + }; + for(ItemAttribute attribute:displayAttrs){ + int stat=buttonItem.GetStats().get(attribute); + if(stat>0){ + MenuLabel*statDisplayLabel=Component(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label"); + std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT); + std::string newLabel=baseLabel+" (+"+std::to_string(stat)+")"; + statDisplayLabel->SetLabel(newLabel); + } + } + return true; + },[&](MenuFuncData data){ + MenuItemItemButton*button=(MenuItemItemButton*)data.component; + Item&buttonItem=button->GetItem(); + const std::arraydisplayAttrs{ + ItemAttribute::health, + ItemAttribute::attack, + ItemAttribute::defense, + ItemAttribute::moveSpdPct, + ItemAttribute::cdrPct, + ItemAttribute::critPct, + ItemAttribute::critDmgPct, + }; + for(ItemAttribute attribute:displayAttrs){ + int stat=buttonItem.GetStats().get(attribute); + if(stat>0){ + MenuLabel*statDisplayLabel=Component(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label"); + std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT); + statDisplayLabel->SetLabel(baseLabel); + } + } + return true; + }); equip->I(Attribute::EQUIP_TYPE)=int(slot); equipList->AddComponent(Menu::menus[CHARACTER_MENU],"Equip Item "+std::to_string(counter),equip); counter++; @@ -163,6 +206,7 @@ void Menu::InitializeCharacterMenuWindow(){ attrStr+="%"; } MenuLabel*attrLabel=NEW MenuLabel(CHARACTER_MENU,{{245,36+2+float(yOffset)},{62,18}},attrStr,1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN); + attrLabel->S(Attribute::DISPLAY_TEXT)=attrStr; yOffset+=20; characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel); } diff --git a/Crawler/ClassSelectionWindow.cpp b/Crawler/ClassSelectionWindow.cpp index f543adcc..4d750d09 100644 --- a/Crawler/ClassSelectionWindow.cpp +++ b/Crawler/ClassSelectionWindow.cpp @@ -44,7 +44,7 @@ All rights reserved. #include "ClassInfo.h" INCLUDE_game -typedef Attribute A; +using A=Attribute; void Menu::InitializeClassSelectionWindow(){ Menu*classSelectionWindow=CreateMenu(CLASS_SELECTION,CENTERED,game->GetScreenSize()-vi2d{24,24}); diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 5b1a5b57..31524a56 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -192,6 +192,7 @@ bool Crawler::OnUserCreate(){ Inventory::AddItem("Dummy Item 13",6); Inventory::AddItem("Bandages",10); Inventory::AddItem("Blue Slime Remains",22); + Inventory::AddItem("Copper Armor"); LoadLevel(LEVEL_NAMES["starting_map"_S]); ChangePlayerClass(WARRIOR); diff --git a/Crawler/InventoryConsumableWindow.cpp b/Crawler/InventoryConsumableWindow.cpp index 4400ae66..1c3f21f3 100644 --- a/Crawler/InventoryConsumableWindow.cpp +++ b/Crawler/InventoryConsumableWindow.cpp @@ -43,7 +43,7 @@ All rights reserved. #include "MenuLabel.h" #include "InventoryScrollableWindowComponent.h" -typedef Attribute A; +using A=Attribute; void Menu::InitializeConsumableInventoryWindow(){ int invWidth="ThemeGlobal.InventoryWidth"_I; diff --git a/Crawler/InventoryScrollableWindowComponent.h b/Crawler/InventoryScrollableWindowComponent.h index b6c0816c..1aa85603 100644 --- a/Crawler/InventoryScrollableWindowComponent.h +++ b/Crawler/InventoryScrollableWindowComponent.h @@ -42,7 +42,7 @@ All rights reserved. #include "Crawler.h" #include "ScrollableWindowComponent.h" -typedef Attribute A; +using A=Attribute; class InventoryScrollableWindowComponent:public ScrollableWindowComponent{ private: diff --git a/Crawler/Item.cpp b/Crawler/Item.cpp index ee270acf..8aaeb0db 100644 --- a/Crawler/Item.cpp +++ b/Crawler/Item.cpp @@ -545,4 +545,19 @@ void ItemInfo::InitializeSets(){ } } } -} \ No newline at end of file +} + +Stats ItemInfo::GetStats(int enhancementLevel){ + if(enhancement.size()<=enhancementLevel){ + return {}; + } + return enhancement[enhancementLevel]; +} + +Stats Item::GetStats()const{ + return it->GetStats(enhancementLevel); +}; + +const size_t EnhancementInfo::size()const{ + return enhancementStats.size(); +}; \ No newline at end of file diff --git a/Crawler/Item.h b/Crawler/Item.h index 468582a2..cc4e567d 100644 --- a/Crawler/Item.h +++ b/Crawler/Item.h @@ -48,10 +48,10 @@ class Crawler; class ItemInfo; class ItemProps; -typedef std::string IT; -typedef std::string ITCategory; +using IT=std::string; +using ITCategory=std::string; -typedef std::function ItemScript; +using ItemScript=std::function; enum class EquipSlot{ HELMET= 0b0000'0001, @@ -81,6 +81,7 @@ private: public: void SetAttribute(int enhanceLevel,ItemAttribute attribute,int value); const Stats&operator[](int level)const; + const size_t size()const; }; //You cannot create instances of this class, access sets from ItemSet::sets and add the appropriate set bonuses. @@ -112,6 +113,7 @@ public: ITCategory Category(); EquipSlot GetEquipSlot(); Decal*Decal(); + Stats GetStats()const; ItemScript&OnUseAction(); float CastTime(); float CooldownTime(); @@ -199,6 +201,7 @@ public: For the useFunc, return true if the item can be used, false otherwise. */ ItemScript&OnUseAction(); + Stats GetStats(int enhancementLevel); float CastTime(); float CooldownTime(); EquipSlot Slot(); diff --git a/Crawler/ItemLoadoutWindow.cpp b/Crawler/ItemLoadoutWindow.cpp index 57ce7724..1290ec3a 100644 --- a/Crawler/ItemLoadoutWindow.cpp +++ b/Crawler/ItemLoadoutWindow.cpp @@ -43,7 +43,7 @@ All rights reserved. #include "State_OverworldMap.h" INCLUDE_game -typedef Attribute A; +using A=Attribute; void Menu::InitializeItemLoadoutWindow(){ Menu*itemLoadoutWindow=CreateMenu(ITEM_LOADOUT,CENTERED,game->GetScreenSize()-vi2d{4,4}); diff --git a/Crawler/MainMenuWindow.cpp b/Crawler/MainMenuWindow.cpp index 166d6a9f..7951860f 100644 --- a/Crawler/MainMenuWindow.cpp +++ b/Crawler/MainMenuWindow.cpp @@ -41,7 +41,7 @@ All rights reserved. #include "MenuLabel.h" INCLUDE_game -typedef Attribute A; +using A=Attribute; void Menu::InitializeMainMenuWindow(){ Menu*mainMenuWindow=CreateMenu(MAIN_MENU,CENTERED,game->GetScreenSize()-vi2d{4,4}); diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 69955f4b..8f9eca0e 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -70,7 +70,7 @@ INCLUDE_game INCLUDE_GFX extern vi2d WINDOW_SIZE; -typedef Attribute A; +using A=Attribute; Menu::Menu(vf2d pos,vf2d size) :pos(pos==CENTERED?WINDOW_SIZE/2-size/2:vi2d{pos}),size(size){ diff --git a/Crawler/Menu.h b/Crawler/Menu.h index 1afc6334..68a31a35 100644 --- a/Crawler/Menu.h +++ b/Crawler/Menu.h @@ -164,4 +164,4 @@ struct MenuFuncData{ ScrollableWindowComponent*parentComponent; }; -typedef std::function MenuFunc; \ No newline at end of file +using MenuFunc=std::function; \ No newline at end of file diff --git a/Crawler/MenuComponent.cpp b/Crawler/MenuComponent.cpp index c9502b97..185ec621 100644 --- a/Crawler/MenuComponent.cpp +++ b/Crawler/MenuComponent.cpp @@ -38,7 +38,7 @@ All rights reserved. #include "Crawler.h" #include "MenuComponent.h" -typedef Attribute A; +using A=Attribute; MenuComponent::MenuComponent(MenuType parent,geom2d::rectrect,std::string label,MenuFunc onClick,ButtonAttr attributes) :parentMenu(parent),rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){ diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index 1a07a0f4..b401e87d 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -55,9 +55,19 @@ private: MenuType itemDescriptionMenu; std::string itemNameLabelName; std::string itemDescriptionLabelName; + bool runHoverFunctions=false; + MenuFunc onHover; + MenuFunc onMouseOut; + bool hoverState=false; public: 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){ + :MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(DO_NOTHING){ + draggable=false; + valid=!itemRef.IsBlank(); + } + inline MenuItemItemButton(MenuType parent,geom2d::rectrect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut) + :MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(MenuType::ENUM_END),itemNameLabelName(""),itemDescriptionLabelName(""),onHover(onHover),onMouseOut(onMouseOut){ + runHoverFunctions=true; draggable=false; valid=!itemRef.IsBlank(); } @@ -68,18 +78,31 @@ protected: virtual inline void Update(Crawler*game)override{ MenuIconButton::Update(game); valid=!itemRef.IsBlank(); + std::string labelNameText; + std::string labelDescriptionText; if(valid){ icon=itemRef.Decal(); - if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ - Component(itemDescriptionMenu,itemNameLabelName)->label=itemRef.Name(); - Component(itemDescriptionMenu,itemDescriptionLabelName)->label=itemRef.Description(); - } + labelNameText=itemRef.Name(); + labelDescriptionText=itemRef.Description(); }else{ icon=nullptr; - if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ - Component(itemDescriptionMenu,itemNameLabelName)->label=""; - Component(itemDescriptionMenu,itemDescriptionLabelName)->label=""; + labelNameText=""; + labelDescriptionText=""; + } + + if(hovered){ + if(itemDescriptionMenu!=MenuType::ENUM_END){ + Component(itemDescriptionMenu,itemNameLabelName)->label=labelNameText; + Component(itemDescriptionMenu,itemDescriptionLabelName)->label=labelDescriptionText; + } + if(runHoverFunctions&&!hoverState){ + hoverState=true; + onHover(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)}); } + }else + if(runHoverFunctions&&hoverState){ + hoverState=false; + onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)}); } } virtual inline void Draw(Crawler*game,vf2d parentPos)override{ diff --git a/Crawler/MonsterAttribute.h b/Crawler/MonsterAttribute.h index 36f2f17e..9617c369 100644 --- a/Crawler/MonsterAttribute.h +++ b/Crawler/MonsterAttribute.h @@ -70,4 +70,5 @@ enum class Attribute{ LOADOUT_SLOT, //Which loadout slot we are selecting an item for. ALLOW_DRAGGING, //Whether or not to allow inventory dragging. EQUIP_TYPE, + DISPLAY_TEXT, }; \ No newline at end of file diff --git a/Crawler/OverworldMapLevelWindow.cpp b/Crawler/OverworldMapLevelWindow.cpp index bc5663b3..9bcccfb2 100644 --- a/Crawler/OverworldMapLevelWindow.cpp +++ b/Crawler/OverworldMapLevelWindow.cpp @@ -47,7 +47,7 @@ All rights reserved. INCLUDE_game INCLUDE_LEVEL_NAMES INCLUDE_MONSTER_DATA -typedef Attribute A; +using A=Attribute; void Menu::InitializeOverworldMapLevelWindow(){ vf2d windowSize={game->GetScreenSize().x/3.f-24,float(game->GetScreenSize().y)-48}; diff --git a/Crawler/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h index e804a3a1..1c831686 100644 --- a/Crawler/ScrollableWindowComponent.h +++ b/Crawler/ScrollableWindowComponent.h @@ -41,7 +41,7 @@ All rights reserved. #include "MenuItemButton.h" #include "Crawler.h" -typedef Attribute A; +using A=Attribute; class ScrollableWindowComponent:public MenuComponent{ protected: diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index e4c58d44..ce55394b 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -50,7 +50,7 @@ INCLUDE_BULLET_LIST INCLUDE_ANIMATION_DATA INCLUDE_MONSTER_NAME_DATA -typedef Attribute A; +using A=Attribute; void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){ float bulletSpd=ConfigFloat("BulletSpd")/100*24; diff --git a/Crawler/TestSubMenu.cpp b/Crawler/TestSubMenu.cpp index 0f44b680..c7e26108 100644 --- a/Crawler/TestSubMenu.cpp +++ b/Crawler/TestSubMenu.cpp @@ -43,7 +43,7 @@ All rights reserved. #include "MenuLabel.h" INCLUDE_GFX -typedef Attribute A; +using A=Attribute; void Menu::InitializeTestSubMenu(){ Menu*testSubMenu=CreateMenu(TEST_2,{30,30},{24*4,24*5}); diff --git a/Crawler/Turret.cpp b/Crawler/Turret.cpp index 291beddc..4bf217c9 100644 --- a/Crawler/Turret.cpp +++ b/Crawler/Turret.cpp @@ -42,7 +42,7 @@ All rights reserved. #include "util.h" #include "MonsterAttribute.h" -typedef Attribute A; +using A=Attribute; INCLUDE_game INCLUDE_BULLET_LIST diff --git a/Crawler/Version.h b/Crawler/Version.h index 898854fa..05b0d7e7 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 3471 +#define VERSION_BUILD 3479 #define stringify(a) stringify_(a) #define stringify_(a) #a