Rendering of decal portions now controllable via point check overrides.
This commit is contained in:
parent
18db45e6c3
commit
472e8eceda
@ -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){
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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::rect<float>rect;
|
||||
std::string label;
|
||||
|
@ -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{
|
||||
|
@ -8,7 +8,7 @@ protected:
|
||||
Renderable r;
|
||||
std::vector<MenuComponent*>components;
|
||||
vf2d scrollOffset{};
|
||||
geom2d::rect<float>bounds;
|
||||
geom2d::rect<float>bounds; //It's for the scrollbar.
|
||||
private:
|
||||
inline bool OnScreen(MenuComponent*component){
|
||||
return geom2d::overlaps(rect,geom2d::rect<float>{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<float>{Menu::menus[parentMenu]->pos+rect.pos,rect.size},drawPos);
|
||||
}
|
||||
};
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user