public Dialog_RenamePackage(DefPackage renamingPackage) { this.renamingPackage = renamingPackage; this.proposedName = renamingPackage.fileName; this.doCloseX = true; this.forcePause = true; }
public void AddImpliedDef(Def def) { if (this.impliedDefPackage == null) { this.impliedDefPackage = new DefPackage("ImpliedDefs", string.Empty); this.defPackages.Add(this.impliedDefPackage); } this.impliedDefPackage.AddDef(def); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: if (this.defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405, false); } enumerator = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").GetEnumerator(); num = 4294967293u; break; case 1u: break; default: return(false); } try { switch (num) { } if (enumerator.MoveNext()) { asset = enumerator.Current; defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); base.AddDefPackage(defPackage); asset.defPackage = defPackage; this.$current = asset; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } this.$PC = -1; return(false); }
public void AddImpliedDef(Def def) { if (impliedDefPackage == null) { impliedDefPackage = new DefPackage("ImpliedDefs", string.Empty); defPackages.Add(impliedDefPackage); } impliedDefPackage.AddDef(def); }
public IEnumerable <LoadableXmlAsset> LoadDefs() { if (this.defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405, false); } foreach (LoadableXmlAsset asset in DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/")) { DefPackage defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); this.AddDefPackage(defPackage); asset.defPackage = defPackage; yield return(asset); } }
public static void ParseAndProcessXML(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup) { XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes; for (int i = 0; i < childNodes.Count; i++) { if (childNodes[i].NodeType == XmlNodeType.Element) { LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(childNodes[i], null); XmlInheritance.TryRegister(childNodes[i], (loadableXmlAsset == null) ? null : loadableXmlAsset.mod); } } XmlInheritance.Resolve(); DefPackage defPackage = new DefPackage("(unknown)", "(unknown)"); ModContentPack modContentPack = LoadedModManager.runningMods.FirstOrDefault <ModContentPack>(); modContentPack.AddDefPackage(defPackage); IEnumerator enumerator = xmlDoc.DocumentElement.ChildNodes.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; XmlNode xmlNode = (XmlNode)obj; LoadableXmlAsset loadableXmlAsset2 = assetlookup.TryGetValue(xmlNode, null); DefPackage defPackage2 = (loadableXmlAsset2 == null) ? defPackage : loadableXmlAsset2.defPackage; Def def = DirectXmlLoader.DefFromNode(xmlNode, loadableXmlAsset2); if (def != null) { def.modContentPack = ((loadableXmlAsset2 == null) ? modContentPack : loadableXmlAsset2.mod); defPackage2.AddDef(def); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } }
public IEnumerable <LoadableXmlAsset> LoadDefs() { if (defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405); } using (IEnumerator <LoadableXmlAsset> enumerator = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").GetEnumerator()) { if (enumerator.MoveNext()) { LoadableXmlAsset asset = enumerator.Current; DefPackage defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); AddDefPackage(defPackage); asset.defPackage = defPackage; yield return(asset); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0131: /*Error near IL_0132: Unexpected return in MoveNext()*/; }
public void LoadDefs(IEnumerable <PatchOperation> patches) { DeepProfiler.Start("Loading all defs"); List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").ToList <LoadableXmlAsset>(); foreach (LoadableXmlAsset current in list) { foreach (PatchOperation current2 in patches) { current2.Apply(current.xmlDoc); } } for (int i = 0; i < list.Count; i++) { if (list[i] == null || list[i].xmlDoc == null || list[i].xmlDoc.DocumentElement == null) { Log.Error(string.Format("{0}: unknown parse failure", list[i].fullFolderPath + "/" + list[i].name)); } else if (list[i].xmlDoc.DocumentElement.Name != "Defs") { Log.Error(string.Format("{0}: root element named {1}; should be named Defs", list[i].fullFolderPath + "/" + list[i].name, list[i].xmlDoc.DocumentElement.Name)); } XmlInheritance.TryRegisterAllFrom(list[i], this); } XmlInheritance.Resolve(); for (int j = 0; j < list.Count; j++) { string relFolder = GenFilePaths.FolderPathRelativeToDefsFolder(list[j].fullFolderPath, this); DefPackage defPackage = new DefPackage(list[j].name, relFolder); foreach (Def current3 in DirectXmlLoader.AllDefsFromAsset(list[j])) { defPackage.defs.Add(current3); } this.defPackages.Add(defPackage); } DeepProfiler.End(); }
public override void DoWindowContents(Rect selectorInner) { Profiler.BeginSample("PackageEditorOnGUI"); Text.Font = GameFont.Tiny; float width = (selectorInner.width - 4f) / 2f; Rect rect = new Rect(0f, 0f, width, 24f); string str = this.curMod.ToString(); if (Widgets.ButtonText(rect, "Editing: " + str, true, false, true)) { Messages.Message("Mod changing not implemented - it's always Core for now.", MessageTypeDefOf.RejectInput, false); } TooltipHandler.TipRegion(rect, "Change the mod being edited."); Rect rect2 = new Rect(rect.xMax + 4f, 0f, width, 24f); string label = "No package loaded"; if (this.curPackage != null) { label = this.curPackage.fileName; } if (Widgets.ButtonText(rect2, label, true, false, true)) { Find.WindowStack.Add(new Dialog_PackageSelector(delegate(DefPackage pack) { if (pack != this.curPackage) { this.curPackage = pack; } }, this.curMod, this.relFolder)); } TooltipHandler.TipRegion(rect2, "Open a Def package for editing."); WidgetRow widgetRow = new WidgetRow(0f, 28f, UIDirection.RightThenUp, 99999f, 4f); if (widgetRow.ButtonIcon(TexButton.NewFile, "Create a new Def package.", null)) { string name = DefPackage.UnusedPackageName(this.relFolder, this.curMod); DefPackage defPackage = new DefPackage(name, this.relFolder); this.curMod.AddDefPackage(defPackage); this.curPackage = defPackage; } if (this.curPackage != null) { if (widgetRow.ButtonIcon(TexButton.Save, "Save the current Def package.", null)) { this.curPackage.SaveIn(this.curMod); } if (widgetRow.ButtonIcon(TexButton.RenameDev, "Rename the current Def package.", null)) { Find.WindowStack.Add(new Dialog_RenamePackage(this.curPackage)); } } float num = 56f; Rect rect3 = new Rect(0f, num, selectorInner.width, selectorInner.height - num); Rect rect4 = new Rect(0f, 0f, rect3.width - 16f, this.viewHeight); Widgets.DrawMenuSection(rect3); Widgets.BeginScrollView(rect3, ref this.scrollPosition, rect4, true); Rect rect5 = rect4.ContractedBy(4f); rect5.height = 9999f; Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(rect5); Text.Font = GameFont.Tiny; if (this.curPackage == null) { listing_Standard.Label("(no package open)", -1f, null); } else { if (this.curPackage.defs.Count == 0) { listing_Standard.Label("(package is empty)", -1f, null); } else { Def deletingDef = null; using (List <Def> .Enumerator enumerator = this.curPackage.GetEnumerator()) { while (enumerator.MoveNext()) { Def def = enumerator.Current; if (listing_Standard.SelectableDef(def.defName, false, delegate { deletingDef = def; })) { bool flag = false; WindowStack windowStack = Find.WindowStack; for (int i = 0; i < windowStack.Count; i++) { EditWindow_DefEditor editWindow_DefEditor = windowStack[i] as EditWindow_DefEditor; if (editWindow_DefEditor != null && editWindow_DefEditor.def == def) { flag = true; } } if (!flag) { Find.WindowStack.Add(new EditWindow_DefEditor(def)); } } } } if (deletingDef != null) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("Really delete Def " + deletingDef.defName + "?", delegate { this.curPackage.RemoveDef(deletingDef); }, true, null)); } } if (listing_Standard.ButtonImage(TexButton.Add, 24f, 24f)) { Def def2 = Activator.CreateInstance <TNewDef>(); def2.defName = "New" + typeof(TNewDef).Name; this.curPackage.AddDef(def2); } } if (Event.current.type == EventType.Layout) { this.viewHeight = listing_Standard.CurHeight; } listing_Standard.End(); Widgets.EndScrollView(); Profiler.EndSample(); }
public void AddDefPackage(DefPackage defPackage) { this.defPackages.Add(defPackage); }
private static IEnumerable <Def> < get_AllDefs > m__0(DefPackage x) { return(x.defs); }