Begin implementations of ability mouseover tooltips.
This commit is contained in:
parent
4a4ffb1c6c
commit
f8c1dbb166
@ -84,6 +84,7 @@ struct Ability{
|
|||||||
static InputGroup DEFAULT;
|
static InputGroup DEFAULT;
|
||||||
const float GetCooldownTime()const;
|
const float GetCooldownTime()const;
|
||||||
const bool operator==(const Ability&a)const;
|
const bool operator==(const Ability&a)const;
|
||||||
|
float iconMouseoverTime{};
|
||||||
Ability();
|
Ability();
|
||||||
//NOTE: icon expects the actual name relative to the "Ability Icons" directory for this constructor!
|
//NOTE: icon expects the actual name relative to the "Ability Icons" directory for this constructor!
|
||||||
Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false);
|
Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false);
|
||||||
|
@ -2073,6 +2073,7 @@ void AiL::RenderCooldowns(){
|
|||||||
bool circle=loadoutSlot==-1;
|
bool circle=loadoutSlot==-1;
|
||||||
if(a.name!="???"){
|
if(a.name!="???"){
|
||||||
const bool HasEnchantWithAbilityAffected{player->HasEnchantWithAbilityAffected(a.name)};
|
const bool HasEnchantWithAbilityAffected{player->HasEnchantWithAbilityAffected(a.name)};
|
||||||
|
const vf2d iconPos{pos+vf2d{12,12}};
|
||||||
|
|
||||||
vf2d keyDisplaySize=vf2d{GetTextSize(a.input->GetDisplayName())}*vf2d{0.5f,0.5f};
|
vf2d keyDisplaySize=vf2d{GetTextSize(a.input->GetDisplayName())}*vf2d{0.5f,0.5f};
|
||||||
InputType controlType=KEY;
|
InputType controlType=KEY;
|
||||||
@ -2083,17 +2084,17 @@ void AiL::RenderCooldowns(){
|
|||||||
}
|
}
|
||||||
InputGroup*input{a.input};
|
InputGroup*input{a.input};
|
||||||
if(a==player->GetAbility4())input=&Player::KEY_ABILITY4;
|
if(a==player->GetAbility4())input=&Player::KEY_ABILITY4;
|
||||||
input->DrawPrimaryInput(game,pos+vf2d{14,0.f}+drawOffset,"",255,controlType,{0.75f,0.75f});
|
input->DrawPrimaryInput(game,iconPos+vf2d{2.f,-12.f}+drawOffset,"",255,controlType,{0.75f,0.75f});
|
||||||
|
|
||||||
if(a.cooldown>0.1){
|
if(a.cooldown>0.1){
|
||||||
vf2d iconScale={1,1};
|
vf2d iconScale={1,1};
|
||||||
if(loadoutSlot!=-1)iconScale={0.7f,0.7f};
|
if(loadoutSlot!=-1)iconScale={0.7f,0.7f};
|
||||||
DrawRotatedDecal(pos+vf2d{12,12},GFX[a.icon].Decal(),0,{12,12},iconScale,{255,255,255,uint8_t(a.charges==0?64:255)});
|
DrawRotatedDecal(iconPos,GFX[a.icon].Decal(),0,{12,12},iconScale,{255,255,255,uint8_t(a.charges==0?64:255)});
|
||||||
if(circle){
|
if(circle){
|
||||||
if(a.charges==0)DrawPie(pos+vf2d{12,12},12,360-(a.cooldown/a.GetCooldownTime())*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.GetCooldownTime())));
|
if(a.charges==0)DrawPie(iconPos,12,360-(a.cooldown/a.GetCooldownTime())*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.GetCooldownTime())));
|
||||||
else DrawPieArc("safeIndicatorGradient.png",pos+vf2d{12,12},11.5f,360-(a.cooldown/a.GetCooldownTime())*360,WHITE);
|
else DrawPieArc("safeIndicatorGradient.png",iconPos,11.5f,360-(a.cooldown/a.GetCooldownTime())*360,WHITE);
|
||||||
}else{
|
}else{
|
||||||
DrawSquarePie(pos+vf2d{12,12},10,360-(a.cooldown/a.GetCooldownTime())*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.GetCooldownTime())));
|
DrawSquarePie(iconPos,10,360-(a.cooldown/a.GetCooldownTime())*360,PixelLerp(a.barColor1,a.barColor2,(a.cooldown/a.GetCooldownTime())));
|
||||||
}
|
}
|
||||||
std::stringstream cooldownTimeDisplay;
|
std::stringstream cooldownTimeDisplay;
|
||||||
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
|
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
|
||||||
@ -2101,7 +2102,7 @@ void AiL::RenderCooldowns(){
|
|||||||
}else{
|
}else{
|
||||||
vf2d iconScale={1,1};
|
vf2d iconScale={1,1};
|
||||||
if(loadoutSlot!=-1)iconScale={0.7f,0.7f};
|
if(loadoutSlot!=-1)iconScale={0.7f,0.7f};
|
||||||
DrawRotatedDecal(pos+vf2d{12,12},GFX[a.icon].Decal(),0,{12,12},iconScale,WHITE);
|
DrawRotatedDecal(iconPos,GFX[a.icon].Decal(),0,{12,12},iconScale,WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decal*overlayIcon=GFX["skill_overlay_icon.png"].Decal();
|
Decal*overlayIcon=GFX["skill_overlay_icon.png"].Decal();
|
||||||
@ -2109,9 +2110,9 @@ void AiL::RenderCooldowns(){
|
|||||||
DrawDecal(pos,overlayIcon);
|
DrawDecal(pos,overlayIcon);
|
||||||
if(a.input->Held()){
|
if(a.input->Held()){
|
||||||
if(circle){
|
if(circle){
|
||||||
DrawPie(pos+vf2d{12,12},12,0,{255,255,255,64});
|
DrawPie(iconPos,12,0,{255,255,255,64});
|
||||||
}else{
|
}else{
|
||||||
DrawSquarePie(pos+vf2d{12,12},10,0,{255,255,255,64});
|
DrawSquarePie(iconPos,10,0,{255,255,255,64});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2140,7 +2141,7 @@ void AiL::RenderCooldowns(){
|
|||||||
if(itemAmt>0){
|
if(itemAmt>0){
|
||||||
std::string amtString="x"+std::to_string(itemAmt);
|
std::string amtString="x"+std::to_string(itemAmt);
|
||||||
vf2d qtySize=vf2d{GetTextSize(amtString)}*vf2d{0.5f,0.75f};
|
vf2d qtySize=vf2d{GetTextSize(amtString)}*vf2d{0.5f,0.75f};
|
||||||
DrawShadowStringDecal(pos+vf2d{20,20}-qtySize/2,amtString,Pixel{0xE0E0E0},BLACK,{0.5f,0.75f},{0.5f,0.75f});
|
DrawShadowStringDecal(iconPos+vf2d{8,8}-qtySize/2,amtString,Pixel{0xE0E0E0},BLACK,{0.5f,0.75f},{0.5f,0.75f});
|
||||||
}else{
|
}else{
|
||||||
DrawDecal(pos,GFX["square_skill_overlay_icon_empty.png"].Decal(),{1,1},DARK_RED);
|
DrawDecal(pos,GFX["square_skill_overlay_icon_empty.png"].Decal(),{1,1},DARK_RED);
|
||||||
shortNameCol=RED;
|
shortNameCol=RED;
|
||||||
@ -2152,7 +2153,7 @@ void AiL::RenderCooldowns(){
|
|||||||
|
|
||||||
if(a.manaCost>0){
|
if(a.manaCost>0){
|
||||||
vf2d manaCostSize=vf2d{GetTextSize(std::to_string(a.manaCost))}*vf2d{0.5f,0.75f};
|
vf2d manaCostSize=vf2d{GetTextSize(std::to_string(a.manaCost))}*vf2d{0.5f,0.75f};
|
||||||
DrawShadowStringDecal(pos+vf2d{20,4}-manaCostSize/2,std::to_string(a.manaCost),{192,192,255},manaCostShadowCol,{0.5f,0.75f},{0.5f,0.75f});
|
DrawShadowStringDecal(iconPos+vf2d{8,-8}-manaCostSize/2,std::to_string(a.manaCost),{192,192,255},manaCostShadowCol,{0.5f,0.75f},{0.5f,0.75f});
|
||||||
}
|
}
|
||||||
|
|
||||||
vf2d shortNameSize=vf2d{GetTextSize(a.shortName)}*vf2d{0.5f,0.75f};
|
vf2d shortNameSize=vf2d{GetTextSize(a.shortName)}*vf2d{0.5f,0.75f};
|
||||||
@ -2163,9 +2164,22 @@ void AiL::RenderCooldowns(){
|
|||||||
if(a.charges>1){
|
if(a.charges>1){
|
||||||
const std::string chargeCountDisplayStr{std::format("x{}",a.charges)};
|
const std::string chargeCountDisplayStr{std::format("x{}",a.charges)};
|
||||||
const vf2d chargeCountStrSize{GetTextSize(chargeCountDisplayStr)};
|
const vf2d chargeCountStrSize{GetTextSize(chargeCountDisplayStr)};
|
||||||
DrawShadowStringDecal(pos+vf2d{13,24}+vf2d{shortNameSize.x-chargeCountStrSize.x*0.75f,-shortNameSize.y}-4.f,chargeCountDisplayStr,WHITE,BLACK,{0.75f,0.75f});
|
DrawShadowStringDecal(iconPos+vf2d{1,12}+vf2d{shortNameSize.x-chargeCountStrSize.x*0.75f,-shortNameSize.y}-4.f,chargeCountDisplayStr,WHITE,BLACK,{0.75f,0.75f});
|
||||||
}
|
}
|
||||||
DrawShadowStringDecal(pos+vf2d{13,24}-shortNameSize/2,a.shortName,shortNameCol,shadowCol,{0.5f,0.75f},{0.5f,0.75f});
|
DrawShadowStringDecal(iconPos+vf2d{1,12}-shortNameSize/2,a.shortName,shortNameCol,shadowCol,{0.5f,0.75f},{0.5f,0.75f});
|
||||||
|
|
||||||
|
#pragma region Mouseover Detection
|
||||||
|
const auto UpdateSkillTooltip=[&](Ability&a){
|
||||||
|
a.iconMouseoverTime+=GetElapsedTime();
|
||||||
|
if(a.iconMouseoverTime>=1.5f){
|
||||||
|
const std::string abilityTooltipText{std::format("{}\n{}",GetPlayer())};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(circle)if(geom2d::overlaps(geom2d::circle<float>{iconPos,16},GetMousePos()))UpdateSkillTooltip(a);
|
||||||
|
else if(geom2d::overlaps(geom2d::rect<float>{pos-vf2d{2,2},vf2d{16,16}},GetMousePos()))UpdateSkillTooltip(a);
|
||||||
|
else a.iconMouseoverTime=0.f;
|
||||||
|
#pragma endregion
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user