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,
|
"nand_saves": false,
|
||||||
"version": 2
|
"scan_cart": false,
|
||||||
|
"ftp-enabled": false,
|
||||||
|
"version": 3
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define CONFIG_VERSION 2
|
#define CONFIG_VERSION 3
|
||||||
|
|
||||||
class Configuration {
|
class Configuration {
|
||||||
public:
|
public:
|
||||||
|
@ -47,6 +47,8 @@ public:
|
||||||
bool filter(u64 id);
|
bool filter(u64 id);
|
||||||
bool favorite(u64 id);
|
bool favorite(u64 id);
|
||||||
bool nandSaves(void);
|
bool nandSaves(void);
|
||||||
|
bool shouldScanCard(void);
|
||||||
|
bool isFTPEnabled(void);
|
||||||
std::vector<std::u16string> additionalSaveFolders(u64 id);
|
std::vector<std::u16string> additionalSaveFolders(u64 id);
|
||||||
std::vector<std::u16string> additionalExtdataFolders(u64 id);
|
std::vector<std::u16string> additionalExtdataFolders(u64 id);
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ private:
|
||||||
nlohmann::json mJson;
|
nlohmann::json mJson;
|
||||||
std::unordered_set<u64> mFilterIds, mFavoriteIds;
|
std::unordered_set<u64> mFilterIds, mFavoriteIds;
|
||||||
std::unordered_map<u64, std::vector<std::u16string>> mAdditionalSaveFolders, mAdditionalExtdataFolders;
|
std::unordered_map<u64, std::vector<std::u16string>> mAdditionalSaveFolders, mAdditionalExtdataFolders;
|
||||||
bool mNandSaves;
|
bool mNandSaves, mScanCard, mFTPEnabled;
|
||||||
std::string BASEPATH = "/3ds/Checkpoint/config.json";
|
std::string BASEPATH = "/3ds/Checkpoint/config.json";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
Configuration::Configuration(void)
|
Configuration::Configuration(void)
|
||||||
{
|
{
|
||||||
// check for existing config.json files on the sd card, BASEPATH
|
// 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();
|
store();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,67 @@ Configuration::Configuration(void)
|
||||||
store();
|
store();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 3.4.2 -> 3.5.0
|
if (mJson["version"] < CONFIG_VERSION) {
|
||||||
if (mJson["version"] < 2) {
|
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();
|
mJson["favorites"] = nlohmann::json::array();
|
||||||
updateJson = true;
|
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) {
|
if (updateJson) {
|
||||||
|
@ -65,8 +121,9 @@ Configuration::Configuration(void)
|
||||||
mFavoriteIds.emplace(strtoull(id.c_str(), NULL, 16));
|
mFavoriteIds.emplace(strtoull(id.c_str(), NULL, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse nand saves
|
|
||||||
mNandSaves = mJson["nand_saves"];
|
mNandSaves = mJson["nand_saves"];
|
||||||
|
mScanCard = mJson["scan_cart"];
|
||||||
|
mFTPEnabled = mJson["ftp-enabled"];
|
||||||
|
|
||||||
// parse additional save folders
|
// parse additional save folders
|
||||||
auto js = mJson["additional_save_folders"];
|
auto js = mJson["additional_save_folders"];
|
||||||
|
@ -148,4 +205,14 @@ std::vector<std::u16string> Configuration::additionalExtdataFolders(u64 id)
|
||||||
std::vector<std::u16string> emptyvec;
|
std::vector<std::u16string> emptyvec;
|
||||||
auto folders = mAdditionalExtdataFolders.find(id);
|
auto folders = mAdditionalExtdataFolders.find(id);
|
||||||
return folders == mAdditionalExtdataFolders.end() ? emptyvec : folders->second;
|
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();
|
hidScanInput();
|
||||||
hidTouchRead(&touch);
|
hidTouchRead(&touch);
|
||||||
|
|
||||||
updateCard();
|
if (Configuration::getInstance().shouldScanCard()) {
|
||||||
|
updateCard();
|
||||||
|
}
|
||||||
|
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
g_screen->doDrawTop();
|
g_screen->doDrawTop();
|
||||||
|
|
|
@ -41,10 +41,10 @@ void Title::load(void)
|
||||||
mMedia = MEDIATYPE_SD;
|
mMedia = MEDIATYPE_SD;
|
||||||
mCard = CARD_CTR;
|
mCard = CARD_CTR;
|
||||||
memset(productCode, 0, 16);
|
memset(productCode, 0, 16);
|
||||||
mShortDescription = StringUtils::UTF8toUTF16(" ");
|
mShortDescription = StringUtils::UTF8toUTF16("");
|
||||||
mLongDescription = StringUtils::UTF8toUTF16(" ");
|
mLongDescription = StringUtils::UTF8toUTF16("");
|
||||||
mSavePath = StringUtils::UTF8toUTF16(" ");
|
mSavePath = StringUtils::UTF8toUTF16("");
|
||||||
mExtdataPath = StringUtils::UTF8toUTF16(" ");
|
mExtdataPath = StringUtils::UTF8toUTF16("");
|
||||||
mIcon = Gui::noIcon();
|
mIcon = Gui::noIcon();
|
||||||
mAccessibleSave = false;
|
mAccessibleSave = false;
|
||||||
mAccessibleExtdata = false;
|
mAccessibleExtdata = false;
|
||||||
|
@ -946,8 +946,8 @@ void updateCard(void)
|
||||||
|
|
||||||
FSUSER_CardSlotIsInserted(&cardIn);
|
FSUSER_CardSlotIsInserted(&cardIn);
|
||||||
if (cardIn != oldCardIn) {
|
if (cardIn != oldCardIn) {
|
||||||
bool power;
|
|
||||||
if (cardIn) {
|
if (cardIn) {
|
||||||
|
bool power;
|
||||||
FSUSER_CardSlotPowerOn(&power);
|
FSUSER_CardSlotPowerOn(&power);
|
||||||
while (!power) {
|
while (!power) {
|
||||||
FSUSER_CardSlotGetCardIFPowerStatus(&power);
|
FSUSER_CardSlotGetCardIFPowerStatus(&power);
|
||||||
|
|
Loading…
Reference in a new issue