mirror of
https://github.com/BernardoGiordano/Checkpoint
synced 2025-02-18 00:08:24 +00:00
parent
e5fd2f04dd
commit
440904590b
6 changed files with 13154 additions and 5 deletions
3
3ds/assets/romfs/config.json
Normal file
3
3ds/assets/romfs/config.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"filter": [ ]
|
||||
}
|
61
3ds/include/confighandler.hpp
Normal file
61
3ds/include/confighandler.hpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file is part of Checkpoint
|
||||
* Copyright (C) 2017-2018 Bernardo Giordano
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#ifndef CONFIGHANDLER_HPP
|
||||
#define CONFIGHANDLER_HPP
|
||||
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include "json.hpp"
|
||||
#include "io.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public:
|
||||
static Configuration& getInstance(void)
|
||||
{
|
||||
static Configuration mConfiguration;
|
||||
return mConfiguration;
|
||||
}
|
||||
|
||||
bool filter(u64 id);
|
||||
|
||||
private:
|
||||
Configuration(void);
|
||||
~Configuration(void) { };
|
||||
|
||||
Configuration(Configuration const&) = delete;
|
||||
void operator=(Configuration const&) = delete;
|
||||
|
||||
nlohmann::json mJson;
|
||||
std::unordered_set<u64> mFilterIds;
|
||||
std::string BASEPATH = "/3ds/Checkpoint/config.json";
|
||||
};
|
||||
|
||||
#endif
|
|
@ -32,6 +32,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include "archive.hpp"
|
||||
#include "confighandler.hpp"
|
||||
#include "directory.hpp"
|
||||
#include "fsstream.hpp"
|
||||
#include "io.hpp"
|
||||
|
|
79
3ds/source/confighandler.cpp
Normal file
79
3ds/source/confighandler.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of Checkpoint
|
||||
* Copyright (C) 2017-2018 Bernardo Giordano
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "confighandler.hpp"
|
||||
|
||||
Configuration::Configuration(void)
|
||||
{
|
||||
// check for existing config.json files on the sd card, BASEPATH
|
||||
if (!io::fileExists(Archive::sdmc(), StringUtils::UTF8toUTF16(BASEPATH.c_str())))
|
||||
{
|
||||
FILE* inFile = fopen("romfs:/config.json", "r");
|
||||
if (inFile == NULL)
|
||||
{
|
||||
// handle failures here
|
||||
return;
|
||||
}
|
||||
fseek(inFile, 0, SEEK_END);
|
||||
u32 size = ftell(inFile);
|
||||
u8* config = new u8[size];
|
||||
if (config == NULL)
|
||||
{
|
||||
fclose(inFile);
|
||||
return;
|
||||
}
|
||||
rewind(inFile);
|
||||
fread(config, size, 1, inFile);
|
||||
fclose(inFile);
|
||||
|
||||
// store the config file inside of BASEPATH
|
||||
FILE* outFile = fopen(BASEPATH.c_str(), "w");
|
||||
if (outFile == NULL)
|
||||
{
|
||||
// handle failures here
|
||||
return;
|
||||
}
|
||||
fwrite(config, 1, size, outFile);
|
||||
fclose(outFile);
|
||||
|
||||
// load json config file
|
||||
std::ifstream i(BASEPATH);
|
||||
i >> mJson;
|
||||
i.close();
|
||||
|
||||
// parse filters
|
||||
std::vector<std::string> filter = mJson["filter"];
|
||||
for (auto& id : filter)
|
||||
{
|
||||
mFilterIds.emplace(strtoull(id.c_str(), NULL, 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Configuration::filter(u64 id)
|
||||
{
|
||||
return mFilterIds.find(id) != mFilterIds.end();
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "title.hpp"
|
||||
|
||||
static bool checkHigh(u64 id);
|
||||
static bool validId(u64 id);
|
||||
static C2D_Image loadTextureIcon(smdh_s *smdh);
|
||||
|
||||
static std::vector<Title> titleSaves;
|
||||
|
@ -330,10 +330,10 @@ C2D_Image Title::icon(void)
|
|||
return mIcon;
|
||||
}
|
||||
|
||||
static bool checkHigh(u64 id)
|
||||
static bool validId(u64 id)
|
||||
{
|
||||
u32 high = id >> 32;
|
||||
return (high == 0x00040000 || high == 0x00040002);
|
||||
return !Configuration::getInstance().filter(id) && (high == 0x00040000 || high == 0x00040002);
|
||||
}
|
||||
|
||||
void loadTitles(bool forceRefresh)
|
||||
|
@ -402,7 +402,7 @@ void loadTitles(bool forceRefresh)
|
|||
|
||||
for (u32 i = 0; i < count; i++)
|
||||
{
|
||||
if (checkHigh(ids[i]))
|
||||
if (validId(ids[i]))
|
||||
{
|
||||
Title title;
|
||||
if (title.load(ids[i], MEDIATYPE_SD, CARD_CTR))
|
||||
|
@ -438,7 +438,7 @@ void loadTitles(bool forceRefresh)
|
|||
if (count > 0)
|
||||
{
|
||||
AM_GetTitleList(NULL, MEDIATYPE_GAME_CARD, count, ids);
|
||||
if (checkHigh(ids[0]))
|
||||
if (validId(ids[0]))
|
||||
{
|
||||
Title title;
|
||||
if (title.load(ids[0], MEDIATYPE_GAME_CARD, cardType))
|
||||
|
|
13005
common/json.hpp
Normal file
13005
common/json.hpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue