Show dialogue only when there are unsaved changes
This commit is contained in:
committed by
abcdefg30
parent
780982dbe2
commit
d2819dca77
@@ -29,6 +29,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
int nextId;
|
||||
|
||||
public bool Modified;
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
Add(new OpenMapAction());
|
||||
@@ -36,6 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Add(IEditorAction editorAction)
|
||||
{
|
||||
Modified = true;
|
||||
editorAction.Execute();
|
||||
|
||||
if (undoStack.Count > 0)
|
||||
@@ -55,6 +58,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!HasUndos())
|
||||
return;
|
||||
|
||||
Modified = true;
|
||||
|
||||
var editorAction = undoStack.Pop();
|
||||
undoStack.Peek().Status = EditorActionStatus.Active;
|
||||
editorAction.Action.Undo();
|
||||
@@ -81,6 +86,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!HasRedos())
|
||||
return;
|
||||
|
||||
Modified = true;
|
||||
|
||||
var editorAction = redoStack.Pop();
|
||||
|
||||
editorAction.Status = EditorActionStatus.Active;
|
||||
@@ -114,6 +121,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
while (undoStack.Peek().Id != id)
|
||||
Redo();
|
||||
}
|
||||
|
||||
public bool HasUnsavedItems()
|
||||
{
|
||||
// Modified and last action isn't the OpenMapAction (+ no redos)
|
||||
return Modified && !(undoStack.Peek().Action is OpenMapAction && !HasRedos());
|
||||
}
|
||||
}
|
||||
|
||||
public enum EditorActionStatus
|
||||
|
||||
Reference in New Issue
Block a user