-
Notifications
You must be signed in to change notification settings - Fork 5
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
Generalize Configuration class #739
Comments
Mostly thinking out loud here. Looking at the Video methods to remove: // Video Options
int graphicsWidth() const;
int graphicsHeight() const;
int graphicsColorDepth() const;
bool fullscreen() const;
bool vsync() const;
void graphicsWidth(int width);
void graphicsHeight(int height);
void graphicsColorDepth(int bpp);
void fullscreen(bool fullscreen);
void vsync(bool vsync); Audio methods to remove: // Audio Options
int audioMixRate() const;
int audioStereoChannels() const;
int audioSfxVolume() const;
int audioMusicVolume() const;
int audioBufferSize() const;
std::string mixer() const;
void audioMixRate(int mixrate);
void audioStereoChannels(int channels);
void audioSfxVolume(int volume);
void audioMusicVolume(int volume);
void audioBufferSize(int size);
void mixer(const std::string& mixer); Similarly the ability to set defaults is currently too specific to video and audio settings, and so may be removed: void setDefaultValues(); Related to the above are the private methods to parse those specific options, which will need to be removed: void parseGraphics(const Dictionary& dictionary);
void parseAudio(const Dictionary& dictionary); Implementation details will need to change. Currently the For the Similarly the One slightly unfortunately aspect of the above design, is that configuration setting names found in configuration files become somewhat dictated by the objects that need initialization settings ( One way to keep coupling loose is to use Effectively these class specific Tied to the parsing of class specific One area that needs further refinement, is how setting changes can be saved. That might involve reading back into a class specific Another option is to not worry about reading back data. Instead, make it a user interface issue. The user interface will somehow be responsible for setting (most) options, and so when they are set, they can be recorded there, by the user interface. The user interface is then responsible for updating the One limitation of saving settings only through the user interface is being able to detect when out of range options are re-mapped. If there is a function that can error check and re-map class specific Similarly, if an object might update it's own state, maybe the OS forces a minimized/maximized type change due to alt-tab or similar, the object might be responsible for providing an event that the user interface can listen to and make appropriate changes. Effectively, push the burden off to the user interface. This seems like the most reasonable approach. |
The external interface for the There's still a bit of work needed to cleanup the internal implementation of |
To remove final internal dependence on section names Error reporting is done using the In the reverse direction, the The There is a |
It seems the existing code for const auto missing = names - required; // Bug This should be the opposite: const auto missing = required - names; The exception message formatting code calls Actually, seeing as how the calculation involves using a custom |
Had an additional thought on this. Since OPHD specifies default configuration settings for each of the With that in mind, we could reasonably safely remove the internal check without worrying about having a corresponding check already being done at the point of call. Effectively this allows us to defer on how we refactor |
Currently there are some outstanding tasks related to this issue:
|
I think I'd like to limit the scope of this issue to generalizing Remaining work to refactor the The support code for |
The
Configuration
class contains quite a bit of code specific toMixer
andRenderer
. It can be generalized to support loading of arbitrary configuration data.Additionally, the
Configuration
class can serve as a bridge between the XML serialized format, and the in memory configuration data, which is largely key/value storage with support for various data types, now implemented asDictionary
. It is one of the few places in NAS2D that is heavily dependent on XML code, the other beingSprite
, and can be used as a basis for theSprite
, along with downstream uses in OPHD.One of the end goals of this work, is to decouple the library and downstream project code from the XML code. That will make it easier to upgrade or replace the TinyXML1 dependency. In particular, it can be made an external dependency installed through
vcpkg
, it can be upgraded to TinyXML2, or it can even possibly be swapped out for another serialization format such as JSON.Reference: #211, #239
A lot of work has already been put into this effort, though was not previously tracked using a specific issue. By opening this issue, that work from various PRs can be collected into a single place, along with new work to complete that goal.
The text was updated successfully, but these errors were encountered: