Delete Stores with <SELECT>.

This commit is contained in:
StackZ
2020-01-06 08:46:52 +01:00
parent 3121f82d61
commit 021f1ebabd
3 changed files with 31 additions and 1 deletions
+1
View File
@@ -57,6 +57,7 @@ private:
void execute(); void execute();
void descript(); void descript();
void updateStore(int selectedStore); void updateStore(int selectedStore);
void deleteStore(int selectedStore);
bool handleIfDisplayText(); bool handleIfDisplayText();
int mode = 0; int mode = 0;
int selectedOptionAppStore = 0; int selectedOptionAppStore = 0;
+2 -1
View File
@@ -110,5 +110,6 @@
"OWNER_AND_REPO": "Owner & Repo", "OWNER_AND_REPO": "Owner & Repo",
"FILENAME": "Filename", "FILENAME": "Filename",
"OK": "OK" "OK": "OK",
"DELETE_STORE": "Would you like to delete this store?"
} }
+28
View File
@@ -476,6 +476,28 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
void UniStore::deleteStore(int selectedStore) {
std::string path = Config::StorePath;
path += dirContents[selectedStore].name;
deleteFile(path.c_str());
// Refresh the list.
dirContents.clear();
storeInfo.clear();
chdir(Config::StorePath.c_str());
getDirectoryContents(dirContents, {"unistore"});
for(uint i=0;i<dirContents.size();i++) {
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
descript();
loadStoreDesc();
}
if (dirContents.size() == 0) {
dirContents.clear();
storeInfo.clear();
mode = 0;
}
}
bool UniStore::handleIfDisplayText() { bool UniStore::handleIfDisplayText() {
if (appStoreJson.at("storeInfo").contains("displayInformation")) { if (appStoreJson.at("storeInfo").contains("displayInformation")) {
if (appStoreJson["storeInfo"]["displayInformation"] != true) { if (appStoreJson["storeInfo"]["displayInformation"] != true) {
@@ -579,6 +601,12 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
} }
if (hDown & KEY_SELECT) {
if (Gui::promptMsg(Lang::get("DELETE_STORE"))) {
deleteStore(selection);
}
}
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (Config::viewMode == 0) { if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)storeInfo.size();i++) { for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)storeInfo.size();i++) {