Added eye wheel. Render only on ddrace/race/ictf+/dm+/gctf+ server.

This commit is contained in:
Chairn 2015-08-30 21:42:16 +02:00
parent f20a6a4934
commit 3552e1a042
5 changed files with 91 additions and 12 deletions

View file

@ -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
{

View file

@ -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, "+");
}

View file

@ -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 <engine/graphics.h>
#include <engine/serverbrowser.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/generated/client_data.h>
#include <game/gamecore.h> // get_angle
#include <game/client/animstate.h>
#include <game/client/ui.h>
#include <game/client/render.h>
#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;
}
}

View file

@ -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

View file

@ -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")