foxnne / pixi

Pixel art editor made with Zig.
https://foxnne.github.io/pixi/
MIT License
645 stars 20 forks source link

added a pixi-settings.json file which stores user settings #28

Closed VisenDev closed 9 months ago

VisenDev commented 9 months ago

Closes https://github.com/foxnne/pixi/issues/26

Added init and deinit functions for settings

This attempts to load user settings from pixi-settings.json. If this is successful, the saved settings are returned. Otherwise, the default settings are used

The deinit method saves the current settings of the user to pixi-settings.json. It doesn't currently deinitialize the memory due to issues with std.json.Parsed(T) - see the comment in deinit

foxnne commented 9 months ago

Thank you so much for the contribution, looks great! I'll give it a go later tonight. Appreciate it!

VisenDev commented 9 months ago

looks great! I'll give it a go later tonight.

Having tested things a bit more, I've realized that the chosen editor theme does not get saved because it is stored in a different location than settings.zig. Moving the variable that stores the currently selected theme to settings.zig would fix this as I automatically save everything in that file.

I'll have to look a bit closer into how the editor theme is implemented though

foxnne commented 9 months ago

I'll have to look a bit closer into how the editor theme is implemented though

Ah yes, I believe I made Theme it's own struct, but like you said, you could likely easily move that into Settings and it not be an issue.