Ejemplo n.º 1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode == _lastSkin ||
                !(e.Node is Skin))
                return;

            Renderer.MakeCurrent();

            if (_lastSkin != null && treeView1.SelectedNode != _lastSkin)
            {
                // Copy over the current changes to the tex stored in the skin.
                // This allows us to pick up where we left off later, without undoing any work.
                _lastSkin.CommitChanges(GlobalDirtiness.CurrentSkin, false);

                // if we aren't dirty, unload
                if (!_lastSkin.Dirty)
                    _lastSkin.Unload();
            }

            //if (_lastSkin != null)
            //	_lastSkin.Undo.Clear();

            var skin = (Skin) treeView1.SelectedNode;
            SetCanSave(skin.Dirty);

            if (skin.GLImage == null)
                skin.Create();

            if (skin == null)
            {
                _currentUndoBuffer = null;
                TextureGL.Unbind();

                using (var currentSkin = new ColorGrabber(GlobalDirtiness.CurrentSkin, 64, 32))
                    currentSkin.Save();

                undoToolStripMenuItem.Enabled = undoToolStripButton.Enabled = false;
                redoToolStripMenuItem.Enabled = redoToolStripButton.Enabled = false;
            }
            else
            {
                using (var glImage = new ColorGrabber(skin.GLImage, skin.Width, skin.Height))
                {
                    glImage.Load();

                    glImage.Texture = GlobalDirtiness.CurrentSkin;
                    glImage.Save();
                    glImage.Texture = _previewPaint;
                    glImage.Save();
                }

                _currentUndoBuffer = skin.Undo;
                CheckUndo();
            }

            _lastSkin = (Skin) treeView1.SelectedNode;

            SetModel(skin.Model);
            Renderer.Invalidate();

            VerifySelectionButtons();
            FillPartList();
        }
Ejemplo n.º 2
0
 public Skin(string fileName)
 {
     Undo = new UndoBuffer(this);
     Name = Path.GetFileNameWithoutExtension(fileName);
 }