AVALANCHE: Implement keyboard control in Help.

This commit is contained in:
uruk 2014-02-12 23:40:17 +01:00
parent e5281bc0db
commit d734e8fc41
2 changed files with 36 additions and 2 deletions

View file

@ -29,6 +29,7 @@
#include "avalanche/avalanche.h" #include "avalanche/avalanche.h"
#include "avalanche/help.h" #include "avalanche/help.h"
#include <cctype>
namespace Avalanche { namespace Avalanche {
@ -36,6 +37,7 @@ Help::Help(AvalancheEngine *vm) {
_vm = vm; _vm = vm;
_highlightWas = 0; _highlightWas = 0;
_buttonNum = 0;
} }
/** /**
@ -89,6 +91,7 @@ void Help::switchPage(byte which) {
// We are now at the end of the text. Next we must read the icons: // We are now at the end of the text. Next we must read the icons:
y = 0; y = 0;
_buttonNum = 0;
while (!file.eos()) { while (!file.eos()) {
_buttons[y]._trigger = file.readByte(); _buttons[y]._trigger = file.readByte();
if (_buttons[y]._trigger == 177) if (_buttons[y]._trigger == 177)
@ -103,10 +106,10 @@ void Help::switchPage(byte which) {
case 254: case 254:
text = Common::String("Esc"); text = Common::String("Esc");
break; break;
case 214: // Latin capital letter O with diaeresis case 214: // PageUp
text = Common::String(24); text = Common::String(24);
break; break;
case 216: // Latin capital letter O with stroke case 216: // PageDown
text = Common::String(25); text = Common::String(25);
break; break;
default: default:
@ -118,6 +121,7 @@ void Help::switchPage(byte which) {
_vm->_graphics->drawBigText(text, _vm->_font, 8, 590 - (text.size() * 8), 17 + (y + 1) * 27, kColorCyan); _vm->_graphics->drawBigText(text, _vm->_font, 8, 590 - (text.size() * 8), 17 + (y + 1) * 27, kColorCyan);
y++; y++;
_buttonNum++;
} }
_vm->_graphics->refreshScreen(); _vm->_graphics->refreshScreen();
@ -142,6 +146,35 @@ byte Help::checkMouse() {
void Help::continueHelp() { void Help::continueHelp() {
warning("STUB: 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 (((_buttons[i]._trigger == upperCase) && (65 <= upperCase) && (upperCase <= 90)) ||
((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);
} }
/** /**

View file

@ -48,6 +48,7 @@ private:
Button _buttons[10]; Button _buttons[10];
byte _highlightWas; byte _highlightWas;
byte _buttonNum; // How many buttons do we have on the screen at the moment.
void switchPage(byte which); void switchPage(byte which);
Common::String getLine(Common::File &file); // It was a nested function in getMe(). Common::String getLine(Common::File &file); // It was a nested function in getMe().