Skip to content
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

Merged
merged 6 commits into from
Oct 3, 2021
Merged

Conversation

JeffAlyanak
Copy link
Contributor

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.

Jeff Alyanak and others added 4 commits October 2, 2021 16:26
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.
@laamaa
Copy link
Owner

laamaa commented Oct 3, 2021

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?

@JeffAlyanak
Copy link
Contributor Author

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.
@JeffAlyanak
Copy link
Contributor Author

@laamaa

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.

@laamaa laamaa merged commit 85462ed into laamaa:main Oct 3, 2021
@laamaa
Copy link
Owner

laamaa commented Oct 3, 2021

Great job! Thank you :) This also fixes #1

laamaa added a commit that referenced this pull request May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants