} // end of BeforeSaveLocalizedString() /// <summary> /// On load we want to see if there any localizations for the strings. /// If there are then we look for one that matches the current language. /// If not we just set all the strings to match each other. /// /// We return the main str so this can be used like Str = OnLoadLocalizedString(Str, ... /// even if Str is an accessor which doesn't work with ref. /// </summary> /// <param name="str"></param> /// <param name="originalStr"></param> /// <param name="localizedStr"></param> /// <param name="dict"></param> /// <returns>The new version of the in use string, str.</returns> public static string OnLoadLocalizedString(string str, ref string originalStr, ref string localizedStr, ref XmlSerializableDictionary <string, string> dict) { string curLang = Boku.Common.Localization.Localizer.LocalLanguage; originalStr = str; if (dict == null) { // If localized dictionary is null, must be an old level so do nothing. } else { // If localized dictionary is not null, see if we have a string from current language to use. string locStr; if (dict.TryGetValue(curLang, out locStr)) { str = TextHelper.CleanUpString(locStr); } } localizedStr = str; return(str); } // end of OnLoadLocalizedString()
} // end of OnAfterSave() protected override bool OnLoad() { // Need to check for localization of any SayStrings in each reflex of each actor's brains. foreach (XmlData.Actor a in actor) { var brain = a.brain; foreach (Task task in brain.tasks) { foreach (Reflex reflex in task.reflexes) { ReflexData rd = reflex.Data; rd.sayString = TextHelper.CleanUpString(rd.sayString); rd.sayString = XmlWorldData.OnLoadLocalizedString(rd.sayString, ref rd.OriginalSayString, ref rd.LocalizedSayString, ref rd.LocalizedSayStringDict); rd.saidString = TextHelper.CleanUpString(rd.saidString); rd.saidString = XmlWorldData.OnLoadLocalizedString(rd.saidString, ref rd.OriginalSaidString, ref rd.LocalizedSaidString, ref rd.LocalizedSaidStringDict); } } } return(base.OnLoad()); } // end of OnLoad()
} // end of Render() /// <summary> /// Called to start the tutorial system. We may need params later hence /// the use of a function rather than a write accessor on Active. /// Note that this may called on a thread other than the main thread so /// we don't do anything here with the graphics device. /// </summary> public static void Activate() { // Start at the beginning. curStepIndex = 0; if (!Active) { active = true; } // Trim tutorial text to eliminate and leading/trailing whitespace. if (InGame.XmlWorldData != null) { for (int i = 0; i < InGame.XmlWorldData.tutorialSteps.Count; i++) { Step step = InGame.XmlWorldData.tutorialSteps[i]; step.GamepadText = TextHelper.CleanUpString(step.GamepadText); step.MouseText = TextHelper.CleanUpString(step.MouseText); step.TouchText = TextHelper.CleanUpString(step.TouchText); step.GoalText = TextHelper.CleanUpString(step.GoalText); } } } // end of Activate()