mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-07 00:39:30 +00:00
Add version checking and don't let it crash, if no files are found.
This commit is contained in:
@@ -68,6 +68,8 @@ namespace Gui
|
|||||||
// Basic GUI.
|
// Basic GUI.
|
||||||
void DrawTop(void);
|
void DrawTop(void);
|
||||||
void DrawBottom(void);
|
void DrawBottom(void);
|
||||||
|
|
||||||
|
void DisplayWarnMsg(std::string Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayMsg(std::string text);
|
void DisplayMsg(std::string text);
|
||||||
|
|||||||
@@ -24,5 +24,8 @@
|
|||||||
|
|
||||||
"ENTER_RED_RGB": "Enter the Red RGB.",
|
"ENTER_RED_RGB": "Enter the Red RGB.",
|
||||||
"ENTER_GREEN_RGB": "Enter the Green RGB.",
|
"ENTER_GREEN_RGB": "Enter the Green RGB.",
|
||||||
"ENTER_BLUE_RGB": "Enter the Blue RGB."
|
"ENTER_BLUE_RGB": "Enter the Blue RGB.",
|
||||||
|
|
||||||
|
"WHAT_DO_YOU_TRY": "What are you trying to do? :P",
|
||||||
|
"INCOMPATIBLE_SCRIPT": "You have an incompatible script."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,21 @@ void DisplayMsg(std::string text) {
|
|||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Gui::DisplayWarnMsg(std::string Text)
|
||||||
|
{
|
||||||
|
Gui::clearTextBufs();
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
C2D_TargetClear(top, BLACK);
|
||||||
|
C2D_TargetClear(bottom, BLACK);
|
||||||
|
Gui::DrawTop();
|
||||||
|
Gui::DrawStringCentered(0, 2, 0.6f, Config::TxtColor, Text.c_str(), 400);
|
||||||
|
Gui::DrawBottom();
|
||||||
|
C3D_FrameEnd(0);
|
||||||
|
for (int i = 0; i < 60*3; i++) {
|
||||||
|
gspWaitForVBlank();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Gui::DrawStringCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth) {
|
void Gui::DrawStringCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth) {
|
||||||
Gui::DrawString((currentScreen ? 200 : 160)+x-(std::min(maxWidth, (int)Gui::GetStringWidth(size, Text))/2), y, size, color, Text, maxWidth);
|
Gui::DrawString((currentScreen ? 200 : 160)+x-(std::min(maxWidth, (int)Gui::GetStringWidth(size, Text))/2), y, size, color, Text, maxWidth);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,19 @@ Info parseInfo(std::string fileName) {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkForValidate(void) {
|
||||||
|
FILE* file = fopen(currentFile.c_str(), "rt");
|
||||||
|
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
std::string version;
|
||||||
|
version = get(json, "info", "version");
|
||||||
|
if (version != "1") {
|
||||||
|
Gui::DisplayWarnMsg(Lang::get("INCOMPATIBLE_SCRIPT"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Objects like Release or Nightly.
|
// Objects like Release or Nightly.
|
||||||
std::vector<std::string> parseObjects(std::string fileName) {
|
std::vector<std::string> parseObjects(std::string fileName) {
|
||||||
FILE* file = fopen(fileName.c_str(), "rt");
|
FILE* file = fopen(fileName.c_str(), "rt");
|
||||||
@@ -235,10 +248,15 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hDown & KEY_A) {
|
if (hDown & KEY_A) {
|
||||||
currentFile = dirContents[selection].name;
|
if (fileInfo.size() == 0) {
|
||||||
fileInfo2 = parseObjects(currentFile);
|
Gui::DisplayWarnMsg(Lang::get("WHAT_DO_YOU_TRY"));
|
||||||
selection = 0;
|
} else {
|
||||||
mode = 1;
|
currentFile = dirContents[selection].name;
|
||||||
|
checkForValidate();
|
||||||
|
fileInfo2 = parseObjects(currentFile);
|
||||||
|
selection = 0;
|
||||||
|
mode = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selection < screenPos) {
|
if(selection < screenPos) {
|
||||||
@@ -275,8 +293,12 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hDown & KEY_A) {
|
if (hDown & KEY_A) {
|
||||||
choice = fileInfo2[selection2];
|
if (fileInfo2.size() == 0) {
|
||||||
runFunctions();
|
Gui::DisplayWarnMsg(Lang::get("WHAT_DO_YOU_TRY"));
|
||||||
|
} else {
|
||||||
|
choice = fileInfo2[selection2];
|
||||||
|
runFunctions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hDown & KEY_B) {
|
if (hDown & KEY_B) {
|
||||||
|
|||||||
Reference in New Issue
Block a user