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; }
public DotaObjectDocument(DotaDataObject RootObject) : base() { DotaObject = RootObject; Source = DotaObject.ObjectInfo.FromVPK ? DocumentSource.VPK : DocumentSource.File; Path = DotaObject.ObjectInfo.OriginatingFile; Name = RootObject.ClassName; }
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; } }
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; }
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); }
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(); }
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. } }
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); }
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); }
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! } }
private void OpenTextEditor(DotaDataObject ddo) { var doc = OpenDocument(ddo); (doc as DotaObjectDocument).OpenTextEditor(); }
private void OpenObjectEditor(DotaDataObject ddo) { var doc = OpenDocument(ddo); doc.OpenDefaultEditor(); }