Notify about chat mentions in editor

This commit is contained in:
12pm 2019-04-06 01:15:02 +02:00
parent dfa06696d6
commit 98bfeb3e72
5 changed files with 38 additions and 1 deletions

View file

@ -2927,6 +2927,7 @@ void CClient::Run()
{
Input()->MouseModeRelative();
GameClient()->OnActivateEditor();
m_pEditor->ResetMentions();
m_EditorActive = true;
}
}

View file

@ -15,6 +15,8 @@ public:
virtual bool HasUnsavedData() = 0;
virtual int Load(const char *pFilename, int StorageType) = 0;
virtual int Save(const char *pFilename) = 0;
virtual void UpdateMentions() = 0;
virtual void ResetMentions() = 0;
};
extern IEditor *CreateEditor();

View file

@ -3,6 +3,7 @@
#include <base/tl/string.h>
#include <engine/editor.h>
#include <engine/engine.h>
#include <engine/graphics.h>
#include <engine/textrender.h>
@ -238,7 +239,7 @@ bool CChat::OnInput(IInput::CEvent Event)
if(FoundAt != m_Input.GetLength())
str_append(aText, m_Input.GetString() + FoundAt, sizeof(aText));
m_Input.Set(aText);
FoundAt = OldOffset;
}
@ -711,6 +712,11 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);
m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
}
if(g_Config.m_ClEditor)
{
GameClient()->Editor()->UpdateMentions();
}
}
}
else if(Team != 2)

View file

@ -5678,6 +5678,28 @@ void CEditor::Render()
StatusBar.Margin(2.0f, &StatusBar);
}
// show mentions
if(m_GuiActive && m_Mentions)
{
char aBuf[16];
if(m_Mentions == 1)
{
str_copy(aBuf, "1 new mention", sizeof(aBuf));
}
else if(m_Mentions <= 9)
{
str_format(aBuf, sizeof(aBuf), "%d new mentions", m_Mentions);
}
else
{
str_copy(aBuf, "9+ new mentions", sizeof(aBuf));
}
TextRender()->TextColor(1.0f, 0.0f, 0.0f, 1.0f);
TextRender()->Text(0, 5.0f, 27.0f, 10.0f, aBuf, -1);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
// do the toolbar
if(m_Mode == MODE_LAYERS)
DoToolbar(ToolBar);

View file

@ -745,11 +745,15 @@ public:
m_PreventUnusedTilesWasWarned = false;
m_AllowPlaceUnusedTiles = 0;
m_BrushDrawDestructive = true;
m_Mentions = 0;
}
virtual void Init();
virtual void UpdateAndRender();
virtual bool HasUnsavedData() { return m_Map.m_Modified; }
virtual void UpdateMentions() { m_Mentions++; }
virtual void ResetMentions() { m_Mentions = 0; }
int64 m_LastUndoUpdateTime;
bool m_UndoRunning;
@ -829,6 +833,8 @@ public:
int m_AllowPlaceUnusedTiles;
bool m_BrushDrawDestructive;
int m_Mentions;
enum
{
FILETYPE_MAP,