Skip to content

Commit

Permalink
actual 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
THEN00P committed Aug 5, 2019
1 parent a8387d1 commit 09e3492
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 48 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Binary file added src/graphics/desc4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
20 changes: 13 additions & 7 deletions src/screens/popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@ void Popup::handleSkprx(SharedData &sharedData, int &currentPlugin, 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++;
}
}
Expand Down Expand Up @@ -107,8 +111,10 @@ void Popup::handleSuprx(SharedData &sharedData, int &currentPlugin, 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:
Expand Down
1 change: 1 addition & 0 deletions src/screens/popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ class Popup {
vector<string> 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");
};
62 changes: 21 additions & 41 deletions src/utils/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <string>

#include "psp2/kernel/clib.h"
#include "filesystem.hpp"

bool hasEndSlash(std::string str) {
Expand Down Expand Up @@ -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;
}

0 comments on commit 09e3492

Please sign in to comment.