See desc for stuff.

Added Max Width to missing stuff.

Added Screenshots and string fix.

Added Missing Regex stuff.

Added skipCount to promptMessage + added exit function.
This commit is contained in:
StackZ
2020-10-30 09:23:24 +01:00
parent 8e369d2d1f
commit 400acf94c8
25 changed files with 110 additions and 70 deletions
+12 -10
View File
@@ -39,7 +39,7 @@ void Msg::DisplayMsg(const std::string &Text) {
C2D_TargetClear(Bottom, TRANSPARENT);
GFX::DrawTop();
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, Text)) / 2, 0.6f, TEXT_COLOR, Text, 395, 100);
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, Text)) / 2, 0.6f, TEXT_COLOR, Text, 395);
GFX::DrawBottom();
C3D_FrameEnd(0);
}
@@ -56,7 +56,7 @@ void Msg::DisplayWarnMsg(const std::string &Text) {
C2D_TargetClear(Bottom, TRANSPARENT);
GFX::DrawTop();
Gui::DrawStringCentered(0, 1, 0.6f, TEXT_COLOR, Text, 400);
Gui::DrawStringCentered(0, 1, 0.6f, TEXT_COLOR, Text, 390);
GFX::DrawBottom();
C3D_FrameEnd(0);
@@ -79,15 +79,16 @@ bool Msg::promptMsg(const std::string &promptMsg) {
GFX::DrawTop();
Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, promptMsg)) / 2, 0.6f, TEXT_COLOR, promptMsg, 395, 100);
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, promptMsg)) / 2, 0.6f, TEXT_COLOR, promptMsg, 395);
Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("CONFIRM_OR_CANCEL"), 400);
Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("CONFIRM_OR_CANCEL"), 390);
C3D_FrameEnd(0);
for (int i = 0; i < 20; i++) gspWaitForVBlank();
for (int i = 0; i < 3; i++) gspWaitForVBlank();
hidScanInput();
while(1) {
hidScanInput();
if (hidKeysDown() & KEY_A) return true;
else if (hidKeysDown() & KEY_B) return false;
}
@@ -106,17 +107,18 @@ void Msg::waitMsg(const std::string &msg) {
C2D_TargetClear(Top, TRANSPARENT);
GFX::DrawTop();
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, msg)) / 2, 0.6f, TEXT_COLOR, msg, 395, 100);
Gui::DrawStringCentered(0, (240 - Gui::GetStringHeight(0.6f, msg)) / 2, 0.6f, TEXT_COLOR, msg, 395);
Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("KEY_CONTINUE"), 400);
Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("KEY_CONTINUE"), 390);
C3D_FrameEnd(0);
for (int i = 0; i < 20; i++) gspWaitForVBlank();
for (int i = 0; i < 3; i++) gspWaitForVBlank();
hidScanInput();
while(!doOut) {
hidScanInput();
if (hidKeysDown()) doOut = !doOut;
}
}
+2 -2
View File
@@ -48,8 +48,8 @@ void Overlays::ShowCredits() {
Gui::DrawString(10, 90, 0.5f, TEXT_COLOR, "- FlagBrew");
Gui::DrawString(10, 110, 0.5f, TEXT_COLOR, "- https://icons8.com/");
Gui::DrawString(10, 130, 0.5f, TEXT_COLOR, "- PabloMK7");
Gui::DrawString(10, 150, 0.5f, TEXT_COLOR, Lang::get("CONTRIBUTOR_TRANSLATORS"));
Gui::DrawString(10, 195, 0.5f, TEXT_COLOR, Lang::get("GITHUB"));
Gui::DrawString(10, 150, 0.5f, TEXT_COLOR, Lang::get("CONTRIBUTOR_TRANSLATORS"), 210);
Gui::DrawString(10, 197, 0.5f, TEXT_COLOR, Lang::get("GITHUB"), 390);
Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR);
+1 -1
View File
@@ -79,7 +79,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms
Gui::Draw_Rect(0, 215, 320, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 320, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 220, 0.5f, TEXT_COLOR, Lang::get("START_SELECT"), 390);
Gui::DrawStringCentered(0, 220, 0.5f, TEXT_COLOR, Lang::get("START_SELECT"), 310);
if (dirContents.size() > 0) {
for(int i = 0; i < 7 && i < (int)dirContents.size(); i++) {
+9 -9
View File
@@ -36,14 +36,14 @@ static const std::vector<std::string> languages = { "Bruh", "Dansk", "Deutsch",
static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "pl", "pt", "ru", "jp "};
static const std::vector<Structs::ButtonPos> mainButtons = {
{ 85, 4, 150, 22 },
{ 85, 34, 150, 22 },
{ 85, 64, 150, 22 },
{ 85, 94, 150, 22 },
{ 85, 124, 150, 22 },
{ 85, 154, 150, 22 },
{ 85, 184, 150, 22 },
{ 85, 214, 150, 22 }
{ 10, 4, 300, 22 },
{ 10, 34, 300, 22 },
{ 10, 64, 300, 22 },
{ 10, 94, 300, 22 },
{ 10, 124, 300, 22 },
{ 10, 154, 300, 22 },
{ 10, 184, 300, 22 },
{ 10, 214, 300, 22 }
};
/*
@@ -66,7 +66,7 @@ void Overlays::SelectLanguage() {
GFX::DrawBottom();
for(int i = 0; i < 8 && i < (int)languages.size(); i++) {
GFX::drawBox(85, mainButtons[i].y, 150, 22, sPos + i == selection);
GFX::drawBox(10, mainButtons[i].y, 300, 22, sPos + i == selection);
Gui::DrawStringCentered(0, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, languages[sPos + i], 280);
}
C3D_FrameEnd(0);
+9 -9
View File
@@ -179,30 +179,30 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
C2D_TargetClear(Bottom, TRANSPARENT);
GFX::DrawTop();
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_UNISTORE_2"));
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_UNISTORE_2"), 390);
if (info.size() > 0) {
if (info[selection].StoreSize != -1) {
Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, info[selection].Title, 370);
Gui::DrawStringCentered(0, 60, 0.5f, TEXT_COLOR, info[selection].Author, 370);
Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, info[selection].Title, 380);
Gui::DrawStringCentered(0, 60, 0.5f, TEXT_COLOR, info[selection].Author, 380);
if (info[selection].Description != "") {
/* "\n\n" breaks C2D_WordWrap, so check here. */
if (!(info[selection].Description.find("\n\n") != std::string::npos)) {
Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 390, 95, nullptr, C2D_WordWrap);
Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 380, 95, nullptr, C2D_WordWrap);
} else {
Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 390, 95);
Gui::DrawStringCentered(0, 100, 0.5f, TEXT_COLOR, info[selection].Description, 380, 95);
}
}
} else {
Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 370);
Gui::DrawStringCentered(0, 30, 0.6f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 380);
}
Gui::DrawString(10, 200, 0.4, TEXT_COLOR, "- " + Lang::get("ENTRIES") + ": " + std::to_string(info[selection].StoreSize));
Gui::DrawString(10, 210, 0.4, TEXT_COLOR, "- " + Lang::get("VERSION") + ": " + std::to_string(info[selection].Version));
Gui::DrawString(10, 220, 0.4, TEXT_COLOR, "- " + Lang::get("REVISION") + ": " + std::to_string(info[selection].Revision));
Gui::DrawString(10, 200, 0.4, TEXT_COLOR, "- " + Lang::get("ENTRIES") + ": " + std::to_string(info[selection].StoreSize), 150);
Gui::DrawString(10, 210, 0.4, TEXT_COLOR, "- " + Lang::get("VERSION") + ": " + std::to_string(info[selection].Version), 150);
Gui::DrawString(10, 220, 0.4, TEXT_COLOR, "- " + Lang::get("REVISION") + ": " + std::to_string(info[selection].Revision), 150);
GFX::DrawBottom();
+1 -1
View File
@@ -68,7 +68,7 @@ MainScreen::MainScreen() {
*/
void MainScreen::Draw(void) const {
GFX::DrawTop();
if (this->store && this->store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7, TEXT_COLOR, this->store->GetUniStoreTitle());
if (this->store && this->store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, this->store->GetUniStoreTitle(), 370);
else Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 370);
config->list() ? StoreUtils::DrawList(this->store, this->entries) : StoreUtils::DrawGrid(this->store, this->entries);
+1 -1
View File
@@ -57,7 +57,7 @@ void StoreUtils::DrawDownList(const std::unique_ptr<Store> &store, const std::ve
}
} else { // If no downloads available..
Gui::DrawStringCentered(25, downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 260);
Gui::DrawStringCentered(25, downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 255);
}
}
}
+2 -2
View File
@@ -47,10 +47,10 @@ void StoreUtils::DrawEntryInfo(const std::unique_ptr<Store> &store, const std::u
if (entry->GetDescription() != "") {
/* "\n\n" breaks C2D_WordWrap, so check here. */
if (!(entry->GetDescription().find("\n\n") != std::string::npos)) {
Gui::DrawStringCentered(25, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 220, 0, nullptr, C2D_WordWrap);
Gui::DrawStringCentered(25, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 240, 0, nullptr, C2D_WordWrap);
} else {
Gui::DrawStringCentered(25, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 220, 0);
Gui::DrawStringCentered(25, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 240, 0);
}
}
+6 -6
View File
@@ -66,16 +66,16 @@ void StoreUtils::DrawSearchMenu(const std::vector<bool> &searchIncludes, const s
GFX::DrawCheckbox(SearchMenu[i + 1].x, SearchMenu[i + 1].y, searchIncludes[i]);
}
Gui::DrawString(84, 60, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"));
Gui::DrawString(84, 60, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"), 265);
Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, TEXT_COLOR, Lang::get("TITLE"));
Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, TEXT_COLOR, Lang::get("AUTHOR"));
Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, TEXT_COLOR, Lang::get("TITLE"), 90);
Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, TEXT_COLOR, Lang::get("AUTHOR"), 90);
Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, TEXT_COLOR, Lang::get("CATEGORY"));
Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"));
Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, TEXT_COLOR, Lang::get("CATEGORY"), 90);
Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"), 90);
/* Filters. */
Gui::DrawString(84, 150, 0.5, TEXT_COLOR, Lang::get("FILTER_TO"));
Gui::DrawString(84, 150, 0.5, TEXT_COLOR, Lang::get("FILTER_TO"), 265);
GFX::drawBox(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, marks & favoriteMarks::STAR);
GFX::drawBox(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, marks & favoriteMarks::HEART);
+7 -7
View File
@@ -55,13 +55,13 @@ static void DrawSettingsMain(const int &selection) {
GFX::drawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, i == selection);
}
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[0].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[0]), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[1].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[1]), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[2].y + 4, 0.45f, TEXT_COLOR, Lang::get(autoupdate()), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[3].y + 4, 0.45f, TEXT_COLOR, Lang::get(updateCheck()), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[4].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[2]), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[5].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[3]), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[6].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[4]), 260);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[0].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[0]), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[1].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[1]), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[2].y + 4, 0.45f, TEXT_COLOR, Lang::get(autoupdate()), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[3].y + 4, 0.45f, TEXT_COLOR, Lang::get(updateCheck()), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[4].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[2]), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[5].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[3]), 255);
Gui::DrawStringCentered(54 - 160 + (262 / 2), mainButtons[6].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[4]), 255);
}
/*
+10 -10
View File
@@ -74,28 +74,28 @@ static const uint8_t GetType(const SortType &st) {
*/
void StoreUtils::DrawSorting(const bool &asc, const SortType &st) {
/* Sort By. */
Gui::DrawString(buttons[0].x + 5, buttons[0].y - 20, 0.6f, TEXT_COLOR, Lang::get("SORT_BY"));
Gui::DrawString(buttons[0].x + 5, buttons[0].y - 20, 0.6f, TEXT_COLOR, Lang::get("SORT_BY"), 90);
for (int i = 0; i < 3; i++) {
DrawCheck(i, i == GetType(st));
}
Gui::DrawString(buttons[0].x + 25, buttons[0].y + 2, 0.4f, TEXT_COLOR, Lang::get("TITLE"));
Gui::DrawString(buttons[1].x + 25, buttons[1].y + 2, 0.4f, TEXT_COLOR, Lang::get("AUTHOR"));
Gui::DrawString(buttons[2].x + 25, buttons[2].y + 2, 0.4f, TEXT_COLOR, Lang::get("LAST_UPDATED"));
Gui::DrawString(buttons[0].x + 25, buttons[0].y + 2, 0.4f, TEXT_COLOR, Lang::get("TITLE"), 80);
Gui::DrawString(buttons[1].x + 25, buttons[1].y + 2, 0.4f, TEXT_COLOR, Lang::get("AUTHOR"), 80);
Gui::DrawString(buttons[2].x + 25, buttons[2].y + 2, 0.4f, TEXT_COLOR, Lang::get("LAST_UPDATED"), 80);
/* Direction. */
Gui::DrawString(buttons[3].x + 5, buttons[3].y - 20, 0.6f, TEXT_COLOR, Lang::get("DIRECTION"));
Gui::DrawString(buttons[3].x + 5, buttons[3].y - 20, 0.6f, TEXT_COLOR, Lang::get("DIRECTION"), 80);
DrawCheck(3, asc);
DrawCheck(4, !asc);
Gui::DrawString(buttons[3].x + 25, buttons[3].y + 2, 0.4f, TEXT_COLOR, Lang::get("ASCENDING"));
Gui::DrawString(buttons[4].x + 25, buttons[4].y + 2, 0.4f, TEXT_COLOR, Lang::get("DESCENDING"));
Gui::DrawString(buttons[3].x + 25, buttons[3].y + 2, 0.4f, TEXT_COLOR, Lang::get("ASCENDING"), 80);
Gui::DrawString(buttons[4].x + 25, buttons[4].y + 2, 0.4f, TEXT_COLOR, Lang::get("DESCENDING"), 80);
/* Top Style. */
Gui::DrawString(buttons[5].x + 5, buttons[5].y - 20, 0.6f, TEXT_COLOR, Lang::get("TOP_STYLE"));
Gui::DrawString(buttons[5].x + 5, buttons[5].y - 20, 0.6f, TEXT_COLOR, Lang::get("TOP_STYLE"), 90);
DrawCheck(5, config->list());
DrawCheck(6, !config->list());
Gui::DrawString(buttons[5].x + 25, buttons[5].y + 2, 0.4f, TEXT_COLOR, Lang::get("LIST"));
Gui::DrawString(buttons[6].x + 25, buttons[6].y + 2, 0.4f, TEXT_COLOR, Lang::get("GRID"));
Gui::DrawString(buttons[5].x + 25, buttons[5].y + 2, 0.4f, TEXT_COLOR, Lang::get("LIST"), 90);
Gui::DrawString(buttons[6].x + 25, buttons[6].y + 2, 0.4f, TEXT_COLOR, Lang::get("GRID"), 90);
}
/*
+1
View File
@@ -383,6 +383,7 @@ std::string Store::GetLicenseEntry(const int &index) const {
*/
C2D_Image Store::GetIconEntry(const int &index) const {
if (!this->valid) return C2D_SpriteSheetGetImage(sprites, sprites_noIcon_idx);
if (this->sheets.empty()) return C2D_SpriteSheetGetImage(sprites, sprites_noIcon_idx);
int iconIndex = -1, sheetIndex = 0;
if (index > (int)this->storeJson["storeContent"].size() - 1) return C2D_SpriteSheetGetImage(sprites, sprites_noIcon_idx);
+48 -11
View File
@@ -53,6 +53,8 @@ bool ScriptUtils::matchPattern(const std::string &pattern, const std::string &te
Result ScriptUtils::removeFile(const std::string &file, const std::string &message) {
std::string out;
out = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
out = std::regex_replace(out, std::regex("%3DSX%"), config->_3dsxPath());
out = std::regex_replace(out, std::regex("%NDS%"), config->ndsPath());
Result ret = NONE;
if (access(out.c_str(), F_OK) != 0) return DELETE_ERROR;
@@ -94,11 +96,19 @@ Result ScriptUtils::copyFile(const std::string &source, const std::string &desti
Result ret = NONE;
if (access(source.c_str(), F_OK) != 0) return COPY_ERROR;
Msg::DisplayMsg(message);
/* If destination does not exist, create dirs. */
if (access(destination.c_str(), F_OK) != 0) makeDirs(destination.c_str());
std::string _source, _dest;
_source = std::regex_replace(source, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
_source = std::regex_replace(_source, std::regex("%3DSX%"), config->_3dsxPath());
_source = std::regex_replace(_source, std::regex("%NDS%"), config->ndsPath());
_dest = std::regex_replace(destination, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
_dest = std::regex_replace(_dest, std::regex("%3DSX%"), config->_3dsxPath());
_dest = std::regex_replace(_dest, std::regex("%NDS%"), config->ndsPath());
fcopy(source.c_str(), destination.c_str());
Msg::DisplayMsg(message);
/* If destination does not exist, create dirs. */
if (access(_dest.c_str(), F_OK) != 0) makeDirs(_dest.c_str());
fcopy(_source.c_str(), _dest.c_str());
return ret;
}
@@ -106,14 +116,23 @@ Result ScriptUtils::copyFile(const std::string &source, const std::string &desti
Rename / Move a file.
*/
Result ScriptUtils::renameFile(const std::string &oldName, const std::string &newName, const std::string &message) {
Result ret = NONE;
if (access(oldName.c_str(), F_OK) != 0) return MOVE_ERROR;
std::string old, _new;
old = std::regex_replace(oldName, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
old = std::regex_replace(old, std::regex("%3DSX%"), config->_3dsxPath());
old = std::regex_replace(old, std::regex("%NDS%"), config->ndsPath());
_new = std::regex_replace(newName, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
_new = std::regex_replace(_new, std::regex("%3DSX%"), config->_3dsxPath());
_new = std::regex_replace(_new, std::regex("%NDS%"), config->ndsPath());
Msg::DisplayMsg(message);
/* TODO: Kinda avoid that? */
makeDirs(newName.c_str());
rename(oldName.c_str(), newName.c_str());
makeDirs(_new.c_str());
rename(old.c_str(), _new.c_str());
return ret;
}
@@ -188,6 +207,11 @@ Result ScriptUtils::downloadFile(const std::string &file, const std::string &out
Install CIA files.
*/
void ScriptUtils::installFile(const std::string &file, const bool &updatingSelf, const std::string &message) {
std::string in;
in = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
in = std::regex_replace(in, std::regex("%3DSX%"), config->_3dsxPath());
in = std::regex_replace(in, std::regex("%NDS%"), config->ndsPath());
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
showProgressBar = true;
progressbarType = ProgressBar::Installing;
@@ -196,7 +220,7 @@ void ScriptUtils::installFile(const std::string &file, const bool &updatingSelf,
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
thread = threadCreate((ThreadFunc)displayProgressBar, NULL, 64 * 1024, prio - 1, -2, false);
installCia(file.c_str(), updatingSelf);
installCia(in.c_str(), updatingSelf);
showProgressBar = false;
threadJoin(thread, U64_MAX);
threadFree(thread);
@@ -208,7 +232,11 @@ void ScriptUtils::installFile(const std::string &file, const bool &updatingSelf,
void ScriptUtils::extractFile(const std::string &file, const std::string &input, const std::string &output, const std::string &message) {
std::string out, in;
in = std::regex_replace(file, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
in = std::regex_replace(in, std::regex("%3DSX%"), config->_3dsxPath());
in = std::regex_replace(in, std::regex("%NDS%"), config->ndsPath());
out = std::regex_replace(output, std::regex("%ARCHIVE_DEFAULT%"), config->archPath());
out = std::regex_replace(out, std::regex("%3DSX%"), config->_3dsxPath());
out = std::regex_replace(out, std::regex("%NDS%"), config->ndsPath());
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
showProgressBar = true;
@@ -391,19 +419,28 @@ Result ScriptUtils::runFunctions(const nlohmann::json &storeJson, const int &sel
else ret = SYNTAX_ERROR;
} else if (type == "promptMessage") {
} else if (type == "promptMessage" || type == "promptMsg") {
std::string Message = "";
int skipCount = -1;
if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) {
Message = storeJson["storeContent"][selection][entry][i]["message"];
}
if (storeJson["storeContent"][selection][entry][i].contains("count") && storeJson["storeContent"][selection][entry][i]["count"].is_number()) {
skipCount = storeJson["storeContent"][selection][entry][i]["count"];
}
ret = ScriptUtils::prompt(Message);
if (ret == SCRIPT_CANCELED) {
if (skipCount > -1 && ret == SCRIPT_CANCELED) {
ret = NONE;
i++; // Skip.
i += skipCount; // Skip.
}
} else if (type == "exit") {
break;
} else if (type == "copy") {
std::string Message = "", source = "", destination = "";
bool missing = false;
@@ -449,7 +486,7 @@ Result ScriptUtils::runFunctions(const nlohmann::json &storeJson, const int &sel
}
}
if (ret == NONE) doneMsg();
if (ret == NONE || ret == SCRIPT_CANCELED) doneMsg();
else if (ret == FAILED_DOWNLOAD) Msg::waitMsg(Lang::get("DOWNLOAD_ERROR"));
else if (ret == SYNTAX_ERROR) Msg::waitMsg(Lang::get("SYNTAX_ERROR"));
else if (ret == COPY_ERROR) Msg::waitMsg(Lang::get("COPY_ERROR"));