exelix11 / SwitchThemeInjector

Create custom themes for the nintendo switch !
GNU General Public License v2.0
956 stars 60 forks source link

Add string deserialization for positions #78

Closed Tran-Foxxo closed 3 years ago

Tran-Foxxo commented 3 years ago

Fixes errors when importing diffs from Switch Layout Editor by adding a cast from string to Vector2 / Vector3 so DeserializeObject doesn't error when seeing a string as a position.

exelix11 commented 3 years ago

How are you setting a string as position ? That is the actual bug. That fix is ok for the injector and the common lib but layouts using "X;Y;Z" won't work for the theme installer.

exelix11 commented 3 years ago

Maybe from here and the serializer decides to use that rather than creating the struct ? Will have to look into this, never noticed it though.

exelix11 commented 3 years ago

I can confirm this is a bug in the layout editor. I just pushed a workaround for it, not extremely proud of it but should fix the issue.

The issue is that for some reason newtonsoft json started using TypeConverters meant for the PropertyGrid when serializing VectorN structs, this didn't happen in previous releases and not sure what caused it, as i couldn't find any way to tell the serializer to ignore the converters (and i can't implement this change in the installer to avoid issues with old layouts) i figured out if i try to serialize a dummy patch before registering the type converters it will cache the converters used and will work as expected afterwards. Will be looking into better solutions but if i don't find will just end up releasing this.