コード例 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (_buffer != null)
                    {
                        _buffer.Dispose();
                    }
                    _buffer = null;
                }
                // Free your own state (unmanaged objects).
                // Set large fields to null.



                CleanupOldUndoFiles(true);
                disposed = true;
            }
        }
コード例 #2
0
        public void Undo()
        {
            if (_currentIndex <= 0)
                return;

            _currentIndex--;

            UndoBuffer redo = new UndoBuffer(string.Format(RedoFile, _currentIndex));

            using (var stream = new FileStream(string.Format(UndoFile, _currentIndex), FileMode.Open))
            using (BinaryReader br = new BinaryReader(stream))
            {
                foreach (var undoTile in UndoBuffer.ReadUndoTilesFromStream(br))
                {

                    var curTile = (Tile)_wvm.CurrentWorld.Tiles[undoTile.Location.X, undoTile.Location.Y];
                    redo.Add(undoTile.Location, curTile);

                    if (Tile.IsChest(curTile.Type))
                    {
                        var curchest = _wvm.CurrentWorld.GetChestAtTile(undoTile.Location.X, undoTile.Location.Y);
                        if (curchest != null)
                        {
                            _wvm.CurrentWorld.Chests.Remove(curchest);
                            var chest = curchest.Copy();
                            redo.Chests.Add(chest);
                        }
                    }
                    if (Tile.IsSign(curTile.Type))
                    {
                        var cursign = _wvm.CurrentWorld.GetSignAtTile(undoTile.Location.X, undoTile.Location.Y);
                        if (cursign != null)
                        {
                            _wvm.CurrentWorld.Signs.Remove(cursign);
                            var sign = cursign.Copy();
                            redo.Signs.Add(sign);
                        }
                    }
                    _wvm.CurrentWorld.Tiles[undoTile.Location.X, undoTile.Location.Y] = (Tile)undoTile.Tile;
                    _wvm.UpdateRenderPixel(undoTile.Location);

                    /* Heathtech */
                    BlendRules.ResetUVCache(_wvm, undoTile.Location.X, undoTile.Location.Y, 1, 1);
                }

                redo.Close();
                redo.Dispose();
                redo = null;

                foreach (var chest in World.LoadChestData(br))
                {
                    _wvm.CurrentWorld.Chests.Add(chest);
                }
                foreach (var sign in World.LoadSignData(br))
                {
                    _wvm.CurrentWorld.Signs.Add(sign);
                }
            }

            OnUndid(this, EventArgs.Empty);
        }
コード例 #3
0
        public void Undo()
        {
            if (_currentIndex <= 0)
            {
                return;
            }

            _currentIndex--;

            UndoBuffer redo = new UndoBuffer(string.Format(RedoFile, _currentIndex));

            using (var stream = new FileStream(string.Format(UndoFile, _currentIndex), FileMode.Open))
                using (BinaryReader br = new BinaryReader(stream))
                {
                    foreach (var undoTile in UndoBuffer.ReadUndoTilesFromStream(br))
                    {
                        var curTile = (Tile)_wvm.CurrentWorld.Tiles[undoTile.Location.X, undoTile.Location.Y];
                        redo.Add(undoTile.Location, curTile);

                        if (Tile.IsChest(curTile.Type))
                        {
                            var curchest = _wvm.CurrentWorld.GetChestAtTile(undoTile.Location.X, undoTile.Location.Y);
                            if (curchest != null)
                            {
                                _wvm.CurrentWorld.Chests.Remove(curchest);
                                var chest = curchest.Copy();
                                redo.Chests.Add(chest);
                            }
                        }
                        if (Tile.IsSign(curTile.Type))
                        {
                            var cursign = _wvm.CurrentWorld.GetSignAtTile(undoTile.Location.X, undoTile.Location.Y);
                            if (cursign != null)
                            {
                                _wvm.CurrentWorld.Signs.Remove(cursign);
                                var sign = cursign.Copy();
                                redo.Signs.Add(sign);
                            }
                        }
                        _wvm.CurrentWorld.Tiles[undoTile.Location.X, undoTile.Location.Y] = (Tile)undoTile.Tile;
                        _wvm.UpdateRenderPixel(undoTile.Location);

                        /* Heathtech */
                        BlendRules.ResetUVCache(_wvm, undoTile.Location.X, undoTile.Location.Y, 1, 1);
                    }

                    redo.Close();
                    redo.Dispose();
                    redo = null;

                    foreach (var chest in World.LoadChestData(br))
                    {
                        _wvm.CurrentWorld.Chests.Add(chest);
                    }
                    foreach (var sign in World.LoadSignData(br))
                    {
                        _wvm.CurrentWorld.Signs.Add(sign);
                    }
                }

            OnUndid(this, EventArgs.Empty);
        }