public static string GetBuildingDetails(ushort buildingId, out ItemClass.Service serviceFound, out ItemClass.SubService subserviceFound, out string prefix, out NamingType namingType, ushort lineId = 0) { BuildingManager bm = Singleton <BuildingManager> .instance; Building b = bm.m_buildings.m_buffer[buildingId]; while (b.m_parentBuilding > 0) { LogUtils.DoLog("getBuildingName(): building id {0} - parent = {1}", buildingId, b.m_parentBuilding); buildingId = b.m_parentBuilding; b = bm.m_buildings.m_buffer[buildingId]; } InstanceID iid = default; iid.Building = buildingId; serviceFound = b.Info?.GetService() ?? default; subserviceFound = b.Info?.GetSubService() ?? default; TransportSystemDefinition tsd = TransportSystemDefinition.From(b.Info.GetAI()); if (tsd is null) { var data = TLMBaseConfigXML.CurrentContextConfig.GetAutoNameData(serviceFound); prefix = data?.NamingPrefix?.Trim(); namingType = NamingTypeExtensions.From(serviceFound, subserviceFound); } else { prefix = tsd.GetConfig().NamingPrefix?.TrimStart(); LogUtils.DoLog($"getBuildingName(): serviceFound {serviceFound} - subserviceFound = {subserviceFound} - tsd = {tsd} - prefix = {prefix}"); namingType = NamingTypeExtensions.From(tsd); } return(bm.GetBuildingName(buildingId, iid)); }
internal static Color CalculateAutoColor(ushort num, TransportSystemDefinition tsdRef, bool avoidRandom = false, bool allowClear = false) { var config = tsdRef.GetConfig(); if (tsdRef.TransportType == TransportInfo.TransportType.EvacuationBus) { return(tsdRef.Color); } bool prefixBased = config.PalettePrefixBased; bool randomOnOverflow = config.PaletteRandomOnOverflow; var pal = new List <string>(); if (num >= 0 && config.Prefix != NamingMode.None) { uint prefix = num / 1000u; ITLMTransportTypeExtension ext = tsdRef.GetTransportExtension(); string tempPal = ext.GetCustomPalette(prefix) ?? string.Empty; if (tempPal != string.Empty) { pal.Add(tempPal); num %= 1000; } else { if (prefix > 0 && prefixBased) { num /= 1000; } else { num %= 1000; } } pal.Add(config.Palette); } else { pal.Add(config.Palette); } Color c; c = TLMAutoColorPaletteContainer.GetColor(num, pal.ToArray(), randomOnOverflow, avoidRandom); if (c == Color.clear && !allowClear) { c = tsdRef.Color; } return(c); }
internal static LineIconSpriteNames GetLineIcon(ushort num, TransportSystemDefinition tsdRef) { var config = tsdRef.GetConfig(); if (num > 0 && config.Prefix != NamingMode.None) { uint prefix = num / 1000u; ITLMTransportTypeExtension ext = tsdRef.GetTransportExtension(); LineIconSpriteNames format = ext.GetCustomFormat(prefix); if (format != default) { return(format); } } return(tsdRef.GetBgIcon()); }
public static void GetNamingRulesFromTSD(out NamingMode prefix, out Separator s, out NamingMode suffix, out NamingMode nonPrefix, out bool zeros, out bool invertPrefixSuffix, TransportSystemDefinition tsd) { if (tsd == TransportSystemDefinition.EVAC_BUS) { suffix = NamingMode.Number; s = Separator.Hyphen; prefix = NamingMode.Roman; nonPrefix = NamingMode.Number; zeros = false; invertPrefixSuffix = false; } else { var config = tsd.GetConfig(); suffix = config.Suffix; s = config.Separator; prefix = config.Prefix; nonPrefix = config.NonPrefixedNaming; zeros = config.UseLeadingZeros; invertPrefixSuffix = config.InvertPrefixSuffix; } }
internal static List <string> GetPrefixesOptions(TransportSystemDefinition tsd, bool addDefaults = true) { var config = tsd.GetConfig(); NamingMode m = config.Prefix; LogUtils.DoLog("getPrefixesOptions: MODO NOMENCLATURA = " + m); var saida = new List <string>(); if (addDefaults) { saida.AddRange(new string[] { Locale.Get("K45_TLM_ALL"), Locale.Get("K45_TLM_UNPREFIXED") }); } else { saida.Add("/"); } switch (m) { case NamingMode.GreekUpper: case NamingMode.GreekUpperNumber: saida.AddRange(gregoMaiusculo.Select(x => x.ToString())); break; case NamingMode.GreekLower: case NamingMode.GreekLowerNumber: saida.AddRange(gregoMinusculo.Select(x => x.ToString())); break; case NamingMode.CyrillicUpper: case NamingMode.CyrillicUpperUpper: saida.AddRange(cirilicoMaiusculo.Select(x => x.ToString())); break; case NamingMode.CyrillicLower: case NamingMode.CyrillicLowerNumber: saida.AddRange(cirilicoMinusculo.Select(x => x.ToString())); break; case NamingMode.LatinUpper: case NamingMode.LatinUpperNumber: saida.AddRange(latinoMaiusculo.Select(x => x.ToString())); break; case NamingMode.LatinLower: case NamingMode.LatinLowerNumber: saida.AddRange(latinoMinusculo.Select(x => x.ToString())); break; case NamingMode.Number: for (int i = 1; i <= 64; i++) { saida.Add(i.ToString()); } break; case NamingMode.Roman: for (ushort i = 1; i <= 64; i++) { saida.Add(NumberingUtils.ToRomanNumeral(i)); } break; } if (TLMLineUtils.m_numberedNamingTypes.Contains(m)) { saida.AddRange(numeros.Select(x => x.ToString())); } return(saida); }
public static bool HasPrefix(TransportSystemDefinition tsd) => tsd != default && tsd != TransportSystemDefinition.EVAC_BUS && tsd.GetConfig().Prefix != NamingMode.None;
internal static string[] GetStringOptionsForPrefix(TransportSystemDefinition tsd, bool showUnprefixed = false, bool useNameRefSystem = false, bool noneOption = true) { var config = tsd.GetConfig(); var prefixNamingMode = config.Prefix; var saida = new List <string>(new string[noneOption ? 1 : 0]); if (!noneOption) { string unprefixedName = Locale.Get("K45_TLM_UNPREFIXED"); if (useNameRefSystem) { string prefixName = tsd.GetTransportExtension().GetName(0); if (!string.IsNullOrEmpty(prefixName)) { unprefixedName += " - " + prefixName; } } saida.Add(unprefixedName); } if (prefixNamingMode == NamingMode.None) { return(saida.ToArray()); } switch (prefixNamingMode) { case NamingMode.GreekUpper: case NamingMode.GreekUpperNumber: AddToArrayWithName(gregoMaiusculo, saida, tsd, useNameRefSystem); break; case NamingMode.GreekLower: case NamingMode.GreekLowerNumber: AddToArrayWithName(gregoMinusculo, saida, tsd, useNameRefSystem); break; case NamingMode.CyrillicUpper: case NamingMode.CyrillicUpperUpper: AddToArrayWithName(cirilicoMaiusculo, saida, tsd, useNameRefSystem); break; case NamingMode.CyrillicLower: case NamingMode.CyrillicLowerNumber: AddToArrayWithName(cirilicoMinusculo, saida, tsd, useNameRefSystem); break; case NamingMode.LatinUpper: case NamingMode.LatinUpperNumber: AddToArrayWithName(latinoMaiusculo, saida, tsd, useNameRefSystem); break; case NamingMode.LatinLower: case NamingMode.LatinLowerNumber: AddToArrayWithName(latinoMinusculo, saida, tsd, useNameRefSystem); break; case NamingMode.Number: string[] temp = new string[64]; for (int i = 1; i <= 64; i++) { temp[i - 1] = i.ToString(); } AddToArrayWithName(temp, saida, tsd, useNameRefSystem); break; case NamingMode.Roman: string[] tempR = new string[64]; for (ushort i = 1; i <= 64; i++) { tempR[i - 1] = NumberingUtils.ToRomanNumeral(i); } AddToArrayWithName(tempR, saida, tsd, useNameRefSystem); break; } if (TLMLineUtils.m_numberedNamingTypes.Contains(prefixNamingMode)) { AddToArrayWithName(numeros, saida, tsd, useNameRefSystem); } if (!noneOption && !showUnprefixed) { saida.RemoveAt(0); } return(saida.ToArray()); }