private string getString(GameData.Instance inst) { if (!inst.ContainsKey("ref")) { return(""); } string item = inst.sdata["ref"]; GameData.Item item1 = this.Source.getItem(item); if (item1 == null) { return(item); } return(item1.Name); }
public void showItemInstance(GameData.Item parent, string id, itemType mask = itemType.ITEM) { GameData.Instance instance = parent.getInstance(id); if (navigation.instForms.ContainsKey(instance)) { navigation.instForms[instance].BringToFront(); return; } InstanceDialog instanceDialog = new InstanceDialog(parent, id, mask, this); instanceDialog.FormClosed += new FormClosedEventHandler(this.instForm_FormClosed); navigation.instForms.Add(instance, instanceDialog); instanceDialog.MdiParent = base.MdiParent; instanceDialog.Show(); }
private static void parseItem(StreamReader r, List <itemType> types) { itemType _itemType; float[] singleArray; float[] singleArray1; string str = "General"; while (!r.EndOfStream && r.Peek() != 91) { string str1 = Definitions.readLine(r); int num = str1.IndexOf("//"); if (num >= 0) { str1 = str1.Remove(num); } str1 = str1.Trim(); if (str1.Length == 0 || Definitions.parseEnum(r, str1) || Definitions.parseCondition(str1, types)) { continue; } string[] strArrays = str1.Split(new char[] { ':' }, 2); if ((int)strArrays.Length != 2) { Definitions.error(string.Concat("Invalid line ", str1)); } else if (strArrays[1].Length != 0) { GameData.Desc desc = new GameData.Desc(); List <string> strs = Definitions.tokenise(strArrays[1], 999); string str2 = strArrays[0].Trim(); if (strs.Count > 1 && strs[strs.Count - 1][0] == '\"') { desc.description = Definitions.stripQuotes(strs[strs.Count - 1]).Replace("\\n", "\n"); } desc.category = str; if (strs[0] == "null") { desc.defaultValue = null; } else if (strs[0] == "TEXTURE_DDS") { desc.defaultValue = new GameData.File(""); desc.mask = "Nvidia dds| *.dds"; } else if (strs[0] == "TEXTURE_ANY") { desc.defaultValue = new GameData.File(""); desc.mask = "Nvidia dds|*.dds|tga|*.tga|jpg|*.jpg|png|*.png|bmp|*.bmp"; } else if (strs[0].Contains("*.") || strs[0].Contains("|")) { desc.defaultValue = new GameData.File(""); desc.mask = Definitions.stripQuotes(strs[0]); } else if (strs[0] != "multiline") { object obj = Definitions.parseValue(strs[0]); object obj1 = obj; desc.defaultValue = obj; if (obj1 == null) { if (!Enum.TryParse <itemType>(strs[0], out _itemType)) { Definitions.error(string.Concat("Invalid type ", strs[0])); continue; } else { if (strs.Count > 1) { singleArray = Definitions.parseVector(strs[1]); } else { singleArray = null; } float[] singleArray2 = singleArray; if (strs.Count > 2) { singleArray1 = Definitions.parseVector(strs[2]); } else { singleArray1 = null; } float[] singleArray3 = singleArray1; if (singleArray2 == null || singleArray3 == null) { GameData.TripleInt tripleInt = new GameData.TripleInt(0, 0, 0); if (singleArray2 != null) { if (singleArray2.Length != 0) { tripleInt.v0 = (int)singleArray2[0]; } if ((int)singleArray2.Length > 1) { tripleInt.v1 = (int)singleArray2[1]; } if ((int)singleArray2.Length > 2) { tripleInt.v2 = (int)singleArray2[2]; } desc.flags = (int)singleArray2.Length; } desc.list = _itemType; desc.defaultValue = tripleInt; } else if ((int)singleArray2.Length != 3 || (int)singleArray3.Length != 4) { Definitions.error("Invalid instance values"); continue; } else { GameData.Instance instance = new GameData.Instance(); instance["x"] = singleArray2[0]; instance["y"] = singleArray2[1]; instance["z"] = singleArray2[2]; instance["qx"] = singleArray3[0]; instance["qy"] = singleArray3[1]; instance["qz"] = singleArray3[2]; instance["qw"] = singleArray3[3]; desc.list = _itemType; desc.defaultValue = instance; } } } } else { desc.defaultValue = ""; } if (desc.defaultValue is string && strs.Contains("multiline")) { desc.flags |= 16; } if ((desc.defaultValue is EnumValue || desc.GetType().IsEnum) && strs.Contains("bitset")) { desc.flags |= 256; } if (strs.Contains("looped")) { desc.limit = 9999; } foreach (itemType type in types) { GameData.Desc desc1 = new GameData.Desc() { category = desc.category, condition = GameData.getDesc(type, str2).condition, defaultValue = desc.defaultValue, description = desc.description, flags = desc.flags, limit = desc.limit, list = desc.list, mask = desc.mask }; GameData.setDesc(type, str2, desc1); } } else { str = strArrays[0].Trim(); } } }
private void mergeButton_Click(object sender, EventArgs e) { string str; GameData.TripleInt referenceValue; int num = 0; this.Cursor = Cursors.WaitCursor; foreach (ChangeListTree.TreeNode node in this.tree.Nodes) { if (!node.Checked) { continue; } GameData.Item item = this.tree.GetItem(node); GameData.Item newValue = this.gameData.getItem(item.stringID); if (item.getState() == GameData.State.OWNED || newValue == null) { this.gameData.items.Add(item.stringID, item); item.resolveReferences(this.gameData); item.changeOwner(this.gameData.activeFileName); num++; } else if (item.getState() != GameData.State.REMOVED) { foreach (ChangeListTree.TreeNode child in node.Children) { if (!child.Checked) { continue; } ChangeListTree.ChangeData changeDatum = child as ChangeListTree.ChangeData; switch (changeDatum.Type) { case ChangeListTree.ChangeType.NAME: { newValue.Name = changeDatum.NewValue.ToString(); break; } case ChangeListTree.ChangeType.VALUE: { newValue[changeDatum.Key] = changeDatum.NewValue; break; } case ChangeListTree.ChangeType.NEWREF: case ChangeListTree.ChangeType.INVALIDREF: { referenceValue = item.getReferenceValue(changeDatum.Section, changeDatum.Key); newValue.addReference(changeDatum.Section, changeDatum.Key, new int?(referenceValue.v0), new int?(referenceValue.v1), new int?(referenceValue.v2)); break; } case ChangeListTree.ChangeType.MODREF: { referenceValue = item.getReferenceValue(changeDatum.Section, changeDatum.Key); newValue.setReferenceValue(changeDatum.Section, changeDatum.Key, referenceValue); break; } case ChangeListTree.ChangeType.DELREF: { newValue.removeReference(changeDatum.Section, changeDatum.Key); break; } case ChangeListTree.ChangeType.NEWINST: { GameData.Instance instance = item.getInstance(changeDatum.Key); GameData.Instance instance1 = newValue.addInstance(changeDatum.Key, instance); using (IEnumerator <KeyValuePair <string, GameData.TripleInt> > enumerator = instance.referenceData("states", false).GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, GameData.TripleInt> current = enumerator.Current; int?nullable = null; int?nullable1 = nullable; nullable = null; int?nullable2 = nullable; nullable = null; instance1.addReference("states", current.Key, nullable1, nullable2, nullable); } break; } break; } case ChangeListTree.ChangeType.MODINST: { if (item.getInstance(changeDatum.Key).getState() != GameData.State.REMOVED) { foreach (ChangeListTree.TreeNode treeNode in child.Children) { if (!treeNode.Checked) { continue; } ChangeListTree.ChangeData changeDatum1 = treeNode as ChangeListTree.ChangeData; if (changeDatum1.Type != ChangeListTree.ChangeType.INSTVALUE) { continue; } newValue.getInstance(changeDatum1.Section)[changeDatum1.Key] = changeDatum1.NewValue; num++; } num--; break; } else { newValue.removeInstance(changeDatum.Key); break; } } case ChangeListTree.ChangeType.INSTVALUE: { newValue.getInstance(changeDatum.Section)[changeDatum.Key] = changeDatum.NewValue; break; } } num++; } } else { if (newValue == null) { continue; } this.gameData.deleteItem(newValue); num++; } } foreach (ChangeListTree.TreeNode node1 in this.tree.Nodes) { if (!node1.Checked) { continue; } GameData.Item item1 = this.gameData.getItem(this.tree.GetItem(node1).stringID); if (item1 == null) { continue; } item1.resolveReferences(this.gameData); } if (num != 0) { str = (num != 1 ? string.Concat(num, " changes merged") : "1 change merged"); } else { str = "No changes detected"; } if (this.leveldata.Checked) { string str1 = string.Concat(Directory.GetParent(this.currentMod), "/leveldata"); string str2 = string.Concat(MergeDialog.nav.ModPath, "leveldata"); if (MergeDialog.nav.ModPath == MergeDialog.nav.BasePath) { str2 = string.Concat(MergeDialog.nav.ModPath, "/newland/leveldata/"); if (!MergeDialog.nav.ActiveFile.EndsWith("gamedata.base")) { FileInfo fileInfo = new FileInfo(MergeDialog.nav.ActiveFile); str2 = string.Concat(str2, fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length)); } } string str3 = MergeDialog.mergeLevelData(str1, str2); if (str3.Length > 0) { str = string.Concat(str, "\n\n", str3); } } this.Cursor = Cursors.Default; MessageBox.Show(str, "合并", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }