protected virtual string GetTitleLocalisationsContent(string line, string gameId) { IEnumerable <Localisation> titleLocalisations = localisations.TryGetValue(gameId); if (EnumerableExt.IsNullOrEmpty(titleLocalisations)) { return(null); } string indentation = Regex.Match(line, "^(\\s*)" + gameId + "\\s*=\\s*\\{.*$").Groups[1].Value + " "; List <string> lines = new List <string>(); foreach (Localisation localisation in titleLocalisations.OrderBy(x => x.LanguageGameId)) { string normalisedName = nameNormaliser.ToWindows1252(localisation.Name); string lineToAdd = $"{indentation}{localisation.LanguageGameId} = \"{normalisedName}\""; if (Settings.Output.AreVerboseCommentsEnabled) { lineToAdd += $" # Language={localisation.LanguageId}"; } if (!string.IsNullOrWhiteSpace(localisation.Comment)) { lineToAdd += $" # {nameNormaliser.ToWindows1252(localisation.Comment)}"; } lines.Add(lineToAdd); } return(string.Join(Environment.NewLine, lines)); }
public void IsNullOrEmpty_CollectionIsNull_ReturnsTrue() { IEnumerable <string> collection = null; bool actual = EnumerableExt.IsNullOrEmpty(collection); Assert.IsTrue(actual); }
protected override string GetTitleLocalisationsContent(string line, string gameId) { IEnumerable <Localisation> titleLocalisations = localisations.TryGetValue(gameId); if (EnumerableExt.IsNullOrEmpty(titleLocalisations)) { return(null); } string indentation1 = Regex.Match(line, "^(\\s*)" + gameId + "\\s*=\\s*\\{.*$").Groups[1].Value + " "; string indentation2 = indentation1 + " "; List <string> lines = new List <string>(); lines.Add($"{indentation1}cultural_names = {{"); foreach (Localisation localisation in titleLocalisations.OrderBy(x => x.LanguageId)) { string lineToAdd = $"{indentation2}name_list_{localisation.LanguageGameId} = cn_{localisation.Id}_{localisation.LanguageGameId}" + $" # {nameNormaliser.ToCK3Charset(localisation.Name)}"; if (Settings.Output.AreVerboseCommentsEnabled) { lineToAdd += $" # Language={localisation.LanguageId}"; } if (!string.IsNullOrWhiteSpace(localisation.Comment)) { lineToAdd += $" # {nameNormaliser.ToCK3Charset(localisation.Comment)}"; } lines.Add(lineToAdd); } lines.Add($"{indentation1}}}"); return(string.Join(Environment.NewLine, lines)); }
string GenerateStateEventForCountry(GameId stateGameId, string countryTag) { string eventId = $"mcn_{countryTag}.{stateGameId.Id}"; string stateName = string.Empty; string eventContent = $"# Event={eventId}, State={stateGameId.Id}"; string nameSetsEventContent = string.Empty; Localisation stateLocalisation = stateLocalisations .TryGetValue(stateGameId.Id) .TryGetValue(countryTag); if (!(stateLocalisation is null)) { stateName = nameNormaliser.ToHOI4StateCharset(stateLocalisation.Name); eventContent += $", LocalisedName=\"{stateName}\""; nameSetsEventContent += $" {stateGameId.Id} = {{ set_state_name = \"{stateName}\" }} # {stateLocalisation.Name}"; if (Settings.Output.AreVerboseCommentsEnabled) { nameSetsEventContent += $" # Language={stateLocalisation.LanguageId}"; } if (!string.IsNullOrWhiteSpace(stateLocalisation.Comment)) { nameSetsEventContent += $" # {stateLocalisation.Comment}"; } nameSetsEventContent += Environment.NewLine; if (stateName != stateLocalisation.Name) { eventContent += $" # {stateLocalisation.Name}"; } } eventContent += Environment.NewLine + $"country_event = {{" + Environment.NewLine + $" id = {eventId}" + Environment.NewLine + $" title = {eventId}.title" + Environment.NewLine + $" desc = {eventId}.description" + Environment.NewLine + $" picture = GFX_report_event_german_reichstag_gathering" + Environment.NewLine + $" hidden = yes" + Environment.NewLine + $" trigger = {{ {countryTag} = {{ owns_state = {stateGameId.Id} }} }}" + Environment.NewLine + $" mean_time_to_happen = {{ days = 3 }}" + Environment.NewLine + $" immediate = {{" + Environment.NewLine + $" hidden_effect = {{" + Environment.NewLine; IEnumerable <GameId> currentStateCities = stateCities.TryGetValue(stateGameId.Id); if (!EnumerableExt.IsNullOrEmpty(currentStateCities)) { foreach (GameId cityGameId in currentStateCities.OrderBy(x => int.Parse(x.Id))) { Localisation cityLocalisation = cityLocalisations .TryGetValue(cityGameId.Id) .TryGetValue(countryTag); if (cityLocalisation is null) { continue; } string cityName = nameNormaliser.ToHOI4CityCharset(cityLocalisation.Name); nameSetsEventContent += $" set_province_name = {{ id = {cityGameId.Id} name = \"{cityName}\" }} # {cityLocalisation.Name}"; if (Settings.Output.AreVerboseCommentsEnabled) { nameSetsEventContent += $" # Language={cityLocalisation.LanguageId}"; } if (!string.IsNullOrWhiteSpace(cityLocalisation.Comment)) { nameSetsEventContent += $" # {cityLocalisation.Comment}"; } nameSetsEventContent += Environment.NewLine; } } if (string.IsNullOrWhiteSpace(nameSetsEventContent)) { return(null); } eventContent += nameSetsEventContent + $" }}" + Environment.NewLine + $" }}" + Environment.NewLine + $" option = {{ name = {eventId}.option }}" + Environment.NewLine + $"}}" + Environment.NewLine; return(eventContent); }