mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Rename killmessages
to infomessages
This commit is contained in:
parent
c90899cc29
commit
cb53c45f8c
|
@ -8,35 +8,35 @@
|
|||
#include <game/generated/protocol.h>
|
||||
#include <game/localization.h>
|
||||
|
||||
#include "killmessages.h"
|
||||
#include "infomessages.h"
|
||||
#include <game/client/animstate.h>
|
||||
#include <game/client/gameclient.h>
|
||||
#include <game/client/prediction/entities/character.h>
|
||||
#include <game/client/prediction/gameworld.h>
|
||||
|
||||
void CKillMessages::OnWindowResize()
|
||||
void CInfoMessages::OnWindowResize()
|
||||
{
|
||||
for(auto &Killmsg : m_aKillmsgs)
|
||||
for(auto &InfoMsg : m_aInfoMsgs)
|
||||
{
|
||||
TextRender()->DeleteTextContainer(Killmsg.m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(Killmsg.m_KillerTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(InfoMsg.m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(InfoMsg.m_KillerTextContainerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void CKillMessages::OnReset()
|
||||
void CInfoMessages::OnReset()
|
||||
{
|
||||
m_KillmsgCurrent = 0;
|
||||
m_InfoMsgCurrent = 0;
|
||||
|
||||
for(auto &Killmsg : m_aKillmsgs)
|
||||
for(auto &InfoMsg : m_aInfoMsgs)
|
||||
{
|
||||
Killmsg.m_Tick = -100000;
|
||||
InfoMsg.m_Tick = -100000;
|
||||
|
||||
TextRender()->DeleteTextContainer(Killmsg.m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(Killmsg.m_KillerTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(InfoMsg.m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(InfoMsg.m_KillerTextContainerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void CKillMessages::OnInit()
|
||||
void CInfoMessages::OnInit()
|
||||
{
|
||||
Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
|
||||
m_SpriteQuadContainerIndex = Graphics()->CreateQuadContainer(false);
|
||||
|
@ -61,48 +61,57 @@ void CKillMessages::OnInit()
|
|||
Graphics()->QuadContainerUpload(m_SpriteQuadContainerIndex);
|
||||
}
|
||||
|
||||
void CKillMessages::CreateKillmessageNamesIfNotCreated(CKillMsg &Kill)
|
||||
void CInfoMessages::AddInfoMsg(int Type, CInfoMsg NewMsg)
|
||||
{
|
||||
NewMsg.m_Type = Type;
|
||||
NewMsg.m_Tick = Client()->GameTick(g_Config.m_ClDummy);
|
||||
|
||||
m_InfoMsgCurrent = (m_InfoMsgCurrent+1)%MAX_INFOMSGS;
|
||||
m_aInfoMsgs[m_InfoMsgCurrent] = NewMsg;
|
||||
}
|
||||
|
||||
void CInfoMessages::CreateKillmessageNamesIfNotCreated(CInfoMsg *pInfoMsg)
|
||||
{
|
||||
const float FontSize = 36.0f;
|
||||
if(!Kill.m_VictimTextContainerIndex.Valid() && Kill.m_aVictimName[0] != 0)
|
||||
if(!pInfoMsg->m_VictimTextContainerIndex.Valid() && pInfoMsg->m_aVictimName[0] != 0)
|
||||
{
|
||||
Kill.m_VictimTextWidth = TextRender()->TextWidth(FontSize, Kill.m_aVictimName, -1, -1.0f);
|
||||
pInfoMsg->m_VictimTextWidth = TextRender()->TextWidth(FontSize, pInfoMsg->m_aVictimName, -1, -1.0f);
|
||||
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);
|
||||
Cursor.m_LineWidth = -1;
|
||||
|
||||
unsigned Color = g_Config.m_ClKillMessageNormalColor;
|
||||
if(Kill.m_aVictimIds[0] == m_pClient->m_Snap.m_LocalClientID)
|
||||
if(pInfoMsg->m_aVictimIds[0] == m_pClient->m_Snap.m_LocalClientID)
|
||||
{
|
||||
Color = g_Config.m_ClKillMessageHighlightColor;
|
||||
}
|
||||
TextRender()->TextColor(color_cast<ColorRGBA>(ColorHSLA(Color)));
|
||||
|
||||
TextRender()->CreateTextContainer(Kill.m_VictimTextContainerIndex, &Cursor, Kill.m_aVictimName);
|
||||
TextRender()->CreateTextContainer(pInfoMsg->m_VictimTextContainerIndex, &Cursor, pInfoMsg->m_aVictimName);
|
||||
}
|
||||
|
||||
if(!Kill.m_KillerTextContainerIndex.Valid() && Kill.m_aKillerName[0] != 0)
|
||||
if(!pInfoMsg->m_KillerTextContainerIndex.Valid() && pInfoMsg->m_aKillerName[0] != 0)
|
||||
{
|
||||
Kill.m_KillerTextWidth = TextRender()->TextWidth(FontSize, Kill.m_aKillerName, -1, -1.0f);
|
||||
pInfoMsg->m_KillerTextWidth = TextRender()->TextWidth(FontSize, pInfoMsg->m_aKillerName, -1, -1.0f);
|
||||
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);
|
||||
Cursor.m_LineWidth = -1;
|
||||
|
||||
unsigned Color = g_Config.m_ClKillMessageNormalColor;
|
||||
if(Kill.m_KillerID == m_pClient->m_Snap.m_LocalClientID)
|
||||
if(pInfoMsg->m_KillerID == m_pClient->m_Snap.m_LocalClientID)
|
||||
{
|
||||
Color = g_Config.m_ClKillMessageHighlightColor;
|
||||
}
|
||||
TextRender()->TextColor(color_cast<ColorRGBA>(ColorHSLA(Color)));
|
||||
|
||||
TextRender()->CreateTextContainer(Kill.m_KillerTextContainerIndex, &Cursor, Kill.m_aKillerName);
|
||||
TextRender()->CreateTextContainer(pInfoMsg->m_KillerTextContainerIndex, &Cursor, pInfoMsg->m_aKillerName);
|
||||
}
|
||||
TextRender()->TextColor(TextRender()->DefaultTextColor());
|
||||
}
|
||||
|
||||
void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
||||
void CInfoMessages::OnMessage(int MsgType, void *pRawMsg)
|
||||
{
|
||||
if(m_pClient->m_SuppressEvents)
|
||||
return;
|
||||
|
@ -111,7 +120,8 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
{
|
||||
CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg;
|
||||
|
||||
CKillMsg Kill{};
|
||||
CInfoMsg Kill{};
|
||||
Kill.m_Type = INFOMSG_KILL;
|
||||
|
||||
std::vector<std::pair<int, int>> vStrongWeakSorted;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
|
@ -167,7 +177,7 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f);
|
||||
|
||||
CreateKillmessageNamesIfNotCreated(Kill);
|
||||
CreateKillmessageNamesIfNotCreated(&Kill);
|
||||
|
||||
bool KillMsgValid = true;
|
||||
for(int i = 0; i < Kill.m_TeamSize; i++)
|
||||
|
@ -178,12 +188,12 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
if(KillMsgValid)
|
||||
{
|
||||
// add the message
|
||||
m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS;
|
||||
m_InfoMsgCurrent = (m_InfoMsgCurrent + 1) % MAX_INFOMSGS;
|
||||
|
||||
TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aInfoMsgs[m_InfoMsgCurrent].m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aInfoMsgs[m_InfoMsgCurrent].m_KillerTextContainerIndex);
|
||||
|
||||
m_aKillmsgs[m_KillmsgCurrent] = Kill;
|
||||
m_aInfoMsgs[m_InfoMsgCurrent] = Kill;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -198,7 +208,8 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
{
|
||||
CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
|
||||
|
||||
CKillMsg Kill{};
|
||||
CInfoMsg Kill{};
|
||||
Kill.m_Type = INFOMSG_KILL;
|
||||
|
||||
Kill.m_TeamSize = 1;
|
||||
Kill.m_aVictimIds[0] = pMsg->m_Victim;
|
||||
|
@ -246,19 +257,19 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f);
|
||||
|
||||
CreateKillmessageNamesIfNotCreated(Kill);
|
||||
CreateKillmessageNamesIfNotCreated(&Kill);
|
||||
|
||||
bool KillMsgValid = (Kill.m_aVictimRenderInfo[0].m_CustomColoredSkin && Kill.m_aVictimRenderInfo[0].m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_aVictimRenderInfo[0].m_CustomColoredSkin && Kill.m_aVictimRenderInfo[0].m_OriginalRenderSkin.m_Body.IsValid());
|
||||
KillMsgValid &= Kill.m_KillerID == -1 || ((Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_OriginalRenderSkin.m_Body.IsValid()));
|
||||
if(KillMsgValid)
|
||||
{
|
||||
// add the message
|
||||
m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS;
|
||||
m_InfoMsgCurrent = (m_InfoMsgCurrent + 1) % MAX_INFOMSGS;
|
||||
|
||||
TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aInfoMsgs[m_InfoMsgCurrent].m_VictimTextContainerIndex);
|
||||
TextRender()->DeleteTextContainer(m_aInfoMsgs[m_InfoMsgCurrent].m_KillerTextContainerIndex);
|
||||
|
||||
m_aKillmsgs[m_KillmsgCurrent] = Kill;
|
||||
m_aInfoMsgs[m_InfoMsgCurrent] = Kill;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -270,7 +281,107 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
}
|
||||
}
|
||||
|
||||
void CKillMessages::OnRender()
|
||||
void CInfoMessages::RenderKillMsg(CInfoMsg *pInfoMsg, float x, float y)
|
||||
{
|
||||
// render victim name
|
||||
x -= pInfoMsg->m_VictimTextWidth;
|
||||
ColorRGBA TextColor;
|
||||
if(g_Config.m_ClChatTeamColors && pInfoMsg->m_VictimDDTeam)
|
||||
TextColor = m_pClient->GetDDTeamColor(pInfoMsg->m_VictimDDTeam, 0.75f);
|
||||
else
|
||||
TextColor = TextRender()->DefaultTextColor();
|
||||
|
||||
CreateKillmessageNamesIfNotCreated(pInfoMsg);
|
||||
|
||||
if(pInfoMsg->m_VictimTextContainerIndex.Valid())
|
||||
TextRender()->RenderTextContainer(pInfoMsg->m_VictimTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||
|
||||
// render victim tee
|
||||
x -= 24.0f;
|
||||
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(pInfoMsg->m_ModeSpecial & 1)
|
||||
{
|
||||
int QuadOffset = 0;
|
||||
if(pInfoMsg->m_aVictimIds[0] == pInfoMsg->m_FlagCarrierBlue)
|
||||
++QuadOffset;
|
||||
|
||||
if(QuadOffset == 0)
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagRed);
|
||||
else
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue);
|
||||
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, QuadOffset, x, y - 16);
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = (pInfoMsg->m_TeamSize - 1); j >= 0; j--)
|
||||
{
|
||||
if(pInfoMsg->m_aVictimIds[j] < 0)
|
||||
continue;
|
||||
|
||||
const CAnimState *pIdleState = CAnimState::GetIdle();
|
||||
vec2 OffsetToMid;
|
||||
RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &pInfoMsg->m_aVictimRenderInfo[j], OffsetToMid);
|
||||
const vec2 TeeRenderPos = vec2(x, y + 46.0f / 2.0f + OffsetToMid.y);
|
||||
RenderTools()->RenderTee(pIdleState, &pInfoMsg->m_aVictimRenderInfo[j], EMOTE_PAIN, vec2(-1, 0), TeeRenderPos);
|
||||
|
||||
x -= 44.0f;
|
||||
}
|
||||
|
||||
// render weapon
|
||||
x -= 32.0f;
|
||||
if(pInfoMsg->m_Weapon >= 0)
|
||||
{
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_aSpriteWeapons[pInfoMsg->m_Weapon]);
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, 4 + pInfoMsg->m_Weapon, x, y + 28);
|
||||
}
|
||||
x -= 52.0f;
|
||||
|
||||
if(pInfoMsg->m_aVictimIds[0] != pInfoMsg->m_KillerID)
|
||||
{
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(pInfoMsg->m_ModeSpecial & 2)
|
||||
{
|
||||
int QuadOffset = 2;
|
||||
if(pInfoMsg->m_KillerID == pInfoMsg->m_FlagCarrierBlue)
|
||||
++QuadOffset;
|
||||
|
||||
if(QuadOffset == 2)
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagRed);
|
||||
else
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue);
|
||||
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, QuadOffset, x - 56, y - 16);
|
||||
}
|
||||
}
|
||||
|
||||
// render killer tee
|
||||
x -= 24.0f;
|
||||
|
||||
if(pInfoMsg->m_KillerID >= 0)
|
||||
{
|
||||
const CAnimState *pIdleState = CAnimState::GetIdle();
|
||||
vec2 OffsetToMid;
|
||||
RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &pInfoMsg->m_KillerRenderInfo, OffsetToMid);
|
||||
const vec2 TeeRenderPos = vec2(x, y + 46.0f / 2.0f + OffsetToMid.y);
|
||||
RenderTools()->RenderTee(pIdleState, &pInfoMsg->m_KillerRenderInfo, EMOTE_ANGRY, vec2(1, 0), TeeRenderPos);
|
||||
}
|
||||
|
||||
x -= 32.0f;
|
||||
|
||||
// render killer name
|
||||
x -= pInfoMsg->m_KillerTextWidth;
|
||||
|
||||
if(pInfoMsg->m_KillerTextContainerIndex.Valid())
|
||||
TextRender()->RenderTextContainer(pInfoMsg->m_KillerTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CInfoMessages::OnRender()
|
||||
{
|
||||
if(!g_Config.m_ClShowKillMessages)
|
||||
return;
|
||||
|
@ -284,138 +395,43 @@ void CKillMessages::OnRender()
|
|||
float StartX = Width * 1.5f - 10.0f;
|
||||
float y = 30.0f + 100.0f * ((g_Config.m_ClShowfps ? 1 : 0) + (g_Config.m_ClShowpred && Client()->State() != IClient::STATE_DEMOPLAYBACK));
|
||||
|
||||
for(int i = 1; i <= MAX_KILLMSGS; i++)
|
||||
for(int i = 1; i <= MAX_INFOMSGS; i++)
|
||||
{
|
||||
int r = (m_KillmsgCurrent + i) % MAX_KILLMSGS;
|
||||
if(Client()->GameTick(g_Config.m_ClDummy) > m_aKillmsgs[r].m_Tick + Client()->GameTickSpeed() * 10)
|
||||
continue;
|
||||
|
||||
float x = StartX;
|
||||
|
||||
// render victim name
|
||||
x -= m_aKillmsgs[r].m_VictimTextWidth;
|
||||
ColorRGBA TextColor;
|
||||
if(g_Config.m_ClChatTeamColors && m_aKillmsgs[r].m_VictimDDTeam)
|
||||
TextColor = m_pClient->GetDDTeamColor(m_aKillmsgs[r].m_VictimDDTeam, 0.75f);
|
||||
else
|
||||
TextColor = TextRender()->DefaultTextColor();
|
||||
|
||||
CreateKillmessageNamesIfNotCreated(m_aKillmsgs[r]);
|
||||
|
||||
if(m_aKillmsgs[r].m_VictimTextContainerIndex.Valid())
|
||||
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||
|
||||
// render victim tee
|
||||
x -= 24.0f;
|
||||
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(m_aKillmsgs[r].m_ModeSpecial & 1)
|
||||
{
|
||||
int QuadOffset = 0;
|
||||
if(m_aKillmsgs[r].m_aVictimIds[0] == m_aKillmsgs[r].m_FlagCarrierBlue)
|
||||
++QuadOffset;
|
||||
|
||||
if(QuadOffset == 0)
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagRed);
|
||||
else
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue);
|
||||
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, QuadOffset, x, y - 16);
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = (m_aKillmsgs[r].m_TeamSize - 1); j >= 0; j--)
|
||||
{
|
||||
if(m_aKillmsgs[r].m_aVictimIds[j] < 0)
|
||||
continue;
|
||||
|
||||
const CAnimState *pIdleState = CAnimState::GetIdle();
|
||||
vec2 OffsetToMid;
|
||||
RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &m_aKillmsgs[r].m_aVictimRenderInfo[j], OffsetToMid);
|
||||
const vec2 TeeRenderPos = vec2(x, y + 46.0f / 2.0f + OffsetToMid.y);
|
||||
RenderTools()->RenderTee(pIdleState, &m_aKillmsgs[r].m_aVictimRenderInfo[j], EMOTE_PAIN, vec2(-1, 0), TeeRenderPos);
|
||||
|
||||
x -= 44.0f;
|
||||
}
|
||||
|
||||
// render weapon
|
||||
x -= 32.0f;
|
||||
if(m_aKillmsgs[r].m_Weapon >= 0)
|
||||
{
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_aSpriteWeapons[m_aKillmsgs[r].m_Weapon]);
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, 4 + m_aKillmsgs[r].m_Weapon, x, y + 28);
|
||||
}
|
||||
x -= 52.0f;
|
||||
|
||||
if(m_aKillmsgs[r].m_aVictimIds[0] != m_aKillmsgs[r].m_KillerID)
|
||||
{
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(m_aKillmsgs[r].m_ModeSpecial & 2)
|
||||
{
|
||||
int QuadOffset = 2;
|
||||
if(m_aKillmsgs[r].m_KillerID == m_aKillmsgs[r].m_FlagCarrierBlue)
|
||||
++QuadOffset;
|
||||
|
||||
if(QuadOffset == 2)
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagRed);
|
||||
else
|
||||
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue);
|
||||
|
||||
Graphics()->RenderQuadContainerAsSprite(m_SpriteQuadContainerIndex, QuadOffset, x - 56, y - 16);
|
||||
}
|
||||
}
|
||||
|
||||
// render killer tee
|
||||
x -= 24.0f;
|
||||
|
||||
if(m_aKillmsgs[r].m_KillerID >= 0)
|
||||
{
|
||||
const CAnimState *pIdleState = CAnimState::GetIdle();
|
||||
vec2 OffsetToMid;
|
||||
RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &m_aKillmsgs[r].m_KillerRenderInfo, OffsetToMid);
|
||||
const vec2 TeeRenderPos = vec2(x, y + 46.0f / 2.0f + OffsetToMid.y);
|
||||
RenderTools()->RenderTee(pIdleState, &m_aKillmsgs[r].m_KillerRenderInfo, EMOTE_ANGRY, vec2(1, 0), TeeRenderPos);
|
||||
}
|
||||
|
||||
x -= 32.0f;
|
||||
|
||||
// render killer name
|
||||
x -= m_aKillmsgs[r].m_KillerTextWidth;
|
||||
|
||||
if(m_aKillmsgs[r].m_KillerTextContainerIndex.Valid())
|
||||
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||
}
|
||||
if(pInfoMsg->m_Type == INFOMSG_KILL)
|
||||
RenderKillMsg(pInfoMsg, StartX, y);
|
||||
|
||||
y += 46.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void CKillMessages::RefindSkins()
|
||||
void CInfoMessages::RefindSkins()
|
||||
{
|
||||
for(auto &KillMsg : m_aKillmsgs)
|
||||
for(auto &InfoMsg : m_aInfoMsgs)
|
||||
{
|
||||
KillMsg.m_KillerRenderInfo.Reset();
|
||||
if(KillMsg.m_KillerID >= 0)
|
||||
InfoMsg.m_KillerRenderInfo.Reset();
|
||||
if(InfoMsg.m_KillerID >= 0)
|
||||
{
|
||||
const CGameClient::CClientData &Client = GameClient()->m_aClients[KillMsg.m_KillerID];
|
||||
const CGameClient::CClientData &Client = GameClient()->m_aClients[InfoMsg.m_KillerID];
|
||||
if(Client.m_Active && Client.m_aSkinName[0] != '\0')
|
||||
KillMsg.m_KillerRenderInfo = Client.m_RenderInfo;
|
||||
InfoMsg.m_KillerRenderInfo = Client.m_RenderInfo;
|
||||
else
|
||||
KillMsg.m_KillerID = -1;
|
||||
InfoMsg.m_KillerID = -1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_KILLMSG_TEAM_MEMBERS; i++)
|
||||
{
|
||||
KillMsg.m_aVictimRenderInfo[i].Reset();
|
||||
if(KillMsg.m_aVictimIds[i] >= 0)
|
||||
InfoMsg.m_aVictimRenderInfo[i].Reset();
|
||||
if(InfoMsg.m_aVictimIds[i] >= 0)
|
||||
{
|
||||
const CGameClient::CClientData &Client = GameClient()->m_aClients[KillMsg.m_aVictimIds[i]];
|
||||
const CGameClient::CClientData &Client = GameClient()->m_aClients[InfoMsg.m_aVictimIds[i]];
|
||||
if(Client.m_Active && Client.m_aSkinName[0] != '\0')
|
||||
KillMsg.m_aVictimRenderInfo[i] = Client.m_RenderInfo;
|
||||
InfoMsg.m_aVictimRenderInfo[i] = Client.m_RenderInfo;
|
||||
else
|
||||
KillMsg.m_aVictimIds[i] = -1;
|
||||
InfoMsg.m_aVictimIds[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,27 @@
|
|||
/* (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_KILLMESSAGES_H
|
||||
#define GAME_CLIENT_COMPONENTS_KILLMESSAGES_H
|
||||
#ifndef GAME_CLIENT_COMPONENTS_INFOMESSAGES_H
|
||||
#define GAME_CLIENT_COMPONENTS_INFOMESSAGES_H
|
||||
#include <game/client/component.h>
|
||||
|
||||
#include <game/client/render.h>
|
||||
class CKillMessages : public CComponent
|
||||
class CInfoMessages : public CComponent
|
||||
{
|
||||
int m_SpriteQuadContainerIndex;
|
||||
enum
|
||||
{
|
||||
MAX_KILLMSGS = 5,
|
||||
MAX_INFOMSGS = 5,
|
||||
MAX_KILLMSG_TEAM_MEMBERS = 4,
|
||||
|
||||
INFOMSG_KILL = 0,
|
||||
};
|
||||
|
||||
public:
|
||||
// kill messages
|
||||
struct CKillMsg
|
||||
// info messages
|
||||
struct CInfoMsg
|
||||
{
|
||||
int m_Weapon;
|
||||
int m_Type;
|
||||
int m_Tick;
|
||||
|
||||
int m_aVictimIds[MAX_KILLMSG_TEAM_MEMBERS];
|
||||
int m_VictimDDTeam;
|
||||
|
@ -32,18 +35,22 @@ public:
|
|||
float m_KillerTextWidth;
|
||||
CTeeRenderInfo m_KillerRenderInfo;
|
||||
|
||||
// kill msg
|
||||
int m_Weapon;
|
||||
int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example
|
||||
int m_Tick;
|
||||
int m_FlagCarrierBlue;
|
||||
int m_TeamSize;
|
||||
};
|
||||
|
||||
private:
|
||||
void CreateKillmessageNamesIfNotCreated(CKillMsg &Kill);
|
||||
void AddInfoMsg(int Type, CInfoMsg NewMsg);
|
||||
void RenderKillMsg(CInfoMsg *pInfoMsg, float x, float y);
|
||||
|
||||
void CreateKillmessageNamesIfNotCreated(CInfoMsg *pInfoMsg);
|
||||
|
||||
public:
|
||||
CKillMsg m_aKillmsgs[MAX_KILLMSGS];
|
||||
int m_KillmsgCurrent;
|
||||
CInfoMsg m_aInfoMsgs[MAX_INFOMSGS];
|
||||
int m_InfoMsgCurrent;
|
||||
|
||||
virtual int Sizeof() const override { return sizeof(*this); }
|
||||
virtual void OnWindowResize() override;
|
|
@ -78,7 +78,7 @@ void CMenus::HandleDemoSeeking(float PositionToSeek, float TimeToSeek)
|
|||
if((PositionToSeek >= 0.0f && PositionToSeek <= 1.0f) || TimeToSeek != 0.0f)
|
||||
{
|
||||
m_pClient->m_Chat.Reset();
|
||||
m_pClient->m_KillMessages.OnReset();
|
||||
m_pClient->m_InfoMessages.OnReset();
|
||||
m_pClient->m_Particles.OnReset();
|
||||
m_pClient->m_Sounds.OnReset();
|
||||
m_pClient->m_Scoreboard.OnReset();
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "components/ghost.h"
|
||||
#include "components/hud.h"
|
||||
#include "components/items.h"
|
||||
#include "components/killmessages.h"
|
||||
#include "components/infomessages.h"
|
||||
#include "components/mapimages.h"
|
||||
#include "components/maplayers.h"
|
||||
#include "components/mapsounds.h"
|
||||
|
@ -135,7 +135,7 @@ void CGameClient::OnConsoleInit()
|
|||
&m_Hud,
|
||||
&m_Spectator,
|
||||
&m_Emoticon,
|
||||
&m_KillMessages,
|
||||
&m_InfoMessages,
|
||||
&m_Chat,
|
||||
&m_Broadcast,
|
||||
&m_DebugHud,
|
||||
|
@ -3389,7 +3389,7 @@ void CGameClient::RefindSkins()
|
|||
}
|
||||
m_Ghost.RefindSkins();
|
||||
m_Chat.RefindSkins();
|
||||
m_KillMessages.RefindSkins();
|
||||
m_InfoMessages.RefindSkins();
|
||||
}
|
||||
|
||||
static bool UnknownMapSettingCallback(const char *pCommand, void *pUser)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "components/ghost.h"
|
||||
#include "components/hud.h"
|
||||
#include "components/items.h"
|
||||
#include "components/killmessages.h"
|
||||
#include "components/infomessages.h"
|
||||
#include "components/mapimages.h"
|
||||
#include "components/maplayers.h"
|
||||
#include "components/mapsounds.h"
|
||||
|
@ -111,7 +111,7 @@ class CGameClient : public IGameClient
|
|||
{
|
||||
public:
|
||||
// all components
|
||||
CKillMessages m_KillMessages;
|
||||
CInfoMessages m_InfoMessages;
|
||||
CCamera m_Camera;
|
||||
CChat m_Chat;
|
||||
CMotd m_Motd;
|
||||
|
|
Loading…
Reference in a new issue