From 5e5658cb750dc05119f8374ad8ece2a72b3c6ea0 Mon Sep 17 00:00:00 2001 From: VoltZ <47382115+SuperSaiyajinVoltZ@users.noreply.github.com> Date: Sun, 17 Nov 2019 23:03:52 +0100 Subject: [PATCH] Music Path can be changed in the JSON now. --- include/utils/common.hpp | 1 + include/utils/config.hpp | 2 +- source/main.cpp | 4 ++-- source/utils/config.cpp | 10 ++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/utils/common.hpp b/include/utils/common.hpp index 200490b..819acea 100644 --- a/include/utils/common.hpp +++ b/include/utils/common.hpp @@ -60,4 +60,5 @@ extern char * arg0; #define WORKING_DIR "/" #define SCRIPTS_PATH "sdmc:/3ds/Universal-Updater/scripts/" // The Scripts will be here. +#define MUSIC_PATH "sdmc:/3ds/Universal-Updater/Music.wav" // Default Music File / Path. #define SCRIPT_VERSION 2 \ No newline at end of file diff --git a/include/utils/config.hpp b/include/utils/config.hpp index 6a06823..c481ae7 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -31,7 +31,7 @@ namespace Config { extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor; - extern std::string ScriptPath; + extern std::string ScriptPath, MusicPath; void load(); void save(); diff --git a/source/main.cpp b/source/main.cpp index 31af536..708b006 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -57,8 +57,8 @@ bool touching(touchPosition touch, Structs::ButtonPos button) { void loadSoundEffects(void) { if (dspFound == true) { - if( access( "sdmc:/3ds/Universal-Updater/Music.wav", F_OK ) != -1 ) { - bgm = new sound("sdmc:/3ds/Universal-Updater/Music.wav", 1, true); + if( access( Config::MusicPath.c_str(), F_OK ) != -1 ) { + bgm = new sound(Config::MusicPath, 1, true); songIsFound = true; } } diff --git a/source/utils/config.cpp b/source/utils/config.cpp index dd98beb..c295ffb 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -44,6 +44,7 @@ int Config::viewMode; int Config::ColorKeys; int Config::progressbarColor; std::string Config::ScriptPath; +std::string Config::MusicPath; nlohmann::json configJson; void Config::load() { @@ -117,6 +118,12 @@ void Config::load() { Config::progressbarColor = getInt("PROGRESSBARCOLOR"); } + if(!configJson.contains("MUSICPATH")) { + Config::MusicPath = MUSIC_PATH; + } else { + Config::MusicPath = getString("MUSICPATH"); + } + fclose(file); } else { Config::Color1 = BarColor; @@ -130,6 +137,7 @@ void Config::load() { Config::viewMode = 0; Config::ColorKeys = C2D_Color32(0, 0, 200, 255); Config::progressbarColor = WHITE; + Config::MusicPath = MUSIC_PATH; } } @@ -145,6 +153,7 @@ void Config::save() { Config::setInt("VIEWMODE", Config::viewMode); Config::setInt("COLORKEYS", Config::ColorKeys); Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor); + Config::setString("MUSICPATH", Config::MusicPath); FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w"); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); fclose(file); @@ -164,6 +173,7 @@ void Config::initializeNewConfig() { Config::setInt("VIEWMODE", 0); Config::setInt("COLORKEYS", C2D_Color32(0, 0, 200, 255)); Config::setInt("PROGRESSBARCOLOR", WHITE); + Config::setString("MUSICPATH", MUSIC_PATH); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); fclose(file);