-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic config handling. #19
Conversation
Still work to do on this before it's really workable for all the settings required, but this at least gets things working well. It uses an MIT licensed library for simple INI reading and supports writing, so GUI options can later be added for writing the config. Currently only supports the fullscreen option (see the included config.ini) which allows you to set the initial state of the application. The config code should be pulled off into its own function for long-ter m cleanliness, but I wanted to get a pull request together and confer with the maintainer regarding style decisions there.
All options will simply be left at default.
Looks good to me, feel free to go ahead. Could you please move the config handling stuff to its own files (as you suggested yourself) so that possible new config parameters wouldn't clutter main.c. I wonder if it also would be a good idea to have the parameters inside a struct? |
Yeah, that's exactly what I was thinking! That'll ensure that it stays nice and clean even as new config params are added. |
I've also created a struct which holds all the config parameters, including the location of the config file. The defaults are set in the init_config() function.
Keyboard and gamepad keys can now be mapped in the config file and are loaded on startup. These currently have to be done as SDL keycodes, but I've included in the comments of the config the requisite links to the lookup tables.
I've moved the code off into it's own files and turned the config into a struct as discussed. I've also had to replace the case statements for the keyboard and gamepad inputs to allow for user configurable inputs. |
Great job! Thank you :) This also fixes #1 |
Still work to do on this before it's really workable for all the settings required, but this at least gets things working.
It uses an MIT licensed library for simple INI reading and supports writing, so GUI options can later be added for writing the config.
Currently only supports the fullscreen option (see the included config.ini) which allows you to set the initial state of the application.
The config code should be pulled off into its own function for long-term cleanliness, but I wanted to get a pull request together and confer with @laamaa regarding whether this is the right type of config library for them before going past a prototype state.