Merge pull request #8765 from Robyt3/Client-Menus7-Interactive-Tee-Fixes

Improve interactive tee in 0.7 tee settings
This commit is contained in:
Dennis Felsing 2024-08-18 10:33:27 +00:00 committed by GitHub
commit 8dd2b6e9e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,7 +68,6 @@ void CMenus::RenderSettingsTee7(CUIRect MainView)
const float ButtonHeight = 20.0f; const float ButtonHeight = 20.0f;
const float SkinHeight = 50.0f; const float SkinHeight = 50.0f;
const float BackgroundHeight = (ButtonHeight + SpacingH) + SkinHeight * 2; const float BackgroundHeight = (ButtonHeight + SpacingH) + SkinHeight * 2;
const vec2 MousePosition = vec2(Ui()->MouseX(), Ui()->MouseY());
MainView.HSplitTop(20.0f, 0, &MainView); MainView.HSplitTop(20.0f, 0, &MainView);
MainView.HSplitTop(BackgroundHeight, &TopView, &MainView); MainView.HSplitTop(BackgroundHeight, &TopView, &MainView);
@ -136,14 +135,18 @@ void CMenus::RenderSettingsTee7(CUIRect MainView)
{ {
// interactive tee: tee looking towards cursor, and it is happy when you touch it // interactive tee: tee looking towards cursor, and it is happy when you touch it
vec2 TeePosition = vec2(Top.x + Top.w / 2.0f, Top.y + Top.h / 2.0f + 6.0f); const vec2 TeePosition = vec2(Top.x + Top.w / 2.0f, Top.y + Top.h / 2.0f + 6.0f);
vec2 DeltaPosition = MousePosition - TeePosition; const vec2 DeltaPosition = Ui()->MousePos() - TeePosition;
float Distance = length(DeltaPosition); const float Distance = length(DeltaPosition);
vec2 TeeDirection = Distance < 20.0f ? normalize(vec2(DeltaPosition.x, maximum(DeltaPosition.y, 0.5f))) : normalize(DeltaPosition); const float InteractionDistance = 20.0f;
int TeeEmote = Distance < 20.0f ? EMOTE_HAPPY : EMOTE_NORMAL; const vec2 TeeDirection = Distance < InteractionDistance ? normalize(vec2(DeltaPosition.x, maximum(DeltaPosition.y, 0.5f))) : normalize(DeltaPosition);
const int TeeEmote = Distance < InteractionDistance ? EMOTE_HAPPY : EMOTE_NORMAL;
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, TeeEmote, TeeDirection, TeePosition); RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, TeeEmote, TeeDirection, TeePosition);
if(Distance < 20.0f && Ui()->MouseButtonClicked(0)) static char s_InteractiveTeeButtonId;
m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_PLAYER_SPAWN, 0); if(Distance < InteractionDistance && Ui()->DoButtonLogic(&s_InteractiveTeeButtonId, 0, &Top))
{
m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_PLAYER_SPAWN, 1.0f);
}
} }
// handle right (team skins) // handle right (team skins)