mirror of
https://github.com/wiiu-env/WiiUPluginLoaderGUI.git
synced 2024-11-25 10:36:54 +01:00
[CONFIG] Only load values from the SD Card at the beginning. Add a save to SD card when existing a application.
This commit is contained in:
parent
993b328f4c
commit
e6f246b947
@ -25,12 +25,10 @@ ConfigInformation::ConfigInformation(WUPSConfig * config, std::string persistPat
|
||||
this->persistPath = persistPath;
|
||||
this->persistFileName = persistFileName;
|
||||
createConfigSettings();
|
||||
loadValuesFromSD();
|
||||
}
|
||||
|
||||
ConfigInformation::~ConfigInformation() {
|
||||
if(configSettings != NULL) {
|
||||
updateAndSaveSettings();
|
||||
delete configSettings;
|
||||
configSettings = NULL;
|
||||
}
|
||||
@ -89,12 +87,12 @@ bool ConfigInformation::loadValuesFromSD() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigInformation::updateAndSaveSettings() {
|
||||
void ConfigInformation::updateAndSaveSettings(bool forceAll) {
|
||||
if(this->config == NULL || this->configSettings == NULL) {
|
||||
return;
|
||||
}
|
||||
updateConfigSettings();
|
||||
configSettings->Save();
|
||||
configSettings->Save(forceAll);
|
||||
}
|
||||
|
||||
bool ConfigInformation::updateConfigSettings() {
|
||||
|
@ -35,12 +35,13 @@ public:
|
||||
|
||||
/**
|
||||
Deletes the given WUPSConfig
|
||||
Calls updateAndSaveSettings
|
||||
Deletes the created ConfigSettings
|
||||
**/
|
||||
~ConfigInformation();
|
||||
|
||||
void updateAndSaveSettings();
|
||||
void updateAndSaveSettings(bool forceAll);
|
||||
|
||||
bool loadValuesFromSD();
|
||||
|
||||
WUPSConfig * getConfig() {
|
||||
return config;
|
||||
@ -48,7 +49,6 @@ public:
|
||||
|
||||
private:
|
||||
bool createConfigSettings();
|
||||
bool loadValuesFromSD();
|
||||
bool updateConfigSettings();
|
||||
|
||||
WUPSConfig * config = NULL;
|
||||
|
@ -342,12 +342,35 @@ void ConfigUtils::deleteConfigInformation(std::vector<ConfigInformation *> confi
|
||||
}
|
||||
|
||||
void ConfigUtils::loadConfigFromSD() {
|
||||
deleteConfigInformation(getConfigInformation());
|
||||
std::vector<ConfigInformation *> configInfos = getConfigInformation();
|
||||
|
||||
for (auto & curConfig : configInfos) {
|
||||
curConfig->loadValuesFromSD();
|
||||
}
|
||||
|
||||
deleteConfigInformation(configInfos);
|
||||
}
|
||||
|
||||
void ConfigUtils::saveConfigToSD() {
|
||||
std::vector<ConfigInformation *> configInfos = getConfigInformation();
|
||||
|
||||
for (auto & curConfig : configInfos) {
|
||||
curConfig->updateAndSaveSettings(true);
|
||||
}
|
||||
|
||||
deleteConfigInformation(configInfos);
|
||||
}
|
||||
|
||||
void ConfigUtils::openConfigMenu() {
|
||||
std::vector<ConfigInformation *> configInfos = getConfigInformation();
|
||||
|
||||
// We rely on the default values here.
|
||||
//if(loadFromSD){
|
||||
// for (auto & curConfig : configInfos) {
|
||||
// configs.loadValuesFromSD();
|
||||
// }
|
||||
//}
|
||||
|
||||
std::vector<WUPSConfig *> configs;
|
||||
|
||||
for (auto & curConfig : configInfos) {
|
||||
@ -364,5 +387,9 @@ void ConfigUtils::openConfigMenu() {
|
||||
DCFlushRange(curConfig, sizeof(WUPSConfig));
|
||||
}
|
||||
|
||||
for (auto & curConfig : configInfos) {
|
||||
curConfig->updateAndSaveSettings(false);
|
||||
}
|
||||
|
||||
deleteConfigInformation(configInfos);
|
||||
}
|
||||
|
@ -26,15 +26,21 @@ class ConfigUtils {
|
||||
public:
|
||||
/**
|
||||
Loads the configuration files of all loaded plugins from the SDCard
|
||||
and triggers the "loadValue" if they differ the default value.
|
||||
and triggers the "callback" if they differ the default/current value.
|
||||
**/
|
||||
static void loadConfigFromSD();
|
||||
|
||||
/**
|
||||
Get the current values from all plugins via the WUPS_GET_CONFIG() hook and
|
||||
save them to the SD Card.
|
||||
**/
|
||||
static void saveConfigToSD();
|
||||
|
||||
/**
|
||||
Opens the configuration menu where plugins can be configured.
|
||||
Plugins need to implement the WUPS_GET_CONFIG() hook to show up in the menu.
|
||||
The menu will be rendered on the TV and DRC screen, with optimization for the DRC.
|
||||
If the menu is low, the menu may be only rendered to the DRC.
|
||||
If the memory is low, the menu may be only rendered to the DRC.
|
||||
**/
|
||||
static void openConfigMenu();
|
||||
|
||||
|
@ -29,6 +29,7 @@ DECL(uint32_t, ProcUIProcessMessages, uint32_t u) {
|
||||
CallHook(WUPS_LOADER_HOOK_APP_STATUS_CHANGED);
|
||||
if(gAppStatus == WUPS_APP_STATUS_CLOSED) {
|
||||
CallHook(WUPS_LOADER_HOOK_ENDING_APPLICATION);
|
||||
ConfigUtils::saveConfigToSD();
|
||||
DeInit();
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ bool ConfigSettings::Reset() {
|
||||
this->SetDefault();
|
||||
bChanged = true;
|
||||
|
||||
if (this->Save()) {
|
||||
if (this->Save(true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -197,8 +197,8 @@ int32_t ConfigSettings::getIdByName(std::string configID) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ConfigSettings::Save() {
|
||||
if(!bChanged) {
|
||||
bool ConfigSettings::Save(bool force) {
|
||||
if(!force && !bChanged) {
|
||||
DEBUG_FUNCTION_LINE("Nothing has changed, we can skip\n");
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
//!Load Settings
|
||||
bool Load();
|
||||
//!Save Settings
|
||||
bool Save();
|
||||
bool Save(bool force);
|
||||
//!Reset Settings
|
||||
bool Reset();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user