示例#1
0
        public void Add(IAction action)
        {
            if(action.GetType() == typeof(SelectionAction) && firstSelectionAction == null)
                firstSelectionAction = (SelectionAction)action;
            else if (action.GetType() == typeof(BiomeAction) && firstBiomeAction == null)
                firstBiomeAction = (BiomeAction)action;
            else if (action.GetType() == typeof(PopulateAction) && firstPopulateAction == null)
                firstPopulateAction = (PopulateAction)action;

            //ensure the first action of each type isn't lost when the redo stack is emptied
            if(firstSelectionAction != null && action != firstSelectionAction && redoStack.Contains(firstSelectionAction))
            {
                redoStack.Remove(firstSelectionAction);
                undoStack.AddLast(firstSelectionAction);
            }
            if (firstBiomeAction != null && action != firstBiomeAction && redoStack.Contains(firstBiomeAction))
            {
                redoStack.Remove(firstBiomeAction);
                undoStack.AddLast(firstBiomeAction);
            }
            if (firstPopulateAction != null && action != firstPopulateAction && redoStack.Contains(firstPopulateAction))
            {
                redoStack.Remove(firstPopulateAction);
                undoStack.AddLast(firstPopulateAction);
            }

            action.PreviousAction = GetPreviousAction(undoStack.Last, action.GetType());
            undoStack.AddLast(action);
            foreach (IAction a in redoStack)
                a.Dispose();
            redoStack.Clear();
        }
示例#2
0
        public void FilterOutType(Type type)
        {
            LinkedList <IAction> newUndo = new LinkedList <IAction>();

            foreach (IAction action in undoStack)
            {
                if (type.Equals(action.GetType()))
                {
                    action.Dispose();
                }
                else
                {
                    newUndo.AddLast(action);
                }
            }

            undoStack = newUndo;

            LinkedList <IAction> newRedo = new LinkedList <IAction>();

            foreach (IAction action in redoStack)
            {
                if (type.Equals(action.GetType()))
                {
                    action.Dispose();
                }
                else
                {
                    newRedo.AddLast(action);
                }
            }

            if (firstBiomeAction != null && type == typeof(BiomeAction))
            {
                firstBiomeAction = null;
            }
            if (firstPopulateAction != null && type == typeof(PopulateAction))
            {
                firstPopulateAction = null;
            }
            if (firstSelectionAction != null && type == typeof(SelectionAction))
            {
                firstSelectionAction = null;
            }

            redoStack = newRedo;
        }
示例#3
0
        private void ApplyPopulateState(PopulateAction action, RegionFile region, Bitmap populateOverlay)
        {
            for (int chunkX = 0; chunkX < 32; chunkX++)
            {
                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    Chunk c = region.Chunks[chunkX, chunkZ];
                    if (c == null || c.Root == null)
                    {
                        continue;
                    }

                    ((TAG_Byte)c.Root["Level"]["TerrainPopulated"]).Payload = action.PopulatedFlags[chunkX, chunkZ];
                }
            }
            RegionUtil.RenderRegionChunkstobePopulated(region, populateOverlay);
        }
示例#4
0
        public void RecordPopulateState(RegionFile region, String description)
        {
            PopulateAction action = new PopulateAction(description);

            for (int chunkX = 0; chunkX < 32; chunkX++)
            {
                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    Chunk c = region.Chunks[chunkX, chunkZ];
                    if (c == null || c.Root == null)
                    {
                        continue;
                    }

                    action.PopulatedFlags[chunkX, chunkZ] = (byte)c.Root["Level"]["TerrainPopulated"];
                }
            }
            Add(action);
            OnChange();
        }
示例#5
0
        public void Add(IAction action)
        {
            if (action.GetType() == typeof(SelectionAction) && firstSelectionAction == null)
            {
                firstSelectionAction = (SelectionAction)action;
            }
            else if (action.GetType() == typeof(BiomeAction) && firstBiomeAction == null)
            {
                firstBiomeAction = (BiomeAction)action;
            }
            else if (action.GetType() == typeof(PopulateAction) && firstPopulateAction == null)
            {
                firstPopulateAction = (PopulateAction)action;
            }

            //ensure the first action of each type isn't lost when the redo stack is emptied
            if (firstSelectionAction != null && action != firstSelectionAction && redoStack.Contains(firstSelectionAction))
            {
                redoStack.Remove(firstSelectionAction);
                undoStack.AddLast(firstSelectionAction);
            }
            if (firstBiomeAction != null && action != firstBiomeAction && redoStack.Contains(firstBiomeAction))
            {
                redoStack.Remove(firstBiomeAction);
                undoStack.AddLast(firstBiomeAction);
            }
            if (firstPopulateAction != null && action != firstPopulateAction && redoStack.Contains(firstPopulateAction))
            {
                redoStack.Remove(firstPopulateAction);
                undoStack.AddLast(firstPopulateAction);
            }

            action.PreviousAction = GetPreviousAction(undoStack.Last, action.GetType());
            undoStack.AddLast(action);
            foreach (IAction a in redoStack)
            {
                a.Dispose();
            }
            redoStack.Clear();
        }
示例#6
0
        public void FilterOutType(Type type)
        {
            LinkedList<IAction> newUndo = new LinkedList<IAction>();

            foreach (IAction action in undoStack)
            {
                if (type.Equals(action.GetType()))
                    action.Dispose();
                else
                    newUndo.AddLast(action);
            }

            undoStack = newUndo;

            LinkedList<IAction> newRedo = new LinkedList<IAction>();

            foreach (IAction action in redoStack)
            {
                if (type.Equals(action.GetType()))
                    action.Dispose();
                else
                    newRedo.AddLast(action);
            }

            if (firstBiomeAction != null && type == typeof(BiomeAction))
                firstBiomeAction = null;
            if (firstPopulateAction != null && type == typeof(PopulateAction))
                firstPopulateAction = null;
            if (firstSelectionAction != null && type == typeof(SelectionAction))
                firstSelectionAction = null;

            redoStack = newRedo;
        }
示例#7
0
        private void ApplyPopulateState(PopulateAction action, RegionFile region, Bitmap populateOverlay)
        {
            for (int chunkX = 0; chunkX < 32; chunkX++)
            {
                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    Chunk c = region.Chunks[chunkX, chunkZ];
                    if (c == null || c.Root == null)
                        continue;

                    ((TAG_Byte)c.Root["Level"]["TerrainPopulated"]).Payload = action.PopulatedFlags[chunkX, chunkZ];
                }
            }
            RegionUtil.RenderRegionChunkstobePopulated(region, populateOverlay);
        }
示例#8
0
 public void SetLastSaveActions()
 {
     lastBiomeAction = (BiomeAction)GetPreviousAction(undoStack.Last, typeof(BiomeAction));
     lastPopulateAction = (PopulateAction)GetPreviousAction(undoStack.Last, typeof(PopulateAction));
 }
示例#9
0
        public void RecordPopulateState(RegionFile region, String description)
        {
            PopulateAction action = new PopulateAction(description);
            for (int chunkX = 0; chunkX < 32; chunkX++)
            {
                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    Chunk c = region.Chunks[chunkX, chunkZ];
                    if (c == null || c.Root == null)
                        continue;

                    action.PopulatedFlags[chunkX, chunkZ] = (byte)c.Root["Level"]["TerrainPopulated"];
                }
            }
            Add(action);
            OnChange();
        }
示例#10
0
 public void SetLastSaveActions()
 {
     lastBiomeAction    = (BiomeAction)GetPreviousAction(undoStack.Last, typeof(BiomeAction));
     lastPopulateAction = (PopulateAction)GetPreviousAction(undoStack.Last, typeof(PopulateAction));
 }