void loadConfig() { loadConfigWithType(configTypeMain); /* This flag states that the initial load of the config has been completed. It MUST go after loading the main config and before loading the theme config. This is because of the following: - The functions which retrieve data from the config check whether configInitialLoad is false - If it is false, they call loadConfig() (this function) - Loading the theme config requires retrieving the currentTheme setting from the main config - If loadConfigWithType(configTypeTheme) is called while configInitialLoad is false, then retrieving the value of currentTheme will trigger loadConfig() to be called again, and we'll enter an infinite loop - To prevent this, we load the main config (so we know that the value of currentTheme will be available), then we set configInitialLoad to true to prevent further calls to loadConfig(), and only then call loadConfigWithType(configTypeTheme). */ configInitialLoad = true; loadConfigWithType(configTypeTheme); }
void setTheme(char * themeName) { audio_stop(); //Save the selected theme in main config setConfigString("currentTheme", themeName, configTypeMain); //Reload theme config loadConfigWithType(configTypeTheme); //Reload theme variables for menu loadThemeConfig(); loadSplashImages(); if (themeImageExists(themeImageSplashTop)) { drawThemeImage(themeImageSplashTop, GFX_TOP, 0, 0); } if (themeImageExists(themeImageSplashBottom)) { drawThemeImage(themeImageSplashBottom, GFX_BOTTOM, 0, 0); } gfxFlip(); int startMs = osGetTime(); playBootSound(); //Reload theme images initThemeImages(); //Load BGM initThemeSounds(); //Re-initialise colours initColours(); //Force reload of GUI elements statusbarNeedsUpdate = true; toolbarNeedsUpdate = true; alphaImagesDrawn = false; waitForDurationOfSound(&themeSoundBoot, startMs); startBGM(); panelsDrawn = false; pageControlPanelsDrawn = false; }