diff --git a/Crawler/Item.cpp b/Crawler/Item.cpp index 6cbddf3b..5ca66934 100644 --- a/Crawler/Item.cpp +++ b/Crawler/Item.cpp @@ -173,7 +173,11 @@ void Inventory::InsertIntoSortedInv(IT item){ } bool Inventory::ExecuteAction(IT item){ - return ITEM_SCRIPTS.at(ITEM_DATA.at(item).useFunc)(game,ITEM_DATA[item].customProps); + if(ITEM_SCRIPTS.count(ITEM_DATA.at(item).useFunc)){ + return ITEM_SCRIPTS.at(ITEM_DATA.at(item).useFunc)(game,ITEM_DATA[item].customProps); + }else{ + return false; + } } bool Inventory::SwapItems(ITCategory itemCategory,uint32_t slot1,uint32_t slot2){ diff --git a/Crawler/MenuComponent.cpp b/Crawler/MenuComponent.cpp index 49fcb70c..08e3f8f8 100644 --- a/Crawler/MenuComponent.cpp +++ b/Crawler/MenuComponent.cpp @@ -62,4 +62,12 @@ bool MenuComponent::GetHoverState(Crawler*game){ bool MenuComponent::GetHoverState(Crawler*game,MenuComponent*child){ return false; +} + +bool MenuComponent::PointWithinParent(MenuComponent*child,vi2d drawPos){ + if(parentComponent!=nullptr){ + return parentComponent->PointWithinParent(child,drawPos); + }else{ + return true; + } } \ No newline at end of file diff --git a/Crawler/MenuComponent.h b/Crawler/MenuComponent.h index 823844a4..84e8ce7d 100644 --- a/Crawler/MenuComponent.h +++ b/Crawler/MenuComponent.h @@ -9,6 +9,8 @@ class MenuComponent{ private: float hoverEffect=0; virtual bool GetHoverState(Crawler*game); + //CALL THIS FOR A PARENT to check a child's DrawDecal validity! + virtual bool PointWithinParent(MenuComponent*child,vi2d drawPos); protected: geom2d::rectrect; std::string label; diff --git a/Crawler/MenuItemButton.h b/Crawler/MenuItemButton.h index acf7a835..15f1c363 100644 --- a/Crawler/MenuItemButton.h +++ b/Crawler/MenuItemButton.h @@ -63,7 +63,10 @@ protected: if(valid){ std::string quantityText="x"+std::to_string(Inventory::GetItemCount(invRef.at(inventoryIndex))); vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5; - game->DrawShadowStringDecal(parentPos+rect.pos+rect.size-textSize,quantityText,WHITE,BLACK,{0.5,0.5},0.5); + vf2d drawPos=parentPos+rect.pos+rect.size-textSize; + if(PointWithinParent(this,drawPos)){ + game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5); + } } } virtual inline MenuComponent*PickUpDraggableItem()override{ diff --git a/Crawler/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h index 96028941..5b08592a 100644 --- a/Crawler/ScrollableWindowComponent.h +++ b/Crawler/ScrollableWindowComponent.h @@ -8,7 +8,7 @@ protected: Renderable r; std::vectorcomponents; vf2d scrollOffset{}; - geom2d::rectbounds; + geom2d::rectbounds; //It's for the scrollbar. private: inline bool OnScreen(MenuComponent*component){ return geom2d::overlaps(rect,geom2d::rect{component->rect.pos+scrollOffset,component->rect.size}); @@ -24,9 +24,9 @@ protected: if(game->GetMouseWheel()!=0){ if(game->GetMouseWheel()>0){ - scrollOffset.y-=4; + scrollOffset.y+="ThemeGlobal.MenuScrollWheelSpeed"_I; }else{ - scrollOffset.y+=4; + scrollOffset.y-="ThemeGlobal.MenuScrollWheelSpeed"_I; } } @@ -83,4 +83,7 @@ public: parentMenu->AddComponent(key,button); } + virtual inline bool PointWithinParent(MenuComponent*child,vi2d drawPos)override{ + return geom2d::overlaps(geom2d::rect{Menu::menus[parentMenu]->pos+rect.pos,rect.size},drawPos); + } }; \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index 2d201c32..9d541036 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1988 +#define VERSION_BUILD 2007 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/config/gfx/themes.txt b/Crawler/assets/config/gfx/themes.txt index f7ed9048..c1f7810a 100644 --- a/Crawler/assets/config/gfx/themes.txt +++ b/Crawler/assets/config/gfx/themes.txt @@ -6,6 +6,8 @@ ThemeGlobal MenuUnfocusedColorMult = 0.4 # Amount of time to hold down an element before a press becomes a drag. MenuHoldTime = 0.1 + # How fast the menu scrolls via Scroll Wheel + MenuScrollWheelSpeed = 8 } Themes