From f8c1dbb1665af6a4bdfb5b0fbe4bc25c445264f6 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 25 Mar 2025 13:28:37 -0700 Subject: [PATCH] Begin implementations of ability mouseover tooltips. --- Adventures in Lestoria/Ability.h | 1 + .../AdventuresInLestoria.cpp | 38 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Adventures in Lestoria/Ability.h b/Adventures in Lestoria/Ability.h index 92757f67..b967fab5 100644 --- a/Adventures in Lestoria/Ability.h +++ b/Adventures in Lestoria/Ability.h @@ -84,6 +84,7 @@ struct Ability{ static InputGroup DEFAULT; const float GetCooldownTime()const; const bool operator==(const Ability&a)const; + float iconMouseoverTime{}; Ability(); //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); diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 3344da2d..082f402f 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2073,6 +2073,7 @@ void AiL::RenderCooldowns(){ bool circle=loadoutSlot==-1; if(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}; InputType controlType=KEY; @@ -2083,17 +2084,17 @@ void AiL::RenderCooldowns(){ } InputGroup*input{a.input}; 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){ vf2d iconScale={1,1}; 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(a.charges==0)DrawPie(pos+vf2d{12,12},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); + 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",iconPos,11.5f,360-(a.cooldown/a.GetCooldownTime())*360,WHITE); }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; cooldownTimeDisplay<Held()){ if(circle){ - DrawPie(pos+vf2d{12,12},12,0,{255,255,255,64}); + DrawPie(iconPos,12,0,{255,255,255,64}); }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){ std::string amtString="x"+std::to_string(itemAmt); 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{ DrawDecal(pos,GFX["square_skill_overlay_icon_empty.png"].Decal(),{1,1},DARK_RED); shortNameCol=RED; @@ -2152,7 +2153,7 @@ void AiL::RenderCooldowns(){ if(a.manaCost>0){ 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}; @@ -2163,9 +2164,22 @@ void AiL::RenderCooldowns(){ if(a.charges>1){ const std::string chargeCountDisplayStr{std::format("x{}",a.charges)}; 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{iconPos,16},GetMousePos()))UpdateSkillTooltip(a); + else if(geom2d::overlaps(geom2d::rect{pos-vf2d{2,2},vf2d{16,16}},GetMousePos()))UpdateSkillTooltip(a); + else a.iconMouseoverTime=0.f; + #pragma endregion } };