mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Minor refactoring of emoticon selector rendering
- Extract variable `ScreenCenter`. - Rename variables `i` to `Emote`. - Move variable declarations closer to their usages.
This commit is contained in:
parent
3bda76ff1f
commit
ed9720f1be
|
@ -137,6 +137,8 @@ void CEmoticon::OnRender()
|
|||
else if(length(m_SelectorMouse) > 40.0f)
|
||||
m_SelectedEyeEmote = (int)(SelectedAngle / (2 * pi) * NUM_EMOTES);
|
||||
|
||||
const vec2 ScreenCenter = Screen.Center();
|
||||
|
||||
Ui()->MapScreen();
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
|
@ -144,26 +146,22 @@ void CEmoticon::OnRender()
|
|||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0, 0, 0, 0.3f);
|
||||
Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64);
|
||||
Graphics()->DrawCircle(ScreenCenter.x, ScreenCenter.y, 190.0f, 64);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
Graphics()->WrapClamp();
|
||||
for(int i = 0; i < NUM_EMOTICONS; i++)
|
||||
for(int Emote = 0; Emote < NUM_EMOTICONS; Emote++)
|
||||
{
|
||||
float Angle = 2 * pi * i / NUM_EMOTICONS;
|
||||
float Angle = 2 * pi * Emote / NUM_EMOTICONS;
|
||||
if(Angle > pi)
|
||||
Angle -= 2 * pi;
|
||||
|
||||
bool Selected = m_SelectedEmote == i;
|
||||
|
||||
float Size = Selected ? 80.0f : 50.0f;
|
||||
|
||||
Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[i]);
|
||||
Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[Emote]);
|
||||
Graphics()->QuadsSetSubset(0, 0, 1, 1);
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
const vec2 Nudge = direction(Angle) * 150.0f;
|
||||
IGraphics::CQuadItem QuadItem(Screen.w / 2 + Nudge.x, Screen.h / 2 + Nudge.y, Size, Size);
|
||||
const float Size = m_SelectedEmote == Emote ? 80.0f : 50.0f;
|
||||
IGraphics::CQuadItem QuadItem(ScreenCenter.x + Nudge.x, ScreenCenter.y + Nudge.y, Size, Size);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
@ -174,34 +172,32 @@ void CEmoticon::OnRender()
|
|||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0, 1.0, 1.0, 0.3f);
|
||||
Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64);
|
||||
Graphics()->DrawCircle(ScreenCenter.x, ScreenCenter.y, 100.0f, 64);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[m_pClient->m_aLocalIds[g_Config.m_ClDummy]].m_RenderInfo;
|
||||
|
||||
for(int i = 0; i < NUM_EMOTES; i++)
|
||||
for(int Emote = 0; Emote < NUM_EMOTES; Emote++)
|
||||
{
|
||||
float Angle = 2 * pi * i / NUM_EMOTES;
|
||||
float Angle = 2 * pi * Emote / NUM_EMOTES;
|
||||
if(Angle > pi)
|
||||
Angle -= 2 * pi;
|
||||
|
||||
const bool Selected = m_SelectedEyeEmote == i;
|
||||
|
||||
const vec2 Nudge = direction(Angle) * 70.0f;
|
||||
TeeInfo.m_Size = Selected ? 64.0f : 48.0f;
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, i, vec2(-1, 0), vec2(Screen.w / 2 + Nudge.x, Screen.h / 2 + Nudge.y));
|
||||
TeeInfo.m_Size = m_SelectedEyeEmote == Emote ? 64.0f : 48.0f;
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, Emote, vec2(-1, 0), ScreenCenter + Nudge);
|
||||
}
|
||||
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0, 0, 0, 0.3f);
|
||||
Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 30.0f, 64);
|
||||
Graphics()->DrawCircle(ScreenCenter.x, ScreenCenter.y, 30.0f, 64);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
else
|
||||
m_SelectedEyeEmote = -1;
|
||||
|
||||
RenderTools()->RenderCursor(m_SelectorMouse + vec2(Screen.w, Screen.h) / 2, 24.0f);
|
||||
RenderTools()->RenderCursor(ScreenCenter + m_SelectorMouse, 24.0f);
|
||||
}
|
||||
|
||||
void CEmoticon::Emote(int Emoticon)
|
||||
|
|
Loading…
Reference in a new issue