From 3552e1a042e2c4161573e413dc231bd3b8b25c7f Mon Sep 17 00:00:00 2001 From: Chairn Date: Sun, 30 Aug 2015 21:42:16 +0200 Subject: [PATCH] Added eye wheel. Render only on ddrace/race/ictf+/dm+/gctf+ server. --- src/engine/serverbrowser.h | 1 + src/engine/shared/serverbrowser.cpp | 5 ++ src/game/client/components/emoticon.cpp | 91 ++++++++++++++++++++++--- src/game/client/components/emoticon.h | 5 +- src/game/variables.h | 1 + 5 files changed, 91 insertions(+), 12 deletions(-) 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..85de1aec3 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, "+"); +} \ No newline at end of file diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 884a2dcd1..38a5e8628 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() @@ -24,7 +27,7 @@ void CEmoticon::ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData) void CEmoticon::ConEmote(IConsole::IResult *pResult, void *pUserData) { - ((CEmoticon *)pUserData)->Emote(pResult->GetInteger(0)); + ((CEmoticon *)pUserData)->Emoticon(pResult->GetInteger(0)); } void CEmoticon::OnConsoleInit() @@ -37,6 +40,8 @@ void CEmoticon::OnReset() { m_WasActive = false; m_Active = false; + //m_DrawEmotes = false; + m_SelectedEmoticon = -1; m_SelectedEmote = -1; } @@ -45,10 +50,6 @@ void CEmoticon::OnRelease() m_Active = false; } -void CEmoticon::OnMessage(int MsgType, void *pRawMsg) -{ -} - bool CEmoticon::OnMouseMove(float x, float y) { if(!m_Active) @@ -73,6 +74,8 @@ void CEmoticon::OnRender() { if(!m_Active) { + if(m_WasActive && m_SelectedEmoticon != -1) + Emoticon(m_SelectedEmoticon); if(m_WasActive && m_SelectedEmote != -1) Emote(m_SelectedEmote); m_WasActive = false; @@ -95,10 +98,13 @@ void CEmoticon::OnRender() if (SelectedAngle < 0) SelectedAngle += 2*pi; + m_SelectedEmoticon = -1; + m_SelectedEmote = -1; if (length(m_SelectorMouse) > 110.0f) - m_SelectedEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTICONS); - else - m_SelectedEmote = -1; + m_SelectedEmoticon = (int)(SelectedAngle / (2*pi) * NUM_EMOTICONS); + else if(length(m_SelectorMouse) > 40.0f) + m_SelectedEmote = (int)((SelectedAngle +2*pi/24) / (2*pi) * NUM_EMOTES); + CUIRect Screen = *UI()->Screen(); @@ -121,7 +127,7 @@ void CEmoticon::OnRender() if (Angle > pi) Angle -= 2*pi; - bool Selected = m_SelectedEmote == i; + bool Selected = m_SelectedEmoticon == i; float Size = Selected ? 80.0f : 50.0f; @@ -133,6 +139,46 @@ 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_SelectedEmote == 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(); + } Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id); Graphics()->QuadsBegin(); @@ -142,7 +188,7 @@ void CEmoticon::OnRender() Graphics()->QuadsEnd(); } -void CEmoticon::Emote(int Emoticon) +void CEmoticon::Emoticon(int Emoticon) { CNetMsg_Cl_Emoticon Msg; Msg.m_Emoticon = Emoticon; @@ -155,3 +201,28 @@ void CEmoticon::Emote(int Emoticon) Client()->SendMsgExY(&Msg, MSGFLAG_VITAL, false, !g_Config.m_ClDummy); } } + +void CEmoticon::Emote(int Emote) +{ + switch(Emote) + { + case EMOTE_NORMAL: + GameClient()->m_pChat->Say(0, "/emote normal"); + return; + case EMOTE_PAIN: + GameClient()->m_pChat->Say(0, "/emote pain"); + return; + case EMOTE_HAPPY: + GameClient()->m_pChat->Say(0, "/emote happy"); + return; + case EMOTE_SURPRISE: + GameClient()->m_pChat->Say(0, "/emote surprise"); + return; + case EMOTE_ANGRY: + GameClient()->m_pChat->Say(0, "/emote angry"); + return; + case EMOTE_BLINK: + GameClient()->m_pChat->Say(0, "/emote blink"); + return; + } +} diff --git a/src/game/client/components/emoticon.h b/src/game/client/components/emoticon.h index 37bc8372e..2030a7033 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_SelectedEmoticon; 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 Emoticon(int Emoticon); + void Emote(int Emote); }; #endif diff --git a/src/game/variables.h b/src/game/variables.h index 91ad9f46f..9d0feb4af 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -34,6 +34,7 @@ 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 with emotes") 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")