diff options
author | uruk | 2013-09-02 01:11:16 +0200 |
---|---|---|
committer | uruk | 2013-09-02 01:11:16 +0200 |
commit | 5720fa1dba82063409472fad41c0c269f9cb2b49 (patch) | |
tree | 9a98a796361f21750269c6ca7c23450cda1f3f37 /engines | |
parent | 4d6573a80ebc2ca2aab356426ea50adf3ca77505 (diff) | |
download | scummvm-rg350-5720fa1dba82063409472fad41c0c269f9cb2b49.tar.gz scummvm-rg350-5720fa1dba82063409472fad41c0c269f9cb2b49.tar.bz2 scummvm-rg350-5720fa1dba82063409472fad41c0c269f9cb2b49.zip |
AVALANCHE: Implement drop-down menu. (Only with mouse control yet.)
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/dropdown2.cpp | 99 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 2 | ||||
-rw-r--r-- | engines/avalanche/lucerna2.cpp | 4 |
3 files changed, 77 insertions, 28 deletions
diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index 4565c2faeb..e7db8750aa 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -170,8 +170,7 @@ void onemenu::wipe() { //setactivepage(cp); CursorMan.showMouse(false); - _dr->chalk(_dr->ddm_m.ddms[_dr->ddm_o.menunum - 1].xpos, 1, _dr->ddm_m.ddms[_dr->ddm_o.menunum - 1].trigger, _dr->ddm_m.ddms[_dr->ddm_o.menunum - 1].title, true); - + _dr->chalk(_dr->ddm_m.ddms[_dr->ddm_o.menunum].xpos, 1, _dr->ddm_m.ddms[_dr->ddm_o.menunum].trigger, _dr->ddm_m.ddms[_dr->ddm_o.menunum].title, true); /*mblit(flx1, 11, flx2 + 1, fly + 1, 3, cp); blitfix();*/ @@ -353,8 +352,11 @@ void Dropdown::chalk(int16 x, int16 y, char t, Common::String z, bool valid) { fontType font; for (byte fv = 0; fv < z.size(); fv++) - for (byte ff = 0; ff < 8; ff++) + for (byte ff = 0; ff < 8; ff++) { font[z[fv]][ff] = _vm->_gyro->characters[z[fv]][ff] & ander; + for (byte i = 0; i < 8; i++) + *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + fv * 8 + i, y + ff) = lightgray; + } _vm->_graphics->drawText(_vm->_graphics->_surface, z, font, 8, x * 8, y, black); @@ -495,7 +497,8 @@ void Dropdown::ddm__action() { Common::String n = _vm->_gyro->f5_does(); for (byte i = 0; i < 2; i++) - n.deleteChar(0); + if (!n.empty()) + n.deleteChar(0); if (n.empty()) ddm_o.opt("Do something", 'D', "f5", false); else @@ -820,31 +823,79 @@ begin; end;*/ void Dropdown::checkclick(Common::Point cursorPos) { - warning("STUB: Lucerna::checkclick()"); + warning("STUB: Dropdown::checkclick()"); } -void Dropdown::menu_link() { - if (!ddm_o.menunow) - return; - +void Dropdown::menu_link() { // TODO: Optimize it ASAP!!! It really needs it... Common::Point cursorPos = _vm->getMousePos(); - checkclick(cursorPos); // Work out click codes. - - // Change arrow... - if ((0 <= cursorPos.y) && (cursorPos.y <= 21)) - _vm->_gyro->newpointer(1); // Up arrow - else if ((22 <= cursorPos.y) && (cursorPos.y <= 339)) { - if ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) && (cursorPos.y > 21) && (cursorPos.y <= ddm_o.fly * 2 + 1)) - _vm->_gyro->newpointer(3); // Right-arrow - else - _vm->_gyro->newpointer(4); // Fletch - } else if ((340 <= cursorPos.y) && (cursorPos.y <= 399)) - _vm->_gyro->newpointer(2); // Screwdriver + ::Graphics::Surface backup; + backup.copyFrom(_vm->_graphics->_surface); + + while (!ddm_o.menunow && (cursorPos.y <= 21) && _vm->_lucerna->holdLeftMouse) { + ddm_m.getmenu(cursorPos.x); + do + _vm->updateEvents(); + while (_vm->_lucerna->holdLeftMouse); + - if (!ddm_o.menunow) - return; + while (!_vm->shouldQuit()) { + do { + _vm->updateEvents(); + + cursorPos = _vm->getMousePos(); + // Change arrow... + if ((0 <= cursorPos.y) && (cursorPos.y <= 21)) + _vm->_gyro->newpointer(1); // Up arrow + else if ((22 <= cursorPos.y) && (cursorPos.y <= 339)) { + if ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) && (cursorPos.y > 21) && (cursorPos.y <= ddm_o.fly * 2 + 1)) + _vm->_gyro->newpointer(3); // Right-arrow + else + _vm->_gyro->newpointer(4); // Fletch + } else if ((340 <= cursorPos.y) && (cursorPos.y <= 399)) + _vm->_gyro->newpointer(2); // Screwdriver + + ddm_o.lightup(cursorPos); + + _vm->_graphics->refreshScreen(); + } while (!_vm->_lucerna->holdLeftMouse); + + if (_vm->_lucerna->holdLeftMouse) { + if (cursorPos.y > 21) { + if (!((ddm_o.firstlix) && ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) + && (cursorPos.y >= 24) && (cursorPos.y <= (ddm_o.fly * 2 + 1))))) { // Clicked OUTSIDE the menu. + if (ddm_o.menunow) { + ddm_o.wipe(); + _vm->_lucerna->holdLeftMouse = false; + return; + } // No "else"- clicking on menu has no effect (only releasing). + } + } else { + // Clicked on menu bar. + if (ddm_o.menunow) { + ddm_o.wipe(); + _vm->_lucerna->holdLeftMouse = true; + _vm->_graphics->_surface.copyFrom(backup); + _vm->_graphics->refreshScreen(); + break; + } + } + + // NOT clicked button... + if ((ddm_o.firstlix) && ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) + && (cursorPos.y >= 12) && (cursorPos.y <= (ddm_o.fly * 2 + 1)))) { + do { + _vm->updateEvents(); + _vm->_graphics->refreshScreen(); + } while (_vm->_lucerna->holdLeftMouse); + uint16 which = (cursorPos.y - 26) / 20; + ddm_o.select(which); + if (ddm_o.oo[which].valid) + return; + } + } - ddm_o.lightup(cursorPos); + } + } } } // End of namespace Avalanche. diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 4c1af54096..ca28772156 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -76,8 +76,6 @@ public: ::Graphics::Surface _scrolls; - ::Graphics::Surface _dropdown; - Graphics(AvalancheEngine *vm); diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index e07e428acf..eda1a8e1a5 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -1103,11 +1103,11 @@ void Lucerna::checkclick() { } else _vm->_gyro->newpointer(4); // fletch } - + if (holdLeftMouse) if ((0 <= cursorPos.y) && (cursorPos.y <= 21)) { // Click on the dropdown menu. if (_vm->_gyro->dropsok) - topcheck(cursorPos); + _vm->_dropdown->menu_link(); } else if ((317 <= cursorPos.y) && (cursorPos.y <= 339)) { // Click on the command line. _vm->_parser->_inputTextPos = (cursorPos.x - 23) / 8; if (_vm->_parser->_inputTextPos > _vm->_parser->_inputText.size() + 1) |