Add in item drop overlays to HUD.
This commit is contained in:
parent
88b8f17edb
commit
933fc16cce
@ -1134,6 +1134,8 @@ Player*Crawler::GetPlayer(){
|
||||
}
|
||||
|
||||
void Crawler::RenderHud(){
|
||||
ItemOverlay::Draw();
|
||||
|
||||
RenderCooldowns();
|
||||
|
||||
auto RenderCastbar=[&](const CastInfo&cast){
|
||||
|
@ -47,6 +47,7 @@ safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
|
||||
Item Item::BLANK;
|
||||
std::map<IT,Item>Inventory::_inventory;
|
||||
std::map<ITCategory,std::vector<Item>>Inventory::sortedInv;
|
||||
std::vector<ItemOverlay>ItemOverlay::items;
|
||||
|
||||
ItemInfo::ItemInfo()
|
||||
:customProps({nullptr,nullptr}),img(nullptr){}
|
||||
@ -328,3 +329,35 @@ void Inventory::Clear(ITCategory itemCategory){
|
||||
bool Item::operator==(const Item&rhs)const{
|
||||
return it==rhs.it;
|
||||
}
|
||||
|
||||
ItemOverlay::ItemOverlay(ItemInfo item)
|
||||
:it(item),width("ItemDrop.Item Drop Scale"_F*24+4+game->GetTextSizeProp(item.Name()).x*0.5){
|
||||
xOffset=-width;
|
||||
}
|
||||
|
||||
void ItemOverlay::Update(){
|
||||
for(ItemOverlay&item:items){
|
||||
item.timer+=game->GetElapsedTime();
|
||||
item.xOffset=std::min(item.xOffset+game->GetElapsedTime()*"ItemOverlay.Item Overlay Speed"_F,0.f);
|
||||
}
|
||||
std::erase_if(items,[](ItemOverlay&item){return item.timer>"ItemOverlay.Item Overlay Time"_F;});
|
||||
}
|
||||
|
||||
void ItemOverlay::Draw(){
|
||||
int counter=0;
|
||||
float itemScale="ItemDrop.Item Drop Scale"_F;
|
||||
for(ItemOverlay&item:items){
|
||||
vf2d pos={item.xOffset,96.f+counter*10};
|
||||
Pixel darkCol=Menu::GetCurrentTheme().GetButtonCol();
|
||||
Pixel lightCol=Menu::GetCurrentTheme().GetButtonCol()*1.2;
|
||||
game->GradientFillRectDecal(pos,{item.width,8},darkCol,darkCol,darkCol,lightCol);
|
||||
game->DrawRectDecal(pos,{item.width,8},Menu::GetCurrentTheme().GetHighlightCol());
|
||||
game->DrawDecal(pos,item.it.Decal(),{itemScale,itemScale});
|
||||
game->DrawShadowStringPropDecal(pos+vf2d{itemScale*24+2,2},item.it.Name(),WHITE,BLACK,{0.5,0.7});
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
void ItemOverlay::AddToItemOverlay(const ItemInfo&it){
|
||||
items.push_back(ItemOverlay{it});
|
||||
}
|
@ -131,3 +131,16 @@ public:
|
||||
For the useFunc, return true if the item can be used, false otherwise.
|
||||
*/
|
||||
};
|
||||
|
||||
class ItemOverlay{
|
||||
ItemInfo it;
|
||||
float timer=0;
|
||||
float xOffset=0;
|
||||
float width=0; //How wide the entire label is.
|
||||
static std::vector<ItemOverlay>items;
|
||||
ItemOverlay(ItemInfo item);
|
||||
public:
|
||||
static void AddToItemOverlay(const ItemInfo&it);
|
||||
static void Update();
|
||||
static void Draw();
|
||||
};
|
@ -130,10 +130,13 @@ void ItemDrop::UpdateDrops(float fElapsedTime){
|
||||
std::erase_if(drops,[](ItemDrop&drop){
|
||||
if(drop.collected){
|
||||
Inventory::AddItem(drop.GetItem()->Name(),1,true);
|
||||
ItemOverlay::AddToItemOverlay(*drop.GetItem());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
ItemOverlay::Update();
|
||||
}
|
||||
|
||||
float ItemDrop::GetZ(){
|
||||
|
@ -35,7 +35,7 @@ SUCH DAMAGE.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 3085
|
||||
#define VERSION_BUILD 3096
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -40,8 +40,8 @@ Images
|
||||
GFX_SkillOverlayIconOverlay = skill_overlay_icon_overlay.png
|
||||
GFX_FinishRing = finishring.png
|
||||
GFX_FinishRingGreen = finishring_green.png
|
||||
GFX_SkillIcon = skill_overlay_icon.png
|
||||
GFX_SkillIconEmpty = skill_overlay_icon_empty.png
|
||||
GFX_SqareSkillIcon = square_skill_overlay_icon.png
|
||||
GFX_SqareSkillIconEmpty = square_skill_overlay_icon_empty.png
|
||||
|
||||
# Ability Icons
|
||||
GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png
|
||||
|
@ -27,3 +27,10 @@ ItemDrop
|
||||
# Item drop scale
|
||||
Item Drop Scale = 0.4
|
||||
}
|
||||
ItemOverlay
|
||||
{
|
||||
# Amount of time the item overlay display remains on-screen.
|
||||
Item Overlay Time = 5.0
|
||||
# How fast the item overlay display moves into the screen (from the left edge).
|
||||
Item Overlay Speed = 200
|
||||
}
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user