Mana costs and ability short names are now displayed on the HUD.
This commit is contained in:
+51
-36
@@ -993,42 +993,7 @@ Player*Crawler::GetPlayer(){
|
||||
}
|
||||
|
||||
void Crawler::RenderHud(){
|
||||
const std::function<std::string(std::string)>capitalize=[](std::string name)->std::string{
|
||||
std::string newName="";
|
||||
for(int i=0;i<name.length();i++){
|
||||
newName.append(1,name[i]>='a'?name[i]-32:name[i]);
|
||||
newName.append(1,' ');
|
||||
}
|
||||
return newName;
|
||||
};
|
||||
std::vector<Ability>cooldowns{
|
||||
player->GetAbility1(),
|
||||
player->GetAbility2(),
|
||||
player->GetAbility3(),
|
||||
player->GetAbility4(),
|
||||
};
|
||||
|
||||
const auto DrawCooldown=[&](vf2d pos,Ability&a){
|
||||
if(a.name!="???"){
|
||||
if(a.cooldown>0.1){
|
||||
DrawPie(pos+vf2d{12,12},12,360-(a.cooldown/a.COOLDOWN_TIME)*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.COOLDOWN_TIME)));
|
||||
std::stringstream cooldownTimeDisplay;
|
||||
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
|
||||
DrawShadowStringPropDecal(pos+vf2d{12,12}-vf2d{float(GetTextSizeProp(cooldownTimeDisplay.str()).x*0.5),float(GetTextSizeProp(cooldownTimeDisplay.str()).y*1)}/2,cooldownTimeDisplay.str(),WHITE,BLACK,{0.5,1});
|
||||
}
|
||||
DrawDecal(pos,GFX["skill_overlay_icon.png"].Decal());
|
||||
}
|
||||
};
|
||||
|
||||
vf2d iconPos={8.f,float(ScreenHeight()-32)};
|
||||
for(Ability&a:cooldowns){
|
||||
if(a.name!="???"){
|
||||
DrawCooldown(iconPos,a);
|
||||
iconPos+={32,0};
|
||||
}
|
||||
}
|
||||
|
||||
DrawCooldown({float(ScreenWidth()-32),float(ScreenHeight()-32)},player->GetRightClickAbility());
|
||||
RenderCooldowns();
|
||||
|
||||
if(GetPlayer()->GetCastInfo().castTimer>0){
|
||||
FillRectDecal(vf2d{ScreenWidth()/2-92.f,ScreenHeight()-90.f},{184,20},BLACK);
|
||||
@@ -1065,6 +1030,56 @@ void Crawler::RenderHud(){
|
||||
}
|
||||
}
|
||||
|
||||
void Crawler::RenderCooldowns(){
|
||||
std::vector<Ability>cooldowns{
|
||||
player->GetAbility1(),
|
||||
player->GetAbility2(),
|
||||
player->GetAbility3(),
|
||||
player->GetAbility4(),
|
||||
};
|
||||
|
||||
const auto DrawCooldown=[&](vf2d pos,Ability&a){
|
||||
if(a.name!="???"){
|
||||
if(a.cooldown>0.1){
|
||||
DrawPie(pos+vf2d{12,12},12,360-(a.cooldown/a.COOLDOWN_TIME)*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.COOLDOWN_TIME)));
|
||||
std::stringstream cooldownTimeDisplay;
|
||||
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
|
||||
DrawShadowStringPropDecal(pos+vf2d{12,12}-vf2d{float(GetTextSizeProp(cooldownTimeDisplay.str()).x*0.5),float(GetTextSizeProp(cooldownTimeDisplay.str()).y*1)}/2,cooldownTimeDisplay.str(),WHITE,BLACK,{0.5,1});
|
||||
}
|
||||
DrawDecal(pos,GFX["skill_overlay_icon.png"].Decal());
|
||||
|
||||
Pixel shortNameCol=BLUE,manaCostShadowCol=DARK_BLUE;
|
||||
if(player->GetMana()<a.manaCost){
|
||||
DrawDecal(pos,GFX["skill_overlay_icon_overlay.png"].Decal(),{1,1},DARK_RED);
|
||||
shortNameCol=RED;
|
||||
manaCostShadowCol=DARK_RED;
|
||||
}else
|
||||
if(a.cooldown>0){
|
||||
shortNameCol=GREY;
|
||||
manaCostShadowCol=DARK_GREY;
|
||||
}
|
||||
|
||||
if(a.manaCost>0){
|
||||
vf2d manaCostSize=vf2d{GetTextSize(std::to_string(a.manaCost))}*vf2d{0.5,0.75};
|
||||
DrawShadowStringDecal(pos+vf2d{20,4}-manaCostSize/2,std::to_string(a.manaCost),{192,192,255},manaCostShadowCol,{0.5,0.75});
|
||||
}
|
||||
|
||||
vf2d shortNameSize=vf2d{GetTextSize(a.shortName)}*vf2d{0.5,0.75};
|
||||
DrawShadowStringDecal(pos+vf2d{13,24}-shortNameSize/2,a.shortName,shortNameCol,{255,255,255,64},{0.5,0.75});
|
||||
}
|
||||
};
|
||||
|
||||
vf2d iconPos={8.f,float(ScreenHeight()-32)};
|
||||
for(Ability&a:cooldowns){
|
||||
if(a.name!="???"){
|
||||
DrawCooldown(iconPos,a);
|
||||
iconPos+={32,0};
|
||||
}
|
||||
}
|
||||
|
||||
DrawCooldown({float(ScreenWidth()-32),float(ScreenHeight()-32)},player->GetRightClickAbility());
|
||||
}
|
||||
|
||||
void Crawler::AddEffect(std::unique_ptr<Effect>foreground,std::unique_ptr<Effect> background){
|
||||
AddEffect(std::move(background),true);
|
||||
AddEffect(std::move(foreground));
|
||||
|
||||
Reference in New Issue
Block a user