Make tooltips more user-friendly and responsive to being in combat. Release Build 12130.
This commit is contained in:
parent
41c3731e91
commit
afe958d617
@ -49,6 +49,9 @@ PrecastData::PrecastData(float castTime,float range,float size)
|
|||||||
|
|
||||||
InputGroup Ability::DEFAULT;
|
InputGroup Ability::DEFAULT;
|
||||||
|
|
||||||
|
float Ability::iconMouseoverTime{};
|
||||||
|
float Ability::alphaMouseoverTime{};
|
||||||
|
|
||||||
Ability::Ability()
|
Ability::Ability()
|
||||||
:name("???"),shortName("???"),description("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){};
|
:name("???"),shortName("???"),description("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){};
|
||||||
Ability::Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast)
|
Ability::Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast)
|
||||||
|
|||||||
@ -85,8 +85,9 @@ 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{};
|
static float iconMouseoverTime;
|
||||||
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.
|
||||||
|
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!
|
||||||
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);
|
||||||
|
|||||||
@ -534,7 +534,7 @@ void AiL::HandleUserInput(float fElapsedTime){
|
|||||||
if(GetKey(SCROLL).bPressed)displayHud=!displayHud;
|
if(GetKey(SCROLL).bPressed)displayHud=!displayHud;
|
||||||
|
|
||||||
bool setIdleAnimation=true;
|
bool setIdleAnimation=true;
|
||||||
bool heldDownMovementKey=false; //Is true when a movement key has been held down.
|
bool heldDownMovementKey=false;
|
||||||
|
|
||||||
if(KEY_MENU.Released()){
|
if(KEY_MENU.Released()){
|
||||||
if(GameState::GetCurrentState()==States::GAME_HUB)Menu::OpenMenu(MenuType::HUB_PAUSE);
|
if(GameState::GetCurrentState()==States::GAME_HUB)Menu::OpenMenu(MenuType::HUB_PAUSE);
|
||||||
@ -2069,6 +2069,9 @@ void AiL::RenderCooldowns(){
|
|||||||
player->GetAbility4(),
|
player->GetAbility4(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool mouseHoveredOverSkill{false};
|
||||||
|
bool heldDownAnyAbilityKey=false;
|
||||||
|
|
||||||
const auto DrawCooldown=[&](vf2d pos,Ability&a,int loadoutSlot=-1/*Set to 0-2 to get an item slot rendered instead*/){
|
const auto DrawCooldown=[&](vf2d pos,Ability&a,int loadoutSlot=-1/*Set to 0-2 to get an item slot rendered instead*/){
|
||||||
bool circle=loadoutSlot==-1;
|
bool circle=loadoutSlot==-1;
|
||||||
if(a.name!="???"){
|
if(a.name!="???"){
|
||||||
@ -2169,16 +2172,16 @@ void AiL::RenderCooldowns(){
|
|||||||
DrawShadowStringDecal(iconPos+vf2d{1,12}-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
|
#pragma region Mouseover Detection
|
||||||
if(circle&&geom2d::overlaps(geom2d::circle<float>{iconPos,16},GetMousePos())||
|
if(!KEY_ATTACK.Held()&&!a.input->Held()){ //Attacking indicates we are busy in combat.
|
||||||
!circle&&geom2d::overlaps(geom2d::rect<float>{pos-vf2d{2,2},vf2d{16,16}},GetMousePos())){
|
if(circle&&geom2d::overlaps(geom2d::circle<float>{iconPos,12},GetMousePos())||
|
||||||
a.iconMouseoverTime+=GetElapsedTime();
|
!circle&&geom2d::overlaps(geom2d::rect<float>{pos,vf2d{24,24}},GetMousePos())){
|
||||||
a.alphaMouseoverTime=std::min(a.alphaMouseoverTime+GetElapsedTime(),0.5f);
|
Ability::iconMouseoverTime=std::min(Ability::iconMouseoverTime+GetElapsedTime(),1.5f);
|
||||||
}else{
|
mouseHoveredOverSkill=true;
|
||||||
a.iconMouseoverTime=0.f;
|
if(Ability::iconMouseoverTime>=1.5f)Ability::alphaMouseoverTime=std::min(Ability::alphaMouseoverTime+GetElapsedTime(),Ability::MAX_DESCRIPTION_HOVER_TIME);
|
||||||
a.alphaMouseoverTime=std::max(0.f,a.alphaMouseoverTime-GetElapsedTime());
|
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));
|
||||||
const std::string abilityTooltipText{std::format("{}\n{}",a.GetName(),a.GetDescription())};
|
}
|
||||||
drawutil::DrawAbilityTooltipAtMouseCursor(this,abilityTooltipText,util::lerp(0U,255U,a.alphaMouseoverTime/0.5f));
|
}else heldDownAnyAbilityKey=true;
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2201,6 +2204,14 @@ void AiL::RenderCooldowns(){
|
|||||||
if(loadoutSlot==2){a=&GetPlayer()->useItem3;}
|
if(loadoutSlot==2){a=&GetPlayer()->useItem3;}
|
||||||
DrawCooldown({float(ScreenWidth()/2+i*26-12),float(ScreenHeight()-26)},*a,loadoutSlot);
|
DrawCooldown({float(ScreenWidth()/2+i*26-12),float(ScreenHeight()-26)},*a,loadoutSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(heldDownAnyAbilityKey){
|
||||||
|
Ability::iconMouseoverTime=0.f;
|
||||||
|
Ability::alphaMouseoverTime=0.f;
|
||||||
|
}else if(!mouseHoveredOverSkill){
|
||||||
|
Ability::iconMouseoverTime=std::max(0.f,Ability::iconMouseoverTime-GetElapsedTime());
|
||||||
|
Ability::alphaMouseoverTime=std::max(0.f,Ability::alphaMouseoverTime-GetElapsedTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
|
|||||||
@ -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 12122
|
#define VERSION_BUILD 12130
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user