AVALANCHE: Simplify continueHelp(), move keyboard control to it's own function.

This commit is contained in:
uruk 2014-02-14 03:18:11 +01:00
parent 3d528b512f
commit c57e98ce8d
2 changed files with 30 additions and 28 deletions

View File

@ -144,37 +144,38 @@ byte Help::checkMouse() {
return 0;
}
bool Help::handleKeyboard(const Common::Event &event) {
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
return true;
for (int i = 0; i < _buttonNum; i++) {
char upperCase = toupper(event.kbd.ascii);
if (((Common::KEYCODE_a <= event.kbd.keycode) && (event.kbd.keycode <= Common::KEYCODE_z) && (_buttons[i]._trigger == upperCase)) ||
((event.kbd.keycode == Common::KEYCODE_PAGEUP) && (_buttons[i]._trigger == 214)) ||
((event.kbd.keycode == Common::KEYCODE_PAGEDOWN) && (_buttons[i]._trigger == 216))) { // We had to handle the pageups/pagedowns separately.
_vm->fadeOut();
switchPage(_buttons[i]._whither);
_vm->fadeIn();
return false;
}
}
return false;
}
void Help::continueHelp() {
warning("STUB: Help::continueHelp()");
do {
Common::Event event;
bool escape = false;
while (!_vm->shouldQuit() && !escape) {
_vm->_graphics->refreshScreen();
while (_vm->getEvent(event)) {
if (event.type == Common::EVENT_KEYDOWN) {
escape = true;
break;
}
}
}
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
break;
for (int i = 0; i < _buttonNum; i++) {
char upperCase = toupper(event.kbd.ascii);
if (((Common::KEYCODE_a <= event.kbd.keycode) && (event.kbd.keycode <= Common::KEYCODE_z) && (_buttons[i]._trigger == upperCase)) ||
((event.kbd.keycode == Common::KEYCODE_PAGEUP) && (_buttons[i]._trigger == 214)) ||
((event.kbd.keycode == Common::KEYCODE_PAGEDOWN) && (_buttons[i]._trigger == 216))) { // We had to handle the pageups/pagedowns separately.
_vm->fadeOut();
switchPage(_buttons[i]._whither);
_vm->fadeIn();
break;
}
}
} while (true);
bool close = false;
Common::Event event;
while (!_vm->shouldQuit() && !close) {
_vm->_graphics->refreshScreen();
_vm->getEvent(event);
if (event.type == Common::EVENT_KEYDOWN) {
close = handleKeyboard(event);
}
}
}
/**

View File

@ -53,6 +53,7 @@ private:
void switchPage(byte which);
Common::String getLine(Common::File &file); // It was a nested function in getMe().
byte checkMouse(); // Returns clicked-on button, or 0 if none.
bool handleKeyboard(const Common::Event &event);
void continueHelp();
};