mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-05 00:38:52 +00:00
*Only* open valid Scripts.
This commit is contained in:
@@ -43,6 +43,8 @@ namespace ScriptHelper {
|
|||||||
void extractFile(std::string file, std::string input, std::string output, std::string message);
|
void extractFile(std::string file, std::string input, std::string output, std::string message);
|
||||||
Result createFile(const char * path);
|
Result createFile(const char * path);
|
||||||
void displayTimeMsg(std::string message, int seconds);
|
void displayTimeMsg(std::string message, int seconds);
|
||||||
|
|
||||||
|
bool checkIfValid(std::string scriptFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -59,7 +59,6 @@ nlohmann::json infoFromScript(const std::string &path) {
|
|||||||
|
|
||||||
FILE* file = fopen(path.c_str(), "r");
|
FILE* file = fopen(path.c_str(), "r");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
fclose(file);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
in = nlohmann::json::parse(file, nullptr, false);
|
in = nlohmann::json::parse(file, nullptr, false);
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ Info parseInfo(std::string fileName) {
|
|||||||
FILE* file = fopen(fileName.c_str(), "rt");
|
FILE* file = fopen(fileName.c_str(), "rt");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
printf("File not found\n");
|
printf("File not found\n");
|
||||||
fclose(file);
|
|
||||||
return {"", ""};
|
return {"", ""};
|
||||||
}
|
}
|
||||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||||
@@ -95,7 +94,6 @@ std::vector<std::string> parseObjects(std::string fileName) {
|
|||||||
FILE* file = fopen(fileName.c_str(), "rt");
|
FILE* file = fopen(fileName.c_str(), "rt");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
printf("File not found\n");
|
printf("File not found\n");
|
||||||
fclose(file);
|
|
||||||
return {{""}};
|
return {{""}};
|
||||||
}
|
}
|
||||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||||
@@ -425,17 +423,19 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
if (hDown & KEY_A) {
|
if (hDown & KEY_A) {
|
||||||
if (dirContents[selection].isDirectory) {
|
if (dirContents[selection].isDirectory) {
|
||||||
} else if (fileInfo.size() != 0) {
|
} else if (fileInfo.size() != 0) {
|
||||||
currentFile = dirContents[selection].name;
|
if (ScriptHelper::checkIfValid(dirContents[selection].name) == true) {
|
||||||
selectedTitle = fileInfo[selection].title;
|
currentFile = dirContents[selection].name;
|
||||||
jsonFile = openScriptFile();
|
selectedTitle = fileInfo[selection].title;
|
||||||
Desc = Description(jsonFile);
|
jsonFile = openScriptFile();
|
||||||
checkForValidate();
|
Desc = Description(jsonFile);
|
||||||
fileInfo2 = parseObjects(currentFile);
|
checkForValidate();
|
||||||
loadColors(jsonFile);
|
fileInfo2 = parseObjects(currentFile);
|
||||||
loadDesc();
|
loadColors(jsonFile);
|
||||||
isScriptSelected = true;
|
loadDesc();
|
||||||
selection = 0;
|
isScriptSelected = true;
|
||||||
mode = 1;
|
selection = 0;
|
||||||
|
mode = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ std::vector<std::string> parseObjects() {
|
|||||||
FILE* file = fopen(tinyDBFile, "rt");
|
FILE* file = fopen(tinyDBFile, "rt");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
printf("File not found\n");
|
printf("File not found\n");
|
||||||
fclose(file);
|
|
||||||
return {{""}};
|
return {{""}};
|
||||||
}
|
}
|
||||||
tinyDBJson = nlohmann::json::parse(file, nullptr, false);
|
tinyDBJson = nlohmann::json::parse(file, nullptr, false);
|
||||||
|
|||||||
@@ -131,4 +131,18 @@ void ScriptHelper::displayTimeMsg(std::string message, int seconds) {
|
|||||||
for (int i = 0; i < 60*seconds; i++) {
|
for (int i = 0; i < 60*seconds; i++) {
|
||||||
gspWaitForVBlank();
|
gspWaitForVBlank();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScriptHelper::checkIfValid(std::string scriptFile) {
|
||||||
|
FILE* file = fopen(scriptFile.c_str(), "rt");
|
||||||
|
if(!file) {
|
||||||
|
printf("File not found\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
if (!json.contains("info")) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user