public BuildingsDialog(mode dialogMode, BuildingsPage page, int fieldID = -1) : this() { CurMode = dialogMode; ID = fieldID; CurPage = page; FillFields(); }
private void Table_building_Click(object sender, RoutedEventArgs e) { BuildingsPage p = new BuildingsPage(this) { Margin = new Thickness(0, 10, 0, 0) }; AddNewTab(p, "Корпуса"); }
public bool LoadData(string path, TabControl tabControl) { tabControl.TabPages.Clear(); Animals.Clear(); //try { SaveDocument = XDocument.Load(path); GameData = new GameData(SaveDocument.Root.XPathSelectElement("game/tickManager")); uniqueIdsManager = new UniqueIDsManager(SaveDocument.Root.XPathSelectElement("game/uniqueIDsManager")); var playerFactionDef = EvaluateSingle <XElement>("scenario/playerFaction/factionDef").Value; foreach (var element in SaveDocument.Root.XPathSelectElements("game/world/factionManager/allFactions/li")) { Faction faction = new Faction(element); if (faction.Def.Equals(playerFactionDef)) { PlayerFaction = faction; } Factions[faction.FactionIDString] = faction; PawnsByFactions[faction] = new List <Pawn>(); } //Console.WriteLine($"playerFaction:{playerFaction}, colonyFaction:{colonyFaction}"); Dictionary <String, List <PawnData> > pawnDataDir = new Dictionary <string, List <PawnData> >(); foreach (var pawnData in SaveDocument.Descendants("pawn")) { String key = pawnData.GetValue(); List <PawnData> pawnDataList; if (!pawnDataDir.TryGetValue(key, out pawnDataList)) { pawnDataList = new List <PawnData>(); pawnDataDir[key] = pawnDataList; } pawnDataList.Add(new PawnData(pawnData.Parent)); } foreach (var pawn in SaveDocument.Root.XPathSelectElements("game/world/worldPawns/pawnsAlive/li")) { Pawn p = new Pawn(pawn); if (p.Faction != null) { List <PawnData> pawnDataList; if (!pawnDataDir.TryGetValue(p.PawnId, out pawnDataList)) { pawnDataList = new List <PawnData>(); } p.addPawnData(pawnDataList); PawnsById[p.PawnId] = p; Faction faction = Factions[p.Faction]; PawnsByFactions[faction].Add(p); } } SaveThingsByClass = new Dictionary <string, List <SaveThing> >(); foreach (var thing in SaveDocument.Descendants("thing")) { if ((string)thing.Attribute("Class") == "Pawn") { Pawn p = new Pawn(thing); if (p.Faction != null) { List <PawnData> pawnDataList; if (!pawnDataDir.TryGetValue(p.PawnId, out pawnDataList)) { pawnDataList = new List <PawnData>(); } p.addPawnData(pawnDataList); PawnsById[p.PawnId] = p; Faction faction = Factions[p.Faction]; PawnsByFactions[faction].Add(p); } } else { SaveThing SaveThing = new SaveThing(thing); String key = SaveThing.Class; if (SaveThing.BaseThing != null && SaveThing.BaseThing.BaseName == "BuildingBase") { key = SaveThing.BaseThing.BaseName; } if (SaveThingsByClass.TryGetValue(key, out List <SaveThing> list)) { list.Add(SaveThing); } else { List <SaveThing> newList = new List <SaveThing>(); newList.Add(SaveThing); SaveThingsByClass.Add(key, newList); } } } if (PawnsByFactions[PlayerFaction].Count == 0) { throw new Exception("No characters found!\nTry playing the game a little more."); } colonistPage = new ColonistPage(); colonistPage.Dock = DockStyle.Fill; animalPage = new AnimalPage(); animalPage.Dock = DockStyle.Fill; itemsPage = new ItemsPage(); itemsPage.Dock = DockStyle.Fill; buidingsPage = new BuildingsPage(); buidingsPage.Dock = DockStyle.Fill; relationsPage = new RelationPage(); generalPage = new GeneralPage(); TabPage colonisTabPage = new TabPage("Colonists"); TabPage animalsTabPage = new TabPage("Animals"); TabPage relationsTabPage = new TabPage("Relations"); TabPage gameDataTabPage = new TabPage("General"); TabPage itemsTabPage = new TabPage("Items"); TabPage buildingsTabPage = new TabPage("Buildings"); colonisTabPage.Controls.Add(colonistPage); animalsTabPage.Controls.Add(animalPage); itemsTabPage.Controls.Add(itemsPage); relationsTabPage.Controls.Add(relationsPage); gameDataTabPage.Controls.Add(generalPage); buildingsTabPage.Controls.Add(buidingsPage); tabControl.TabPages.Add(gameDataTabPage); tabControl.TabPages.Add(colonisTabPage); tabControl.TabPages.Add(animalsTabPage); tabControl.TabPages.Add(relationsTabPage); tabControl.TabPages.Add(itemsTabPage); tabControl.TabPages.Add(buildingsTabPage); return(true); }