Only save config if changes are made.
This commit is contained in:
parent
1a20cc50f3
commit
becb99cdd3
4 changed files with 26 additions and 3 deletions
|
|
@ -51,6 +51,7 @@ sound *bgm = NULL;
|
|||
bool songIsFound = false;
|
||||
bool UniStoreAutoboot = false;
|
||||
int AutobootWhat = 0; // 0 -> MainMenu ; 1 -> Store; 2 -> Script.
|
||||
bool changesMade = false;
|
||||
|
||||
// Include all spritesheet's.
|
||||
C2D_SpriteSheet sprites;
|
||||
|
|
@ -193,7 +194,11 @@ Result Init::Exit() {
|
|||
|
||||
// Free UniStore spritesheet, just in case.
|
||||
freeSheet();
|
||||
// Only save config, if *any* changes are made. (To reduce SD Writes.)
|
||||
if (changesMade) {
|
||||
Config::save();
|
||||
}
|
||||
|
||||
Gui::exit();
|
||||
Gui::unloadSheet(sprites);
|
||||
gfxExit();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ extern bool checkWifiStatus(void);
|
|||
extern void notImplemented(void);
|
||||
|
||||
bool isScriptSelected = false;
|
||||
extern bool changesMade;
|
||||
|
||||
// Parse the script for the list.
|
||||
ScriptInfo parseInfo(std::string fileName) {
|
||||
|
|
@ -395,6 +396,7 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {});
|
||||
if (tempScript != "") {
|
||||
Config::ScriptPath = tempScript;
|
||||
changesMade = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -430,6 +432,7 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {});
|
||||
if (tempScript != "") {
|
||||
Config::ScriptPath = tempScript;
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
|
||||
int selectedLang;
|
||||
extern bool changesMade;
|
||||
|
||||
Settings::Settings() {
|
||||
selectedLang = Config::lang;
|
||||
|
|
@ -220,10 +221,12 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), {"wav"}, 2);
|
||||
if (tempMusic != "") {
|
||||
Config::MusicPath = tempMusic;
|
||||
changesMade = true;
|
||||
}
|
||||
} else if (Selection == 1) {
|
||||
if (Config::UseBars == true) Config::UseBars = false;
|
||||
else if (Config::UseBars == false) Config::UseBars = true;
|
||||
changesMade = true;
|
||||
} else if (Selection == 2) {
|
||||
if (Msg::promptMsg(Lang::get("ENABLE_GODMODE_PROMPT"))) {
|
||||
Config::GodMode = true;
|
||||
|
|
@ -236,10 +239,12 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), {"wav"}, 2);
|
||||
if (tempMusic != "") {
|
||||
Config::MusicPath = tempMusic;
|
||||
changesMade = true;
|
||||
}
|
||||
} else if (touching(touch, mainButtons[1])) {
|
||||
if (Config::UseBars == true) Config::UseBars = false;
|
||||
else if (Config::UseBars == false) Config::UseBars = true;
|
||||
changesMade = true;
|
||||
} else if (touching(touch, mainButtons[2])) {
|
||||
if (Msg::promptMsg(Lang::get("ENABLE_GODMODE_PROMPT"))) {
|
||||
Config::GodMode = true;
|
||||
|
|
@ -297,6 +302,7 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
|
|||
selectedLang = language;
|
||||
Config::lang = language;
|
||||
Lang::load(Config::lang);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -306,6 +312,7 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
|
|||
selectedLang--;
|
||||
Config::lang = selectedLang;
|
||||
Lang::load(Config::lang);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,6 +321,7 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
|
|||
selectedLang++;
|
||||
Config::lang = selectedLang;
|
||||
Lang::load(Config::lang);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,6 +331,7 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
|
|||
selectedLang -= 5;
|
||||
Config::lang = selectedLang;
|
||||
Lang::load(Config::lang);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -331,6 +340,7 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
|
|||
selectedLang += 5;
|
||||
Config::lang = selectedLang;
|
||||
Lang::load(Config::lang);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +396,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
|||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(red, ColorHelper::getColorValue(Config::progressbarColor, 1), ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -408,6 +419,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
|||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), green, ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
} else if (touching(touch, buttons[2])) {
|
||||
int temp = Input::getUint(255, Lang::get("ENTER_BLUE_RGB"));
|
||||
|
|
@ -428,6 +440,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
|||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), ColorHelper::getColorValue(Config::progressbarColor, 1), blue, 255);
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ extern u32 selected;
|
|||
extern u32 unselected;
|
||||
extern int AutobootWhat;
|
||||
bool changeBackState = false;
|
||||
|
||||
extern bool changesMade;
|
||||
C2D_SpriteSheet appStoreSheet;
|
||||
|
||||
// Parse informations like URL, Title, Author, Description.
|
||||
|
|
@ -515,6 +515,7 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), {});
|
||||
if (tempStore != "") {
|
||||
Config::StorePath = tempStore;
|
||||
changesMade = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -549,6 +550,7 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), {});
|
||||
if (tempStore != "") {
|
||||
Config::StorePath = tempStore;
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue