/// <summary> /// Initialize the form. /// </summary> public void initialize() { List <string> monarchIDs = new List <string>(); reader.goTo(this.countryLoc); textBlock country = new textBlock('{', '}', reader); int historyLocLocal = country.getPosition("history="); reader.goTo(this.countryLoc + historyLocLocal); textBlock history = new textBlock('{', '}', reader); monarchs = history.findAll("monarch=", 2, '{', '}'); heirs = history.findAll("heir=", 2, '{', '}'); uniqueHeirs = new List <int>(); repeatHeirs = new List <int>(); historyLoc = countryLoc + historyLocLocal; monarchBox.Items.Clear(); monarchIDs.Clear(); monarchBlocks.Clear(); heirBox.Items.Clear(); heirBlocks.Clear(); int i = monarchs.Length - 1; while (i >= 0) { reader.goTo(historyLoc + monarchs[i]); textBlock monarch = new textBlock('{', '}', reader); string name = monarch.getLine(monarch.getPosition("name=")).Split('=')[1].Replace("\"", "").Trim(); int thing = monarch.getPosition("id="); string ID = monarch.getLine(monarch.getPosition("id=", false, 2)).Split('=')[1].Trim(); monarchBox.Items.Add(name); monarchIDs.Add(ID); monarchBlocks.Add(monarch); i--; } i = heirs.Length - 1; while (i >= 0) { reader.goTo(historyLoc + heirs[i]); textBlock monarch = new textBlock('{', '}', reader); string name = monarch.getLine(monarch.getPosition("name=")).Split('=')[1].Replace("\"", "").Trim(); string ID = monarch.getLine(monarch.getPosition("id=", false, 2)).Split('=')[1].Trim(); if (!monarchIDs.Contains(ID)) { heirBox.Items.Add(name); heirBlocks.Add(monarch); uniqueHeirs.Add(i); repeatHeirs.Add(-1); } else { repeatHeirs.Add(monarchIDs.IndexOf(ID)); } i--; } }
/// <summary> /// Initialize a monarchEditForm for a specified monarch /// </summary> /// <param name="monarch">textBlock containing info about specified monarch</param> public monarchEditForm(textBlock monarch) { InitializeComponent(); name = monarch.getLine(monarch.getPosition("name=")).Split('=')[1].Replace("\"", "").Trim(); dip = monarch.getLine(monarch.getPosition("DIP=")).Split('=')[1].Trim(); adm = monarch.getLine(monarch.getPosition("ADM=")).Split('=')[1].Trim(); mil = monarch.getLine(monarch.getPosition("MIL=")).Split('=')[1].Trim(); try { dynasty = monarch.getLine(monarch.getPosition("dynasty=")).Split('=')[1].Replace("\"", "").Trim(); } catch { dynasty = ""; } try { birthDate = monarch.getLine(monarch.getPosition("birth_date=")).Split('=')[1].Trim(); } catch { birthDate = "1.1.1"; } nameLabel.Text = name; dipLabel.Text = dip; admLabel.Text = adm; milLabel.Text = mil; dynastyLabel.Text = dynasty; birthdateLabel.Text = birthDate; }
/// <summary> /// Initialize a form for changing country resources /// </summary> /// <param name="readerIn">a reader for the save to edit</param> /// <param name="Loc">the index for the beginning of the relevant country text block</param> /// <param name="tag">the three letter identifier for the country to edit (e.g. FRA for France)</param> public countryResources(fileReader readerIn, int Loc, string tag) { //read in all the current values from the save loc = Loc; countryTag = tag; reader = readerIn; InitializeComponent(); reader.goTo(loc); country = new textBlock('{', '}', reader); cash = country.getLine(country.getPosition("treasury=")).Split('=')[1]; manpower = country.getLine(country.getPosition("manpower=")).Split('=')[1]; int powerLoc = country.getPosition("powers="); adm = country.getLine(powerLoc + 2).Split(' ')[0].Trim(); dip = country.getLine(powerLoc + 2).Split(' ')[1].Trim(); mil = country.getLine(powerLoc + 2).Split(' ')[2].Trim(); techGroup = country.getLine(country.getPosition("technology_group=")).Split('=')[1]; capital = country.getLine(country.getPosition("capital=")).Split('=')[1]; stability = country.getLine(country.getPosition("stability=")).Split('=')[1]; cultures = new List <string>(); cultures.Add(country.getLine(country.getPosition("primary_culture=")).Split('=')[1]); int[] acceptedCultureLocs = country.findAll("accepted_culture="); foreach (int pos in acceptedCultureLocs) { cultures.Add(country.getLine(pos).Split('=')[1]); } religion = country.getLine(country.getPosition("religion=")).Split('=')[1]; government = country.getLine(country.getPosition("government=")).Split('=')[1]; int warExPos = country.getPosition("war_exhaustion="); if (warExPos != -1) { warExhaustion = country.getLine(country.getPosition("war_exhaustion=")).Split('=')[1]; } else { warExhaustion = "0.000"; } cashLabel.Text = cash; manpowerLabel.Text = manpower; admLabel.Text = adm; dipLabel.Text = dip; milLabel.Text = mil; techGroupLabel.Text = techGroup; capitalLabel.Text = capital; stabilityLabel.Text = stability; cultureLabel.Text = string.Join(", ", cultures); religionLabel.Text = religion; governmentLabel.Text = government; warExhaustionLabel.Text = warExhaustion; int dipPosition = reader.getPosition("diplomacy=", 0, '{', '}'); reader.goTo(dipPosition); textBlock diplomacy = new textBlock('{', '}', reader); int[] vassalages = diplomacy.findAll("vassal="); string overlord = ""; foreach (int i in vassalages) { reader.goTo(dipPosition + i); textBlock vassal = new textBlock('{', '}', reader); if (vassal.getLine(vassal.getPosition("second=")).Split('=')[1] == "\"" + tag + "\"") { overlord = vassal.getLine(vassal.getPosition("first=")).Split('=')[1].Replace("\"", ""); vassalLoc = dipPosition + i; break; } } if (overlord == "") { vassalLabel.Text = "none"; vassalLoc = dipPosition + 2; } else { vassalLabel.Text = overlord; } }