Added coloring to the title ability tooltip text for more flavor. Made entire ability tooltip global state. Ready for merge. Release Build 12137.

This commit is contained in:
sigonasr2 2025-03-26 23:16:30 -05:00
parent afe958d617
commit 5664ee327c
7 changed files with 27 additions and 8 deletions

View File

@ -51,6 +51,9 @@ InputGroup Ability::DEFAULT;
float Ability::iconMouseoverTime{}; float Ability::iconMouseoverTime{};
float Ability::alphaMouseoverTime{}; float Ability::alphaMouseoverTime{};
std::string Ability::tooltipText{""};
std::string Ability::tooltipTitle{""};
Pixel Ability::tooltipTitleCol{};
Ability::Ability() Ability::Ability()
:name("???"),shortName("???"),description("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){}; :name("???"),shortName("???"),description("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){};

View File

@ -87,6 +87,9 @@ struct Ability{
const bool operator==(const Ability&a)const; const bool operator==(const Ability&a)const;
static float iconMouseoverTime; static float iconMouseoverTime;
static float alphaMouseoverTime; //Goes from 0 to 0.5 which affects the alpha of the tooltip. static float alphaMouseoverTime; //Goes from 0 to 0.5 which affects the alpha of the tooltip.
static std::string tooltipText;
static std::string tooltipTitle;
static Pixel tooltipTitleCol;
constexpr static float MAX_DESCRIPTION_HOVER_TIME{0.3f}; constexpr static float MAX_DESCRIPTION_HOVER_TIME{0.3f};
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!

View File

@ -2178,8 +2178,13 @@ void AiL::RenderCooldowns(){
Ability::iconMouseoverTime=std::min(Ability::iconMouseoverTime+GetElapsedTime(),1.5f); Ability::iconMouseoverTime=std::min(Ability::iconMouseoverTime+GetElapsedTime(),1.5f);
mouseHoveredOverSkill=true; mouseHoveredOverSkill=true;
if(Ability::iconMouseoverTime>=1.5f)Ability::alphaMouseoverTime=std::min(Ability::alphaMouseoverTime+GetElapsedTime(),Ability::MAX_DESCRIPTION_HOVER_TIME); if(Ability::iconMouseoverTime>=1.5f)Ability::alphaMouseoverTime=std::min(Ability::alphaMouseoverTime+GetElapsedTime(),Ability::MAX_DESCRIPTION_HOVER_TIME);
const std::string abilityTooltipText{std::format("{}\n{}",a.GetName(),a.GetDescription())};
drawutil::DrawAbilityTooltipAtMouseCursor(this,abilityTooltipText,util::lerp(0U,255U,Ability::alphaMouseoverTime/Ability::MAX_DESCRIPTION_HOVER_TIME)); Pixel abilityTitleCol{0x00FF51};
if(HasEnchantWithAbilityAffected)abilityTitleCol=Pixel{0xFFCD00};
if(a.itemAbility)abilityTitleCol=Pixel{0xA2FF00};
Ability::tooltipTitleCol=abilityTitleCol;
Ability::tooltipTitle=std::format("{}",a.GetName());
Ability::tooltipText=std::format("{}",a.GetDescription());
} }
}else heldDownAnyAbilityKey=true; }else heldDownAnyAbilityKey=true;
#pragma endregion #pragma endregion
@ -2212,6 +2217,9 @@ void AiL::RenderCooldowns(){
Ability::iconMouseoverTime=std::max(0.f,Ability::iconMouseoverTime-GetElapsedTime()); Ability::iconMouseoverTime=std::max(0.f,Ability::iconMouseoverTime-GetElapsedTime());
Ability::alphaMouseoverTime=std::max(0.f,Ability::alphaMouseoverTime-GetElapsedTime()); Ability::alphaMouseoverTime=std::max(0.f,Ability::alphaMouseoverTime-GetElapsedTime());
} }
drawutil::DrawAbilityTooltipAtMouseCursor(this);
} }
std::pair<ForegroundWrapper,BackgroundWrapper>AiL::AddEffect(std::unique_ptr<Effect>foreground,std::unique_ptr<Effect> background){ std::pair<ForegroundWrapper,BackgroundWrapper>AiL::AddEffect(std::unique_ptr<Effect>foreground,std::unique_ptr<Effect> background){
@ -3930,7 +3938,7 @@ void AiL::SetLoadoutItem(int slot,std::string itemName){
inputGroup=&Player::KEY_ITEM3; inputGroup=&Player::KEY_ITEM3;
}break; }break;
} }
Ability itemAbility{itemName,"","","Item.Item Cooldown Time"_F,0,inputGroup,"items/"+itemName+".png",VERY_DARK_RED,DARK_RED,PrecastData{GetLoadoutItem(slot).lock()->CastTime(),GetLoadoutItem(slot).lock()->CastRange(),GetLoadoutItem(slot).lock()->CastSize()},true}; Ability itemAbility{itemName,"",GetLoadoutItem(slot).lock()->Description(),"Item.Item Cooldown Time"_F,0,inputGroup,"items/"+itemName+".png",VERY_DARK_RED,DARK_RED,PrecastData{GetLoadoutItem(slot).lock()->CastTime(),GetLoadoutItem(slot).lock()->CastRange(),GetLoadoutItem(slot).lock()->CastSize()},true};
itemAbility.actionPerformedDuringCast=GetLoadoutItem(slot).lock()->UseDuringCast(); itemAbility.actionPerformedDuringCast=GetLoadoutItem(slot).lock()->UseDuringCast();
itemAbility.itemAbility=true; itemAbility.itemAbility=true;

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 12130 #define VERSION_BUILD 12137
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

View File

@ -207,17 +207,22 @@ void drawutil::DrawCrosshairDecalViewPort(olc::ViewPort&window,geom2d::rect<floa
window.FillRectDecal(pos,size,RED); window.FillRectDecal(pos,size,RED);
} }
void drawutil::DrawAbilityTooltipAtMouseCursor(AiL*game,const std::string_view tooltipText,const uint8_t alpha){ void drawutil::DrawAbilityTooltipAtMouseCursor(AiL*game){
constexpr int ABILITY_TOOLTIP_WIDTH{200}; constexpr int ABILITY_TOOLTIP_WIDTH{200};
const uint8_t alpha{util::lerp(uint8_t(0),uint8_t(255),Ability::alphaMouseoverTime/Ability::MAX_DESCRIPTION_HOVER_TIME)};
const float alphaMult{alpha/255.f}; const float alphaMult{alpha/255.f};
const Pixel topColor{0,0,0,uint8_t(192*alphaMult)}; const Pixel topColor{0,0,0,uint8_t(192*alphaMult)};
const Pixel bottomColor{0,0,0,uint8_t(164*alphaMult)}; const Pixel bottomColor{0,0,0,uint8_t(164*alphaMult)};
const vf2d abilityTooltipSize{game->GetWrappedTextSizeProp(tooltipText,ABILITY_TOOLTIP_WIDTH)+vi2d{6,6}}; //Add 3 pixel padding to the edges of the tooltip. const vf2d abilityTooltipSize{game->GetWrappedTextSizeProp(std::format("{}\n\n{}",Ability::tooltipTitle,Ability::tooltipText),ABILITY_TOOLTIP_WIDTH)+vi2d{6,6}}; //Add 3 pixel padding to the edges of the tooltip.
const vf2d abilityTitleSize{game->GetWrappedTextSizeProp(std::format("{}\n",Ability::tooltipTitle),ABILITY_TOOLTIP_WIDTH)}; //Just the title, because we need to position the description below it.
geom2d::rect<float>tooltipRect{game->GetMousePos()-vf2d{abilityTooltipSize.x/2,abilityTooltipSize.y},abilityTooltipSize}; //We will attempt to center it horizontally and bottom-align it to the cursor. geom2d::rect<float>tooltipRect{game->GetMousePos()-vf2d{abilityTooltipSize.x/2,abilityTooltipSize.y},abilityTooltipSize}; //We will attempt to center it horizontally and bottom-align it to the cursor.
tooltipRect.pos.x=std::clamp(tooltipRect.pos.x,1.f,WINDOW_SIZE.x-tooltipRect.size.x-1); //It's possible the tooltip goes off-screen along the x-axis, clamp it to edges by a 1-pixel border. tooltipRect.pos.x=std::clamp(tooltipRect.pos.x,1.f,WINDOW_SIZE.x-tooltipRect.size.x-1); //It's possible the tooltip goes off-screen along the x-axis, clamp it to edges by a 1-pixel border.
game->GradientFillRectDecal(tooltipRect.pos,tooltipRect.size,topColor,bottomColor,bottomColor,topColor); game->GradientFillRectDecal(tooltipRect.pos,tooltipRect.size,topColor,bottomColor,bottomColor,topColor);
game->DrawShadowStringPropDecal(tooltipRect.pos+vf2d{2.f,2.f},tooltipText,{255,255,255,uint8_t(255*alphaMult)},{32,32,32,uint8_t(255*alphaMult)},{1.f,1.f},{1.f,1.f},tooltipRect.size.x-4.f); Pixel tooltipTitleCol{Ability::tooltipTitleCol};
tooltipTitleCol.a=alpha;
game->DrawShadowStringPropDecal(tooltipRect.pos+vf2d{2.f,2.f},Ability::tooltipTitle,tooltipTitleCol,{32,32,32,uint8_t(255*alphaMult)},{1.f,1.f},{1.f,1.f},tooltipRect.size.x-4.f);
game->DrawShadowStringPropDecal(tooltipRect.pos+vf2d{2.f,2.f+abilityTitleSize.y},Ability::tooltipText,{255,255,255,uint8_t(255*alphaMult)},{32,32,32,uint8_t(255*alphaMult)},{1.f,1.f},{1.f,1.f},tooltipRect.size.x-4.f);
game->DrawRectDecal(tooltipRect.pos+vf2d{1.f,1.f},tooltipRect.size-vf2d{2.f,2.f},{220,220,220,uint8_t(255*alphaMult)}); game->DrawRectDecal(tooltipRect.pos+vf2d{1.f,1.f},tooltipRect.size-vf2d{2.f,2.f},{220,220,220,uint8_t(255*alphaMult)});
} }

View File

@ -48,5 +48,5 @@ namespace drawutil{
void DrawCrosshairDecal(AiL*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4); void DrawCrosshairDecal(AiL*game,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawCrosshairDecalTransformedView(TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4); void DrawCrosshairDecalTransformedView(TransformedView&view,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawCrosshairDecalViewPort(ViewPort&window,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4); void DrawCrosshairDecalViewPort(ViewPort&window,geom2d::rect<float>rect,float accTime,float pulsatingAmt=2,float borderThickness=4);
void DrawAbilityTooltipAtMouseCursor(AiL*game,const std::string_view tooltipText,const uint8_t alpha); void DrawAbilityTooltipAtMouseCursor(AiL*game);
} }