diff --git a/CMakeLists.txt b/CMakeLists.txt index c6b5660..80d51d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,4 +106,5 @@ vita_create_vpk(easyplugin.vpk ${VITA_TITLEID} easyplugin.self FILE src/graphics/desc1.png resources/desc1.png FILE src/graphics/desc2.png resources/desc2.png FILE src/graphics/desc3.png resources/desc3.png + FILE src/graphics/desc4.png resources/desc4.png ) diff --git a/src/graphics/desc4.png b/src/graphics/desc4.png new file mode 100644 index 0000000..1debfd6 Binary files /dev/null and b/src/graphics/desc4.png differ diff --git a/src/main.cpp b/src/main.cpp index 5b86eba..037cbee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,6 +120,7 @@ int main() { vita2d_draw_texture(bgIMG, 0, 0); if(pad.buttons != SCE_CTRL_CROSS) sharedData.blockCross = false; + if(pad.buttons != SCE_CTRL_CIRCLE) sharedData.blockCircle = false; if(pad.buttons != SCE_CTRL_START) sharedData.blockStart = false; if(sharedData.scene == 0) listView.draw(sharedData, pad.buttons); diff --git a/src/main.hpp b/src/main.hpp index 1749502..e651807 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -29,6 +29,7 @@ struct SharedData { int scene = 0; int cursorY = 0; bool blockCross = false; + bool blockCircle = false; bool blockStart = false; bool initDetail = true; string taiConfig = ""; diff --git a/src/screens/popup.cpp b/src/screens/popup.cpp index afef39e..6fbf637 100644 --- a/src/screens/popup.cpp +++ b/src/screens/popup.cpp @@ -20,25 +20,29 @@ void Popup::handleSkprx(SharedData &sharedData, int ¤tPlugin, unsigned int string pluginEntry = "\n\n*Kernel\n"+sharedData.taiConfigPath+installFiles[currentPlugin]; size_t pluginEntryPos = sharedData.taiConfig.find(pluginEntry); - if(pluginEntryPos != string::npos) { - int textWidth = vita2d_font_text_width(sharedData.font, 40, (installFiles[currentPlugin]+" is already installed").c_str()); + int textWidth = vita2d_font_text_width(sharedData.font, 40, (pluginEntryPos != string::npos ? installFiles[currentPlugin]+" is already installed" : "Install "+installFiles[currentPlugin]+"?").c_str()); - vita2d_font_draw_textf(sharedData.font, 480 - (textWidth/2), 272, RGBA8(255,255,255,255), 40, "%s is already installed.", installFiles[currentPlugin].c_str()); - vita2d_draw_texture(desc2, 0, 504); - } + vita2d_font_draw_textf(sharedData.font, 480 - (textWidth/2), 272, pluginEntryPos != string::npos ? RGBA8(255,100,100,255) : RGBA8(255,255,255,255), 40, pluginEntryPos != string::npos ? "%s is already installed." : "Install %s?", installFiles[currentPlugin].c_str()); + vita2d_draw_texture(pluginEntryPos != string::npos ? desc2 : desc3, 0, 504); - if(pluginEntryPos == string::npos) { + if(pluginEntryPos == string::npos && button == SCE_CTRL_CROSS && !sharedData.blockCross) { Filesystem::copyFile(plPath+installFiles[currentPlugin], sharedData.taiConfigPath+installFiles[currentPlugin]); sharedData.taiConfig += pluginEntry; + sharedData.blockCross = true; currentPlugin++; } else if(button == SCE_CTRL_CROSS && !sharedData.blockCross) { sharedData.taiConfig.erase(pluginEntryPos, pluginEntry.length()); + + if(sharedData.taiConfig.find(sharedData.taiConfigPath+installFiles[currentPlugin]) != string::npos) + sceIoRemove((sharedData.taiConfigPath+installFiles[currentPlugin]).c_str()); + sharedData.blockCross = true; currentPlugin++; } - if(button == SCE_CTRL_CIRCLE) { + if(button == SCE_CTRL_CIRCLE && !sharedData.blockCircle) { + sharedData.blockCircle = true; currentPlugin++; } } @@ -107,8 +111,10 @@ void Popup::handleSuprx(SharedData &sharedData, int ¤tPlugin, unsigned int currentPlugin++; break; case SCE_CTRL_CIRCLE: + if(sharedData.blockCircle) break; selected = 0; selectedApps.clear(); + sharedData.blockCircle = true; currentPlugin++; break; case SCE_CTRL_CROSS: diff --git a/src/screens/popup.hpp b/src/screens/popup.hpp index 0c81da9..b85b8d9 100644 --- a/src/screens/popup.hpp +++ b/src/screens/popup.hpp @@ -33,4 +33,5 @@ class Popup { vector installFiles; vita2d_texture *desc = vita2d_load_PNG_file("ux0:app/ESPL00009/resources/desc2.png"); vita2d_texture *desc2 = vita2d_load_PNG_file("ux0:app/ESPL00009/resources/desc3.png"); + vita2d_texture *desc3 = vita2d_load_PNG_file("ux0:app/ESPL00009/resources/desc4.png"); }; \ No newline at end of file diff --git a/src/utils/filesystem.cpp b/src/utils/filesystem.cpp index 0d616e0..cfdd21e 100644 --- a/src/utils/filesystem.cpp +++ b/src/utils/filesystem.cpp @@ -3,6 +3,7 @@ #include #include +#include "psp2/kernel/clib.h" #include "filesystem.hpp" bool hasEndSlash(std::string str) { @@ -189,48 +190,27 @@ int Filesystem::copyPath(std::string src, std::string dst) { int Filesystem::removePath(std::string path) { SceUID dfd = sceIoDopen(path.c_str()); - if (dfd >= 0) { - int res = 0; - - do { - SceIoDirent dir; - memset(&dir, 0, sizeof(SceIoDirent)); - - res = sceIoDread(dfd, &dir); - if (res > 0) { - char *new_path = (char *)malloc(path.length() + strlen(dir.d_name) + 2); - snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name); - - if (SCE_S_ISDIR(dir.d_stat.st_mode)) { - int ret = removePath(new_path); - if (ret <= 0) { - free(new_path); - sceIoDclose(dfd); - return ret; - } - } else { - int ret = sceIoRemove(new_path); - if (ret < 0) { - free(new_path); - sceIoDclose(dfd); - return ret; - } - } - - free(new_path); - } - } while (res > 0); - - sceIoDclose(dfd); - - int ret = sceIoRmdir(path.c_str()); - if (ret < 0) - return ret; - } else { - int ret = sceIoRemove(path.c_str()); - if (ret < 0) - return ret; + if(dfd < 0) + return dfd; + + SceIoDirent dir; + memset(&dir, 0, sizeof(SceIoDirent)); + while(sceIoDread(dfd, &dir) > 0) { + std::string newString = path + (hasEndSlash(path) ? "" : "/") + dir.d_name; + + if(SCE_S_ISDIR(dir.d_stat.st_mode)) { + Filesystem::removePath(newString); + } + else { + if(int ret = sceIoRemove(newString.c_str()) < 0) + return ret; + } } + if(int ret = sceIoDclose(dfd) < 0) + return ret; + + if(int ret = sceIoRmdir(path.c_str()) < 0) + return ret; return 1; } \ No newline at end of file