/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* 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 .
*
* 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 "download.hpp"
#include "fileBrowse.hpp"
#include "formatting.hpp"
#include "keyboard.hpp"
#include "mainMenu.hpp"
#include "unistore.hpp"
#include "unistore_v1.hpp"
#include "unistore_v2.hpp"
#include
extern void notImplemented(void);
extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern bool changesMade;
bool specialHandling = false;
bool didAutoboot = false;
UniStore::UniStore(bool doAutoboot, std::string file) {
this->doAutoboot = doAutoboot;
this->autobootFile = file;
}
// Autoboot stuff.
void UniStore::autobootLogic() {
if (this->doAutoboot) {
if (!didAutoboot) {
specialHandling = true; // Special back handling.
if (ScriptHelper::checkIfValid(this->autobootFile, 1) == true) {
storeInfo.push_back(parseStoreInfo(this->autobootFile));
// Update if WiFi found and wanted.
if (checkWifiStatus()) {
if (Msg::promptMsg(Lang::get("WOULD_YOU_LIKE_UPDATE"))) {
if (storeInfo[0].url != "" && storeInfo[0].url != "MISSING: storeInfo.url" &&
storeInfo[0].file != "" && storeInfo[0].file != "MISSING: storeInfo.file") {
ScriptHelper::downloadFile(storeInfo[0].url, storeInfo[0].file, Lang::get("UPDATING"));
}
if (storeInfo[0].sheetURL != "" && storeInfo[0].sheetURL != "MISSING: storeInfo.sheetURL" &&
storeInfo[0].storeSheet != "" && storeInfo[0].storeSheet != "MISSING: storeInfo.sheet") {
ScriptHelper::downloadFile(storeInfo[0].sheetURL, storeInfo[0].storeSheet, Lang::get("UPDATING"));
}
}
}
currentStoreFile = this->autobootFile;
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
JSON = openStoreFile();
displayInformations = handleIfDisplayText();
const std::string sheetURL = storeInfo[0].storeSheet;
if (storeInfo[0].version == 0) {
Gui::setScreen(std::make_unique(JSON, sheetURL, displayInformations), Config::fading, true);
} else if (storeInfo[0].version == 1) {
Gui::setScreen(std::make_unique(JSON, sheetURL), Config::fading, true);
} else {
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
}
} else {
specialHandling = true; // Special back handling.
// Display Warn or so?
}
}
}
}
// Parse informations like URL, Title, Author, Description.
StoreInfo UniStore::parseStoreInfo(std::string fileName) {
FILE* file = fopen(fileName.c_str(), "rt");
if (!file) {
printf("File not found\n");
return {"", ""};
}
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
fclose(file);
StoreInfo info;
info.title = ScriptHelper::getString(json, "storeInfo", "title");
info.author = ScriptHelper::getString(json, "storeInfo", "author");
info.description = ScriptHelper::getString(json, "storeInfo", "description");
info.url = ScriptHelper::getString(json, "storeInfo", "url");
info.file = ScriptHelper::getString(json, "storeInfo", "file");
info.storeSheet = ScriptHelper::getString(json, "storeInfo", "sheet");
info.sheetURL = ScriptHelper::getString(json, "storeInfo", "sheetURL");
info.version = ScriptHelper::getNum(json, "storeInfo", "version");
return info;
}
// Return a parsed UniStore file.
nlohmann::json UniStore::openStoreFile() {
FILE* file = fopen(currentStoreFile.c_str(), "rt");
nlohmann::json jsonFile;
if (file) jsonFile = nlohmann::json::parse(file, nullptr, false);
fclose(file);
return jsonFile;
}
// Do the description, if found.
void UniStore::descript() {
if (storeInfo[Selection].description != "" || storeInfo[Selection].description != "MISSING: storeInfo.description") {
storeDesc = storeInfo[Selection].description;
} else storeDesc = "";
}
// Load the store description.
void UniStore::loadStoreDesc(void) {
descLines.clear();
while(storeDesc.find('\n') != storeDesc.npos) {
descLines.push_back(storeDesc.substr(0, storeDesc.find('\n')));
storeDesc = storeDesc.substr(storeDesc.find('\n')+1);
}
descLines.push_back(storeDesc.substr(0, storeDesc.find('\n')));
}
void UniStore::DrawSubMenu(void) const {
GFX::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SUBMENU"), 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SUBMENU"), 400);
}
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
GFX::DrawBottom();
GFX::DrawArrow(0, 218, 0, 1);
GFX::DrawButton(subPos[0].x, subPos[0].y,Lang::get("STORE_LIST"));
GFX::DrawButton(subPos[1].x, subPos[1].y, Lang::get("STORE_SEARCH"));
GFX::DrawButton(subPos[2].x, subPos[2].y, Lang::get("CHANGE_STOREPATH"));
// Selector.
Animation::Button(subPos[Selection].x, subPos[Selection].y, .060);
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
}
// First Screen -> Storelist.
void UniStore::DrawStoreList(void) const {
std::string line1;
std::string line2;
std::string storeAmount = std::to_string(Selection +1) + " | " + std::to_string(storeInfo.size());
GFX::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, storeInfo[Selection].title, 400);
Gui::DrawString(5, 220, 0.6f, Config::TxtColor, Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 239-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, Config::TxtColor, storeAmount);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, storeInfo[Selection].title, 400);
Gui::DrawString(5, 218, 0.6f, Config::TxtColor, Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 237-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, Config::TxtColor, storeAmount);
}
for(uint i = 0; i < descLines.size(); i++) {
Gui::DrawStringCentered(0, 120-((descLines.size()*20)/2)+i*20, 0.6f, Config::TxtColor, descLines[i], 400);
}
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
GFX::DrawBottom();
GFX::DrawArrow(295, -1);
GFX::DrawArrow(315, 240, 180.0);
GFX::DrawArrow(0, 218, 0, 1);
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
if (Config::viewMode == 0) {
for(int i=0;i 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
}
void UniStore::Draw(void) const {
if (mode == 0) {
DrawSubMenu();
} else if (mode == 1) {
DrawStoreList();
} else if (mode == 2) {
DrawSearch();
} else if (mode == 3) {
DrawFullURLScreen();
} else if (mode == 4) {
DrawGitHubScreen();
}
}
void UniStore::updateStore(int selectedStore) {
if (checkWifiStatus()) {
if (Msg::promptMsg(Lang::get("WOULD_YOU_LIKE_UPDATE"))) {
if (storeInfo[selectedStore].url != "" && storeInfo[selectedStore].url != "MISSING: storeInfo.url" &&
storeInfo[selectedStore].file != "" && storeInfo[selectedStore].file != "MISSING: storeInfo.file") {
ScriptHelper::downloadFile(storeInfo[selectedStore].url, storeInfo[selectedStore].file, Lang::get("UPDATING"));
}
if (storeInfo[selectedStore].sheetURL != "" && storeInfo[selectedStore].sheetURL != "MISSING: storeInfo.sheetURL" &&
storeInfo[selectedStore].storeSheet != "" && storeInfo[selectedStore].storeSheet != "MISSING: storeInfo.sheet") {
ScriptHelper::downloadFile(storeInfo[selectedStore].sheetURL, storeInfo[selectedStore].storeSheet, Lang::get("UPDATING"));
}
// Refresh the list.
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
dirContents.clear();
storeInfo.clear();
chdir(Config::StorePath.c_str());
getDirectoryContents(dirContents, {"unistore"});
for(uint i=0;i(), true, true);
} else {
Gui::screenBack(Config::fading);
return;
}
}
if (hDown & KEY_UP) {
if(Selection > 0) Selection--;
}
if (hDown & KEY_DOWN) {
if(Selection < 2) Selection++;
}
if (hDown & KEY_A) {
switch(Selection) {
case 0:
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
dirContents.clear();
storeInfo.clear();
chdir(Config::StorePath.c_str());
getDirectoryContents(dirContents, {"unistore"});
for(uint i=0;i 0) dropSelection--;
}
if (hDown & KEY_A) {
switch(dropSelection) {
case 0:
if (Msg::promptMsg(Lang::get("DELETE_STORE"))) {
deleteStore(Selection);
}
break;
case 1:
updateStore(Selection);
break;
case 2:
if (Config::viewMode == 0) {
Config::viewMode = 1;
} else {
Config::viewMode = 0;
}
break;
}
dropDownMenu = false;
}
if (hDown & KEY_TOUCH) {
if (touching(touch, dropPos2[0])) {
if (Msg::promptMsg(Lang::get("DELETE_STORE"))) {
deleteStore(Selection);
}
dropDownMenu = false;
} else if (touching(touch, dropPos2[1])) {
updateStore(Selection);
dropDownMenu = false;
} else if (touching(touch, dropPos2[2])) {
if (Config::viewMode == 0) {
Config::viewMode = 1;
} else {
Config::viewMode = 0;
}
dropDownMenu = false;
}
}
} else {
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) {
dropSelection = 0;
dropDownMenu = true;
}
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
storeInfo.clear();
Selection = 0;
mode = 0;
}
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
if (Selection < (int)storeInfo.size()-1) {
Selection++;
descript();
loadStoreDesc();
} else {
Selection = 0;
descript();
loadStoreDesc();
}
keyRepeatDelay = Config::keyDelay;
}
if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) {
if (Selection > 0) {
Selection--;
descript();
loadStoreDesc();
} else {
Selection = (int)storeInfo.size()-1;
descript();
loadStoreDesc();
}
keyRepeatDelay = Config::keyDelay;
}
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
if (Config::viewMode == 0) {
if (Selection < (int)storeInfo.size()-1-3) {
Selection += 3;
descript();
loadStoreDesc();
} else {
Selection = (int)storeInfo.size()-1;
descript();
loadStoreDesc();
}
} else {
if (Selection < (int)storeInfo.size()-1-6) {
Selection += 7;
descript();
loadStoreDesc();
} else {
Selection = (int)storeInfo.size()-1;
descript();
loadStoreDesc();
}
}
keyRepeatDelay = Config::keyDelay;
}
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
if (Config::viewMode == 0) {
if (Selection > 2) {
Selection -= 3;
descript();
loadStoreDesc();
} else {
Selection = 0;
descript();
loadStoreDesc();
}
} else {
if (Selection > 6) {
Selection -= 7;
descript();
loadStoreDesc();
} else {
Selection = 0;
descript();
loadStoreDesc();
}
}
keyRepeatDelay = Config::keyDelay;
}
if (hDown & KEY_A) {
if (dirContents[Selection].isDirectory) {
} else if (storeInfo.size() != 0) {
if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) {
updateStore(Selection);
currentStoreFile = dirContents[Selection].name;
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
JSON = openStoreFile();
displayInformations = handleIfDisplayText();
const std::string sheetURL = storeInfo[Selection].storeSheet;
if (storeInfo[Selection].version == 0) {
Gui::setScreen(std::make_unique(JSON, sheetURL, displayInformations), Config::fading, true);
} else if (storeInfo[Selection].version == 1) {
Gui::setScreen(std::make_unique(JSON, sheetURL), Config::fading, true);
} else {
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
}
}
}
}
if (Config::viewMode == 0) {
if(Selection < screenPos) {
screenPos = Selection;
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
}
} else if (Config::viewMode == 1) {
if(Selection < screenPosList) {
screenPosList = Selection;
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
screenPosList = Selection - ENTRIES_PER_LIST + 1;
}
}
if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) {
for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) {
if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name, 1) == true) {
updateStore(screenPos + i);
currentStoreFile = dirContents[screenPos + i].name;
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
JSON = openStoreFile();
displayInformations = handleIfDisplayText();
const std::string sheetURL = storeInfo[screenPos + i].storeSheet;
if (storeInfo[screenPos + i].version == 0) {
Gui::setScreen(std::make_unique(JSON, sheetURL, displayInformations), Config::fading, true);
} else if (storeInfo[screenPos + i].version == 1) {
Gui::setScreen(std::make_unique(JSON, sheetURL), Config::fading, true);
} else {
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
}
}
}
}
} else if (Config::viewMode == 1) {
for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) {
if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name, 1) == true) {
updateStore(screenPosList + i);
currentStoreFile = dirContents[screenPosList + i].name;
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
JSON = openStoreFile();
displayInformations = handleIfDisplayText();
const std::string sheetURL = storeInfo[screenPosList + i].storeSheet;
if (storeInfo[screenPosList + i].version == 0) {
Gui::setScreen(std::make_unique(JSON, sheetURL, displayInformations), Config::fading, true);
} else if (storeInfo[screenPosList + i].version == 1) {
Gui::setScreen(std::make_unique(JSON, sheetURL), Config::fading, true);
} else {
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
}
}
}
}
}
}
if (hDown & KEY_START) {
if (Config::autoboot == 1) {
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) {
Config::autoboot = 0;
Config::AutobootFile = "";
changesMade = true;
}
} else {
if (dirContents[Selection].isDirectory) {
} else if (storeInfo.size() != 0) {
if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) {
if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) {
Config::AutobootFile = Config::StorePath + dirContents[Selection].name;
Config::autoboot = 1;
changesMade = true;
}
}
}
}
}
}
}
void UniStore::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
this->autobootLogic();
if (mode == 0) {
SubMenuLogic(hDown, hHeld, touch);
} else if (mode == 1) {
StoreSelectionLogic(hDown, hHeld, touch);
} else if (mode == 2) {
SearchLogic(hDown, hHeld, touch);
} else if (mode == 3) {
FullURLLogic(hDown, hHeld, touch);
} else if (mode == 4) {
GitHubLogic(hDown, hHeld, touch);
}
}
void UniStore::DrawSearch(void) const {
GFX::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SEARCH"), 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SEARCH"), 400);
}
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
GFX::DrawBottom();
GFX::DrawArrow(0, 218, 0, 1);
GFX::DrawButton(URLBtn[0].x, URLBtn[0].y,Lang::get("FULL_URL"));
GFX::DrawButton(URLBtn[1].x, URLBtn[1].y, Lang::get("GITHUB"));
GFX::DrawButton(URLBtn[2].x, URLBtn[2].y, "TinyDB");
GFX::DrawButton(URLBtn[3].x, URLBtn[3].y, "Universal DB");
// Selector.
Animation::Button(URLBtn[Selection].x, URLBtn[Selection].y, .060);
}
void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) {
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
Selection = 0;
mode = 0;
}
if (hDown & KEY_RIGHT || hDown & KEY_R) {
if (Selection == 0) Selection = 1;
else if (Selection == 2) Selection = 3;
}
if (hDown & KEY_LEFT || hDown & KEY_L) {
if (Selection == 1) Selection = 0;
else if (Selection == 3) Selection = 2;
}
if (hDown & KEY_DOWN) {
if (Selection == 0) Selection = 2;
else if (Selection == 1) Selection = 3;
}
if (hDown & KEY_UP) {
if (Selection == 2) Selection = 0;
else if (Selection == 3) Selection = 1;
}
if (hDown & KEY_A) {
if (Selection == 0) {
Selection = 0;
mode = 3;
} else if (Selection == 1) {
Selection = 0;
mode = 4;
} else if (Selection == 2) {
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
} else if (Selection == 3) {
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
}
}
if (hDown & KEY_TOUCH && touching(touch, URLBtn[0])) {
Selection = 0;
mode = 3;
} else if (hDown & KEY_TOUCH && touching(touch, URLBtn[1])) {
Selection = 0;
mode = 4;
} else if (hDown & KEY_TOUCH && touching(touch, URLBtn[2])) {
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
} else if (hDown & KEY_TOUCH && touching(touch, URLBtn[3])) {
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
}
}
void UniStore::DrawGitHubScreen(void) const {
GFX::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("GITHUB"), 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("GITHUB"), 400);
}
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
GFX::DrawBottom();
GFX::DrawArrow(0, 218, 0, 1);
Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("OWNER_AND_REPO"), 300);
Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 300);
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, Config::Color1);
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1);
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1);
Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40);
Gui::DrawStringCentered(0, 57, 0.5f, Config::TxtColor, OwnerAndRepo, 250);
Gui::DrawStringCentered(0, 137, 0.5f, Config::TxtColor, fileName, 250);
}
void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[0])) {
OwnerAndRepo = Input::getStringLong(Lang::get("ENTER_OWNER_AND_REPO"));
}
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[1])) {
fileName = Input::getStringLong(Lang::get("ENTER_FILENAME"));
}
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[2])) {
if (checkWifiStatus() == true) {
std::string URL = "https://github.com/";
URL += OwnerAndRepo;
URL += "/raw/master/unistore/";
URL += fileName;
ScriptHelper::downloadFile(URL, Config::StorePath + fileName, Lang::get("DOWNLOADING") + fileName);
} else {
notConnectedMsg();
}
}
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
// Reset everything.
OwnerAndRepo = "";
fileName = "";
Selection = 0;
mode = 2;
}
}
void UniStore::DrawFullURLScreen(void) const {
GFX::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 400);
}
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
GFX::DrawBottom();
GFX::DrawArrow(0, 218, 0, 1);
Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 320);
Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 320);
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, Config::Color1);
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1);
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1);
Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40);
Gui::DrawStringCentered(0, 57, 0.45f, Config::TxtColor, FullURL, 250);
Gui::DrawStringCentered(0, 137, 0.45f, Config::TxtColor, fileName, 250);
}
void UniStore::FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[0])) {
FullURL = Input::getStringLong(Lang::get("ENTER_FULL_URL"));
}
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[1])) {
fileName = Input::getStringLong(Lang::get("ENTER_FILENAME"));
}
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[2])) {
if (checkWifiStatus() == true) {
ScriptHelper::downloadFile(FullURL, Config::StorePath + fileName, Lang::get("DOWNLOADING") + fileName);
} else {
notConnectedMsg();
}
}
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
// Reset everything.
FullURL = "";
fileName = "";
Selection = 0;
mode = 2;
}
}