diff --git a/GameObjects/GameObjects/Event.cs b/GameObjects/GameObjects/Event.cs index 464a3211..e4f30035 100644 --- a/GameObjects/GameObjects/Event.cs +++ b/GameObjects/GameObjects/Event.cs @@ -31,6 +31,8 @@ public class Event : GameObject public Dictionary> matchedEffect; public List architectureEffect; public List factionEffect; + public List scenBiography = new List<>(); + public List matchedScenBiography = new List<>(); public String Image = ""; public String Sound = ""; public bool GloballyDisplayed = false; @@ -48,6 +50,9 @@ public void ApplyEventDialogs(Architecture a) { this.OnApplyEvent(this, a); } + for (PersonDialog i : matchedScenBiography) { + this.Scenario.YearTable.addPersonInGameBiography(i.SpeakingPerson, this.Scenario.Date, i.Text); + } if (nextScenario.Length > 0) { base.Scenario.EnableLoadAndSave = false; @@ -220,6 +225,21 @@ public bool matchEventPersons(Architecture a) } matchedDialog.Add(pd); } + + matchedScenBiography = new List(); + foreach (PersonIdDialog i in this.scenBiography) + { + if (!matchedPersons.ContainsKey(i.id)) return false; + + PersonDialog pd = new PersonDialog(); + pd.SpeakingPerson = matchedPersons[i.id]; + pd.Text = i.dialog; + for (int j = 0; j < matchedPersons.Count; ++j) + { + pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name); + } + matchedScenBiography.Add(pd); + } matchedEffect = new Dictionary>(); foreach (KeyValuePair> i in this.effect) @@ -445,6 +465,21 @@ public void LoadDialogFromString(string data) this.dialog.Add(d); } } + + public void LoadScenBiographyFromString(string data) + { + char[] separator = new char[] { ' ', '\n', '\r', '\t' }; + string[] strArray = data.Split(separator, StringSplitOptions.RemoveEmptyEntries); + + this.scenBiography = new List(); + for (int i = 0; i < strArray.Length; i += 2) + { + PersonIdDialog d = new PersonIdDialog(); + d.id = int.Parse(strArray[i]); + d.dialog = strArray[i + 1]; + this.scenBiography.Add(d); + } + } public string SaveDialogToString() { @@ -455,6 +490,16 @@ public string SaveDialogToString() } return result; } + + public string SaveScenBiographyToString() + { + string result = ""; + foreach (PersonIdDialog i in this.scenBiography) + { + result += i.id + " " + i.scenBiography + " "; + } + return result; + } public void LoadEffectFromString(EventEffectTable allEffect, string data) { @@ -546,4 +591,4 @@ public bool CheckFactionEvent(Architecture a) public delegate void ApplyEvent(Event te, Architecture a); } -} \ No newline at end of file +} diff --git a/GameObjects/GameObjects/GameScenario.cs b/GameObjects/GameObjects/GameScenario.cs index b107c0c6..fa2019d6 100644 --- a/GameObjects/GameObjects/GameScenario.cs +++ b/GameObjects/GameObjects/GameScenario.cs @@ -4539,6 +4539,11 @@ private List LoadGameDataFromDataBase(OleDbConnection DbConnection, stri te.CheckArea = (EventCheckAreaKind)((short)reader["CheckAreaKind"]); te.LoadTargetPersonFromString(this.AllPersons, reader["TargetPersons"].ToString()); te.LoadDialogFromString(this.AllPersons, reader["Dialogs"].ToString()); + try { + te.LoadScenBiographyFromString(this.AllPersons, reader["ScenBiography"].ToString()); + } catch { + + } te.LoadSelfEffectFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectSelf"].ToString()); te.LoadEffectPersonFromString(this.AllPersons, this.GameCommonData.AllTroopEventEffects, reader["EffectPersons"].ToString()); te.LoadEffectAreaFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectAreas"].ToString()); @@ -5580,6 +5585,7 @@ public bool SaveGameScenarioToDatabase(string connectionString, bool saveMap, bo row["CheckAreaKind"] = event2.CheckArea; row["TargetPersons"] = event2.SaveTargetPersonToString(); row["Dialogs"] = event2.SaveDialogToString(); + row["ScenBiography"] = event2.SaveScenBiographyToString(); row["EffectSelf"] = event2.SaveSelfEffectToString(); row["EffectPersons"] = event2.SaveEffectPersonToString(); row["EffectAreas"] = event2.SaveEffectAreaToString();