2013-07-01 16:14:48 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
|
|
|
|
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* DROPDOWN A customised version of Oopmenu (qv). */
|
|
|
|
|
|
|
|
#include "avalanche/avalanche.h"
|
|
|
|
|
|
|
|
#include "avalanche/dropdown2.h"
|
|
|
|
#include "avalanche/lucerna2.h"
|
|
|
|
#include "avalanche/gyro2.h"
|
|
|
|
#include "avalanche/acci2.h"
|
|
|
|
#include "avalanche/trip6.h"
|
|
|
|
#include "avalanche/enid2.h"
|
|
|
|
|
|
|
|
#include "common/textconsole.h"
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
namespace Avalanche {
|
|
|
|
|
|
|
|
void HeadType::init(char trig, char altTrig, Common::String title, byte pos, DropdownFunc setupFunc, DropdownFunc chooseFunc, Dropdown *dr) {
|
|
|
|
_trigger = trig;
|
|
|
|
_altTrigger = altTrig;
|
|
|
|
_title = title;
|
|
|
|
_position = pos;
|
|
|
|
_xpos = _position * _dr->kSpacing + _dr->kIndent;
|
|
|
|
_xright = (_position + 1) * _dr->kSpacing + _dr->kIndent;
|
|
|
|
_setupFunc = setupFunc;
|
|
|
|
_chooseFunc = chooseFunc;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr = dr;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void HeadType::draw() {
|
|
|
|
CursorMan.showMouse(false);
|
2013-09-04 18:57:25 +00:00
|
|
|
_dr->drawMenuText(_xpos, 1, _trigger, _title, true, false);
|
2013-09-04 16:12:06 +00:00
|
|
|
CursorMan.showMouse(true);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void HeadType::highlight() {
|
2013-08-16 11:40:58 +00:00
|
|
|
CursorMan.showMouse(false);
|
2013-07-01 16:14:48 +00:00
|
|
|
|
|
|
|
//nosound();
|
|
|
|
//setactivepage(cp);
|
|
|
|
warning("STUB: Dropdown::headytpe::highlight()");
|
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
_dr->drawMenuText(_xpos, 1, _trigger, _title, true, true);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr->_activeMenuItem._left = _xpos;
|
|
|
|
_dr->_activeMenuItem._activeNow = true;
|
2013-09-01 15:15:55 +00:00
|
|
|
_dr->_vm->_gyro->ddmnow = true;
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr->_activeMenuItem._activeNum = _position;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr->_vm->_gyro->cmp = 177; // Force redraw of cursor.
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
bool HeadType::parseAltTrigger(char key) {
|
|
|
|
if (key != _altTrigger)
|
2013-07-01 16:14:48 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::init(Dropdown *dr) {
|
2013-07-01 16:14:48 +00:00
|
|
|
_dr = dr;
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNow = false;
|
2013-07-24 16:25:07 +00:00
|
|
|
_dr->_vm->_gyro->ddmnow = false;
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNum = 1;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::reset() {
|
|
|
|
_optionNum = 0;
|
|
|
|
_width = 0;
|
|
|
|
_firstlix = false;
|
|
|
|
_oldY = 0;
|
|
|
|
_highlightNum = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::setupOption(Common::String title, char trigger, Common::String shortcut, bool valid) {
|
|
|
|
uint16 width = (title + shortcut).size() + 3;
|
|
|
|
if (_width < width)
|
|
|
|
_width = width;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_options[_optionNum]._title = title;
|
|
|
|
_options[_optionNum]._trigger = trigger;
|
|
|
|
_options[_optionNum]._shortcut = shortcut;
|
|
|
|
_options[_optionNum]._valid = valid;
|
|
|
|
_optionNum++;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::displayOption(byte y, bool highlit) {
|
2013-09-01 15:15:55 +00:00
|
|
|
byte backgroundColor;
|
|
|
|
if (highlit)
|
|
|
|
backgroundColor = 0;
|
|
|
|
else
|
|
|
|
backgroundColor = 7;
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10), backgroundColor);
|
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
Common::String text = _options[y]._title;
|
|
|
|
while (text.size() + _options[y]._shortcut.size() < _width)
|
|
|
|
text += ' '; // Pad _options[y] with spaces.
|
|
|
|
text += _options[y]._shortcut;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
_dr->drawMenuText(_left, 4 + (y + 1) * 10, _options[y]._trigger, text, _options[y]._valid, highlit);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::display() {
|
2013-09-01 15:15:55 +00:00
|
|
|
CursorMan.showMouse(false);
|
2013-09-05 00:29:09 +00:00
|
|
|
//setactivepage(cp);
|
|
|
|
//setvisualpage(cp);
|
|
|
|
//setfillstyle(1, menu_b);
|
|
|
|
//setcolor(menu_border);
|
2013-09-04 16:12:06 +00:00
|
|
|
_firstlix = true;
|
|
|
|
_flx1 = _left - 2;
|
|
|
|
_flx2 = _left + _width;
|
|
|
|
fly = 15 + _optionNum * 10;
|
|
|
|
_activeNow = true;
|
2013-09-01 15:15:55 +00:00
|
|
|
_dr->_vm->_gyro->ddmnow = true;
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 12, (_flx2 + 1) * 8, fly), _dr->kMenuBackgroundColor);
|
|
|
|
_dr->_vm->_graphics->_surface.frameRect(Common::Rect((_flx1 + 1) * 8 - 1, 11, (_flx2 + 1) * 8 + 1, fly + 1), _dr->kMenuBorderColor);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
displayOption(0, true);
|
|
|
|
for (byte y = 1; y < _optionNum; y++)
|
|
|
|
displayOption(y, false);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
|
|
|
_dr->_vm->_gyro->defaultled = 1;
|
|
|
|
_dr->_vm->_gyro->cmp = 177;
|
|
|
|
//mousepage(cp);
|
|
|
|
CursorMan.showMouse(true); // 4 = fletch
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::wipe() {
|
2013-09-01 15:15:55 +00:00
|
|
|
//setactivepage(cp);
|
|
|
|
CursorMan.showMouse(false);
|
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
_dr->drawMenuText(_dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._xpos, 1, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._trigger, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._title, true, false);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNow = false;
|
2013-09-01 15:15:55 +00:00
|
|
|
_dr->_vm->_gyro->ddmnow = false;
|
2013-09-04 16:12:06 +00:00
|
|
|
_firstlix = false;
|
2013-09-01 15:15:55 +00:00
|
|
|
_dr->_vm->_gyro->defaultled = 2;
|
|
|
|
|
|
|
|
CursorMan.showMouse(true);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::moveHighlight(int8 inc) {
|
|
|
|
int8 highlightNum;
|
|
|
|
if (inc != 0) {
|
|
|
|
highlightNum = _highlightNum + inc;
|
|
|
|
if ((highlightNum < 0) || (highlightNum >= _optionNum))
|
2013-09-01 15:15:55 +00:00
|
|
|
return;
|
2013-09-04 16:12:06 +00:00
|
|
|
_highlightNum = highlightNum;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
//setactivepage(cp);
|
|
|
|
CursorMan.showMouse(false);
|
2013-09-04 16:12:06 +00:00
|
|
|
displayOption(_oldY, false);
|
|
|
|
displayOption(_highlightNum, true);
|
2013-09-01 15:15:55 +00:00
|
|
|
//setactivepage(1 - cp);
|
2013-09-04 16:12:06 +00:00
|
|
|
_oldY = _highlightNum;
|
2013-09-01 15:15:55 +00:00
|
|
|
CursorMan.showMouse(true);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::lightUp(Common::Point cursorPos) {
|
|
|
|
if ((cursorPos.x < _flx1 * 8) || (cursorPos.x > _flx2 * 8) || (cursorPos.y <= 25) || (cursorPos.y > ((fly - 3) * 2 + 1)))
|
2013-09-01 15:15:55 +00:00
|
|
|
return;
|
2013-09-04 16:12:06 +00:00
|
|
|
_highlightNum = (cursorPos.y - 26) / 20;
|
|
|
|
if (_highlightNum == _oldY)
|
2013-09-01 15:15:55 +00:00
|
|
|
return;
|
2013-09-04 16:12:06 +00:00
|
|
|
moveHighlight(0);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::select(byte which) {
|
|
|
|
if (!_options[which]._valid)
|
2013-09-01 15:15:55 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_choiceNum = which;
|
2013-07-01 16:14:48 +00:00
|
|
|
wipe();
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_choiceNum == _optionNum)
|
2013-09-05 00:29:09 +00:00
|
|
|
_choiceNum--; // Off the bottom.
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_choiceNum > _optionNum)
|
2013-09-05 00:29:09 +00:00
|
|
|
_choiceNum = 0; // Off the top, I suppose.
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
(_dr->*_dr->_menuBar._menuItems[_activeNum]._chooseFunc)();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::parseKey(char c) {
|
2013-07-01 16:14:48 +00:00
|
|
|
c = toupper(c);
|
2013-09-04 16:12:06 +00:00
|
|
|
bool found = false;
|
|
|
|
for (byte i = 0; i < _optionNum; i++) {
|
|
|
|
if ((toupper(_options[i]._trigger) == c) && _options[i]._valid) {
|
|
|
|
select(i);
|
2013-07-01 16:14:48 +00:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
if (!found)
|
2013-07-24 16:25:07 +00:00
|
|
|
_dr->_vm->_gyro->blip();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::init(Dropdown *dr) {
|
2013-07-01 16:14:48 +00:00
|
|
|
_dr = dr;
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuNum = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::createMenuItem(char trig, Common::String title, char altTrig, DropdownFunc setupFunc, DropdownFunc chooseFunc) {
|
|
|
|
_menuItems[_menuNum].init(trig, altTrig, title, _menuNum, setupFunc, chooseFunc, _dr);
|
|
|
|
_menuNum++;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::draw() {
|
2013-07-23 10:34:58 +00:00
|
|
|
const bytefield menuspace = {0, 0, 80, 9};
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
//setactivepage(3);
|
|
|
|
|
2013-09-05 11:20:03 +00:00
|
|
|
_dr->_vm->_graphics->_surface.fillRect(Common::Rect(0, 0, 640, 10), _dr->kMenuBackgroundColor);
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
byte savecp = _dr->_vm->_gyro->cp;
|
2013-07-24 16:25:07 +00:00
|
|
|
_dr->_vm->_gyro->cp = 3;
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
for (byte i = 0; i < _menuNum; i++)
|
|
|
|
_menuItems[i].draw();
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
for (byte page = 0; page <= 1; page++)
|
|
|
|
_dr->_vm->_trip->getset[page].remember(menuspace);
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2013-07-24 16:25:07 +00:00
|
|
|
_dr->_vm->_gyro->cp = savecp;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::parseAltTrigger(char c) {
|
|
|
|
byte i = 0;
|
|
|
|
while ((i < _menuNum) && (_menuItems[i].parseAltTrigger(c)))
|
|
|
|
i++;
|
|
|
|
if (i == _menuNum)
|
2013-09-01 15:15:55 +00:00
|
|
|
return;
|
2013-09-04 16:12:06 +00:00
|
|
|
setupMenuItem(i);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::setupMenuItem(byte which) {
|
|
|
|
if (_dr->_activeMenuItem._activeNow) {
|
|
|
|
_dr->_activeMenuItem.wipe(); // Get rid of menu.
|
|
|
|
if (_dr->_activeMenuItem._activeNum == _menuItems[which]._position)
|
2013-09-01 15:15:55 +00:00
|
|
|
return; // Clicked on own highlight.
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuItems[which].highlight();
|
|
|
|
(_dr->*_menuItems[which]._setupFunc)();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::chooseMenuItem(int16 x) {
|
|
|
|
byte i = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
do {
|
2013-09-04 16:12:06 +00:00
|
|
|
if ((x > _menuItems[i]._xpos * 8) && (x < _menuItems[i]._xright * 8)) {
|
|
|
|
setupMenuItem(i);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
i++;
|
|
|
|
} while (i < _menuNum);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 17:43:10 +00:00
|
|
|
Dropdown::Dropdown(AvalancheEngine *vm) {
|
2013-07-01 16:14:48 +00:00
|
|
|
_vm = vm;
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.init(this);
|
|
|
|
_menuBar.init(this);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::findWhatYouCanDoWithIt() {
|
2013-07-24 16:25:07 +00:00
|
|
|
switch (_vm->_gyro->thinks) {
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::wine:
|
|
|
|
case Gyro::potion:
|
|
|
|
case Gyro::ink:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeDrink;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::bell:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeRing;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::chastity:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeWear;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::lute:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodePlay;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::mushroom:
|
|
|
|
case Gyro::onion:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeEat;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::clothes:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeWear;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-09-04 16:12:06 +00:00
|
|
|
_vm->_gyro->verbstr = _vm->_acci->kVerbCodeExam; // Anything else.
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
void Dropdown::drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted) {
|
|
|
|
byte fontColor;
|
|
|
|
byte backgroundColor;
|
|
|
|
if (highlighted) {
|
|
|
|
fontColor = white;
|
|
|
|
backgroundColor = black;
|
|
|
|
} else {
|
|
|
|
fontColor = black;
|
|
|
|
backgroundColor = lightgray;
|
|
|
|
}
|
|
|
|
|
2013-07-01 16:14:48 +00:00
|
|
|
byte ander;
|
2013-07-23 15:21:53 +00:00
|
|
|
if (valid)
|
|
|
|
ander = 255;
|
|
|
|
else
|
|
|
|
ander = 170;
|
|
|
|
|
2013-09-05 11:20:03 +00:00
|
|
|
FontType font;
|
2013-09-05 06:11:27 +00:00
|
|
|
for (byte i = 0; i < text.size(); i++) {
|
2013-09-04 18:57:25 +00:00
|
|
|
for (byte j = 0; j < 8; j++) {
|
2013-09-05 06:11:27 +00:00
|
|
|
byte idx = text[i];
|
|
|
|
font[idx][j] = _vm->_gyro->characters[idx][j] & ander; // Set the font.
|
2013-09-04 18:57:25 +00:00
|
|
|
// And set the background of the text to the desired color.
|
|
|
|
for (byte k = 0; k < 8; k++)
|
|
|
|
*(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + i * 8 + k, y + j) = backgroundColor;
|
2013-09-01 23:11:16 +00:00
|
|
|
}
|
2013-09-05 06:11:27 +00:00
|
|
|
}
|
2013-07-23 15:21:53 +00:00
|
|
|
|
2013-09-04 18:57:25 +00:00
|
|
|
_vm->_graphics->drawText(_vm->_graphics->_surface, text, font, 8, x * 8, y, fontColor);
|
2013-08-11 12:06:15 +00:00
|
|
|
|
|
|
|
// Underline the selected character.
|
2013-09-04 18:57:25 +00:00
|
|
|
if (!text.contains(trigger))
|
2013-07-23 15:21:53 +00:00
|
|
|
return;
|
|
|
|
else {
|
2013-09-04 18:57:25 +00:00
|
|
|
byte i;
|
|
|
|
for (i = 0; text[i] != trigger; i++); // Search for the character in the string.
|
2013-07-23 15:21:53 +00:00
|
|
|
|
2013-08-11 12:06:15 +00:00
|
|
|
byte pixel = ander;
|
2013-07-23 15:21:53 +00:00
|
|
|
for (byte bit = 0; bit < 8; bit++) {
|
|
|
|
byte pixelBit = (pixel >> bit) & 1;
|
2013-08-11 12:06:15 +00:00
|
|
|
if (pixelBit)
|
2013-09-05 11:20:03 +00:00
|
|
|
*(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + i * 8 + 7 - bit, y + 8) = fontColor;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-01 15:15:55 +00:00
|
|
|
_vm->_graphics->refreshScreen();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dropdown::bleep() {
|
|
|
|
warning("STUB: Dropdown::bleep()");
|
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::parseKey(char r, char re) {
|
|
|
|
//switch (r) {
|
|
|
|
//case 0:
|
|
|
|
//case 224: {
|
|
|
|
// switch (re) {
|
|
|
|
// case 'K':
|
|
|
|
// if (_activeMenuItem._activeNum > 1) {
|
|
|
|
// _activeMenuItem.wipe();
|
|
|
|
// _menuBar.setupMenuItem(_activeMenuItem._activeNum - 1);
|
|
|
|
// } else {
|
|
|
|
// // Get menu on the left-hand side.
|
|
|
|
// _activeMenuItem.wipe();
|
|
|
|
// _menuBar.chooseMenuItem((_menuBar._menuNum - 1) * kSpacing + kIndent);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case 'M':
|
|
|
|
// if (_activeMenuItem._activeNum < _menuBar._menuNum) {
|
|
|
|
// _activeMenuItem.wipe();
|
|
|
|
// _menuBar.setupMenuItem(_activeMenuItem._activeNum + 1);
|
|
|
|
// } else {
|
|
|
|
// // Get menu on the far right-hand side.
|
|
|
|
// _activeMenuItem.wipe();
|
|
|
|
// _menuBar.chooseMenuItem(kIndent);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case 'H':
|
|
|
|
// _activeMenuItem.moveHighlight(-1);
|
|
|
|
// break;
|
|
|
|
// case 'P':
|
|
|
|
// _activeMenuItem.moveHighlight(1);
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// _menuBar.parseAltTrigger(re);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//break;
|
|
|
|
//case 13:
|
|
|
|
// _activeMenuItem.select(_activeMenuItem._highlightNum);
|
|
|
|
// break;
|
|
|
|
//default: {
|
|
|
|
// if (_activeMenuItem._activeNow)
|
|
|
|
// _activeMenuItem.parseKey(r);
|
|
|
|
// }
|
|
|
|
//}
|
2013-09-04 18:57:25 +00:00
|
|
|
warning("STUB: Dropdown::parseKey()"); // To be implemented properly later! Don't remove the comment above!
|
2013-09-04 16:12:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::String Dropdown::selectGender(byte x) {
|
|
|
|
if (x < 175)
|
|
|
|
return "im";
|
|
|
|
else
|
|
|
|
return "er";
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuGame() {
|
|
|
|
_activeMenuItem.reset();
|
|
|
|
_activeMenuItem.setupOption("Help...", 'H', "f1", true);
|
|
|
|
_activeMenuItem.setupOption("Boss Key", 'B', "alt-B", true);
|
|
|
|
_activeMenuItem.setupOption("Untrash screen", 'U', "ctrl-f7", true);
|
|
|
|
_activeMenuItem.setupOption("Score and rank", 'S', "f9", true);
|
|
|
|
_activeMenuItem.setupOption("About Avvy...", 'A', "shift-f10", true);
|
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuFile() {
|
|
|
|
_activeMenuItem.reset();
|
|
|
|
_activeMenuItem.setupOption("New game", 'N', "f4", true);
|
|
|
|
_activeMenuItem.setupOption("Load...", 'L', "^f3", true);
|
|
|
|
_activeMenuItem.setupOption("Save", 'S', "^f2", _vm->_gyro->alive);
|
|
|
|
_activeMenuItem.setupOption("Save As...", 'v', "", _vm->_gyro->alive);
|
|
|
|
_activeMenuItem.setupOption("DOS Shell", 'D', _vm->_gyro->atkey + '1', true);
|
|
|
|
_activeMenuItem.setupOption("Quit", 'Q', "alt-X", true);
|
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuAction() {
|
|
|
|
_activeMenuItem.reset();
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
Common::String f5Does = _vm->_gyro->f5_does();
|
2013-09-01 15:15:55 +00:00
|
|
|
for (byte i = 0; i < 2; i++)
|
2013-09-04 16:12:06 +00:00
|
|
|
if (!f5Does.empty())
|
|
|
|
f5Does.deleteChar(0);
|
|
|
|
if (f5Does.empty())
|
|
|
|
_activeMenuItem.setupOption("Do something", 'D', "f5", false);
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption(f5Does, f5Does[0], "f5", true);
|
|
|
|
_activeMenuItem.setupOption("Pause game", 'P', "f6", true);
|
2013-09-01 15:15:55 +00:00
|
|
|
if (_vm->_gyro->dna.room == 99)
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Journey thither", 'J', "f7", _vm->_trip->neardoor());
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Open the door", 'O', "f7", _vm->_trip->neardoor());
|
|
|
|
_activeMenuItem.setupOption("Look around", 'L', "f8", true);
|
|
|
|
_activeMenuItem.setupOption("Inventory", 'I', "Tab", true);
|
2013-09-01 15:15:55 +00:00
|
|
|
if (_vm->_trip->tr[0].xs == _vm->_gyro->walk)
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Run fast", 'R', "^R", true);
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Walk slowly", 'W', "^W", true);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuPeople() {
|
2013-09-01 15:15:55 +00:00
|
|
|
if (!people.empty())
|
|
|
|
people.clear();
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
for (byte i = 150; i <= 178; i++)
|
2013-09-04 18:57:25 +00:00
|
|
|
if (_vm->_gyro->whereis[i - 150] == _vm->_gyro->dna.room) {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption(_vm->_gyro->getname(i), _vm->_gyro->getnamechar(i), "", true);
|
|
|
|
people = people + i;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuObjects() {
|
|
|
|
_activeMenuItem.reset();
|
|
|
|
for (byte i = 0; i < numobjs; i++) {
|
|
|
|
if (_vm->_gyro->dna.obj[i])
|
|
|
|
_activeMenuItem.setupOption(_vm->_gyro->get_thing(i + 1), _vm->_gyro->get_thingchar(i + 1), "", true);
|
2013-09-02 18:09:44 +00:00
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenuWith() {
|
|
|
|
_activeMenuItem.reset();
|
2013-09-01 15:15:55 +00:00
|
|
|
|
|
|
|
if (_vm->_gyro->thinkthing) {
|
2013-09-04 16:12:06 +00:00
|
|
|
findWhatYouCanDoWithIt();
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
for (byte i = 0; i < _vm->_gyro->verbstr.size(); i++) {
|
2013-09-04 23:55:08 +00:00
|
|
|
char vbchar;
|
|
|
|
Common::String verb;
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_vm->_acci->verbOpt(_vm->_gyro->verbstr[i], verb, vbchar);
|
|
|
|
_activeMenuItem.setupOption(verb, vbchar, "", true);
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
// We disable the "give" option if: (a), you haven't selected anybody, (b), the _person you've selected isn't in the room,
|
|
|
|
// or (c), the _person you've selected is YOU!
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
if ((_vm->_gyro->last_person == _vm->_gyro->pavalot) || (_vm->_gyro->last_person == _vm->_acci->kNothing)
|
|
|
|
|| (_vm->_gyro->whereis[_vm->_gyro->last_person - 150] != _vm->_gyro->dna.room))
|
2013-09-05 00:29:09 +00:00
|
|
|
_activeMenuItem.setupOption("Give to...", 'G', "", false); // Not here.
|
2013-09-01 15:15:55 +00:00
|
|
|
else {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption(Common::String("Give to ") + _vm->_gyro->getname(_vm->_gyro->last_person), 'G', "", true);
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = _vm->_gyro->verbstr + _vm->_acci->kVerbCodeGive;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Examine", 'x', "", true);
|
|
|
|
_activeMenuItem.setupOption(Common::String("Talk to h") + selectGender(_vm->_gyro->thinks), 'T', "", true);
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = Common::String(_vm->_acci->kVerbCodeExam) + _vm->_acci->kVerbCodeTalk;
|
2013-09-01 15:15:55 +00:00
|
|
|
switch (_vm->_gyro->thinks) {
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::pgeida:
|
|
|
|
case Gyro::parkata: {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Kiss her", 'K', "", true);
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = _vm->_gyro->verbstr + _vm->_acci->kVerbCodeKiss;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::pdogfood: {
|
2013-09-05 00:29:09 +00:00
|
|
|
_activeMenuItem.setupOption("Play his game", 'P', "", !_vm->_gyro->dna.wonnim); // True if you HAVEN'T won.
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_gyro->verbstr = _vm->_gyro->verbstr + _vm->_acci->kVerbCodePlay;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::pmalagauche: {
|
2013-09-04 16:12:06 +00:00
|
|
|
bool isSober = !_vm->_gyro->dna.teetotal;
|
|
|
|
_activeMenuItem.setupOption("Buy some wine", 'w', "", !_vm->_gyro->dna.obj[_vm->_gyro->wine - 1]);
|
|
|
|
_activeMenuItem.setupOption("Buy some beer", 'b', "", isSober);
|
|
|
|
_activeMenuItem.setupOption("Buy some whisky", 'h', "", isSober);
|
|
|
|
_activeMenuItem.setupOption("Buy some cider", 'c', "", isSober);
|
|
|
|
_activeMenuItem.setupOption("Buy some mead", 'm', "", isSober);
|
|
|
|
_vm->_gyro->verbstr = _vm->_gyro->verbstr + 101 + 100 + 102 + 103 + 104;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-03 23:06:03 +00:00
|
|
|
case Gyro::ptrader: {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Buy an onion", 'o', "", !_vm->_gyro->dna.obj[_vm->_gyro->onion - 1]);
|
|
|
|
_vm->_gyro->verbstr = _vm->_gyro->verbstr + 105;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.display();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dropdown::runMenuGame() {
|
|
|
|
// Help, boss, untrash screen.
|
|
|
|
switch (_activeMenuItem._choiceNum) {
|
2013-07-01 16:14:48 +00:00
|
|
|
case 0:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeHelp);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBoss);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-07-24 17:43:10 +00:00
|
|
|
_vm->_lucerna->major_redraw();
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeScore);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeInfo);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::runMenuFile() {
|
|
|
|
// New game, load, save, save as, DOS shell, about, quit.
|
|
|
|
switch (_activeMenuItem._choiceNum) {
|
2013-07-01 16:14:48 +00:00
|
|
|
case 0:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeRestart);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 1: {
|
2013-09-03 13:35:09 +00:00
|
|
|
if (!_vm->_acci->_realWords[1].empty())
|
|
|
|
_vm->_acci->_realWords[1].clear();
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeLoad);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: {
|
2013-09-03 13:35:09 +00:00
|
|
|
if (!_vm->_acci->_realWords[1].empty())
|
|
|
|
_vm->_acci->_realWords[1].clear();
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeSave);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-03 15:51:30 +00:00
|
|
|
//_vm->_basher->filename_edit();
|
2013-09-04 16:12:06 +00:00
|
|
|
warning("STUB: Dropdown::runMenuFile()");
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-05 10:59:01 +00:00
|
|
|
_vm->_enid->backToBootstrap(2);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeQuit);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::runMenuAction() {
|
|
|
|
Common::String f5Does;
|
|
|
|
// Get up, pause game, open door, look, inventory, walk/run.
|
|
|
|
switch (_activeMenuItem._choiceNum) {
|
2013-07-01 16:14:48 +00:00
|
|
|
case 0: {
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_person = _vm->_acci->kPardon;
|
|
|
|
_vm->_acci->_thing = _vm->_acci->kPardon;
|
2013-09-04 16:12:06 +00:00
|
|
|
f5Does = _vm->_gyro->f5_does();
|
|
|
|
_vm->_lucerna->callverb(f5Does[0]);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodePause);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeOpen);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeLook);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeInv);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 5: {
|
2013-09-01 15:15:55 +00:00
|
|
|
if (_vm->_trip->tr[0].xs == _vm->_gyro->walk)
|
|
|
|
_vm->_trip->tr[0].xs = _vm->_gyro->run;
|
|
|
|
else
|
|
|
|
_vm->_trip->tr[0].xs = _vm->_gyro->walk;
|
2013-07-24 17:43:10 +00:00
|
|
|
_vm->_trip->newspeed();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::runMenuObjects() {
|
|
|
|
_vm->_lucerna->thinkabout(_vm->_gyro->objlist[_activeMenuItem._choiceNum + 1], _vm->_gyro->a_thing);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::runMenuPeople() {
|
|
|
|
_vm->_lucerna->thinkabout(people[_activeMenuItem._choiceNum], _vm->_gyro->a_person);
|
|
|
|
_vm->_gyro->last_person = people[_activeMenuItem._choiceNum];
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::runMenuWith() {
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = _vm->_gyro->thinks;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-07-24 16:25:07 +00:00
|
|
|
if (_vm->_gyro->thinkthing) {
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing += 49;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_vm->_gyro->verbstr[_activeMenuItem._choiceNum] == _vm->_acci->kVerbCodeGive)
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_person = _vm->_gyro->last_person;
|
2013-07-01 16:14:48 +00:00
|
|
|
else
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_person = 254;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
|
|
|
} else {
|
2013-09-04 16:12:06 +00:00
|
|
|
switch (_vm->_gyro->verbstr[_activeMenuItem._choiceNum]) {
|
2013-09-01 15:15:55 +00:00
|
|
|
case 100: { // Beer
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 100;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
|
|
|
case 101: { // Wine
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 50;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
|
|
|
case 102: { // Whisky
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 102;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
|
|
|
case 103: { // Cider
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 103;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
|
|
|
case 104: { // Mead
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 107;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
|
|
|
case 105: { // Onion (trader)
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_thing = 67;
|
|
|
|
_vm->_lucerna->callverb(_vm->_acci->kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 15:15:55 +00:00
|
|
|
break;
|
2013-07-01 16:14:48 +00:00
|
|
|
default: {
|
2013-09-03 13:35:09 +00:00
|
|
|
_vm->_acci->_person = _vm->_acci->_thing;
|
|
|
|
_vm->_acci->_thing = 254;
|
2013-09-02 18:09:44 +00:00
|
|
|
_vm->_gyro->subjnumber = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
_vm->_lucerna->callverb(_vm->_gyro->verbstr[_activeMenuItem._choiceNum]);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::setupMenu() {
|
|
|
|
_menuBar.init(this);
|
|
|
|
_activeMenuItem.init(this);
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuBar.createMenuItem('F', "File", '!', &Avalanche::Dropdown::setupMenuFile, &Avalanche::Dropdown::runMenuFile);
|
|
|
|
_menuBar.createMenuItem('G', "Game", 34, &Avalanche::Dropdown::setupMenuGame, &Avalanche::Dropdown::runMenuGame);
|
|
|
|
_menuBar.createMenuItem('A', "Action", 30, &Avalanche::Dropdown::setupMenuAction, &Avalanche::Dropdown::runMenuAction);
|
|
|
|
_menuBar.createMenuItem('O', "Objects", 24, &Avalanche::Dropdown::setupMenuObjects, &Avalanche::Dropdown::runMenuObjects);
|
|
|
|
_menuBar.createMenuItem('P', "People", 25, &Avalanche::Dropdown::setupMenuPeople, &Avalanche::Dropdown::runMenuPeople);
|
|
|
|
_menuBar.createMenuItem('W', "With", 17, &Avalanche::Dropdown::setupMenuWith, &Avalanche::Dropdown::runMenuWith);
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuBar.draw();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it...
|
2013-09-01 15:15:55 +00:00
|
|
|
Common::Point cursorPos = _vm->getMousePos();
|
2013-09-01 23:11:16 +00:00
|
|
|
::Graphics::Surface backup;
|
|
|
|
backup.copyFrom(_vm->_graphics->_surface);
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
while (!_activeMenuItem._activeNow && (cursorPos.y <= 21) && _vm->_lucerna->holdLeftMouse) {
|
|
|
|
_menuBar.chooseMenuItem(cursorPos.x);
|
2013-09-01 23:11:16 +00:00
|
|
|
do
|
|
|
|
_vm->updateEvents();
|
|
|
|
while (_vm->_lucerna->holdLeftMouse);
|
|
|
|
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-01 23:11:16 +00:00
|
|
|
while (!_vm->shouldQuit()) {
|
|
|
|
do {
|
|
|
|
_vm->updateEvents();
|
|
|
|
|
2013-09-02 10:53:01 +00:00
|
|
|
// We updadte the cursor's picture.
|
2013-09-01 23:11:16 +00:00
|
|
|
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)) {
|
2013-09-04 16:12:06 +00:00
|
|
|
if ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8) && (cursorPos.y > 21) && (cursorPos.y <= _activeMenuItem.fly * 2 + 1))
|
2013-09-01 23:11:16 +00:00
|
|
|
_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
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.lightUp(cursorPos);
|
2013-09-01 23:11:16 +00:00
|
|
|
|
|
|
|
_vm->_graphics->refreshScreen();
|
|
|
|
} while (!_vm->_lucerna->holdLeftMouse);
|
|
|
|
|
|
|
|
if (_vm->_lucerna->holdLeftMouse) {
|
|
|
|
if (cursorPos.y > 21) {
|
2013-09-04 16:12:06 +00:00
|
|
|
if (!((_activeMenuItem._firstlix) && ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8)
|
|
|
|
&& (cursorPos.y >= 24) && (cursorPos.y <= (_activeMenuItem.fly * 2 + 1))))) {
|
2013-09-02 13:44:55 +00:00
|
|
|
// Clicked OUTSIDE the menu.
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_activeMenuItem._activeNow) {
|
|
|
|
_activeMenuItem.wipe();
|
2013-09-01 23:11:16 +00:00
|
|
|
_vm->_lucerna->holdLeftMouse = false;
|
|
|
|
return;
|
|
|
|
} // No "else"- clicking on menu has no effect (only releasing).
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Clicked on menu bar.
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_activeMenuItem._activeNow) {
|
|
|
|
_activeMenuItem.wipe();
|
2013-09-01 23:11:16 +00:00
|
|
|
_vm->_graphics->_surface.copyFrom(backup);
|
|
|
|
_vm->_graphics->refreshScreen();
|
2013-09-02 13:44:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
if (((_activeMenuItem._left * 8) <= cursorPos.x) && (cursorPos.x <= (_activeMenuItem._left * 8 + 80))) { // 80: the width of one menu item on the bar in pixels.
|
2013-09-02 18:09:44 +00:00
|
|
|
// If we clicked on the same menu item (the one that is already active) on the bar...
|
2013-09-02 13:44:55 +00:00
|
|
|
_vm->_lucerna->holdLeftMouse = false;
|
|
|
|
return;
|
2013-09-02 18:09:44 +00:00
|
|
|
} else {
|
|
|
|
_vm->_lucerna->holdLeftMouse = true;
|
|
|
|
break;
|
2013-09-02 13:44:55 +00:00
|
|
|
}
|
2013-09-01 23:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOT clicked button...
|
2013-09-04 16:12:06 +00:00
|
|
|
if ((_activeMenuItem._firstlix) && ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8)
|
|
|
|
&& (cursorPos.y >= 12) && (cursorPos.y <= (_activeMenuItem.fly * 2 + 1)))) {
|
2013-09-02 10:53:01 +00:00
|
|
|
|
2013-09-02 13:44:55 +00:00
|
|
|
// We act only if the button is released over a menu item.
|
2013-09-02 10:53:01 +00:00
|
|
|
while (!_vm->shouldQuit()) {
|
|
|
|
cursorPos = _vm->getMousePos();
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.lightUp(cursorPos);
|
2013-09-01 23:11:16 +00:00
|
|
|
_vm->_graphics->refreshScreen();
|
2013-09-02 10:53:01 +00:00
|
|
|
|
|
|
|
_vm->updateEvents();
|
|
|
|
if (!_vm->_lucerna->holdLeftMouse)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-01 23:11:16 +00:00
|
|
|
uint16 which = (cursorPos.y - 26) / 20;
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.select(which);
|
|
|
|
if (_activeMenuItem._options[which]._valid) // If the menu item wasn't active, we do nothing.
|
2013-09-01 23:11:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-01 23:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-05 09:05:03 +00:00
|
|
|
|
|
|
|
backup.free();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Avalanche.
|