GNU General Public License for more details.

You should have received a copy of the GNU General Public License

- along with this program. If not, see <http://www.gnu.org/licenses/>.

+ along with this program. If not, see <http://www.gnu.org/licenses/>.

void drawFakeDialog(const plgmRes &res, int buttonType, int dialogId) {

- bool isJapFont = res.languageID == SCE_SYSTEM_PARAM_LANG_JAPANESE;

- char okBtn = res.enterBtnId == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? 'O':'X';

- char cancelBtn = res.enterBtnId == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE ? 'X':'O';

- int cancTxLen = std::strlen(res.language[DIALOG_CANCEL]) + 3;

- int okTxLen = std::strlen(res.language[DIALOG_RBT_BUTTON]) + 3;

- char okText[okTxLen], cancelText[cancTxLen], *msg = nullptr;

- float msgPad = 11.0f, cancelTxPad = 9.0f, cancelTextX, dialogW = 400, dialogX = 280;

+ char okBtn = res.okBtn == SCE_CTRL_CIRCLE ? 'O':'X';

+ float textW, dialogW, dialogX;

+ size_t len = sizeof(char) * 40;

+ char okText[40] = {0};

+ char *msg = nullptr;

- if (buttonType == 0) {

- } else {

switch (dialogId) {

case 1:

case 3:

msg = res.language[DIALOG_REQ_REBOOT];

case 10:

msg = res.language[DIALOG_SUCCESS_MSG];

- msgPad = isJapFont ? 7.0f:msgPad;

- cancelTxPad = isJapFont ? 5.0f:cancelTxPad;

- dialogW = std::strlen(msg)*msgPad;

- dialogW = dialogW < 400 ? 400:dialogW;

- dialogX = (960/2)-(dialogW/2);

- if (buttonType == 0)

- cancelTextX = (dialogX+dialogW-40)-(std::strlen(cancelText)*cancelTxPad);

+ textW = vita2d_pgf_text_width(res.pgf, 1.1f, msg);

+ dialogW = textW + 30;

+ dialogX = (960/2) - (dialogW/2);

+ if (buttonType == 0) {

+ char cancText[40] = {0};

+ float textX;

- if (buttonType == 0)

+ std::snprintf(cancText, len, "%c %s", okBtn == 'O' ? 'X':'O', res.language[DIALOG_CANCEL]);

+ textX = dialogX + dialogW - vita2d_pgf_text_width(res.pgf, 1.0f, cancText) - 15;

-void drawSectionSelect(const plgmRes &res, std::vector<titleID_t> &idsList, std::vector<int> &selectedIDs) {

+int getKeys(const plgmRes &res) {

SceCtrlData pad, opad;

- int startIdx = 0, curS = 0, draw = 1, idListSz = idsList.size()-1;

- int lastIdx = idListSz > 13 ? 13:idListSz;

- float txY = 110.0f;

while (true) {

- if (pad.ly < ANALOG_CENTER-ANALOG_THRESHOLD) {

+ if (pad.ly < ANALOG_CENTER_THRSLD_DOWN)

- } else if (pad.ly > ANALOG_CENTER+ANALOG_THRESHOLD) {

+ else if (pad.ly > ANALOG_CENTER_THRSLD_UP)

- if (HOLD_END(opad, pad, res.cancelBtn)) {

+ if (HOLD_END(opad, pad, res.cancelBtn))

+ return res.cancelBtn;

- } else if (HOLD_END(opad, pad, SCE_CTRL_SQUARE)) {

- draw = 1;

+ else if (HOLD_END(opad, pad, res.okBtn))

+ return res.okBtn;

- if (!idsList[curS].selected) {

- } else {

+ else if (HOLD_END(opad, pad, SCE_CTRL_SQUARE))

+ return SCE_CTRL_SQUARE;

- for (int i=0; i<selectedIDs.size(); ++i) {

- if (selectedIDs[i] == curS) {

+ else if (HOLD_END(opad, pad, SCE_CTRL_TRIANGLE))

+ return SCE_CTRL_TRIANGLE;

+ else if (IS_BTN(pad, SCE_CTRL_UP))

+ return SCE_CTRL_UP;

- } else if (HOLD_END(opad, pad, res.okBtn)) {

- if (!selectedIDs.size())

- } else if (IS_BTN(pad, SCE_CTRL_UP) || IS_BTN(pad, SCE_CTRL_DOWN) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN)) {

- bool isPadUp = IS_BTN(pad, SCE_CTRL_UP);

- bool isAnalogUp = IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP);

- int delayThread = 170000;

- if ( (isPadUp || isAnalogUp) && curS-1 >= 0 ) {

- if (curS-1 < startIdx) {

+ else if (IS_BTN(pad, SCE_CTRL_DOWN))

+ return SCE_CTRL_DOWN;

- } else if ( (!isPadUp && !isAnalogUp) && curS+1 < idListSz ) {

- if (curS+1 >= lastIdx) {

+ else if (IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP))

+ return SCE_CTRL_LEFT_ANALOG_UP;

+ else if (IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN))

+ return SCE_CTRL_LEFT_ANALOG_DOWN;

- if (isAnalogUp || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN))

- delayThread = 40000;

+ else if (IS_BTN(pad, SCE_CTRL_LEFT))

+ return SCE_CTRL_LEFT;

- draw = 1;

+ else if (IS_BTN(pad, SCE_CTRL_RIGHT))

+ return SCE_CTRL_RIGHT;

opad = pad;

- if (!draw)

+ return -1;

+void drawSectionSelect(const plgmRes &res, std::vector<titleID_t> &idsList, std::vector<int> &selectedIDs) {

+ int startIdx = 0, curS = 0, idListSz = idsList.size()-1;

+ int lastIdx = idListSz > 13 ? 13:idListSz;

+ float txY = 110.0f;

+ int key;

+ while (true) {

txY = 110.0f;

- draw = 0;

- for (int i=0; i<selectedIDs.size(); ++i)

-void browseF(const plgmRes &res, std::string &plugin) {

- const char *mp[] = {"ux0:", "ur0:", "uma0:", "imc0:"};

- SceCtrlData pad, opad;

- int draw = 1, cur = 0, startIdx = 0, lastIdx;

- float yTx = 110.0f;

- for (int i=0; i<4; ++i) {

- if (exists(mp[i]))

- lastIdx = items.size() > 13 ? 13:items.size();

+ key = getKeys(res);

+ switch (key) {

+ case SCE_CTRL_CIRCLE:

+ case SCE_CTRL_CROSS: {

+ if (key == res.cancelBtn)

+ else if (!selectedIDs.size())

- while (true) {

+ for (int i=0, l=selectedIDs.size(); i<l; ++i)

- if (pad.ly < ANALOG_CENTER-ANALOG_THRESHOLD) {

- } else if (pad.ly > ANALOG_CENTER+ANALOG_THRESHOLD) {

- if (HOLD_END(opad, pad, res.okBtn) || HOLD_END(opad, pad, res.cancelBtn)) {

- int isCancBtn = IS_BTN(opad, res.cancelBtn);

- if (isCancBtn && !path.size())

- else if (items[cur] == ".." || isCancBtn)

- else

- if (!path.size()) {

- for (int i=0; i<4; ++i) {

- if (exists(mp[i]))

- } else {

+ case SCE_CTRL_SQUARE: {

+ if (!idsList[curS].selected) {

- for (int i=0; i<path.size(); ++i) {

- const char *slash = (i == 0 || i+1 == path.size()) ? "":"/";

+ } else {

- tmp << path[i] << slash;

+ for (int i=0, l=selectedIDs.size(); i<l; ++i) {

+ if (selectedIDs[i] != curS)

- if (!isDir(tmp.str().c_str())) {

- plugin = tmp.str();

- cPath = tmp.str();

- std::sort(items.begin(), items.end(), [](const std::string a, const std::string b) {

- return std::tolower(a[0]) < std::tolower(b[0]);

+ case SCE_CTRL_UP:

+ case SCE_CTRL_LEFT_ANALOG_UP: {

+ bool isPad = key == SCE_CTRL_UP;

- draw = 1;

- startIdx = cur = 0;

- lastIdx = items.size() > 13 ? 13:items.size();

- } else if (IS_BTN(pad, SCE_CTRL_UP) || IS_BTN(pad, SCE_CTRL_DOWN) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN)) {

- bool isPadUp = IS_BTN(pad, SCE_CTRL_UP);

- bool isAnalogUp = IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP);

- int delayThread = 170000;

+ if (curS-1 < 0)

- if ( (isPadUp || isAnalogUp) && cur-1 >= 0 ) {

- if (cur-1 < startIdx) {

+ if (curS-1 < startIdx) {

- } else if ( (!isPadUp && !isAnalogUp) && cur+1 < items.size() ) {

- if (cur+1 >= lastIdx) {

+ case SCE_CTRL_DOWN:

+ case SCE_CTRL_LEFT_ANALOG_DOWN: {

+ bool isPad = key == SCE_CTRL_DOWN;

+ if (curS+1 >= idListSz)

+ if (curS+1 >= lastIdx) {

- if (isAnalogUp || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN))

- delayThread = 40000;

- draw = 1;

- opad = pad;

+void browseF(const plgmRes &res, std::string &plugin) {

+ int cur = 0, startIdx = 0, lastIdx, key;

+ float yTx = 110.0f;

- if (!draw)

+ items = res.mountpoints;

+ lastIdx = items.size() > 13 ? 13:items.size();

+ while (true) {

yTx = 110.0f;

- draw = 0;

+ key = getKeys(res);

+ switch (key) {

+ case SCE_CTRL_CIRCLE:

+ case SCE_CTRL_CROSS: {

+ bool isCancel = key == res.cancelBtn;

+ if (isCancel && !path.size()) {

+ } else if (items[cur] == ".." || isCancel) {

+ } else {

+ if (!path.size()) {

+ items = res.mountpoints;

+ } else {

+ for (int i=0; i<path.size(); ++i) {

+ const char *slash = (i == 0 || i+1 == path.size()) ? "":"/";

+ tmp << path[i] << slash;

+ if (!isDir(tmp.str().c_str())) {

+ plugin = tmp.str();

+ cPath = tmp.str();

+ std::sort(items.begin(), items.end(), [](const std::string a, const std::string b) {

+ return std::tolower(a[0]) < std::tolower(b[0]);

+ startIdx = cur = 0;

+ lastIdx = items.size() > 13 ? 13:items.size();

+ case SCE_CTRL_UP:

+ case SCE_CTRL_LEFT_ANALOG_UP: {

+ bool isPad = key == SCE_CTRL_UP;

+ if (cur-1 < 0)

+ if (cur-1 < startIdx) {

+ case SCE_CTRL_DOWN:

+ case SCE_CTRL_LEFT_ANALOG_DOWN: {

+ bool isPad = key == SCE_CTRL_DOWN;

+ if (cur+1 >= items.size())

+ if (cur+1 >= lastIdx) {

-void pluginsManager(std::vector<taiSection_t> &config, PlgmUtils &utils, const plgmRes &res, std::vector<titleID_t> &idsList) {

- int curSecIdx = 0, startIdx = 0, curSel = 0, lastIdx, draw = 1;

+void pluginsManager(taiConfig_t &config, PlgmUtils &utils, const plgmRes &res, std::vector<titleID_t> &idsList) {

+ int curSecIdx = 0, startIdx = 0, curSel = 0, lastIdx, key;

int isDialogOpen = 0, dialogT, dialogId = 0;

float entryX, entryY = 110;

char viewMode = 'd';

- SceCtrlData pad, opad;

- PlgmMenu menu {res};

+ PlgmMenu menu;

sectionStr = "< "+config[0].section+" >";

lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

while (true) {

- if (pad.ly < ANALOG_CENTER-ANALOG_THRESHOLD)

- else if (pad.ly > ANALOG_CENTER+ANALOG_THRESHOLD)

+ for (int i=startIdx; i<lastIdx; ++i) {

+ uint colorTx = i == curSel ? RGBA8(0,255,0,240):RGBA8(255,255,255,255);

+ entryX = viewMode == 'e' && (config[curSecIdx].plugins[i][0] != '*' ) ? 90:40;

- if (menu.isOpen()) {

- if (HOLD_END(opad, pad, SCE_CTRL_TRIANGLE)) {

- } else if (IS_BTN(pad, SCE_CTRL_UP) || IS_BTN(pad, SCE_CTRL_DOWN) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN)) {

- bool isPadUp = IS_BTN(pad, SCE_CTRL_UP);

- bool isAnalogUp = IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP);

+ entryY += 25;

- menu = isPadUp || isAnalogUp ? --menu:++menu;

+ if (lastIdx < config[curSecIdx].plugins.size())

- } else if (HOLD_END(opad, pad, res.okBtn)) {

- bool success = false;

+ if (startIdx > 0)

- case DELETE_SECTION: {

- success = utils.delSection(config, curSel);

- if (success)

- case DELETE_PLUGIN: {

- isDialogOpen = dialogId = 1;

- dialogT = 0;

+ if (menu.isOpen())

- if (config[curSecIdx].plugins[curSel][3] != ':')

+ if (isDialogOpen)

- toDelete = config[curSecIdx].plugins[curSel];

- case DISABLE_PLUGIN: {

- int oldConfigSize = config.size(), curStrSz;

- bool isEnabldSec = curSecIdx == (config.size()-3);

- bool isSkprx = false;

+ entryY = 110;

- success = utils.disblPlugin(config, curSel, curSecIdx);

- curStrSz = config[curSecIdx].plugins[curSel].size();

- isSkprx = config[curSecIdx].plugins[curSel][curStrSz-4] == 'k';

- if (success) {

- bool isSzChanged = oldConfigSize != config.size();

+ key = getKeys(res);

+ switch (key) {

+ case SCE_CTRL_CROSS:

+ case SCE_CTRL_CIRCLE: {

+ bool isCancel = key == res.cancelBtn;

+ if (menu.isOpen() && !isCancel) {

+ bool success = false;

- if (isSzChanged && isEnabldSec) {

+ case DELETE_SECTION: {

+ success = utils.delSection(config, curSel);

+ if (success)

+ case DELETE_PLUGIN: {

+ isDialogOpen = dialogId = 1;

+ dialogT = 0;

- } else {

- sectionStr = "< " + config[curSecIdx].section + " >";

- viewMode = curSecIdx == (config.size()-3) ? 'e' : 'd';

+ if (config[curSecIdx].plugins[curSel][3] != ':' && config[curSecIdx].plugins[curSel][4] != ':')

- if (isSkprx) {

- isDialogOpen = 1;

- dialogT = 0;

- dialogId = 3;

+ toDelete = config[curSecIdx].plugins[curSel];

- case ENABLE_PLUGIN:

- case BROWSE: {

- int oldConfigSize = config.size();

- int curStrSz, isSkprx, idx;

+ case DISABLE_PLUGIN: {

+ int oldConfigSize = config.size(), curStrSz;

+ bool isEnabldSec = curSecIdx == (config.size()-3);

+ bool isSkprx = false;

- if (menu.getSelected() == ENABLE_PLUGIN) {

curStrSz = config[curSecIdx].plugins[curSel].size();

isSkprx = config[curSecIdx].plugins[curSel][curStrSz-4] == 'k';

- idx = curSel;

+ success = utils.disblPlugin(config, curSel, curSecIdx);

- } else {

+ if (success) {

+ bool isSzChanged = oldConfigSize != config.size();

- curStrSz = str.size();

- isSkprx = str[curStrSz-4] == 'k';

- idx = -1;

+ if (isSzChanged && isEnabldSec) {

+ } else {

+ sectionStr = "< " + config[curSecIdx].section + " >";

+ viewMode = curSecIdx == (config.size()-3) ? 'e' : 'd';

- if (!curStrSz)

+ if (isSkprx) {

+ isDialogOpen = 1;

+ dialogT = 0;

+ dialogId = 3;

+ case ENABLE_PLUGIN:

+ case BROWSE: {

+ int oldConfigSize = config.size();

+ int curStrSz, isSkprx, idx;

- if (isSkprx) {

- success = utils.enblPlugin(config, idx, curSecIdx, str, idsList, selIDsList);

+ if (menu.getSelected() == ENABLE_PLUGIN) {

+ curStrSz = config[curSecIdx].plugins[curSel].size();

+ isSkprx = config[curSecIdx].plugins[curSel][curStrSz-4] == 'k';

+ idx = curSel;

- isDialogOpen = 1;

- dialogT = 0;

- dialogId = 3;

+ } else {

- } else {

+ curStrSz = str.size();

+ isSkprx = str[curStrSz-4] == 'k';

+ idx = -1;

+ if (!curStrSz)

- if (selIDsList.size())

+ if (isSkprx) {

success = utils.enblPlugin(config, idx, curSecIdx, str, idsList, selIDsList);

- if (success && oldConfigSize != config.size()) {

- int newSecIdx = curSecIdx + (config.size() - oldConfigSize);

+ isDialogOpen = 1;

+ dialogT = 0;

+ dialogId = 3;

- if (newSecIdx >= config.size()-3)

- curSecIdx = newSecIdx;

+ } else {

- case MOVE_UP: {

- success = utils.movePlugin(config, curSel, curSecIdx, 'u');

- case MOVE_DOWN: {

- success = utils.movePlugin(config, curSel, curSecIdx, 'd');

- case SAVE_CONFIG: {

- success = utils.saveConfig(config);

- isDialogOpen = dialogT = 1;

- if (!success) {

- writeToLog("Cannot save config.txt!", res);

- dialogId = 99;

- } else {

- dialogId = 10;

+ if (selIDsList.size())

+ success = utils.enblPlugin(config, idx, curSecIdx, str, idsList, selIDsList);

+ if (success && oldConfigSize != config.size()) {

+ int newSecIdx = curSecIdx + (config.size() - oldConfigSize);

+ if (newSecIdx >= config.size()-3)

+ curSecIdx = newSecIdx;

- case RELOAD_CONFIG: {

- isDialogOpen = 1;

- dialogT = 0;

- dialogId = 2;

- case ADD_HALT: {

- int oldConfigSize = config.size();

- bool isSpecialSec = curSecIdx >= config.size()-3;

+ case MOVE_UP: {

+ success = utils.movePlugin(config, curSel, curSecIdx, 'u');

+ case MOVE_DOWN: {

+ success = utils.movePlugin(config, curSel, curSecIdx, 'd');

+ case SAVE_CONFIG: {

+ success = utils.saveConfig(config);

+ isDialogOpen = dialogT = 1;

+ dialogId = success ? 10:99;

+ case RELOAD_CONFIG: {

+ isDialogOpen = 1;

+ dialogT = 0;

+ dialogId = 2;

+ case ADD_HALT: {

+ int oldConfigSize = config.size();

+ bool isSpecialSec = curSecIdx >= config.size()-3;

- if (selIDsList.size()) {

- success = utils.addHaltPoint(config, idsList, selIDsList);

+ if (selIDsList.size()) {

+ success = utils.addHaltPoint(config, idsList, selIDsList);

- if (success && (isSpecialSec && oldConfigSize != config.size()))

- curSecIdx += (config.size()-oldConfigSize);

+ if (success && (isSpecialSec && oldConfigSize != config.size()))

+ curSecIdx += (config.size()-oldConfigSize);

+ case TO_HALT: {

+ success = utils.manageHaltPoint(config, curSel, 'h');

+ case REMOVE_HALT: {

+ success = utils.manageHaltPoint(config, curSel, 's');

- case TO_HALT: {

- success = utils.manageHaltPoint(config, curSel, 'h');

- case REMOVE_HALT: {

- success = utils.manageHaltPoint(config, curSel, 's');

- if (success) {

- startIdx = curSel = 0;

- lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

+ if (success) {

+ startIdx = curSel = 0;

+ lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

- draw = 1;

+ } else if (isDialogOpen) {

+ if (isCancel) {

+ if (!dialogT)

+ isDialogOpen = dialogId = 0;

- } else if (isDialogOpen) {

- if (HOLD_END(opad, pad, res.cancelBtn)) {

- if (!dialogT)

- isDialogOpen = dialogId = 0;

+ } else {

+ bool success = false;

- } else if (HOLD_END(opad, pad, res.okBtn)) {

- bool success = false;

+ switch (dialogId) {

+ case 1: {

+ int confSz = config.size();

- switch (dialogId) {

- case 1: {

- int confSz = config.size();

+ if (toDelete.size()) {

+ filePath = toDelete;

- if (toDelete.size()) {

- filePath = toDelete;

+ if (!containsStr(toDelete, "plugins") && !containsStr(toDelete, "henkaku") && !containsStr(toDelete, "adrenaline")) {

+ success = utils.delPlugin(config, filePath, -1);

- if (!containsStr(toDelete, "plugins") && !containsStr(toDelete, "henkaku") && !containsStr(toDelete, "adrenaline")) {

- success = utils.delPlugin(filePath.c_str(), config, -1);

+ } else {

+ int idx = config[confSz-2].plugins.size() - 1;

- } else {

- int idx = config[confSz-2].plugins.size() - 1;

+ success = utils.delPlugin(config, filePath, idx);

- success = utils.delPlugin(filePath.c_str(), config, idx);

+ } else {

+ filePath = utils.getPath(config[curSecIdx].plugins[curSel]);

+ success = utils.delPlugin(config, filePath, curSel);

- } else {

- filePath = utils.getPath(config[curSecIdx].plugins[curSel]);

- success = utils.delPlugin(filePath.c_str(), config, curSel);

+ isDialogOpen = dialogId = 0;

- isDialogOpen = dialogId = 0;

+ // go to enabled and remove the plugin entries, if any

+ curSecIdx = confSz-3;

+ sectionStr = "< " + config[curSecIdx].section + " >";

+ viewMode = 'e';

- // go to enabled and remove the plugin entries, if any

- curSecIdx = confSz-3;

- sectionStr = "< " + config[curSecIdx].section + " >";

- viewMode = 'e';

+ for (int j=0, i=confSz-3; j<config[i].plugins.size();) {

+ bool ret;

- for (int j=0, i=confSz-3; j<config[i].plugins.size();) {

- bool ret;

+ if (config[i].plugins[j][0] == '*' || config[i].plugins[j][0] == '!' || !containsStr(config[i].plugins[j], filePath.c_str()))

- if (config[i].plugins[j][0] == '*' || config[i].plugins[j][0] == '!' || !containsStr(config[i].plugins[j], filePath.c_str()))

+ ret = utils.disblPlugin(config, j, i);

- ret = utils.disblPlugin(config, j, i);

+ if (confSz != config.size()) {

+ confSz = config.size();

- if (confSz != config.size()) {

- confSz = config.size();

+ isDialogOpen = dialogT = 1;

+ dialogId = success ? 10:99;

- if (!success) {

- int sz = 24 + filePath.size();

- char msg[sz];

+ case 2: {

+ char * const argv[] = { (char *)"restart", NULL };

- isDialogOpen = dialogT = 1;

- dialogId = 99;

- std::snprintf(msg, sizeof(char) * sz, "Cannot delete plugin: %s", filePath.c_str());

- } else {

- isDialogOpen = dialogT = 1;

- dialogId = 10;

+ case 3: {

+ success = utils.saveConfig(config);

+ if (!success) {

+ isDialogOpen = dialogT = 1;

+ dialogId = 99;

+ } else {

+ case 10:

+ case 99: {

+ isDialogOpen = dialogId = 0;

- case 2: {

- char * const argv[] = { (char *)"restart", NULL };

- case 3: {

- success = utils.saveConfig(config);

- if (!success) {

- isDialogOpen = dialogT = 1;

- dialogId = 99;

- } else {

+ if (success) {

+ startIdx = curSel = 0;

+ lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

- case 10:

- case 99: {

- isDialogOpen = dialogId = 0;

- if (success) {

- startIdx = curSel = 0;

- lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

+ case SCE_CTRL_TRIANGLE: {

+ if (isDialogOpen) {

- draw = 1;

- } else if (IS_BTN(pad, SCE_CTRL_RIGHT) || IS_BTN(pad, SCE_CTRL_LEFT)) {

- bool isPadRight = IS_BTN(pad, SCE_CTRL_RIGHT);

- if (isPadRight)

- curSecIdx = curSecIdx+1 > config.size()-1 ? 0:++curSecIdx;

- else

- curSecIdx = curSecIdx-1 < 0 ? config.size()-1:--curSecIdx;

- viewMode = curSecIdx == (config.size()-3) ? 'e':'d';

- sectionStr = "< "+config[curSecIdx].section+" >";

- startIdx = curSel = 0;

- lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

- draw = 1;

+ } else if (menu.isOpen()) {

+ } else {

+ int menuType = 0;

- } else if (IS_BTN(pad, SCE_CTRL_UP) || IS_BTN(pad, SCE_CTRL_DOWN) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP) || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN)) {

- bool isPadUp = IS_BTN(pad, SCE_CTRL_UP);

- bool isAnalogUp = IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_UP);

- int delayThread = 160000; // Buttons

+ if (lastIdx > 0) {

+ bool hasNoHalt = config[curSecIdx].plugins[curSel][1] != '!';

- if ((isPadUp || isAnalogUp) && curSel-1 >= 0) {

- if (curSel-1 < startIdx) {

+ if (config[curSecIdx].plugins[curSel][0] == '*') // section

+ menuType = curSecIdx == (config.size()-3) && hasNoHalt ? 12:11;

+ else if (config[curSecIdx].plugins[curSel][3] == ':' || config[curSecIdx].plugins[curSel][4] == ':') // plugin

+ menuType = 1;

+ else if (curSecIdx == (config.size()-2))

+ menuType = 2;

+ else if (curSecIdx == (config.size()-1))

+ menuType = 3;

- } else if ((!isPadUp && !isAnalogUp) && curSel+1 < config[curSecIdx].plugins.size()) {

- if (curSel+1 >= lastIdx) {

+ case SCE_CTRL_RIGHT:

+ case SCE_CTRL_LEFT: {

+ if (isDialogOpen || menu.isOpen())

- if (isAnalogUp || IS_BTN(pad, SCE_CTRL_LEFT_ANALOG_DOWN))

- delayThread = 40000;

- draw = 1;

+ if (key == SCE_CTRL_RIGHT)

+ curSecIdx = curSecIdx+1 > config.size()-1 ? 0:++curSecIdx;

+ else

+ curSecIdx = curSecIdx-1 < 0 ? config.size()-1:--curSecIdx;

- } else if (HOLD_END(opad, pad, SCE_CTRL_TRIANGLE)) {

- int menuType = 0;

+ viewMode = curSecIdx == (config.size()-3) ? 'e':'d';

+ sectionStr = "< "+config[curSecIdx].section+" >";

+ startIdx = curSel = 0;

+ lastIdx = config[curSecIdx].plugins.size() > 13 ? 13:config[curSecIdx].plugins.size();

- if (lastIdx > 0) {

- bool isSection = config[curSecIdx].plugins[curSel][0] == '*';

- bool isPlugin = config[curSecIdx].plugins[curSel][3] == ':';

- bool hasNoHalt = config[curSecIdx].plugins[curSel][1] != '!';

+ case SCE_CTRL_UP:

+ case SCE_CTRL_LEFT_ANALOG_UP: {

+ bool isPad = key == SCE_CTRL_UP;

- if (isSection) {

- menuType = 11;

+ if (isDialogOpen) {

- if (curSecIdx == (config.size()-3) && hasNoHalt)

- menuType = 12;

+ } else if (menu.isOpen()) {

- } else if (isPlugin) {

- menuType = 1;

+ } else {

+ if (curSel-1 < 0)

- } else if (curSecIdx == (config.size()-2)) {

- menuType = 2;

+ if (curSel-1 < startIdx) {

- } else if (curSecIdx == (config.size()-1)) {

- menuType = 3;

- draw = 1;

+ case SCE_CTRL_DOWN:

+ case SCE_CTRL_LEFT_ANALOG_DOWN: {

+ bool isPad = key == SCE_CTRL_DOWN;

- opad = pad;

+ if (isDialogOpen) {

- if (!draw)

+ } else if (menu.isOpen()) {

+ } else {

+ if (curSel+1 >= config[curSecIdx].plugins.size())

- for (int i=startIdx; i<lastIdx; ++i) {

- uint colorTx = i == curSel ? RGBA8(0,255,0,240):RGBA8(255,255,255,255);

- entryX = viewMode == 'e' && (config[curSecIdx].plugins[i][0] != '*' ) ? 90:40;

+ if (curSel+1 >= lastIdx) {

- entryY += 25;

- if (lastIdx < config[curSecIdx].plugins.size())

- if (startIdx > 0)

- if (menu.isOpen())

- if (isDialogOpen)

- entryY = 110;

- draw = 0;

int main() {

PlgmUtils utils;

plgmRes commonRes;

- char *logFileName = new char[30];

- SceDateTime time;

- int ret = 0;

// Init

- ret = initPlgm(commonRes);

- if (!ret) {

- delete logFileName;

- return 0;

+ if (!initPlgm(commonRes))

+ goto exit;

// Set language

- ret = setLanguage(commonRes);

- if (!ret) {

- delete logFileName;

- return 0;

+ if (!setLanguage(commonRes))

+ goto exit;

// Gen Title IDs list

- ret = genIDsList(idsList);

- if (ret < 3) {

- char msg[20];

// Parse taiHEN config

- ret = utils.parseConfig(config, commonRes);

- if (!ret) {

- delete logFileName;

+ if (!utils.parseConfig(config, commonRes)) {

- return 0;

+ goto exit;

- delete logFileName;