Devlog #11 - Adding A Settings Page, A Config System, And More Module API
Yesterday I wrote about my commitment to making PSim an actual, usable desktop application that doesn’t feel limiting to the user. What I did yesterday was create an error notification system, so if something goes wrong the user can understand why and code has a standard philosophy to handle issues.
Today, I put my focus on improving the user experience by adding a settings page to PSim.
The Layout
Personally, when I think of a settings page in a desktop application, I usually imagine a blocking pop-up (as in, a subwindow inside the application window that while opened, does not let you touch anything outside of it) with a few tabs for different categories of settings.
ImGui actually has great support for this, with OpenPopup to create one. the smaller, left-side portion of the settings page is a tab-selection area, and the right-side portion is the tab which is selected.
There are 4 tabs:
- General
- Simulation
- Modules - modules can register custom settings
- About - basically just the full text of the MIT License + a link to the project’s GitHub page
The Config System
Personally, when I change a setting on a desktop application, I generally expect that change to still be in effect when I close and reopen it. To do this, PSim needs to get to the target platform’s app data folder, create a folder for itself if one doesn’t already exist, and then save whatever information it needs there. Now, this is obviously annoying to have to re-write every time you want to save something as simple as what FPS the user wants, so I wrote a template system to save and access binary settings files on the fly.
I now had a way to make it so arbitrary settings stay the same every time I open the app. Now, I need to make it so modules have the same privilege. I created 3 new functions in the module API, writeConfig, readConfig, and registerSwitch. Each of these does as the name implies, and it allows you to add on-off switches (support for more will come later) and read/write configs to disk.
Conclusion
It may have taken 6 hours of work, but I managed to create a fully-functional settings UI with module support to my first desktop application. This is an important piece of architechture and makes it much easier to add more features in the future and expand the app into something I can be very proud of. Thank you very much for reading! Please enjoy this proof-of-concept video of me changing settings and reopening the app.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.