예제 #1
0
        private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            TreeNode node = SelectedNode();

            if (node == null)
            {
                return;
            }

            DotaDataObject ddo = node.Tag as DotaDataObject;

            if (ddo == null) //We are a folder.  Disable all of the options
            {
                foreach (ToolStripItem item in contextMenuStrip.Items)
                {
                    item.Enabled = false;
                }

                return;
            }
            else
            { //We are not a folder, so lets enable everything then decide what to disable
                openAsTextToolStripMenuItem.Enabled = true;
                openToolStripMenuItem.Enabled       = true;
            }

            //Enable the delete option if not from the VPK.  Disable override if we are not default
            deleteToolStripMenuItem.Enabled   = !ddo.ObjectInfo.FromVPK;
            overrideToolStripMenuItem.Enabled = ddo.ObjectInfo.ObjectClass == DotaDataObject.DataObjectInfo.ObjectDataClass.Default;
        }
예제 #2
0
        public DotaObjectDocument(DotaDataObject RootObject)
            : base()
        {
            DotaObject = RootObject;

            Source = DotaObject.ObjectInfo.FromVPK ? DocumentSource.VPK : DocumentSource.File;
            Path   = DotaObject.ObjectInfo.OriginatingFile;

            Name = RootObject.ClassName;
        }
예제 #3
0
 public void NotifyDocumentSaved(IEditor source)
 {
     //If we are the source, don't do anything.  We already have the changes
     if (source != this)
     {
         DotaDataObject obj = EditingObject;
         //Force the property editor to clear out the data and redraw
         EditingObject = null;
         EditingObject = obj;
     }
 }
예제 #4
0
        public DotaObjectDocument(DotaDataObject RootObject)
            : base()
        {
            DotaObject = RootObject;

            //TODO: Some discovery if this object came from the VPK or from the addon.
            //For now, source it from the addon.  We'll fix this stuff later.
            Source = DocumentSource.File;
            Path   = ""; //Path here is empty.  Saving this document does 'nothing' as it will be serialized into the npc_units_custom.txt when the addon is
                         //put together
            Name = RootObject.ClassName;
        }
예제 #5
0
        private Document OpenDocument(DotaDataObject ddo)
        {
            Document doc = DocumentRegistry.GetDocumentFor(ddo);

            if (doc == null)
            {
                //If we don't have this document open, create it and add it to the registry
                doc = new DotaObjectDocument(ddo);
                DocumentRegistry.OpenDocument(ddo, doc);
            }

            return(doc);
        }
예제 #6
0
        private void OpenTextEditor(DotaDataObject ddo)
        {
            Document doc = DocumentRegistry.GetDocumentFor(ddo);

            if (doc == null)
            {
                //If we don't have this document open, create it and add it to the registry
                doc = new DotaObjectDocument(ddo);
                DocumentRegistry.OpenDocument(ddo, doc);
            }

            (doc as DotaObjectDocument).OpenTextEditor();
        }
예제 #7
0
        private void overrideToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = SelectedNode();

            if (node == null)
            {
                return;
            }
            DotaDataObject ddo = node.Tag as DotaDataObject;

            if (ddo == null)
            {
                return;              //It's a folder, we cant override this.
            }
        }
예제 #8
0
        private void openAsTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = SelectedNode();

            if (node == null)
            {
                return;
            }
            DotaDataObject ddo = node.Tag as DotaDataObject;

            if (ddo == null)
            {
                return;              //It's a folder!
            }
            OpenTextEditor(ddo);
        }
예제 #9
0
        private void assetTreeView_DoubleClick(object sender, EventArgs e)
        {
            if (assetTreeView.SelectedNode == null)
            {
                return;
            }

            TreeNode       SelectedNode = assetTreeView.SelectedNode;
            DotaDataObject ddo          = SelectedNode.Tag as DotaDataObject;

            if (ddo == null)
            {
                return;              //We selected a root node.  Don't do anything here
            }
            OpenObjectEditor(ddo);
        }
예제 #10
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = SelectedNode();

            if (node == null)
            {
                return;
            }
            DotaDataObject ddo = node.Tag as DotaDataObject;

            if (ddo == null)
            {
                return;              //It's a folder, we cant delete this.
            }
            if (ddo.ObjectInfo.ObjectClass == DotaDataObject.DataObjectInfo.ObjectDataClass.Default)
            {
                return;                                                                                      //Can't delete default objects
            }
            if (MessageBox.Show("Are you sure?  This cannot be undone", "Delete Object", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                //Get the document for this and close the editors
                Document doc = DocumentRegistry.GetDocumentFor(ddo);
                if (doc != null)
                {
                    doc.CloseAllEditors(false);
                }


                IList list = DotaData.FindListThatHasObject(ddo);
                list.Remove(ddo);

                //remove this node from the tree view
                node.Parent.Nodes.Remove(node);
                //And it's gone!
            }
        }
예제 #11
0
        private void OpenTextEditor(DotaDataObject ddo)
        {
            var doc = OpenDocument(ddo);

            (doc as DotaObjectDocument).OpenTextEditor();
        }
예제 #12
0
        private void OpenObjectEditor(DotaDataObject ddo)
        {
            var doc = OpenDocument(ddo);

            doc.OpenDefaultEditor();
        }