mirror of
https://github.com/BernardoGiordano/Checkpoint
synced 2024-11-14 21:57:13 +00:00
Only update the card optionally
This commit is contained in:
parent
a54fcb8834
commit
1cba69344e
5 changed files with 86 additions and 13 deletions
|
@ -12,5 +12,7 @@
|
|||
|
||||
},
|
||||
"nand_saves": false,
|
||||
"version": 2
|
||||
"scan_cart": false,
|
||||
"ftp-enabled": false,
|
||||
"version": 3
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#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<std::u16string> additionalSaveFolders(u64 id);
|
||||
std::vector<std::u16string> additionalExtdataFolders(u64 id);
|
||||
|
||||
|
@ -64,7 +66,7 @@ private:
|
|||
nlohmann::json mJson;
|
||||
std::unordered_set<u64> mFilterIds, mFavoriteIds;
|
||||
std::unordered_map<u64, std::vector<std::u16string>> mAdditionalSaveFolders, mAdditionalExtdataFolders;
|
||||
bool mNandSaves;
|
||||
bool mNandSaves, mScanCard, mFTPEnabled;
|
||||
std::string BASEPATH = "/3ds/Checkpoint/config.json";
|
||||
};
|
||||
|
||||
|
|
|
@ -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"];
|
||||
|
@ -149,3 +206,13 @@ std::vector<std::u16string> Configuration::additionalExtdataFolders(u64 id)
|
|||
auto folders = mAdditionalExtdataFolders.find(id);
|
||||
return folders == mAdditionalExtdataFolders.end() ? emptyvec : folders->second;
|
||||
}
|
||||
|
||||
bool Configuration::shouldScanCard(void)
|
||||
{
|
||||
return mScanCard;
|
||||
}
|
||||
|
||||
bool Configuration::isFTPEnabled(void)
|
||||
{
|
||||
return mFTPEnabled;
|
||||
}
|
|
@ -45,7 +45,9 @@ int main()
|
|||
hidScanInput();
|
||||
hidTouchRead(&touch);
|
||||
|
||||
if (Configuration::getInstance().shouldScanCard()) {
|
||||
updateCard();
|
||||
}
|
||||
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
g_screen->doDrawTop();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue