Read description for changes.
- Add Script Deletion. - Display "This script does not exist." if script does not exist on ScriptBrowse. - Display "Refreshing List..." if you have more scripts.
This commit is contained in:
parent
331a348846
commit
05d809e0bc
5 changed files with 43 additions and 6 deletions
|
|
@ -39,6 +39,8 @@ public:
|
|||
void Draw(void) const override;
|
||||
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
|
||||
private:
|
||||
void deleteScript(int selectedScript);
|
||||
|
||||
void DrawSubMenu(void) const;
|
||||
void DrawList(void) const;
|
||||
void DrawSingleObject(void) const;
|
||||
|
|
|
|||
|
|
@ -124,5 +124,9 @@
|
|||
"ENABLE_GODMODE_PROMPT": "Would you like to enable GodMode?\n\nBe careful when you use GodMode!!",
|
||||
|
||||
"DISABLE_AUTOBOOT_STORE": "Would you like to disable autoboot?",
|
||||
"AUTOBOOT_STORE": "Would you like to autoboot this Store?\n\nThis will autoboot this store on startup!"
|
||||
"AUTOBOOT_STORE": "Would you like to autoboot this Store?\n\nThis will autoboot this store on startup!",
|
||||
|
||||
"SCRIPT_NOT_FOUND": "This script does not exist.",
|
||||
"DELETE_SCRIPT": "Would you like to delete this script?",
|
||||
"REFRESHING_LIST": "Refreshing List..."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ void fixInfo(nlohmann::json &json) {
|
|||
if(!json[i].contains("author")) json[i]["author"] = "AUTHOR";
|
||||
if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
|
||||
if(!json[i].contains("revision")) json[i]["revision"] = 0;
|
||||
if(!json[i].contains("curRevision")) json[i]["curRevision"] = 0;
|
||||
if(!json[i].contains("version")) json[i]["revision"] = 0;
|
||||
if(!json[i].contains("curRevision")) json[i]["curRevision"] = -1;
|
||||
if(!json[i].contains("version")) json[i]["revision"] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,9 @@ void ScriptBrowse::Draw(void) const {
|
|||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(infoJson[selection]["shortDesc"]), 400);
|
||||
if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) {
|
||||
if (infoJson[selection]["curRevision"] == -1) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("SCRIPT_NOT_FOUND"), 370);
|
||||
} else if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("OUTDATED_SCRIPT"), 370);
|
||||
} else if(infoJson[selection]["curRevision"] == infoJson[selection]["revision"]) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("UP-TO-DATE"), 370);
|
||||
|
|
|
|||
|
|
@ -441,6 +441,7 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
switch(SubSelection) {
|
||||
case 0:
|
||||
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
|
|
@ -478,6 +479,7 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, subPos[0])) {
|
||||
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
|
|
@ -509,6 +511,26 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptList::deleteScript(int selectedScript) {
|
||||
std::string path = Config::ScriptPath;
|
||||
path += dirContents[selectedScript].name;
|
||||
deleteFile(path.c_str());
|
||||
// Refresh the list.
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
fileInfo.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
}
|
||||
if (dirContents.size() == 0) {
|
||||
dirContents.clear();
|
||||
fileInfo.clear();
|
||||
mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (keyRepeatDelay) keyRepeatDelay--;
|
||||
|
||||
|
|
@ -529,6 +551,11 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
keyRepeatDelay = 6;
|
||||
}
|
||||
}
|
||||
if (hDown & KEY_SELECT) {
|
||||
if (Msg::promptMsg(Lang::get("DELETE_SCRIPT"))) {
|
||||
deleteScript(selection);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) {
|
||||
if (selection > 0) {
|
||||
|
|
|
|||
|
|
@ -217,8 +217,6 @@ UniStore::UniStore() {
|
|||
ScriptHelper::downloadFile(SI.sheetURL, SI.storeSheet, Lang::get("UPDATING"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notConnectedMsg();
|
||||
}
|
||||
|
||||
if (ScriptHelper::checkIfValid(Config::UniStoreFile, 1) == true) {
|
||||
|
|
@ -438,6 +436,7 @@ void UniStore::updateStore(int selectedStore) {
|
|||
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());
|
||||
|
|
@ -474,6 +473,7 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
switch(subSelection) {
|
||||
case 0:
|
||||
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
|
|
@ -507,6 +507,7 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, subPos[0])) {
|
||||
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
|
|
@ -540,6 +541,7 @@ void UniStore::deleteStore(int selectedStore) {
|
|||
path += dirContents[selectedStore].name;
|
||||
deleteFile(path.c_str());
|
||||
// Refresh the list.
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue