-
Notifications
You must be signed in to change notification settings - Fork 27
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
Save Scene #128
Save Scene #128
Conversation
Co-Authored-By: Jonas Gilg <[email protected]>
Co-Authored-By: Jonas Gilg <[email protected]>
Co-Authored-By: Jonas Gilg <[email protected]>
As I said before, for Next I will try to implement that the user interface is updated when settings are reloaded. This shouldn't be so complicated but this PR is already huge enough... |
I have no idea what's happening to clang there... I cannot even reproduce it with the same version of clang... |
Finally. GitHub's clang insisted that struct Trail {
double mLength{};
int32_t mSamples{};
std::string mParent;
}; is not default-constructible. Even for struct Trail {
Trail() = default;
double mLength{};
int32_t mSamples{};
std::string mParent;
}; the assert failed. However struct Trail {
Trail() {}
double mLength{};
int32_t mSamples{};
std::string mParent;
}; works?! |
So... any open issues? |
This PR adds initial support for saving the current scene. The idea is to extend our settings file to store the scene state (including the state of each and every plugin). There are now basically four setting types in the
Settings
class mapping to elements in the JSON file:std::optional< T >: Settings which have a std::optional type can be defined in the JSON file but do not have to. If they are not present in the JSON file, they will be set to std::nullopt. When settings were reloaded, you have to check whether the value has changed. When saving, it will only be written if it is not currently set to std::nullopt.
cs::utils::Property< T >: This is a mandatory element; omitting it in the JSON file will lead to an error. You can connect to the onChange() signal in order to be notified when the value changes. This, for example, could be caused by by modifing a corresponding widget in the user interface or by reloading the settings.
cs::utils::DefaultProperty< T >: Similar to the Property but not mandatory. When reading from file, it will be set to its default state if it's not present in the file. On save, it will not be written to file when it's currently in its default state.
Everything else: Everything else is considered to be mandatory.
The following has been implemented:
Settings
class has been extended to store all properties describing the current scene state. This includes most of the properties which previously were public members of theGraphicsEngine
, such aspEnableLighting
.deserialize
method instead of aparseSection
,parseMap
,parseOptional
,parseOptionalSection
,parseOptionalVector
, ....cs::utils::DefaultProperty
template class.from_json
andto_json
of all members of theSettings
class.from_json
andto_json
of all members of the plugin settings classes.CosmoScout.callbacks.core.load(settingsFile)
CosmoScout.callbacks.core.save(settingsFile)
csp-atmospheres
plugin.The following is still missing:
csp-atmospheres
is implemented for now)Related PRs:
Feel free to experiment and add some comments!