diff --git a/3ds/assets/romfs/config.json b/3ds/assets/romfs/config.json index 940df32..26d2dd5 100644 --- a/3ds/assets/romfs/config.json +++ b/3ds/assets/romfs/config.json @@ -12,5 +12,7 @@ }, "nand_saves": false, - "version": 2 + "scan_cart": false, + "ftp-enabled": false, + "version": 3 } \ No newline at end of file diff --git a/3ds/include/configuration.hpp b/3ds/include/configuration.hpp index 8d1d163..3a8f4cc 100644 --- a/3ds/include/configuration.hpp +++ b/3ds/include/configuration.hpp @@ -34,7 +34,7 @@ #include #include -#define CONFIG_VERSION 2 +#define CONFIG_VERSION 3 class Configuration { public: @@ -47,6 +47,8 @@ public: bool filter(u64 id); bool favorite(u64 id); bool nandSaves(void); + bool shouldScanCard(void); + bool isFTPEnabled(void); std::vector additionalSaveFolders(u64 id); std::vector additionalExtdataFolders(u64 id); @@ -64,7 +66,7 @@ private: nlohmann::json mJson; std::unordered_set mFilterIds, mFavoriteIds; std::unordered_map> mAdditionalSaveFolders, mAdditionalExtdataFolders; - bool mNandSaves; + bool mNandSaves, mScanCard, mFTPEnabled; std::string BASEPATH = "/3ds/Checkpoint/config.json"; }; diff --git a/3ds/source/configuration.cpp b/3ds/source/configuration.cpp index a307495..6eb0a94 100644 --- a/3ds/source/configuration.cpp +++ b/3ds/source/configuration.cpp @@ -29,7 +29,7 @@ Configuration::Configuration(void) { // check for existing config.json files on the sd card, BASEPATH - if (!io::fileExists(Archive::sdmc(), StringUtils::UTF8toUTF16(BASEPATH.c_str()))) { + if (!mJson.is_object() || mJson.find("version") == mJson.end() || !mJson["version"].is_number_integer()) { store(); } @@ -41,11 +41,67 @@ Configuration::Configuration(void) store(); } else { - // 3.4.2 -> 3.5.0 - if (mJson["version"] < 2) { + if (mJson["version"] < CONFIG_VERSION) { + mJson["version"] = CONFIG_VERSION; + updateJson = true; + } + if (!(mJson.contains("nand_saves") && mJson["nand_saves"].is_boolean())) { + mJson["nand_saves"] = false; + updateJson = true; + } + if (!(mJson.contains("ftp-enabled") && mJson["ftp-enabled"].is_boolean())) { + mJson["ftp-enabled"] = false; + updateJson = true; + } + if (!(mJson.contains("scan_cart") && mJson["scan_cart"].is_boolean())) { + mJson["scan_cart"] = false; + updateJson = true; + } + if (!(mJson.contains("filter") && mJson["filter"].is_array())) { + mJson["filter"] = nlohmann::json::array(); + updateJson = true; + } + if (!(mJson.contains("favorites") && mJson["favorites"].is_array())) { mJson["favorites"] = nlohmann::json::array(); updateJson = true; } + if (!(mJson.contains("additional_save_folders") && mJson["additional_save_folders"].is_array())) { + mJson["additional_save_folders"] = nlohmann::json::array(); + updateJson = true; + } + if (!(mJson.contains("additional_extdata_folders") && mJson["additional_extdata_folders"].is_array())) { + mJson["additional_extdata_folders"] = nlohmann::json::array(); + updateJson = true; + } + // check every single entry in the arrays... + for (auto& obj : mJson["filter"]) { + if (!obj.is_string()) { + mJson["filter"] = nlohmann::json::array(); + updateJson = true; + break; + } + } + for (auto& obj : mJson["favorites"]) { + if (!obj.is_string()) { + mJson["favorites"] = nlohmann::json::array(); + updateJson = true; + break; + } + } + for (auto& obj : mJson["additional_save_folders"]) { + if (!obj.is_string()) { + mJson["additional_save_folders"] = nlohmann::json::array(); + updateJson = true; + break; + } + } + for (auto& obj : mJson["additional_extdata_folders"]) { + if (!obj.is_string()) { + mJson["additional_extdata_folders"] = nlohmann::json::array(); + updateJson = true; + break; + } + } } if (updateJson) { @@ -65,8 +121,9 @@ Configuration::Configuration(void) mFavoriteIds.emplace(strtoull(id.c_str(), NULL, 16)); } - // parse nand saves mNandSaves = mJson["nand_saves"]; + mScanCard = mJson["scan_cart"]; + mFTPEnabled = mJson["ftp-enabled"]; // parse additional save folders auto js = mJson["additional_save_folders"]; @@ -148,4 +205,14 @@ std::vector Configuration::additionalExtdataFolders(u64 id) std::vector emptyvec; auto folders = mAdditionalExtdataFolders.find(id); return folders == mAdditionalExtdataFolders.end() ? emptyvec : folders->second; +} + +bool Configuration::shouldScanCard(void) +{ + return mScanCard; +} + +bool Configuration::isFTPEnabled(void) +{ + return mFTPEnabled; } \ No newline at end of file diff --git a/3ds/source/main.cpp b/3ds/source/main.cpp index de73621..ac74559 100644 --- a/3ds/source/main.cpp +++ b/3ds/source/main.cpp @@ -45,7 +45,9 @@ int main() hidScanInput(); hidTouchRead(&touch); - updateCard(); + if (Configuration::getInstance().shouldScanCard()) { + updateCard(); + } C3D_FrameBegin(C3D_FRAME_SYNCDRAW); g_screen->doDrawTop(); diff --git a/3ds/source/title.cpp b/3ds/source/title.cpp index d7b5139..0cd0e90 100644 --- a/3ds/source/title.cpp +++ b/3ds/source/title.cpp @@ -41,10 +41,10 @@ void Title::load(void) mMedia = MEDIATYPE_SD; mCard = CARD_CTR; memset(productCode, 0, 16); - mShortDescription = StringUtils::UTF8toUTF16(" "); - mLongDescription = StringUtils::UTF8toUTF16(" "); - mSavePath = StringUtils::UTF8toUTF16(" "); - mExtdataPath = StringUtils::UTF8toUTF16(" "); + mShortDescription = StringUtils::UTF8toUTF16(""); + mLongDescription = StringUtils::UTF8toUTF16(""); + mSavePath = StringUtils::UTF8toUTF16(""); + mExtdataPath = StringUtils::UTF8toUTF16(""); mIcon = Gui::noIcon(); mAccessibleSave = false; mAccessibleExtdata = false; @@ -946,8 +946,8 @@ void updateCard(void) FSUSER_CardSlotIsInserted(&cardIn); if (cardIn != oldCardIn) { - bool power; if (cardIn) { + bool power; FSUSER_CardSlotPowerOn(&power); while (!power) { FSUSER_CardSlotGetCardIFPowerStatus(&power);