CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
574 stars 85 forks source link

use SerializableUIOptionBase for all options. #1510

Closed kianzarrin closed 2 years ago

kianzarrin commented 2 years ago

there are still some UI options that are not using the SerializableUIOptionBase . Specially drop downs that use Enums. For more flexibility all options should use SerializableUIOptionBase .

kianzarrin commented 2 years ago

@aubergine10 Also noticed 2 drop-downs not yet converted in GeneralTab_LocalisationGroup.cs:

  • language
  • road sign theme

I did some investigation on how to do this in https://github.com/CitiesSkylinesMods/TMPE/tree/DropDownOption2 But I realised that its not worth doing it because:

krzychu124 commented 2 years ago

Hot-reload stopped working... (this._ui is null)

image

Stacktrace

```cs NullReferenceException: Object reference not set to an instance of an object at TrafficManager.UI.Helpers.DropDownOption`1[TrafficManager.API.Traffic.Enums.SimulationAccuracy].set_Value (SimulationAccuracy value) [0x00000] in :0 at TrafficManager.UI.Helpers.DropDownOption`1[TrafficManager.API.Traffic.Enums.SimulationAccuracy].Load (Byte data) [0x00000] in :0 at TrafficManager.Manager.Impl.OptionsManager.ToDropDown[SimulationAccuracy] (System.Byte[] data, UInt32 idx, ILegacySerializableOption opt, SimulationAccuracy defaultVal) [0x00000] in :0 at TrafficManager.Manager.Impl.OptionsManager.LoadData (System.Byte[] data) [0x00000] in :0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) TrafficManager.Util.Shortcuts:LogException(Exception, Boolean) TrafficManager.Manager.Impl.OptionsManager:LoadData(Byte[]) TrafficManager.Lifecycle.SerializableDataExtension:Load() TrafficManager.Lifecycle.TMPELifecycle:Awake() UnityEngine.GameObject:Internal_AddComponentWithType(Type) UnityEngine.GameObject:AddComponent(Type) UnityEngine.GameObject:.ctor(String, Type[]) TrafficManager.Lifecycle.TMPELifecycle:StartMod() TrafficManager.Lifecycle.TrafficManagerMod:OnEnabled() System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) ColossalFramework.Plugins.PluginManager:AddPlugins(Dictionary`2) ColossalFramework.Plugins.PluginManager:LoadPluginAtPath(String, Boolean, PublishedFileId) ColossalFramework.Plugins.PluginManager:OnPluginAdded(String) ColossalFramework.Plugins.<>c__DisplayClass20:b__1a() ColossalFramework.Threading.<>c__DisplayClass4:b__3() ColossalFramework.Threading.<>c__DisplayClassa:<.ctor>b__8(Task) ColossalFramework.Threading.Task`1:Execute() ColossalFramework.Threading.Task:InternalExecute() ColossalFramework.Threading.Dispatcher:RunTask(Task) ColossalFramework.Threading.Dispatcher:ProcessSingleTask(Task) ColossalFramework.Threading.Dispatcher:InternalProcessTasks() ColossalFramework.Threading.Dispatcher:ProcessTasks() ```

kianzarrin commented 2 years ago

ill put a guard