diff --git a/CommonsWindow/List/Components/UVMLineListItem.cs b/CommonsWindow/List/Components/UVMLineListItem.cs index 9e9749dd..d0804217 100644 --- a/CommonsWindow/List/Components/UVMLineListItem.cs +++ b/CommonsWindow/List/Components/UVMLineListItem.cs @@ -418,13 +418,13 @@ public void ChangeLineVisibility(bool r) { if (r) { - TransportLine[] expr_2A_cp_0 = Singleton.instance.m_lines.m_buffer; + ref TransportLine[] expr_2A_cp_0 = ref Singleton.instance.m_lines.m_buffer; ushort expr_2A_cp_1 = m_lineID; expr_2A_cp_0[expr_2A_cp_1].m_flags = (expr_2A_cp_0[expr_2A_cp_1].m_flags & ~TransportLine.Flags.Hidden); } else { - TransportLine[] expr_5C_cp_0 = Singleton.instance.m_lines.m_buffer; + ref TransportLine[] expr_5C_cp_0 = ref Singleton.instance.m_lines.m_buffer; ushort expr_5C_cp_1 = m_lineID; expr_5C_cp_0[expr_5C_cp_1].m_flags = (expr_5C_cp_0[expr_5C_cp_1].m_flags | TransportLine.Flags.Hidden); } @@ -447,7 +447,7 @@ private void OnMouseEnter(UIComponent comp, UIMouseEventParameter param) { if ((Singleton.instance.m_lines.m_buffer[m_lineID].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None) { - TransportLine[] expr_40_cp_0 = Singleton.instance.m_lines.m_buffer; + ref TransportLine[] expr_40_cp_0 = ref Singleton.instance.m_lines.m_buffer; ushort expr_40_cp_1 = m_lineID; expr_40_cp_0[expr_40_cp_1].m_flags = (expr_40_cp_0[expr_40_cp_1].m_flags | TransportLine.Flags.Highlighted); } @@ -467,7 +467,7 @@ private void OnMouseLeave(UIComponent comp, UIMouseEventParameter param) { if ((Singleton.instance.m_lines.m_buffer[m_lineID].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None) { - TransportLine[] expr_40_cp_0 = Singleton.instance.m_lines.m_buffer; + ref TransportLine[] expr_40_cp_0 = ref Singleton.instance.m_lines.m_buffer; ushort expr_40_cp_1 = m_lineID; expr_40_cp_0[expr_40_cp_1].m_flags = (expr_40_cp_0[expr_40_cp_1].m_flags & ~TransportLine.Flags.Highlighted); } diff --git a/Extensors/GameServiceExtensions.cs b/Extensors/GameServiceExtensions.cs index b9d9eb4b..1f7e2ef1 100644 --- a/Extensors/GameServiceExtensions.cs +++ b/Extensors/GameServiceExtensions.cs @@ -68,21 +68,21 @@ public static TLMConfigWarehouse.ConfigIndex ToConfigIndex(ItemClass.Service s, case ItemClass.Service.FireDepartment: return TLMConfigWarehouse.ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG; case ItemClass.Service.PublicTransport: - return ss switch + switch (ss) { - ItemClass.SubService.PublicTransportBus => TLMConfigWarehouse.ConfigIndex.BUS_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportCableCar => TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportMetro => TLMConfigWarehouse.ConfigIndex.METRO_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportMonorail => TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportPlane => TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportShip => TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportTaxi => TLMConfigWarehouse.ConfigIndex.TAXI_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportTours => TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportTrain => TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportTram => TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - ItemClass.SubService.PublicTransportTrolleybus => TLMConfigWarehouse.ConfigIndex.TROLLEY_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - _ => TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG, - }; + case ItemClass.SubService.PublicTransportBus: return TLMConfigWarehouse.ConfigIndex.BUS_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportCableCar: return TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportMetro: return TLMConfigWarehouse.ConfigIndex.METRO_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportMonorail: return TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportPlane: return TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportShip: return TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportTaxi: return TLMConfigWarehouse.ConfigIndex.TAXI_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportTours: return TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportTrain: return TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportTram: return TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + case ItemClass.SubService.PublicTransportTrolleybus: return TLMConfigWarehouse.ConfigIndex.TROLLEY_CONFIG | TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + default: return TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG; + } case ItemClass.Service.Disaster: return TLMConfigWarehouse.ConfigIndex.DISASTER_SERVICE_CONFIG; case ItemClass.Service.PlayerIndustry: diff --git a/Extensors/TransportLineStorageBasicData.cs b/Extensors/TransportLineStorageBasicData.cs index 0a0e70fa..1964a71d 100644 --- a/Extensors/TransportLineStorageBasicData.cs +++ b/Extensors/TransportLineStorageBasicData.cs @@ -36,38 +36,40 @@ public IDataExtensor Deserialize(Type type, byte[] rawData) maxVehicles = 16384; } - using var s = new MemoryStream(data); - long version = ReadLong(s); - foreach (Enum e in LoadOrder) + using (var s = new MemoryStream(data)) { - if (version >= GetMinVersion(e)) + long version = ReadLong(s); + foreach (Enum e in LoadOrder) { - var isVehicleData = IsVehicleEnum(e); - TLMTransportLineStatusesManager.instance.DoWithArray(e, (ref long[][] arrayRef) => + if (version >= GetMinVersion(e)) { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - - for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + var isVehicleData = IsVehicleEnum(e); + TLMTransportLineStatusesManager.instance.DoWithArray(e, (ref long[][] arrayRef) => { - arrayRef[i][idx] = DeserializeFunction(s); - } - }, (ref int[][] arrayRef) => - { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + { + arrayRef[i][idx] = DeserializeFunction(s); + } + }, (ref int[][] arrayRef) => { - arrayRef[i][idx] = (int)DeserializeFunction(s); - } - }, (ref ushort[][] arrayRef) => - { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + { + arrayRef[i][idx] = (int)DeserializeFunction(s); + } + }, (ref ushort[][] arrayRef) => { - arrayRef[i][idx] = (ushort)DeserializeFunction(s); - } - }); + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + + for (int i = 0; i < (isVehicleData ? maxVehicles : arrayRef.Length); i++) + { + arrayRef[i][idx] = (ushort)DeserializeFunction(s); + } + }); + } } } return this; @@ -86,41 +88,41 @@ private bool IsVehicleEnum(Enum e) public byte[] Serialize() { - using var s = new MemoryStream(); - - WriteLong(s, CURRENT_VERSION); - - - foreach (Enum e in LoadOrder) + using (var s = new MemoryStream()) { - TLMTransportLineStatusesManager.instance.DoWithArray(e, (ref long[][] arrayRef) => + + WriteLong(s, CURRENT_VERSION); + foreach (Enum e in LoadOrder) { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - for (int i = 0; i < arrayRef.Length; i++) + TLMTransportLineStatusesManager.instance.DoWithArray(e, (ref long[][] arrayRef) => { - SerializeFunction(s, arrayRef[i][idx]); - } - LogUtils.DoWarnLog($"idxs= {arrayRef.Length};byte[] size: {s.Length} ({e.GetType()} {e})"); - }, (ref int[][] arrayRef) => - { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - for (int i = 0; i < arrayRef.Length; i++) + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + for (int i = 0; i < arrayRef.Length; i++) + { + SerializeFunction(s, arrayRef[i][idx]); + } + LogUtils.DoWarnLog($"idxs= {arrayRef.Length};byte[] size: {s.Length} ({e.GetType()} {e})"); + }, (ref int[][] arrayRef) => { - SerializeFunction(s, arrayRef[i][idx]); - } - LogUtils.DoWarnLog($"idxs= {arrayRef.Length};byte[] size: {s.Length} ({e.GetType()} {e})"); - }, (ref ushort[][] arrayRef) => - { - int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); - for (int i = 0; i < arrayRef.Length; i++) + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + for (int i = 0; i < arrayRef.Length; i++) + { + SerializeFunction(s, arrayRef[i][idx]); + } + LogUtils.DoWarnLog($"idxs= {arrayRef.Length};byte[] size: {s.Length} ({e.GetType()} {e})"); + }, (ref ushort[][] arrayRef) => { - SerializeFunction(s, arrayRef[i][idx]); - } - LogUtils.DoWarnLog($"idxs= {arrayRef.Length}; byte[] size: {s.Length} ({e.GetType()} {e})"); - }); + int idx = TLMTransportLineStatusesManager.instance.GetIdxFor(e); + for (int i = 0; i < arrayRef.Length; i++) + { + SerializeFunction(s, arrayRef[i][idx]); + } + LogUtils.DoWarnLog($"idxs= {arrayRef.Length}; byte[] size: {s.Length} ({e.GetType()} {e})"); + }); + } + return (s.ToArray()); } - return (s.ToArray()); } protected static void WriteLong(Stream s, long value) { diff --git a/Extensors/TransportSystemDefinition.cs b/Extensors/TransportSystemDefinition.cs index 3cf1c916..a5f91a45 100644 --- a/Extensors/TransportSystemDefinition.cs +++ b/Extensors/TransportSystemDefinition.cs @@ -179,14 +179,14 @@ public bool IsPrefixable() public string GetTransportTypeIcon() { - return TransportType switch + switch (TransportType) { - TransportInfo.TransportType.EvacuationBus => "SubBarFireDepartmentDisaster", - TransportInfo.TransportType.Pedestrian => "SubBarPublicTransportWalkingTours", - TransportInfo.TransportType.TouristBus => "SubBarPublicTransportTours", - TransportInfo.TransportType.HotAirBalloon => "IconBalloonTours", - TransportInfo.TransportType.Post => "SubBarPublicTransportPost", - TransportInfo.TransportType.CableCar => PublicTransportWorldInfoPanel.GetVehicleTypeIcon(TransportInfo.TransportType.EvacuationBus), + case TransportInfo.TransportType.EvacuationBus: return "SubBarFireDepartmentDisaster"; + case TransportInfo.TransportType.Pedestrian: return "SubBarPublicTransportWalkingTours"; + case TransportInfo.TransportType.TouristBus: return "SubBarPublicTransportTours"; + case TransportInfo.TransportType.HotAirBalloon: return "IconBalloonTours"; + case TransportInfo.TransportType.Post: return "SubBarPublicTransportPost"; + case TransportInfo.TransportType.CableCar: return PublicTransportWorldInfoPanel.GetVehicleTypeIcon(TransportInfo.TransportType.EvacuationBus); //case TransportInfo.TransportType.Ship: //case TransportInfo.TransportType.Airplane: //case TransportInfo.TransportType.Bus: @@ -195,7 +195,7 @@ public string GetTransportTypeIcon() //case TransportInfo.TransportType.Taxi: //case TransportInfo.TransportType.Tram: //case TransportInfo.TransportType.Monorail: - _ => PublicTransportWorldInfoPanel.GetVehicleTypeIcon(TransportType), + default: return PublicTransportWorldInfoPanel.GetVehicleTypeIcon(TransportType); }; } diff --git a/Interfaces/ExtensionInterfaces.cs b/Interfaces/ExtensionInterfaces.cs index 20a85c89..a385a553 100644 --- a/Interfaces/ExtensionInterfaces.cs +++ b/Interfaces/ExtensionInterfaces.cs @@ -34,7 +34,7 @@ public interface ITicketPriceExtension : ISafeGettable, ILi public interface ITicketPriceStorage { - public TimeableList TicketPriceEntries { get; set; } + TimeableList TicketPriceEntries { get; set; } } public interface IAssetSelectorExtension : ISafeGettable, ILineNumberToIndexable diff --git a/Interfaces/ITLMTransportTypeExtension.cs b/Interfaces/ITLMTransportTypeExtension.cs index 3204776c..71d47b40 100644 --- a/Interfaces/ITLMTransportTypeExtension.cs +++ b/Interfaces/ITLMTransportTypeExtension.cs @@ -10,22 +10,22 @@ public interface ITLMTransportTypeExtension : ISafeGettable { #region Use Color For Model - public bool IsUsingColorForModel(uint prefix); + bool IsUsingColorForModel(uint prefix); - public void SetUsingColorForModel(uint prefix, bool value); + void SetUsingColorForModel(uint prefix, bool value); #endregion #region Custom Palette - public string GetCustomPalette(uint prefix); + string GetCustomPalette(uint prefix); - public void SetCustomPalette(uint prefix, string paletteName); + void SetCustomPalette(uint prefix, string paletteName); #endregion #region Custom Format - public LineIconSpriteNames GetCustomFormat(uint prefix); + LineIconSpriteNames GetCustomFormat(uint prefix); - public void SetCustomFormat(uint prefix, LineIconSpriteNames icon); + void SetCustomFormat(uint prefix, LineIconSpriteNames icon); #endregion diff --git a/LegacyWarehouse/ConfigWarehouseBaseLegacy.cs b/LegacyWarehouse/ConfigWarehouseBaseLegacy.cs index 88422a9a..00a16116 100644 --- a/LegacyWarehouse/ConfigWarehouseBaseLegacy.cs +++ b/LegacyWarehouse/ConfigWarehouseBaseLegacy.cs @@ -219,10 +219,10 @@ internal class TLMConfigWarehouseLegacy : ConfigWarehouseBaseLegacy 0, - }; + default: return 0; + } } } diff --git a/ModShared/TLMShared.cs b/ModShared/TLMShared.cs index 22a6defd..e856381f 100644 --- a/ModShared/TLMShared.cs +++ b/ModShared/TLMShared.cs @@ -48,12 +48,12 @@ string GetLinePrefix() { if (linePrefix == null) { - ref TransportLine tl = ref TransportManager.instance.m_lines.m_buffer[tlId]; - if (TLMPrefixesUtils.HasPrefix(ref tl)) + ref TransportLine tl2 = ref TransportManager.instance.m_lines.m_buffer[tlId]; + if (TLMPrefixesUtils.HasPrefix(ref tl2)) { - var tsd = TransportSystemDefinition.From(tl.Info); + var tsd2 = TransportSystemDefinition.From(tl2.Info); var prefix = (int)TLMPrefixesUtils.GetPrefix(tlId); - var nameMode = TLMPrefixesUtils.GetPrefixModoNomenclatura(tsd.ToConfigIndex()); + var nameMode = TLMPrefixesUtils.GetPrefixModoNomenclatura(tsd2.ToConfigIndex()); linePrefix = TLMPrefixesUtils.GetStringFromNameMode(nameMode, prefix).Trim().PadLeft(3, '\0'); } else @@ -151,6 +151,56 @@ string GetVehicleNthTrailer() return vehicleNthTrailer; } + + char GetLetter(char item) + { + switch (item) + { + case 'D': return GetDepotPrefix()[0]; + case 'E': return GetDepotPrefix()[1]; + case 'F': return GetDepotPrefix()[2]; + + case 'M': return GetModelPrefix()[0]; + case 'N': return GetModelPrefix()[1]; + case 'O': return GetModelPrefix()[2]; + + case 'P': return GetLinePrefix()[0]; + case 'Q': return GetLinePrefix()[1]; + case 'R': return GetLinePrefix()[2]; + + case 'J': return GetVehicleNthTrailer().Replace('\0', '0')[0]; + case 'K': return GetVehicleNthTrailer().Replace('\0', '0')[1]; + case 'L': return GetVehicleNthTrailer().Replace('\0', '0')[2]; + + case 'S': return GetVehicleNthDepot().Replace('\0', '0')[0]; + case 'T': return GetVehicleNthDepot().Replace('\0', '0')[1]; + case 'U': return GetVehicleNthDepot().Replace('\0', '0')[2]; + + case 'V': return GetVehicleInstanceString().Replace('\0', '0')[0]; + case 'W': return GetVehicleInstanceString().Replace('\0', '0')[1]; + case 'X': return GetVehicleInstanceString().Replace('\0', '0')[2]; + case 'Y': return GetVehicleInstanceString().Replace('\0', '0')[3]; + case 'Z': return GetVehicleInstanceString().Replace('\0', '0')[4]; + + case 'j': return GetVehicleNthTrailer()[0]; + case 'k': return GetVehicleNthTrailer()[1]; + case 'l': return GetVehicleNthTrailer()[2]; + + case 's': return GetVehicleNthDepot()[0]; + case 't': return GetVehicleNthDepot()[1]; + case 'u': return GetVehicleNthDepot()[2]; + + case 'v': return GetVehicleInstanceString()[0]; + case 'w': return GetVehicleInstanceString()[1]; + case 'x': return GetVehicleInstanceString()[2]; + case 'y': return GetVehicleInstanceString()[3]; + case 'z': + return GetVehicleInstanceString()[4]; + + default: return item; + }; + } + bool escapeNext = false; foreach (char item in identifierFormat) { @@ -165,50 +215,7 @@ string GetVehicleNthTrailer() } else { - result += item switch - { - 'D' => GetDepotPrefix()[0], - 'E' => GetDepotPrefix()[1], - 'F' => GetDepotPrefix()[2], - - 'M' => GetModelPrefix()[0], - 'N' => GetModelPrefix()[1], - 'O' => GetModelPrefix()[2], - - 'P' => GetLinePrefix()[0], - 'Q' => GetLinePrefix()[1], - 'R' => GetLinePrefix()[2], - - 'J' => GetVehicleNthTrailer().Replace('\0', '0')[0], - 'K' => GetVehicleNthTrailer().Replace('\0', '0')[1], - 'L' => GetVehicleNthTrailer().Replace('\0', '0')[2], - - 'S' => GetVehicleNthDepot().Replace('\0', '0')[0], - 'T' => GetVehicleNthDepot().Replace('\0', '0')[1], - 'U' => GetVehicleNthDepot().Replace('\0', '0')[2], - - 'V' => GetVehicleInstanceString().Replace('\0', '0')[0], - 'W' => GetVehicleInstanceString().Replace('\0', '0')[1], - 'X' => GetVehicleInstanceString().Replace('\0', '0')[2], - 'Y' => GetVehicleInstanceString().Replace('\0', '0')[3], - 'Z' => GetVehicleInstanceString().Replace('\0', '0')[4], - - 'j' => GetVehicleNthTrailer()[0], - 'k' => GetVehicleNthTrailer()[1], - 'l' => GetVehicleNthTrailer()[2], - - 's' => GetVehicleNthDepot()[0], - 't' => GetVehicleNthDepot()[1], - 'u' => GetVehicleNthDepot()[2], - - 'v' => GetVehicleInstanceString()[0], - 'w' => GetVehicleInstanceString()[1], - 'x' => GetVehicleInstanceString()[2], - 'y' => GetVehicleInstanceString()[3], - 'z' => GetVehicleInstanceString()[4], - - _ => item - }; + result += GetLetter(item); } } return result.Replace("\0", "").Trim(); @@ -216,5 +223,6 @@ string GetVehicleNthTrailer() public static void CalculateAutoName(ushort lineId, out ushort startStation, out ushort endStation, out string startStationStr, out string endStationStr) => TLMLineUtils.CalculateAutoName(lineId, out startStation, out endStation, out startStationStr, out endStationStr); public static string GetLineStringId(ushort lineId) => TLMLineUtils.GetLineStringId(lineId); + } } \ No newline at end of file diff --git a/OptionsMenu/TLMConfigOptions.cs b/OptionsMenu/TLMConfigOptions.cs index 51d0be86..5ca6d099 100644 --- a/OptionsMenu/TLMConfigOptions.cs +++ b/OptionsMenu/TLMConfigOptions.cs @@ -336,57 +336,58 @@ internal static class TabsExtension { public static string GetTabName(this ConfigTabs tab) { - return tab switch + switch (tab) { - ConfigTabs.TransportSystem => Locale.Get("K45_TLM_TRANSPORT_SYSTEM"), - ConfigTabs.TicketPrices => Locale.Get("K45_TLM_DEFAULT_PRICE"), - ConfigTabs.NearLines => Locale.Get("K45_TLM_NEAR_LINES_CONFIG"), - ConfigTabs.Automation => Locale.Get("K45_TLM_AUTOMATION_CONFIG"), - ConfigTabs.AutoName_PT => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT"), - ConfigTabs.AutoName_BD => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_OTHER"), - ConfigTabs.AutoName_PA => Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS"), - ConfigTabs.Palettes => Locale.Get("K45_TLM_CUSTOM_PALETTE_CONFIG"), - ConfigTabs.About => Locale.Get("K45_TLM_BETAS_EXTRA_INFO"), - ConfigTabs.CostPerPassenger => Locale.Get("K45_TLM_COST_PER_PASSENGER_CONFIG"), - _ => throw new Exception($"Not supported: {tab}"), + case ConfigTabs.TransportSystem: return Locale.Get("K45_TLM_TRANSPORT_SYSTEM"); + case ConfigTabs.TicketPrices: return Locale.Get("K45_TLM_DEFAULT_PRICE"); + case ConfigTabs.NearLines: return Locale.Get("K45_TLM_NEAR_LINES_CONFIG"); + case ConfigTabs.Automation: return Locale.Get("K45_TLM_AUTOMATION_CONFIG"); + case ConfigTabs.AutoName_PT: return Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT"); + case ConfigTabs.AutoName_BD: return Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_OTHER"); + case ConfigTabs.AutoName_PA: return Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS"); + case ConfigTabs.Palettes: return Locale.Get("K45_TLM_CUSTOM_PALETTE_CONFIG"); + case ConfigTabs.About: return Locale.Get("K45_TLM_BETAS_EXTRA_INFO"); + case ConfigTabs.CostPerPassenger: return Locale.Get("K45_TLM_COST_PER_PASSENGER_CONFIG"); + default: throw new Exception($"Not supported: {tab}"); }; } public static string GetTabFgSprite(this ConfigTabs tab) { - return tab switch + switch (tab) { - ConfigTabs.TransportSystem => "ParkLevelStar", - ConfigTabs.TicketPrices => "FootballTicketIcon", - ConfigTabs.NearLines => "RelocateIcon", - ConfigTabs.Automation => "Options", - ConfigTabs.AutoName_PT => "ToolbarIconPublicTransport", - ConfigTabs.AutoName_BD => "ToolbarIconMonuments", - ConfigTabs.AutoName_PA => "ToolbarIconDistrict", - ConfigTabs.Palettes => "ZoningOptionFill", - ConfigTabs.About => "CityInfo", - ConfigTabs.CostPerPassenger => "IconCitizen", - _ => throw new Exception($"Not supported: {tab}"), + case ConfigTabs.TransportSystem: return "ParkLevelStar"; + case ConfigTabs.TicketPrices: return "FootballTicketIcon"; + case ConfigTabs.NearLines: return "RelocateIcon"; + case ConfigTabs.Automation: return "Options"; + case ConfigTabs.AutoName_PT: return "ToolbarIconPublicTransport"; + case ConfigTabs.AutoName_BD: return "ToolbarIconMonuments"; + case ConfigTabs.AutoName_PA: return "ToolbarIconDistrict"; + case ConfigTabs.Palettes: return "ZoningOptionFill"; + case ConfigTabs.About: return "CityInfo"; + case ConfigTabs.CostPerPassenger: + return "IconCitizen"; + default: throw new Exception($"Not supported: {tab}"); }; } public static Type GetTabGenericContentImpl(this ConfigTabs tab) { - return tab switch + switch (tab) { - ConfigTabs.TransportSystem => typeof(TLMShowConfigTabContainer), - ConfigTabs.TicketPrices => typeof(TLMDefaultTicketPriceConfigTab), - ConfigTabs.NearLines => typeof(TLMNearLinesConfigTab), - ConfigTabs.Automation => typeof(TLMAutomationOptionsTab), - ConfigTabs.AutoName_PT => typeof(TLMAutoNamePublicTransportTab), - ConfigTabs.AutoName_BD => typeof(TLMAutoNameBuildingsTab), - ConfigTabs.AutoName_PA => typeof(TLMAutoNamePublicAreasTab), - ConfigTabs.Palettes => typeof(TLMPaletteOptionsTab), - ConfigTabs.About => typeof(TLMModInfoTab), - ConfigTabs.CostPerPassenger => typeof(TLMDefaultCostPerPassengerConfigTab), - _ => null, + case ConfigTabs.TransportSystem: return typeof(TLMShowConfigTabContainer); + case ConfigTabs.TicketPrices: return typeof(TLMDefaultTicketPriceConfigTab); + case ConfigTabs.NearLines: return typeof(TLMNearLinesConfigTab); + case ConfigTabs.Automation: return typeof(TLMAutomationOptionsTab); + case ConfigTabs.AutoName_PT: return typeof(TLMAutoNamePublicTransportTab); + case ConfigTabs.AutoName_BD: return typeof(TLMAutoNameBuildingsTab); + case ConfigTabs.AutoName_PA: return typeof(TLMAutoNamePublicAreasTab); + case ConfigTabs.Palettes: return typeof(TLMPaletteOptionsTab); + case ConfigTabs.About: return typeof(TLMModInfoTab); + case ConfigTabs.CostPerPassenger: return typeof(TLMDefaultCostPerPassengerConfigTab); + default: return null; }; - } } +} } diff --git a/TLMConfigWarehouse.cs b/TLMConfigWarehouse.cs index 90825e4d..417f3b65 100644 --- a/TLMConfigWarehouse.cs +++ b/TLMConfigWarehouse.cs @@ -157,33 +157,74 @@ public static Color32 getColorForTransportType(ConfigIndex i) private static string GetLocaleIdForIndex(ConfigIndex i, out string key, out int index) { - index = (i & ConfigIndex.DESC_DATA) switch + index = 0; + switch (i & ConfigIndex.DESC_DATA) { - ConfigIndex.PLAYER_EDUCATION_SERVICE_CONFIG => 2, - _ => 0, + case ConfigIndex.PLAYER_EDUCATION_SERVICE_CONFIG: + index = 2; + break; }; - key = (i & ConfigIndex.DESC_DATA) switch + key = null; + + switch (i & ConfigIndex.DESC_DATA) { - ConfigIndex.BEAUTIFICATION_SERVICE_CONFIG => "Beautification", - ConfigIndex.ELECTRICITY_SERVICE_CONFIG => "Electricity", - ConfigIndex.WATER_SERVICE_CONFIG => "WaterAndSewage", - ConfigIndex.GARBAGE_SERVICE_CONFIG => "Garbage", - ConfigIndex.ROAD_SERVICE_CONFIG => "Roads", - ConfigIndex.HEALTHCARE_SERVICE_CONFIG => "Healthcare", - ConfigIndex.POLICEDEPARTMENT_SERVICE_CONFIG => "Police", - ConfigIndex.EDUCATION_SERVICE_CONFIG => "Education", - ConfigIndex.MONUMENT_SERVICE_CONFIG => "Monuments", - ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG => "FireDepartment", - ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG => "PublicTransport", - ConfigIndex.DISASTER_SERVICE_CONFIG => "FireDepartment", - ConfigIndex.DISTRICT_NAME_CONFIG => "District", - ConfigIndex.VARSITY_SPORTS_SERVICE_CONFIG => "VarsitySports", - ConfigIndex.MUSEUMS_SERVICE_CONFIG => "CampusAreaMuseums", - ConfigIndex.PLAYER_INDUSTRY_SERVICE_CONFIG => "Industry", - ConfigIndex.PARKAREA_NAME_CONFIG => "ParkAreas", - ConfigIndex.INDUSTRIAL_AREA_NAME_CONFIG => "IndustryAreas", - ConfigIndex.CAMPUS_AREA_NAME_CONFIG => "CampusAreas", - _ => null, + case ConfigIndex.BEAUTIFICATION_SERVICE_CONFIG: + key = "Beautification"; + break; + case ConfigIndex.ELECTRICITY_SERVICE_CONFIG: + key = "Electricity"; + break; + case ConfigIndex.WATER_SERVICE_CONFIG: + key = "WaterAndSewage"; + break; + case ConfigIndex.GARBAGE_SERVICE_CONFIG: + key = "Garbage"; + break; + case ConfigIndex.ROAD_SERVICE_CONFIG: + key = "Roads"; + break; + case ConfigIndex.HEALTHCARE_SERVICE_CONFIG: + key = "Healthcare"; + break; + case ConfigIndex.POLICEDEPARTMENT_SERVICE_CONFIG: + key = "Police"; + break; + case ConfigIndex.EDUCATION_SERVICE_CONFIG: + key = "Education"; + break; + case ConfigIndex.MONUMENT_SERVICE_CONFIG: + key = "Monuments"; + break; + case ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG: + key = "FireDepartment"; + break; + case ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG: + key = "PublicTransport"; + break; + case ConfigIndex.DISASTER_SERVICE_CONFIG: + key = "FireDepartment"; + break; + case ConfigIndex.DISTRICT_NAME_CONFIG: + key = "District"; + break; + case ConfigIndex.VARSITY_SPORTS_SERVICE_CONFIG: + key = "VarsitySports"; + break; + case ConfigIndex.MUSEUMS_SERVICE_CONFIG: + key = "CampusAreaMuseums"; + break; + case ConfigIndex.PLAYER_INDUSTRY_SERVICE_CONFIG: + key = "Industry"; + break; + case ConfigIndex.PARKAREA_NAME_CONFIG: + key = "ParkAreas"; + break; + case ConfigIndex.INDUSTRIAL_AREA_NAME_CONFIG: + key = "IndustryAreas"; + break; + case ConfigIndex.CAMPUS_AREA_NAME_CONFIG: + key = "CampusAreas"; + break; }; switch (i & ConfigIndex.DESC_DATA) { diff --git a/TLMController.cs b/TLMController.cs index e7a44482..e4c53e58 100644 --- a/TLMController.cs +++ b/TLMController.cs @@ -42,7 +42,8 @@ public class TLMController : BaseController m_showLinearMapWhileCreatingLine; - set { + set + { m_showLinearMapWhileCreatingLine.value = value; instance.LinearMapCreatingLine.setVisible(value); } @@ -292,11 +295,13 @@ public void OnRenameStationAction(string autoName) protected override void StartActions() { - using var x = new EnumerableActionThread(new Func(VehicleUtils.UpdateCapacityUnits)); - KlyteMonoUtils.CreateElement(out m_linearMapCreatingLine, transform); - m_linearMapCreatingLine.parent = this; - m_linearMapCreatingLine.setVisible(false); - initNearLinesOnWorldInfoPanel(); + using (var x = new EnumerableActionThread(new Func(VehicleUtils.UpdateCapacityUnits))) + { + KlyteMonoUtils.CreateElement(out m_linearMapCreatingLine, transform); + m_linearMapCreatingLine.parent = this; + m_linearMapCreatingLine.setVisible(false); + initNearLinesOnWorldInfoPanel(); + } } public void OpenTLMPanel() => TransportLinesManagerMod.Instance.OpenPanelAtModTab(); diff --git a/TransportLinesManager.cs b/TransportLinesManager.cs index 8c4fed0a..d7cd3603 100644 --- a/TransportLinesManager.cs +++ b/TransportLinesManager.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; using System.Reflection; -[assembly: AssemblyVersion("13.5.0.2")] +[assembly: AssemblyVersion("13.5.0.10000")] namespace Klyte.TransportLinesManager { public class TransportLinesManagerMod : BasicIUserMod diff --git a/TransportLinesManager.csproj b/TransportLinesManager.csproj index bf58fbb5..1b4bd164 100644 --- a/TransportLinesManager.csproj +++ b/TransportLinesManager.csproj @@ -11,7 +11,7 @@ TransportLinesManager v3.5 - 8.0 + latest True @@ -30,7 +30,8 @@ true - TransportLinesManager.ruleset + + none @@ -56,14 +57,16 @@ full AnyCPU prompt - TransportLinesManager.ruleset + + bin\x64\Release\ true x64 prompt - MinimumRecommendedRules.ruleset + + diff --git a/TransportLinesManager.csproj.user b/TransportLinesManager.csproj.user index 9b86104e..c10e84ba 100644 --- a/TransportLinesManager.csproj.user +++ b/TransportLinesManager.csproj.user @@ -1,6 +1,6 @@  - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/UI/VersionNotes.txt b/UI/VersionNotes.txt index 13c111b6..ff43819c 100644 --- a/UI/VersionNotes.txt +++ b/UI/VersionNotes.txt @@ -4,6 +4,8 @@ Update r1: Fixed game sometimes freezing when saving. IMPORTANT NOTE: Some stats data will be lost due More Vehicles compatibility implementation! - + Update r2: Fixed auto-save issue - NOTE: The savegame size will be increased. \ No newline at end of file + NOTE: The savegame size will be increased. + +Update r10000: Downgrade to C# 7.x \ No newline at end of file diff --git a/Utils/TLMStationUtils.cs b/Utils/TLMStationUtils.cs index bbc5775a..22e89f8c 100644 --- a/Utils/TLMStationUtils.cs +++ b/Utils/TLMStationUtils.cs @@ -124,12 +124,16 @@ public static string GetStationName(ushort stopId, ushort lineId, ItemClass.SubS { prefix = idx.GetSystemStationNamePrefix(lineId)?.TrimStart(); serviceFound = idx.ToServiceSubservice(out subserviceFound); - resultNamingType = idx switch + resultNamingType = NamingType.PARKAREA; + switch (idx) { - CIdx.CAMPUS_AREA_NAME_CONFIG => NamingType.CAMPUS, - CIdx.INDUSTRIAL_AREA_NAME_CONFIG => NamingType.INDUSTRY_AREA, - _ => NamingType.PARKAREA, - }; + case CIdx.CAMPUS_AREA_NAME_CONFIG: + resultNamingType = NamingType.CAMPUS; + break; + case CIdx.INDUSTRIAL_AREA_NAME_CONFIG: + resultNamingType = NamingType.INDUSTRY_AREA; + break; + } return DistrictManager.instance.GetParkName(parkId); } } diff --git a/WorldInfoPanel/Components/TLMPassengerAgeReportLine.cs b/WorldInfoPanel/Components/TLMPassengerAgeReportLine.cs index 08b4c3c6..d5d77e97 100644 --- a/WorldInfoPanel/Components/TLMPassengerAgeReportLine.cs +++ b/WorldInfoPanel/Components/TLMPassengerAgeReportLine.cs @@ -41,7 +41,6 @@ protected override void AsTitleInternal() m_total.textAlignment = UIHorizontalAlignment.Center; } - public string FloatToHour(float time) => $"{((int)time).ToString("00")}:{((int)(time % 1 * 60)).ToString("00")}"; protected override void AddColumns(ref float xAdvance) { xAdvance += InitField(out m_child, "Ch", "ZONEDBUILDING_CHILDREN", xAdvance, TOTAL_DATA_COLUMNS_SPACE / 6); diff --git a/_requiredDLLs/TransportLinesManager.dll b/_requiredDLLs/TransportLinesManager.dll index 721ce7a6..46a7f366 100644 Binary files a/_requiredDLLs/TransportLinesManager.dll and b/_requiredDLLs/TransportLinesManager.dll differ diff --git a/commons b/commons index 41efa4da..2c6f6db8 160000 --- a/commons +++ b/commons @@ -1 +1 @@ -Subproject commit 41efa4da862d27510e2ef583135c61c7118d7a4c +Subproject commit 2c6f6db8fc092c70912b98a743d4308b58c26b78