From a031ec343a159e80e9b01d67b38567af64266a75 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 19 Jan 2014 18:06:56 +0100 Subject: [PATCH] Editor Undo: Fix some issues --- src/game/editor/editor.cpp | 31 +++++++++++++++++++++++++++---- src/game/editor/editor.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b67a16665..8ae036f63 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -141,7 +141,6 @@ void CLayerGroup::Render() void CLayerGroup::AddLayer(CLayer *l) { m_pMap->m_Modified = true; - m_pMap->m_UndoModified++; m_lLayers.add(l); } @@ -1219,6 +1218,8 @@ void CEditor::DoQuad(CQuad *q, int Index) { if(!UI()->MouseButton(1)) { + m_Map.m_UndoModified++; + static int s_QuadPopupID = 0; UiInvokePopupMenu(&s_QuadPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupQuad); m_LockMouse = false; @@ -1230,6 +1231,11 @@ void CEditor::DoQuad(CQuad *q, int Index) { if(!UI()->MouseButton(0)) { + if(s_Operation == OP_ROTATE || s_Operation == OP_MOVE_ALL || s_Operation == OP_MOVE_PIVOT) + { + m_Map.m_UndoModified++; + } + m_LockMouse = false; s_Operation = OP_NONE; UI()->SetActiveItem(0); @@ -1393,6 +1399,8 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) { if(!UI()->MouseButton(1)) { + m_Map.m_UndoModified++; + static int s_PointPopupID = 0; UiInvokePopupMenu(&s_PointPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 150, PopupPoint); UI()->SetActiveItem(0); @@ -1409,6 +1417,10 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) else m_SelectedPoints = 1<SetActiveItem(0); } @@ -2068,7 +2080,9 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) // release mouse if(!UI()->MouseButton(0)) { - m_Map.m_UndoModified++; + if(s_Operation == OP_BRUSH_DRAW || s_Operation == OP_BRUSH_PAINT) + m_Map.m_UndoModified++; + s_Operation = OP_NONE; UI()->SetActiveItem(0); } @@ -3652,11 +3666,13 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); } + if (m_SelectedEnvelopePoint != i) + m_Map.m_UndoModified++; + m_SelectedQuadEnvelope = m_SelectedEnvelope; m_ShowEnvelopePreview = 1; m_SelectedEnvelopePoint = i; m_Map.m_Modified = true; - m_Map.m_UndoModified++; } ColorMod = 100.0f; @@ -4060,6 +4076,7 @@ void CEditor::Reset(bool CreateDefault) m_Map.m_Modified = false; m_Map.m_UndoModified = 0; m_LastUndoUpdateTime = time_get(); + m_UndoRunning = false; m_ShowEnvelopePreview = 0; } @@ -4269,6 +4286,7 @@ void CEditor::CreateUndoStepThread(void *pUser) pEditor->Save(aBuffer); pEditor->m_lUndoSteps.add(NewStep); + pEditor->m_UndoRunning = false; } void CEditor::UpdateAndRender() @@ -4341,7 +4359,12 @@ void CEditor::UpdateAndRender() { m_Map.m_UndoModified = 0; m_LastUndoUpdateTime = time_get(); - CreateUndoStep(); + + if (!m_UndoRunning) + { + m_UndoRunning = true; + CreateUndoStep(); + } } Render(); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index a6519c7c6..91dc7a179 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -618,6 +618,7 @@ public: virtual bool HasUnsavedData() { return m_Map.m_Modified; } int64 m_LastUndoUpdateTime; + bool m_UndoRunning; void CreateUndoStep(); static void CreateUndoStepThread(void *pUser); int UndoStep();