private void UnitListBox_Click(object sender, EventArgs e) { if (UnitListBox.SelectedItems.Count == 1) { SimUnitXML unit = ((UISimObjectItem)UnitListBox.SelectedItems[0]).mUnitXML; if (unit != null) { IUnitPicker pickerInterface = CoreGlobals.getEditorMain().mIGUI.getActiveClientPage() as IUnitPicker; if (pickerInterface != null) { pickerInterface.UnitSelectedChanged(unit); } } } }
private void UnitTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag != null) { SimUnitXML unit = e.Node.Tag as SimUnitXML; if (unit != null) { IUnitPicker pickerInterface = CoreGlobals.getEditorMain().mIGUI.getActiveClientPage() as IUnitPicker; if (pickerInterface != null) { pickerInterface.UnitSelectedChanged(unit); } } } }
public UISimObjectItem(SimUnitXML unit) { mUnitXML = unit; }
private void AddViaAnimButton_Click(object sender, EventArgs e) { try { string filename = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, "xobjects.xml"); if (File.GetAttributes(filename) == FileAttributes.ReadOnly) { MessageBox.Show(filename + " is readonly. please check it out"); } if (NodeComboBox.SelectedItem == null) { return; } UnitHolder copyholder = NodeComboBox.SelectedItem as UnitHolder; if (copyholder == null) { return; } OpenFileDialog d = new OpenFileDialog(); d.Filter = "AnimXML (*.xml)|*.xml"; d.FilterIndex = 0; d.InitialDirectory = CoreGlobals.getSaveLoadPaths().mGameArtDirectory; if (d.ShowDialog() == DialogResult.OK) { //Validate xml List <string> models = SimUnitXML.getGrannyFileNames(d.FileName); if (models.Count == 0) { if (MessageBox.Show(String.Format("No models found in {0} add anyway?", d.FileName), "", MessageBoxButtons.YesNo) == DialogResult.Yes) { } else { return; } } string name = Path.GetFileNameWithoutExtension(d.FileName); //check for duplicates foreach (UnitHolder holder in this.NodeComboBox.Items) { if (holder.mName == name) { MessageBox.Show(name + " has already been added to xobjects"); return; } } mHightestID++; int id = mHightestID; string artpath = CoreGlobals.getWorkPaths().mGameArtDirectory + "\\"; string animFileName = d.FileName.Substring(artpath.Length); //BuildNode XmlNode unit = copyholder.mNode.Clone(); XmlAttribute nameAttr = (XmlAttribute)unit.Attributes.GetNamedItem("name"); nameAttr.Value = name; XmlAttribute idAttr = (XmlAttribute)unit.Attributes.GetNamedItem("id"); idAttr.Value = id.ToString(); XmlNode animFile = ((XmlElement)unit).GetElementsByTagName("Visual")[0]; animFile.InnerText = animFileName; //Add to File XmlNode protoNode = doc.GetElementsByTagName("Proto")[0]; protoNode.AppendChild(unit); doc.Save(filename); CoreGlobals.getSaveLoadPaths().mGameArtDirectory = Path.GetDirectoryName(d.FileName); listBox1.Items.Add(String.Format("Added: {0}", name)); this.NodeComboBox.Items.Add(new UnitHolder(name, unit)); foreach (string modelname in models) { listBox1.Items.Add(String.Format(" Model: {0}", modelname)); } } } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); } }