CitiesSkylinesMods / TMPE

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

central default values #1699

Closed kianzarrin closed 1 year ago

kianzarrin commented 1 year ago

Partially addresses #1508. Paves the path to xml serialization of options. Store Default Value in SerializableUIOptionBase Reorganized SerializableUIOptionBase<TVal, TUI, TComponent>:

Note: no functional changes. TMPE.zip

kianzarrin commented 1 year ago

I think I should make 2 more changes. 1- move UI option classes into options subfolder because the UI.helpers folder is getting crowded. 2- rename PersistTo to Scope because these options do not necessarily persist(eg: when used as debug switches). does everyone agree?

kianzarrin commented 1 year ago

I didn't move default values for global config because they are already handled by xml

krzychu124 commented 1 year ago

how about this: https://github.com/CitiesSkylinesMods/TMPE/issues/1372 To me this PR is complete opposite and I don't see how it paves the path for xml serialization. Could you elaborate a little bit @kianzarrin ? IMO to make it useful for serialization, the rule is quite simple: make UI only an UI and don't hold any state inside, UI controls should be created on demand(now they are static...) always passing default value, e.g.: by creating UI control factory to keep everything in one place which also prevents partial initialization just because you forgot to call some method or set some value.