Remove Emojis

This commit is contained in:
def 2018-01-25 20:00:35 +01:00
parent 214a8ba10a
commit 151da9af97
15 changed files with 6 additions and 11786 deletions

View file

@ -827,8 +827,6 @@ if(CLIENT)
components/debughud.h
components/effects.cpp
components/effects.h
components/emojis.cpp
components/emojis.h
components/emoticon.cpp
components/emoticon.h
components/flow.cpp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -639,8 +639,6 @@ public:
Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA);
}
pCursor->m_EmojiX = DrawX;
while(pCurrent < pEnd && (pCursor->m_MaxLines < 1 || LineCount <= pCursor->m_MaxLines))
{
int NewLine = 0;
@ -719,8 +717,6 @@ public:
Graphics()->QuadsDrawTL(&QuadItem, 1);
}
pCursor->m_EmojiX = DrawX + (pChr->m_OffsetX + pChr->m_Width) * Size;
DrawX += Advance*Size;
pCursor->m_CharCount++;
}

View file

@ -25,7 +25,6 @@ public:
float m_StartY;
float m_LineWidth;
float m_X, m_Y;
float m_EmojiX;
CFont *m_pFont;
float m_FontSize;

View file

@ -38,7 +38,6 @@ void CChat::OnReset()
m_aLines[i].m_aText[0] = 0;
m_aLines[i].m_aName[0] = 0;
m_aLines[i].m_Friend = false;
m_aLines[i].m_Emojis.clear();
}
m_ReverseTAB = false;
@ -483,7 +482,6 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
m_aLines[m_CurrentLine].m_ClientID = ClientID;
m_aLines[m_CurrentLine].m_Team = Team;
m_aLines[m_CurrentLine].m_NameColor = -2;
m_aLines[m_CurrentLine].m_Emojis.clear();
// check for highlighted name
if (Client()->State() != IClient::STATE_DEMOPLAYBACK)
@ -552,58 +550,6 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
m_aLines[m_CurrentLine].m_Friend = ClientID >= 0 ? m_pClient->m_aClients[ClientID].m_Friend : false;
char aBuffer[64];
int Length = str_length(m_aLines[m_CurrentLine].m_aText);
// lookup for aliases of emojis
for(int i = 0; i < Length; )
{
const char *pIndex1 = str_find(m_aLines[m_CurrentLine].m_aText + i, ":");
if (pIndex1 == NULL) break;
const char *pIndex2 = str_find(pIndex1 + 1, ":");
if (pIndex2 == NULL) break;
i = pIndex2 - m_aLines[m_CurrentLine].m_aText;
// prevents buffer overflow
if ((size_t)(pIndex2 - pIndex1 + 2) > sizeof(aBuffer)) continue;
str_copy(aBuffer, pIndex1, pIndex2 - pIndex1 + 2); // extra place for ":\0"
// skip "::" and those aliases containing space
if (str_length(aBuffer) <= 2 || str_find(aBuffer, " ")) continue;
CEmojis::CEmoji const *pEmoji = m_pClient->m_pEmojis->GetByAlias(aBuffer);
if (pEmoji == NULL) continue;
// to prevent usage of the same ":"
i++;
CEmojis::CEmojiInfo Info;
Info.index = pIndex1 - m_aLines[m_CurrentLine].m_aText;
Info.length = str_length(aBuffer);
Info.m_ID = pEmoji->m_ID;
m_aLines[m_CurrentLine].m_Emojis.add(Info);
}
// lookup for utf emojis
for(int i = 0; i < m_pClient->m_pEmojis->Num(); i++)
{
int Offset = 0;
CEmojis::CEmoji const *pEmoji = m_pClient->m_pEmojis->GetByIndex(i);
const char *pResult = str_find(m_aLines[m_CurrentLine].m_aText + Offset, pEmoji->m_UTF);
while (pResult != NULL)
{
CEmojis::CEmojiInfo Info;
Info.index = pResult - m_aLines[m_CurrentLine].m_aText;
Info.length = str_length(pEmoji->m_UTF);
Info.m_ID = pEmoji->m_ID;
m_aLines[m_CurrentLine].m_Emojis.add(Info);
Offset = Info.index + Info.length;
pResult = str_find(m_aLines[m_CurrentLine].m_aText + Offset, pEmoji->m_UTF);
}
}
m_aLines[m_CurrentLine].m_Emojis.sort_range();
char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2?"whisper":(m_aLines[m_CurrentLine].m_Team?"teamchat":"chat"), aBuf, Highlighted);
@ -761,10 +707,8 @@ void CChat::OnRender()
float Begin = x;
CTextCursor Cursor;
int OffsetType = m_pClient->m_pScoreboard->Active() ? 1 : 0;
for(int i = 0; i < MAX_LINES; i++)
{
int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES;
if(Now > m_aLines[r].m_Time+16*time_freq() && !m_Show)
break;
@ -790,29 +734,9 @@ void CChat::OnRender()
Cursor.m_LineWidth = LineWidth;
TextRender()->TextEx(&Cursor, "", -1);
TextRender()->TextEx(&Cursor, aName, -1);
int index = 0;
for(int j = 0; j < m_aLines[r].m_Emojis.size(); j++)
{
CEmojis::CEmojiInfo info = m_aLines[r].m_Emojis[j];
TextRender()->TextEx(&Cursor, &m_aLines[r].m_aText[index], info.index - index);
Cursor.m_X += Cursor.m_FontSize + (Cursor.m_EmojiX - Cursor.m_X);
if(Begin + Cursor.m_LineWidth < Cursor.m_X)
{
Cursor.m_X = Cursor.m_StartX;
Cursor.m_Y += Cursor.m_FontSize;
Cursor.m_LineCount++;
}
index = info.index + info.length;
}
TextRender()->TextEx(&Cursor, &m_aLines[r].m_aText[index], -1);
TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);
m_aLines[r].m_YOffset[OffsetType] = Cursor.m_Y + Cursor.m_FontSize;
}
y -= m_aLines[r].m_YOffset[OffsetType];
// cut off if msgs waste too much space
@ -863,6 +787,7 @@ void CChat::OnRender()
TextRender()->TextColor(0.8f, 0.8f, 0.8f, Blend);
TextRender()->TextEx(&Cursor, aName, -1);
// render line
if (m_aLines[r].m_ClientID == -1) // system
{
@ -890,25 +815,7 @@ void CChat::OnRender()
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, Blend);
}
int index = 0;
for(int j = 0; j < m_aLines[r].m_Emojis.size(); j++)
{
CEmojis::CEmojiInfo info = m_aLines[r].m_Emojis[j];
TextRender()->TextEx(&Cursor, &m_aLines[r].m_aText[index], info.index - index);
m_pClient->m_pEmojis->Render(info.m_ID, (Cursor.m_EmojiX) + Cursor.m_FontSize/2, Cursor.m_Y + Cursor.m_FontSize-2, Cursor.m_FontSize, Cursor.m_FontSize);
Cursor.m_X += Cursor.m_FontSize + (Cursor.m_EmojiX - Cursor.m_X);
if(Begin + Cursor.m_LineWidth < Cursor.m_X)
{
Cursor.m_X = Cursor.m_StartX;
Cursor.m_Y += Cursor.m_FontSize;
Cursor.m_LineCount++;
}
index = info.index + info.length;
}
TextRender()->TextEx(&Cursor, &m_aLines[r].m_aText[index], -1);
TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);
}
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

View file

@ -2,11 +2,9 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef GAME_CLIENT_COMPONENTS_CHAT_H
#define GAME_CLIENT_COMPONENTS_CHAT_H
#include <base/tl/sorted_array.h>
#include <engine/shared/ringbuffer.h>
#include <game/client/component.h>
#include <game/client/lineinput.h>
#include <game/client/components/emojis.h>
class CChat : public CComponent
{
@ -28,7 +26,6 @@ class CChat : public CComponent
char m_aText[512];
bool m_Friend;
bool m_Highlighted;
sorted_array<CEmojis::CEmojiInfo> m_Emojis;
};
CLine m_aLines[MAX_LINES];

View file

@ -1,132 +0,0 @@
/* (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 <base/math.h>
#include <game/generated/client_data.h>
#include <engine/console.h>
#include <engine/graphics.h>
#include <engine/storage.h>
#include <engine/shared/config.h>
#include <engine/shared/linereader.h>
#include "emojis.h"
void CEmojis::LoadEmojisIndexfile()
{
IOHANDLE File = Storage()->OpenFile("emojis/index.txt", IOFLAG_READ, IStorage::TYPE_ALL);
if (!File)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "emojis", "couldn't open index file");
return;
}
CLineReader LineReader;
LineReader.Init(File);
char aUTF[17];
char aUNICODE[64];
char *pLine;
int curr = 0;
bool failed = false;
while ((pLine = LineReader.Get()) && !failed)
{
if (!str_length(pLine)) continue;
str_copy(aUTF, pLine, sizeof(aUTF));
pLine = LineReader.Get();
if (!pLine)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "emojis", "unexpected end of index file");
failed = true;
break;
}
str_copy(aUNICODE, pLine, sizeof(aUNICODE));
pLine = LineReader.Get();
if (!pLine)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "emojis", "unexpected end of index file");
failed = true;
break;
}
int Count = str_toint(pLine); //TODO: add verification if valid number
while (Count-- > 0) {
char *pAlias = LineReader.Get();
if (!pAlias)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "emojis", "unexpected end of index file");
failed = true;
break;
}
CEmoji Emoji;
Emoji.m_ID = curr;
str_copy(Emoji.m_UTF, aUTF, sizeof(Emoji.m_UTF));
str_copy(Emoji.m_UNICODE, aUNICODE, sizeof(Emoji.m_UNICODE));
str_copy(Emoji.m_Alias, pAlias, sizeof(Emoji.m_Alias));
char aBuf[128];
if (g_Config.m_Debug)
{
str_format(aBuf, sizeof(aBuf), "loaded emoji '%s': %s", aUNICODE, pAlias);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "emojis", aBuf);
}
m_aEmojis.add(Emoji);
}
curr++;
}
io_close(File);
}
int CEmojis::Num() const
{
if (!g_Config.m_ClShowChatEmojis)
return 0;
return m_aEmojis.size();
}
const CEmojis::CEmoji *CEmojis::GetByAlias(const char *alias) const
{
if (g_Config.m_ClShowChatEmojis)
{
for (int i = 0; i < m_aEmojis.size(); i++)
{
if (str_comp(alias, m_aEmojis[i].m_Alias) == 0)
return GetByIndex(i);
}
}
return NULL;
}
const CEmojis::CEmoji *CEmojis::GetByIndex(int index) const
{
return &m_aEmojis[max(0, index%m_aEmojis.size())];
}
void CEmojis::OnInit()
{
m_aEmojis.clear();
LoadEmojisIndexfile();
if (!m_aEmojis.size())
{
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emojis", "failed to load emojis. folder='emojis/'");
}
}
void CEmojis::Render(int i, float x, float y, float w, float h)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_EMOJIS].m_Id);
Graphics()->QuadsBegin();
RenderTools()->SelectSprite(SPRITE_0023_20E3 + i);
IGraphics::CQuadItem QuadItem(x, y, w, h);
Graphics()->QuadsDraw(&QuadItem, 1);
Graphics()->QuadsEnd();
}

View file

@ -1,39 +0,0 @@
/* (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. */
#ifndef GAME_CLIENT_COMPONENTS_EMOJIS_H
#define GAME_CLIENT_COMPONENTS_EMOJIS_H
#include <base/tl/array.h>
#include <game/client/component.h>
class CEmojis : public CComponent
{
public:
struct CEmojiInfo {
int m_ID;
int index;
int length;
bool operator<(const CEmojiInfo &Other) {
if (index < Other.index)
return true;
if (index == Other.index)
return length >= Other.length;
return false;
}
};
struct CEmoji
{
int m_ID;
char m_UTF[17];
char m_UNICODE[64];
char m_Alias[64];
};
int Num() const;
const CEmoji *GetByAlias(const char *alias) const;
const CEmoji *GetByIndex(int index) const;
void Render(int i, float x, float y, float w, float h);
private:
array<CEmoji> m_aEmojis;
void LoadEmojisIndexfile();
void OnInit();
};
#endif

View file

@ -58,8 +58,8 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
{
char aBuf[128];
CUIRect Label, Button, Left, Right, Game, Client, AutoReconnect;
MainView.HSplitTop(220.0f, &Game, &Client);
Client.HSplitTop(120.0f, &Client, &AutoReconnect);
MainView.HSplitTop(180.0f, &Game, &Client);
Client.HSplitTop(160.0f, &Client, &AutoReconnect);
// game
{
@ -108,21 +108,6 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
if(DoButton_CheckBox(&g_Config.m_ClResetWantedWeaponOnDeath, Localize("Reset wanted weapon on death"), g_Config.m_ClResetWantedWeaponOnDeath, &Button))
g_Config.m_ClResetWantedWeaponOnDeath ^= 1;
Left.HSplitTop(5.0f, 0, &Left);
Left.HSplitTop(20.0f, &Button, &Left);
if(DoButton_CheckBox(&g_Config.m_ClShowEmotes, Localize("Show tee emotes"), g_Config.m_ClShowEmotes, &Button))
g_Config.m_ClShowEmotes ^= 1;
Left.HSplitTop(5.0f, 0, &Left);
Left.HSplitTop(20.0f, &Button, &Left);
if(DoButton_CheckBox(&g_Config.m_ClShowChatEmojis, Localize("Show emojis in chat"), g_Config.m_ClShowChatEmojis, &Button))
g_Config.m_ClShowChatEmojis ^= 1;
Left.HSplitTop(5.0f, 0, &Left);
Left.HSplitTop(20.0f, &Button, &Left);
if(DoButton_CheckBox(&g_Config.m_ClShowChatSystem, Localize("Show chat messages by system"), g_Config.m_ClShowChatSystem, &Button))
g_Config.m_ClShowChatSystem ^= 1;
// chat messages
Right.HSplitTop(5.0f, 0, &Right);
Right.HSplitTop(20.0f, &Button, &Right);
@ -1530,13 +1515,6 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
{
g_Config.m_ClShowVotesAfterVoting ^= 1;
}
Right.HSplitTop(20.0f, &Button, &Right);
if (DoButton_CheckBox(&g_Config.m_ClShowNotifications, Localize("Show notifications"), g_Config.m_ClShowNotifications, &Button))
{
g_Config.m_ClShowNotifications ^= 1;
}
MainView.HSplitTop(170.0f, &Messages, &MainView);
Messages.HSplitTop(30.0f, &Label, &Messages);
Label.VSplitMid(&Label, &Button);

View file

@ -39,7 +39,6 @@
#include "components/damageind.h"
#include "components/debughud.h"
#include "components/effects.h"
#include "components/emojis.h"
#include "components/emoticon.h"
#include "components/flow.h"
#include "components/hud.h"
@ -71,7 +70,6 @@ CGameClient g_GameClient;
static CKillMessages gs_KillMessages;
static CCamera gs_Camera;
static CChat gs_Chat;
static CEmojis gs_Emojis;
static CMotd gs_Motd;
static CBroadcast gs_Broadcast;
static CGameConsole gs_GameConsole;
@ -140,7 +138,6 @@ void CGameClient::OnConsoleInit()
m_pSkins = &::gs_Skins;
m_pCountryFlags = &::gs_CountryFlags;
m_pChat = &::gs_Chat;
m_pEmojis = &::gs_Emojis;
m_pFlow = &::gs_Flow;
m_pCamera = &::gs_Camera;
m_pControls = &::gs_Controls;
@ -193,7 +190,6 @@ void CGameClient::OnConsoleInit()
m_All.Add(&gs_Spectator);
m_All.Add(&gs_Emoticon);
m_All.Add(&gs_KillMessages);
m_All.Add(m_pEmojis);
m_All.Add(m_pChat);
m_All.Add(&gs_Broadcast);
m_All.Add(&gs_DebugHud);

View file

@ -338,7 +338,6 @@ public:
class CCountryFlags *m_pCountryFlags;
class CFlow *m_pFlow;
class CChat *m_pChat;
class CEmojis *m_pEmojis;
class CDamageInd *m_pDamageind;
class CCamera *m_pCamera;
class CControls *m_pControls;

View file

@ -33,7 +33,6 @@ MACRO_CONFIG_INT(ClShowRecord, cl_showrecord, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SA
MACRO_CONFIG_INT(ClShowNotifications, cl_shownotifications, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Make the client notify when someone highlights you")
MACRO_CONFIG_INT(ClShowEmotes, cl_showemotes, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show tee emotes")
MACRO_CONFIG_INT(ClShowChat, cl_showchat, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show chat")
MACRO_CONFIG_INT(ClShowChatEmojis, cl_showchatemojis, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show emojis in chat")
MACRO_CONFIG_INT(ClShowChatFriends, cl_show_chat_friends, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show only chat messages from friends")
MACRO_CONFIG_INT(ClShowChatSystem, cl_show_chat_system, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show chat messages from the server")
MACRO_CONFIG_INT(ClShowKillMessages, cl_showkillmessages, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show kill messages")

View file

@ -3,7 +3,7 @@
#ifndef GAME_VERSION_H
#define GAME_VERSION_H
#include "generated/nethash.cpp"
#define GAME_VERSION "0.6.4, 11.0.2"
#define GAME_VERSION "11.0.2"
#define GAME_NETVERSION "0.6 626fce9a778df4d4"
#define GAME_RELEASE_VERSION "11.0.2"
#define CLIENT_VERSIONNR 11002