diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 5cbbb935f..612fa68fd 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -55,6 +55,7 @@ bool IsRace(const CServerInfo *pInfo); bool IsDDRace(const CServerInfo *pInfo); bool IsDDNet(const CServerInfo *pInfo); bool Is64Player(const CServerInfo *pInfo); +bool IsPlus(const CServerInfo *pInfo); class IServerBrowser : public IInterface { diff --git a/src/engine/shared/serverbrowser.cpp b/src/engine/shared/serverbrowser.cpp index 3dbcac6d1..45bc4418d 100644 --- a/src/engine/shared/serverbrowser.cpp +++ b/src/engine/shared/serverbrowser.cpp @@ -25,3 +25,8 @@ bool Is64Player(const CServerInfo *pInfo) || str_find(pInfo->m_aName, "64") || IsDDNet(pInfo); } + +bool IsPlus(const CServerInfo *pInfo) +{ + return str_find(pInfo->m_aGameType, "+"); +} diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 884a2dcd1..50eadd9d0 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -1,13 +1,16 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include +#include #include #include #include #include // get_angle +#include #include #include +#include "chat.h" #include "emoticon.h" CEmoticon::CEmoticon() @@ -38,6 +41,7 @@ void CEmoticon::OnReset() m_WasActive = false; m_Active = false; m_SelectedEmote = -1; + m_SelectedEyeEmote = -1; } void CEmoticon::OnRelease() @@ -45,10 +49,6 @@ void CEmoticon::OnRelease() m_Active = false; } -void CEmoticon::OnMessage(int MsgType, void *pRawMsg) -{ -} - bool CEmoticon::OnMouseMove(float x, float y) { if(!m_Active) @@ -75,6 +75,8 @@ void CEmoticon::OnRender() { if(m_WasActive && m_SelectedEmote != -1) Emote(m_SelectedEmote); + if(m_WasActive && m_SelectedEyeEmote != -1) + EyeEmote(m_SelectedEyeEmote); m_WasActive = false; return; } @@ -95,10 +97,13 @@ void CEmoticon::OnRender() if (SelectedAngle < 0) SelectedAngle += 2*pi; + m_SelectedEmote = -1; + m_SelectedEyeEmote = -1; if (length(m_SelectorMouse) > 110.0f) m_SelectedEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTICONS); - else - m_SelectedEmote = -1; + else if(length(m_SelectorMouse) > 40.0f) + m_SelectedEyeEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTES); + CUIRect Screen = *UI()->Screen(); @@ -134,6 +139,48 @@ void CEmoticon::OnRender() Graphics()->QuadsEnd(); + CServerInfo pServerInfo; + Client()->GetServerInfo(&pServerInfo); + if((IsDDRace(&pServerInfo) || IsDDNet(&pServerInfo) || IsPlus(&pServerInfo)) && g_Config.m_ClEyeWheel) + { + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1.0,1.0,1.0,0.3f); + DrawCircle(Screen.w/2, Screen.h/2, 100.0f, 64); + Graphics()->QuadsEnd(); + + CTeeRenderInfo *pTeeInfo; + if(g_Config.m_ClDummy) + pTeeInfo = &m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[1]].m_RenderInfo; + else + pTeeInfo = &m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[0]].m_RenderInfo; + + Graphics()->TextureSet(pTeeInfo->m_Texture); + + for (int i = 0; i < NUM_EMOTES; i++) + { + float Angle = 2*pi*i/NUM_EMOTES; + if (Angle > pi) + Angle -= 2*pi; + + bool Selected = m_SelectedEyeEmote == i; + + pTeeInfo->m_Size = Selected ? 64.0f : 48.0f; + + float NudgeX = 70.0f * cosf(Angle); + float NudgeY = 70.0f * sinf(Angle); + RenderTools()->RenderTee(CAnimState::GetIdle(), pTeeInfo, i, vec2(-1,0), vec2(Screen.w/2 + NudgeX, Screen.h/2 + NudgeY)); + } + + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0,0,0,0.3f); + DrawCircle(Screen.w/2, Screen.h/2, 30.0f, 64); + Graphics()->QuadsEnd(); + } + else + m_SelectedEyeEmote = -1; + Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id); Graphics()->QuadsBegin(); Graphics()->SetColor(1,1,1,1); @@ -155,3 +202,30 @@ void CEmoticon::Emote(int Emoticon) Client()->SendMsgExY(&Msg, MSGFLAG_VITAL, false, !g_Config.m_ClDummy); } } + +void CEmoticon::EyeEmote(int Emote) +{ + char aBuf[32]; + switch(Emote) + { + case EMOTE_NORMAL: + str_format(aBuf, sizeof(aBuf), "/emote normal %d", g_Config.m_ClEyeDuration); + break; + case EMOTE_PAIN: + str_format(aBuf, sizeof(aBuf), "/emote pain %d", g_Config.m_ClEyeDuration); + break; + case EMOTE_HAPPY: + str_format(aBuf, sizeof(aBuf), "/emote happy %d", g_Config.m_ClEyeDuration); + break; + case EMOTE_SURPRISE: + str_format(aBuf, sizeof(aBuf), "/emote surprise %d", g_Config.m_ClEyeDuration); + break; + case EMOTE_ANGRY: + str_format(aBuf, sizeof(aBuf), "/emote angry %d", g_Config.m_ClEyeDuration); + break; + case EMOTE_BLINK: + str_format(aBuf, sizeof(aBuf), "/emote blink %d", g_Config.m_ClEyeDuration); + break; + } + GameClient()->m_pChat->Say(0, aBuf); +} diff --git a/src/game/client/components/emoticon.h b/src/game/client/components/emoticon.h index 37bc8372e..4d5645091 100644 --- a/src/game/client/components/emoticon.h +++ b/src/game/client/components/emoticon.h @@ -14,6 +14,7 @@ class CEmoticon : public CComponent vec2 m_SelectorMouse; int m_SelectedEmote; + int m_SelectedEyeEmote; static void ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData); static void ConEmote(IConsole::IResult *pResult, void *pUserData); @@ -25,10 +26,10 @@ public: virtual void OnConsoleInit(); virtual void OnRender(); virtual void OnRelease(); - virtual void OnMessage(int MsgType, void *pRawMsg); virtual bool OnMouseMove(float x, float y); - void Emote(int Emoticon); + void Emote(int Emote); + void EyeEmote(int EyeEmote); }; #endif diff --git a/src/game/variables.h b/src/game/variables.h index 7317b5984..b7904c214 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -35,6 +35,8 @@ MACRO_CONFIG_INT(ClShowChatFriends, cl_show_chat_friends, 0, 0, 1, CFGFLAG_CLIEN MACRO_CONFIG_INT(ClShowKillMessages, cl_showkillmessages, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show kill messages") MACRO_CONFIG_INT(ClShowVotesAfterVoting, cl_show_votes_after_voting, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show votes window after voting") MACRO_CONFIG_INT(ClShowfps, cl_showfps, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame FPS counter") +MACRO_CONFIG_INT(ClEyeWheel, cl_eye_wheel, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show eye wheel along together with emotes") +MACRO_CONFIG_INT(ClEyeDuration, cl_eye_duration, 999999, 1, 999999, CFGFLAG_CLIENT|CFGFLAG_SAVE, "How long the eyes emotes last") MACRO_CONFIG_INT(ClAirjumpindicator, cl_airjumpindicator, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") MACRO_CONFIG_INT(ClThreadsoundloading, cl_threadsoundloading, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Load sound files threaded")