1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 22:40:39 +02:00

Allow exiting the selector with B when not in explorer mode

This commit is contained in:
Paul Cercueil 2013-08-30 07:02:56 -04:00
parent 5eb8fb7fd7
commit 20339c8849

View File

@ -75,7 +75,8 @@ int Selector::exec(int startSelection) {
gmenu2x->drawButton(&bg, "left", "", 5)-10))); gmenu2x->drawButton(&bg, "left", "", 5)-10)));
} else { } else {
gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"], gmenu2x->drawButton(&bg, "start", gmenu2x->tr["Exit"],
gmenu2x->drawButton(&bg, "accept", gmenu2x->tr["Select a file"], 5)); gmenu2x->drawButton(&bg, "cancel", "",
gmenu2x->drawButton(&bg, "accept", gmenu2x->tr["Select a file"], 5)) - 10);
} }
bg.convertToDisplayFormat(); bg.convertToDisplayFormat();
@ -128,128 +129,75 @@ int Selector::exec(int startSelection) {
gmenu2x->drawScrollBar(SELECTOR_ELEMENTS, fl.size(), firstElement); gmenu2x->drawScrollBar(SELECTOR_ELEMENTS, fl.size(), firstElement);
gmenu2x->s->flip(); gmenu2x->s->flip();
switch (gmenu2x->input.waitForPressedButton()) { switch (gmenu2x->input.waitForPressedButton()) {
case InputManager::SETTINGS: case InputManager::SETTINGS:
close = true; close = true;
result = false; result = false;
break; break;
case InputManager::UP:
if (selected == 0) selected = fl.size() -1;
else selected -= 1;
selTick = SDL_GetTicks();
break;
case InputManager::ALTLEFT:
if ((int)(selected-SELECTOR_ELEMENTS+1)<0) selected = 0;
else selected -= SELECTOR_ELEMENTS-1;
selTick = SDL_GetTicks();
break;
case InputManager::DOWN:
if (selected+1>=fl.size()) selected = 0;
else selected += 1;
selTick = SDL_GetTicks();
break;
case InputManager::ALTRIGHT:
if (selected+SELECTOR_ELEMENTS-1>=fl.size()) selected = fl.size()-1;
else selected += SELECTOR_ELEMENTS-1;
selTick = SDL_GetTicks();
break;
case InputManager::CANCEL:
case InputManager::LEFT:
if (link->getSelectorBrowser()) {
string::size_type p = dir.rfind("/", dir.size()-2);
if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) {
close = true;
result = false;
} else {
dir = dir.substr(0,p+1);
INFO("%s\n", dir.c_str());
selected = 0;
firstElement = 0;
prepare(&fl,&screens,&titles);
}
}
break;
case InputManager::ACCEPT:
if (fl.isFile(selected)) {
file = fl[selected];
close = true;
} else {
dir = dir+fl[selected]+"/";
selected = 0;
firstElement = 0;
prepare(&fl,&screens,&titles);
}
break;
default:
break;
}
/* case InputManager::UP:
gmenu2x->input.update(); if (selected == 0) selected = fl.size() -1;
if ( gmenu2x->input[ACTION_START] ) { close = true; result = false; } else selected -= 1;
if ( gmenu2x->input[ACTION_UP] ) { selTick = SDL_GetTicks();
if (selected==0) { break;
selected = fl.size()-1;
} else { case InputManager::ALTLEFT:
selected -= 1; if ((int)(selected-SELECTOR_ELEMENTS+1)<0) selected = 0;
} else selected -= SELECTOR_ELEMENTS-1;
selTick = SDL_GetTicks(); selTick = SDL_GetTicks();
} break;
if ( gmenu2x->input[ACTION_L] ) {
if ((int)(selected-SELECTOR_ELEMENTS+1)<0) { case InputManager::DOWN:
selected = 0; if (selected+1>=fl.size()) selected = 0;
} else { else selected += 1;
selected -= SELECTOR_ELEMENTS-1; selTick = SDL_GetTicks();
} break;
selTick = SDL_GetTicks();
} case InputManager::ALTRIGHT:
if ( gmenu2x->input[ACTION_DOWN] ) { if (selected+SELECTOR_ELEMENTS-1>=fl.size()) selected = fl.size()-1;
if (selected+1>=fl.size()) { else selected += SELECTOR_ELEMENTS-1;
selected = 0; selTick = SDL_GetTicks();
} else { break;
selected += 1;
} case InputManager::CANCEL:
selTick = SDL_GetTicks(); if (!link->getSelectorBrowser()) {
}
if ( gmenu2x->input[ACTION_R] ) {
if (selected+SELECTOR_ELEMENTS-1>=fl.size()) {
selected = fl.size()-1;
} else {
selected += SELECTOR_ELEMENTS-1;
}
selTick = SDL_GetTicks();
}
if ( gmenu2x->input[ACTION_X] ) {
if (link->getSelectorBrowser()) {
string::size_type p = dir.rfind("/", dir.size()-2);
if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) {
close = true; close = true;
result = false; result = false;
break;
}
case InputManager::LEFT:
if (link->getSelectorBrowser()) {
string::size_type p = dir.rfind("/", dir.size()-2);
if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) {
close = true;
result = false;
} else {
dir = dir.substr(0,p+1);
selected = 0;
firstElement = 0;
prepare(&fl,&screens,&titles);
}
}
break;
case InputManager::ACCEPT:
if (fl.isFile(selected)) {
file = fl[selected];
close = true;
} else { } else {
dir = dir.substr(0,p+1); dir = dir+fl[selected]+"/";
INFO("%s\n", dir.c_str());
selected = 0; selected = 0;
firstElement = 0; firstElement = 0;
prepare(&fl,&screens,&titles); prepare(&fl,&screens,&titles);
} }
} else { break;
close = true;
result = false; default:
} break;
} }
if ( gmenu2x->input[ACTION_B] ) {
if (fl.isFile(selected)) {
file = fl[selected];
close = true;
} else {
dir = dir+fl[selected]+"/";
selected = 0;
firstElement = 0;
prepare(&fl,&screens,&titles);
}
}
*/
} }
gmenu2x->sc.defaultAlpha = true; gmenu2x->sc.defaultAlpha = true;
freeScreenshots(&screens); freeScreenshots(&screens);