mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Show message in editor when player is moved ingame
Show a short message below the existing chat mentions message that is shown in the top left area of the editor above the layers/images/sounds button when the player character is moved ingame while the editor is open. The messages are cleared when the editor is activated and when the client is disconnected. Closes #1993.
This commit is contained in:
parent
3a5228bb8f
commit
43109bec3c
|
@ -3200,7 +3200,7 @@ void CClient::Run()
|
|||
{
|
||||
Input()->MouseModeRelative();
|
||||
GameClient()->OnActivateEditor();
|
||||
m_pEditor->ResetMentions();
|
||||
m_pEditor->OnActivate();
|
||||
m_EditorActive = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ public:
|
|||
virtual void Init() = 0;
|
||||
virtual void OnUpdate() = 0;
|
||||
virtual void OnRender() = 0;
|
||||
virtual void OnActivate() = 0;
|
||||
virtual bool HasUnsavedData() const = 0;
|
||||
virtual bool Load(const char *pFilename, int StorageType) = 0;
|
||||
virtual bool Save(const char *pFilename) = 0;
|
||||
virtual void UpdateMentions() = 0;
|
||||
virtual void ResetMentions() = 0;
|
||||
virtual void OnIngameMoved() = 0;
|
||||
virtual void ResetIngameMoved() = 0;
|
||||
};
|
||||
|
||||
extern IEditor *CreateEditor();
|
||||
|
|
|
@ -567,6 +567,9 @@ void CGameClient::OnReset()
|
|||
m_LastDummyConnected = false;
|
||||
|
||||
m_ReceivedDDNetPlayer = false;
|
||||
|
||||
Editor()->ResetMentions();
|
||||
Editor()->ResetIngameMoved();
|
||||
}
|
||||
|
||||
void CGameClient::UpdatePositions()
|
||||
|
@ -1754,6 +1757,13 @@ void CGameClient::OnNewSnapshot()
|
|||
for(auto &pComponent : m_vpAll)
|
||||
pComponent->OnNewSnapshot();
|
||||
|
||||
// notify editor when local character moved
|
||||
if(m_Snap.m_pLocalCharacter && m_Snap.m_pLocalPrevCharacter &&
|
||||
(m_Snap.m_pLocalCharacter->m_X != m_Snap.m_pLocalPrevCharacter->m_X || m_Snap.m_pLocalCharacter->m_Y != m_Snap.m_pLocalPrevCharacter->m_Y))
|
||||
{
|
||||
Editor()->OnIngameMoved();
|
||||
}
|
||||
|
||||
// detect air jump for other players
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
if(m_Snap.m_aCharacters[i].m_Active && (m_Snap.m_aCharacters[i].m_Cur.m_Jumped & 2) && !(m_Snap.m_aCharacters[i].m_Prev.m_Jumped & 2))
|
||||
|
|
|
@ -5263,8 +5263,10 @@ void CEditor::ShowFileDialogError(const char *pFormat, ...)
|
|||
|
||||
void CEditor::RenderModebar(CUIRect View)
|
||||
{
|
||||
CUIRect Mentions, ModeButton;
|
||||
View.HSplitTop(30.0f, &Mentions, &ModeButton);
|
||||
CUIRect Mentions, IngameMoved, ModeButton;
|
||||
View.HSplitTop(12.0f, &Mentions, &View);
|
||||
View.HSplitTop(12.0f, &IngameMoved, &View);
|
||||
View.HSplitTop(8.0f, nullptr, &ModeButton);
|
||||
ModeButton.VSplitLeft(65.0f, &ModeButton, nullptr);
|
||||
|
||||
// mentions
|
||||
|
@ -5283,6 +5285,14 @@ void CEditor::RenderModebar(CUIRect View)
|
|||
TextRender()->TextColor(TextRender()->DefaultTextColor());
|
||||
}
|
||||
|
||||
// ingame moved warning
|
||||
if(m_IngameMoved)
|
||||
{
|
||||
TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
UI()->DoLabel(&IngameMoved, Localize("Moved ingame"), 10.0f, TEXTALIGN_MC);
|
||||
TextRender()->TextColor(TextRender()->DefaultTextColor());
|
||||
}
|
||||
|
||||
// mode button
|
||||
{
|
||||
const char *pModeLabel = "";
|
||||
|
@ -7220,6 +7230,12 @@ void CEditor::OnRender()
|
|||
CLineInput::RenderCandidates();
|
||||
}
|
||||
|
||||
void CEditor::OnActivate()
|
||||
{
|
||||
ResetMentions();
|
||||
ResetIngameMoved();
|
||||
}
|
||||
|
||||
void CEditor::LoadCurrentMap()
|
||||
{
|
||||
if(Load(m_pClient->GetCurrentMapPath(), IStorage::TYPE_SAVE))
|
||||
|
|
|
@ -866,16 +866,17 @@ public:
|
|||
m_PreventUnusedTilesWasWarned = false;
|
||||
m_AllowPlaceUnusedTiles = 0;
|
||||
m_BrushDrawDestructive = true;
|
||||
|
||||
m_Mentions = 0;
|
||||
}
|
||||
|
||||
void Init() override;
|
||||
void OnUpdate() override;
|
||||
void OnRender() override;
|
||||
void OnActivate() override;
|
||||
bool HasUnsavedData() const override { return m_Map.m_Modified; }
|
||||
void UpdateMentions() override { m_Mentions++; }
|
||||
void ResetMentions() override { m_Mentions = 0; }
|
||||
void OnIngameMoved() override { m_IngameMoved = true; }
|
||||
void ResetIngameMoved() override { m_IngameMoved = false; }
|
||||
|
||||
void HandleCursorMovement();
|
||||
void HandleAutosave();
|
||||
|
@ -956,7 +957,8 @@ public:
|
|||
int m_AllowPlaceUnusedTiles;
|
||||
bool m_BrushDrawDestructive;
|
||||
|
||||
int m_Mentions;
|
||||
int m_Mentions = 0;
|
||||
bool m_IngameMoved = false;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue