diff --git a/Crawler/CharacterMenuWindow.cpp b/Crawler/CharacterMenuWindow.cpp index edbb3ba6..d9068acf 100644 --- a/Crawler/CharacterMenuWindow.cpp +++ b/Crawler/CharacterMenuWindow.cpp @@ -177,7 +177,14 @@ void Menu::InitializeCharacterMenuWindow(){ Inventory::EquipItem(*equippedItem,slot); } return true; - },DO_NOTHING); + },[](MenuFuncData data){ + for(int counter=0;ItemAttribute attribute:displayAttrs){ + StatLabel*statDisplayLabel=Component(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label"); + statDisplayLabel->SetStatChangeAmt(0); + counter++; + } + return true; + }); equip->I(Attribute::EQUIP_TYPE)=int(slot); if(Inventory::GetEquip(slot)==&itemInvRef){ equip->SetSelected(true); diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 35786060..49c09150 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -292,6 +292,18 @@ void Menu::Update(Crawler*game){ } KeyboardButtonNavigation(game,pos); + for(auto&[key,value]:buttons){ + for(auto&button:value){ + if(button->renderInMain){ + button->BeforeUpdate(game); + } + } + } + for(auto&component:displayComponents){ + if(component->renderInMain){ + component->BeforeUpdate(game); + } + } for(auto&[key,value]:buttons){ for(auto&button:value){ if(button->renderInMain){ diff --git a/Crawler/MenuComponent.cpp b/Crawler/MenuComponent.cpp index a72f8010..17df5112 100644 --- a/Crawler/MenuComponent.cpp +++ b/Crawler/MenuComponent.cpp @@ -67,6 +67,8 @@ MenuComponent::~MenuComponent(){ void MenuComponent::AfterCreate(){} +void MenuComponent::BeforeUpdate(Crawler*game){} + void MenuComponent::Update(Crawler*game){ if(hovered){ hoverEffect=std::min("ThemeGlobal.HighlightTime"_F,hoverEffect+game->GetElapsedTime()); diff --git a/Crawler/MenuComponent.h b/Crawler/MenuComponent.h index 283d2d3b..eec67727 100644 --- a/Crawler/MenuComponent.h +++ b/Crawler/MenuComponent.h @@ -53,7 +53,7 @@ enum class ComponentAttr{ BACKGROUND=0b1000, //Renders the background of the menu theme for this component. }; -class MenuComponent:IAttributable{ +class MenuComponent:public IAttributable{ friend class Menu; friend class MenuItemButton; friend class ScrollableWindowComponent; @@ -63,6 +63,12 @@ class MenuComponent:IAttributable{ private: virtual bool GetHoverState(Crawler*game); std::pairmemoryLeakInfo; //Used to identify memory leak hints for this component. + virtual void BeforeUpdate(Crawler*game); + void _Update(Crawler*game); + void _Draw(Crawler*game); + void _Draw(Crawler*game,vf2d parentPos); + void _DrawDecal(Crawler*game,bool focused); + void _DrawDecal(Crawler*game,vf2d parentPos,bool focused); protected: float hoverEffect=0; std::string name=""; @@ -73,8 +79,6 @@ protected: bool background=true; bool showDefaultLabel=true; MenuFunc onClick; - MenuType parentMenu=MenuType::ENUM_END; - MenuComponent*parentComponent=nullptr; bool hovered=false; bool selectable=true; bool selectableViaKeyboard=true; @@ -89,14 +93,11 @@ protected: //CALL THIS FOR A PARENT to check a child's DrawDecal validity! virtual bool PointWithinParent(MenuComponent*child,vi2d drawPos); public: + MenuType parentMenu=MenuType::ENUM_END; + MenuComponent*parentComponent=nullptr; MenuComponent(MenuType parent,geom2d::rectrect,std::string label,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE); MenuComponent(MenuType parent,geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE); virtual ~MenuComponent(); - void _Update(Crawler*game); - void _Draw(Crawler*game); - void _Draw(Crawler*game,vf2d parentPos); - void _DrawDecal(Crawler*game,bool focused); - void _DrawDecal(Crawler*game,vf2d parentPos,bool focused); vf2d GetPos(); //We picked up a draggable component, we should make a copy and return it here. If a nullptr is returned here, the pickup is not allowed. //WARNING!!! This allocates a brand new component when successful!!! Be prepared to clear it! diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index ac6f2605..f65afc0b 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -86,6 +86,12 @@ public: this->hideQty=!show; } protected: + virtual inline void BeforeUpdate(Crawler*game)override{ + if(!hovered&&runHoverFunctions&&hoverState){ + hoverState=false; + onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)}); + } + } virtual inline void Update(Crawler*game)override{ MenuIconButton::Update(game); valid=!itemRef.get().IsBlank(); @@ -110,10 +116,6 @@ protected: 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/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h index c45c68d4..22f51f74 100644 --- a/Crawler/ScrollableWindowComponent.h +++ b/Crawler/ScrollableWindowComponent.h @@ -99,6 +99,11 @@ public: delete button; } protected: + virtual inline void BeforeUpdate(Crawler*game)override{ + for(MenuComponent*component:components){ + component->BeforeUpdate(game); + } + } virtual inline void Update(Crawler*game)override{ MenuComponent::Update(game); diff --git a/Crawler/Version.h b/Crawler/Version.h index 227e062f..25abf16e 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 3592 +#define VERSION_BUILD 3598 #define stringify(a) stringify_(a) #define stringify_(a) #a