Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PSP-Archive/ARK-4
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Feb 3, 2025
2 parents 9c276a7 + 3f205bf commit 8bcafd6
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions extras/menus/arkMenu/src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ typedef BrowserFolder Folder;

extern "C" int kuKernelLoadModule(const char*, int, void*);

#define MAX_OPTIONS 12

static char* pEntries[MAX_OPTIONS] = {
static char* pEntries[] = {
(char*) "Cancel",
(char*) "Copy",
(char*) "Cut",
Expand All @@ -50,6 +49,8 @@ static char* pEntries[MAX_OPTIONS] = {
(char*) "Go to disc0:/",
};

SceUID max_options = sizeof(pEntries)/sizeof(pEntries[0]);

BrowserDriver* Browser::ftp_driver = NULL;

Browser* Browser::getInstance(){
Expand Down Expand Up @@ -103,6 +104,16 @@ Browser::Browser(){
if (ark_config->exec_mode == PS_VITA)
pEntries[USB_DEV] = NULL;

static int i = 0;
static int new_size = 0;
for(;i<max_options;i++) {
if(pEntries[i])
new_size++;
}

max_options = new_size;


}

Browser::~Browser(){
Expand Down Expand Up @@ -1492,7 +1503,7 @@ void Browser::drawOptionsMenu(){
int x = 10;
int y = 55;
static TextScroll scroll = {0, 0, 0, 125};
for (int i=0; i<MAX_OPTIONS; i++){
for (int i=0; i<max_options; i++){
if (this->clipboard->size()<1 && i == 3) continue; // Hide Paste unless clipboard has something in it.
if (pEntries[i] == NULL) continue;
if (i == pEntryIndex){
Expand Down Expand Up @@ -1552,7 +1563,7 @@ void Browser::optionsMenu(){
if (pad->down()){
common::playMenuSound();
do {
if (pEntryIndex < MAX_OPTIONS-1){
if (pEntryIndex < max_options-1){
if(this->clipboard->size()<1 && pEntryIndex == 2) pEntryIndex += 2;
else pEntryIndex++;
}
Expand All @@ -1570,28 +1581,28 @@ void Browser::optionsMenu(){
else pEntryIndex--;
}
else{
pEntryIndex = MAX_OPTIONS-1;
pEntryIndex = max_options-1;
}
} while (pEntries[pEntryIndex] == NULL);
}
// Right
else if (pad->right()) {
common::playMenuSound();
do {
if(pEntryIndex >= (int)((MAX_OPTIONS-1)/2))
pEntryIndex = MAX_OPTIONS-1;
else if(pEntryIndex <= 0)
pEntryIndex = (int)((MAX_OPTIONS-1)/2);
if(pEntryIndex >= (int)((max_options-1)/2))
pEntryIndex = max_options-1;
else if(pEntryIndex <= (int)((max_options-1)/2))
pEntryIndex = (int)((max_options-1)/2);
} while (pEntries[pEntryIndex] == NULL);
}
// Left
else if (pad->left()) {
common::playMenuSound();
do {
if(pEntryIndex <= (int)((MAX_OPTIONS-1)/2))
if(pEntryIndex <= (int)((max_options-1)/2))
pEntryIndex = 0;
else if(pEntryIndex <= MAX_OPTIONS-1)
pEntryIndex = (int)((MAX_OPTIONS-1)/2);
else if(pEntryIndex <= max_options-1)
pEntryIndex = (int)((max_options-1)/2);
} while (pEntries[pEntryIndex] == NULL);
}
else if (pad->decline() || pad->LT()){
Expand Down

0 comments on commit 8bcafd6

Please sign in to comment.