diff options
-rw-r--r-- | engines/avalanche/graphics.cpp | 11 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 1 | ||||
-rw-r--r-- | engines/avalanche/help.cpp | 74 | ||||
-rw-r--r-- | engines/avalanche/help.h | 8 |
4 files changed, 82 insertions, 12 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index ec1446dbee..e1d92230a5 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -687,6 +687,17 @@ void GraphicManager::helpDrawButton(int y, byte which) { } /** + * @remarks Originally called 'light' + */ +void GraphicManager::helpDrawHighlight(byte which, Color color) { + if (which == 177) // Dummy value for "no button at all". + return; + + which &= 31; + drawRectangle(Common::Rect(466, 38 + which * 27, 555, 63 + which * 27), color); +} + +/** * This function mimics Pascal's getimage(). */ Graphics::Surface GraphicManager::loadPictureGraphic(Common::File &file) { diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 8e74b18e42..de7a07f271 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -105,6 +105,7 @@ public: // Help's function: void helpDrawButton(int y, byte which); + void helpDrawHighlight(byte which, Color color); void clearAlso(); void clearTextBar(); diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp index 9985e9ea6d..5b8158e016 100644 --- a/engines/avalanche/help.cpp +++ b/engines/avalanche/help.cpp @@ -36,8 +36,13 @@ namespace Avalanche { Help::Help(AvalancheEngine *vm) { _vm = vm; + for (int i = 0; i < 10; i++) { + _buttons[i]._trigger = 0; + _buttons[i]._whither = 0; + } _highlightWas = 0; _buttonNum = 0; + _holdLeft = false; } /** @@ -139,9 +144,59 @@ Common::String Help::getLine(Common::File &file) { return line; } -byte Help::checkMouse() { - warning("STUB: Help::checkMouse()"); - return 0; +bool Help::handleMouse(const Common::Event &event) { + Common::Point mousePos; + mousePos.x = event.mouse.x; + mousePos.y = event.mouse.y / 2; + + int index = -1; + + if (event.type == Common::EVENT_LBUTTONUP) { // Clicked *somewhere*... + _holdLeft = false; + + if ((mousePos.x < 470) || (mousePos.x > 550) || (((mousePos.y - 13) % 27) > 20)) + index = -1; + else // Clicked on a button. + index = ((mousePos.y - 13) / 27) - 1; + } else { // LBUTTONDOWN or MOUSEMOVE + int highlightIs = 0; + + if ((mousePos.x > 470) && (mousePos.x <= 550) && (((mousePos.y - 13) % 27) <= 20)) { // No click, so highlight. + highlightIs = (mousePos.y - 13) / 27 - 1; + if ((highlightIs < 0) || (5 < highlightIs)) + highlightIs = 177; // In case of silly values. + } else + highlightIs = 177; + + if (((highlightIs != 177) && (event.type == Common::EVENT_LBUTTONDOWN)) || _holdLeft) { + _holdLeft = true; + highlightIs += 32; + } + + if (_highlightWas != highlightIs) { + _vm->_graphics->helpDrawHighlight(_highlightWas, kColorBlue); + _highlightWas = highlightIs; + if (_buttons[highlightIs & 31]._trigger != 0) { + if (highlightIs > 31) + _vm->_graphics->helpDrawHighlight(highlightIs, kColorLightcyan); + else + _vm->_graphics->helpDrawHighlight(highlightIs, kColorLightblue); + } + } + } + + if ((index >= 0) && (_buttons[index]._trigger != 0)) { + if (_buttons[index]._trigger == 254) + return true; + else { + _vm->fadeOut(); + switchPage(_buttons[index]._whither); + _vm->fadeIn(); + return false; + } + } + + return false; } bool Help::handleKeyboard(const Common::Event &event) { @@ -164,18 +219,17 @@ bool Help::handleKeyboard(const Common::Event &event) { } void Help::continueHelp() { - warning("STUB: Help::continueHelp()"); - bool close = false; - Common::Event event; while (!_vm->shouldQuit() && !close) { - _vm->_graphics->refreshScreen(); + Common::Event event; _vm->getEvent(event); - if (event.type == Common::EVENT_KEYDOWN) { + if (event.type == Common::EVENT_KEYDOWN) close = handleKeyboard(event); - } + else if ((event.type == Common::EVENT_LBUTTONDOWN) || (event.type == Common::EVENT_LBUTTONUP) || (event.type == Common::EVENT_MOUSEMOVE)) + close = handleMouse(event); + + _vm->_graphics->refreshScreen(); } - } /** diff --git a/engines/avalanche/help.h b/engines/avalanche/help.h index 8ac552d440..c63bacdfc6 100644 --- a/engines/avalanche/help.h +++ b/engines/avalanche/help.h @@ -48,12 +48,16 @@ private: Button _buttons[10]; byte _highlightWas; - byte _buttonNum; // How many buttons do we have on the screen at the moment. + byte _buttonNum; // How many buttons do we have on the screen at the moment? + bool _holdLeft; // Is the left mouse button is still being held? 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. + + // These two return true if we have to leave the Help: + bool handleMouse(const Common::Event &event); bool handleKeyboard(const Common::Event &event); + void continueHelp(); }; |