internal string ProcessTemplate(Vessel v, Bloc b, int vesselNumber, int blocNumber) { string s = ProcessTemplate(LaunchNumberer.Instance.SelectedTemplate, v.vesselName, b, vesselNumber, blocNumber); //Debug.Log("template: " + SelectTemplate.selectedTemplate); //Debug.Log("vesselName: " + s); return(s); }
internal string ProcessTemplate(string template, string vesselName, Bloc b, int vesselNumber, int blocNumber) { #if true Debug.Log("ProcessTemplate, template: " + template); Debug.Log("vesselName: " + vesselName); Debug.Log("Bloc: " + b); Debug.Log("vesselNumber: " + vesselNumber); Debug.Log("blocNumber: " + blocNumber); #endif var settings = HighLogic.CurrentGame.Parameters.CustomParams <LNSettings>(); string name = ""; string outerPattern = "{.*?}"; var sections = Regex.Split(template, "(" + outerPattern + ")"); foreach (string section in sections) { Debug.Log("section: " + section); if (section != "") { string s = section; if (s.Contains("[name]") || s.Contains("[launchNumber]") || s.Contains("blocNumber]")) { if (s.Contains("[name]")) { s = s.Replace("[name]", vesselName); } if (vesselNumber > 1 || b.addAlways) { s = s.Replace("[launchNumber]", (b.vesselRoman ? ToRoman(vesselNumber) : vesselNumber.ToString("D" + (settings.launchNumberMinDigits).ToString()))); } if (b.showBloc && (b.addBlocAlways || blocNumber > 1)) { s = s.Replace("[blocNumber]", (b.blocRoman ? ToRoman(blocNumber) : blocNumber.ToString("D" + (settings.blocNumberMinDigits).ToString()))); } if (s != section) { name += s.Substring(1, s.Length - 2); } } else { name += s; } } } Debug.Log("name: " + name); return(name); }
internal void MakeExample() { Bloc b = LaunchNumbererMono.InitializeNewBloc(1); example = LaunchNumbererMono.Instance.ProcessTemplate(template, "Ship Name", b, 1, 1); }