Refactor/rethink how duality handles settings
See original GitHub issueSummary
There are some things that might be improved in the settings department of duality:
First it seems that duality uses 2 approaches to storing settings.
EditorUserData.xml
seems to use a completely separate code flow for writing to the settings file inDualityEditorApp.SaveUserData()
. The file itself also has 2<?xml version="1.0" encoding="utf-8"?>
which I have never seen before in a single file. Maybe some hack around dockpanel behavior?- Other setting files are using the duality
Serializer
class to write to the files. They also use the.dat
file extension instead of.xml
Second there’s not a clear location for where saving and loading is implemented. Sometimes it happens in DualityApp
or DualityEditorApp
and other times it happens in the settings class itself. I think we might benefit from making a interface with Save and Load methods where these are implemented on the class itself as that would allow us to treat settings in a more generic way (such as here https://github.com/AdamsLair/duality/blob/master/Source/Editor/DualityEditor/DualityEditorApp.cs#L1012) and also clean up some code from the already big DualityApp
and DualityEditorApp
classes.
Thirdly because of how the serializer api works atm it always creates a new instance. This makes it impossible to put change events on the settings class itself because then you would also have to resubscribe to those events which kinda defeats the purpose. It might be beneficial if the serializer api could take a already existing instance and update that instance.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (15 by maintainers)
Top GitHub Comments
Extensions are currently changed to xml in #860 actually. Didn’t changed them all in #856 due to conflicts.
The PR is still WIP though. Will probably split it up since it has grown quite a bit.
In that case, the code that serializes any of these settings should choose the XmlSerializer specifically via
preferredSerializer
, avoiding that any future or project-specific change will cause them to use a different one. Having binary (or something else entirely) in a.xml
is not fun 😄