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:
StackZ
2020-03-06 15:59:14 +01:00
parent 331a348846
commit 05d809e0bc
5 changed files with 43 additions and 6 deletions
+27
View File
@@ -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) {