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.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2013-07-01 16:14:48 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2013-07-01 16:14:48 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-09-20 05:55:10 +00:00
|
|
|
/* Original name: DROPDOWN A customized version of Oopmenu (qv). */
|
2013-07-01 16:14:48 +00:00
|
|
|
|
|
|
|
#include "avalanche/avalanche.h"
|
2014-03-03 21:38:39 +00:00
|
|
|
#include "avalanche/dropdown.h"
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
namespace Avalanche {
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void HeadType::init(char trig, char altTrig, Common::String title, byte pos, MenuFunc setupFunc, MenuFunc chooseFunc, DropDownMenu *menu) {
|
2013-09-04 16:12:06 +00:00
|
|
|
_trigger = trig;
|
|
|
|
_altTrigger = altTrig;
|
|
|
|
_title = title;
|
|
|
|
_position = pos;
|
2014-03-03 21:38:39 +00:00
|
|
|
_xpos = _position * _dropdown->kSpacing + _dropdown->kIndent;
|
|
|
|
_xright = (_position + 1) * _dropdown->kSpacing + _dropdown->kIndent;
|
2013-09-04 16:12:06 +00:00
|
|
|
_setupFunc = setupFunc;
|
|
|
|
_chooseFunc = chooseFunc;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown = menu;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void HeadType::draw() {
|
2013-09-07 07:00:34 +00:00
|
|
|
CursorMan.showMouse(false);
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->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
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_sound->stopSound();
|
|
|
|
_dropdown->drawMenuText(_xpos, 1, _trigger, _title, true, true);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_activeMenuItem._left = _xpos;
|
|
|
|
_dropdown->_activeMenuItem._activeNow = true;
|
|
|
|
_dropdown->_activeMenuItem._activeNum = _position;
|
|
|
|
_dropdown->_menuActive = true;
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-10-17 06:17:03 +00:00
|
|
|
// Force reload and redraw of cursor.
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_currentMouse = 177;
|
2013-11-22 20:31:39 +00:00
|
|
|
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
bool HeadType::parseAltTrigger(char key) {
|
2013-09-07 07:00:34 +00:00
|
|
|
if (key != _altTrigger)
|
2013-07-01 16:14:48 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void MenuItem::init(DropDownMenu *menu) {
|
|
|
|
_dropdown = menu;
|
2013-09-18 05:47:52 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNow = false;
|
|
|
|
_activeNum = 1;
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_menuActive = false;
|
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-29 17:03:52 +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-27 19:57:24 +00:00
|
|
|
Color backgroundColor;
|
2013-09-01 15:15:55 +00:00
|
|
|
if (highlit)
|
2013-09-27 19:57:24 +00:00
|
|
|
backgroundColor = kColorBlack;
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-09-27 19:57:24 +00:00
|
|
|
backgroundColor = kColorLightgray;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_graphics->drawMenuBlock((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10, backgroundColor);
|
|
|
|
_dropdown->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-21 11:33:43 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_firstlix = true;
|
|
|
|
_flx1 = _left - 2;
|
|
|
|
_flx2 = _left + _width;
|
2013-09-17 22:05:14 +00:00
|
|
|
_fly = 15 + _optionNum * 10;
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNow = true;
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_menuActive = true;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_graphics->drawMenuItem((_flx1 + 1) * 8, 12, (_flx2 + 1) * 8, _fly);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
displayOption(0, true);
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int y = 1; y < _optionNum; y++)
|
2013-09-04 16:12:06 +00:00
|
|
|
displayOption(y, false);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_currentMouse = 177;
|
2013-09-20 21:09:43 +00:00
|
|
|
|
2013-09-01 15:15:55 +00:00
|
|
|
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-07 07:00:34 +00:00
|
|
|
CursorMan.showMouse(false);
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->drawMenuText(_dropdown->_menuBar._menuItems[_dropdown->_activeMenuItem._activeNum]._xpos, 1,
|
|
|
|
_dropdown->_menuBar._menuItems[_dropdown->_activeMenuItem._activeNum]._trigger,
|
|
|
|
_dropdown->_menuBar._menuItems[_dropdown->_activeMenuItem._activeNum]._title, true, false);
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeNow = false;
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_menuActive = false;
|
2013-09-04 16:12:06 +00:00
|
|
|
_firstlix = false;
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-07 07:00:34 +00:00
|
|
|
CursorMan.showMouse(true);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuItem::moveHighlight(int8 inc) {
|
|
|
|
if (inc != 0) {
|
2013-09-08 08:29:38 +00:00
|
|
|
int8 highlightNum = _highlightNum + inc;
|
2013-09-04 16:12:06 +00:00
|
|
|
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
|
|
|
}
|
2013-09-07 07:00:34 +00:00
|
|
|
CursorMan.showMouse(false);
|
2013-09-04 16:12:06 +00:00
|
|
|
displayOption(_oldY, false);
|
|
|
|
displayOption(_highlightNum, true);
|
|
|
|
_oldY = _highlightNum;
|
2013-09-07 07:00:34 +00:00
|
|
|
CursorMan.showMouse(true);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-10-03 05:49:29 +00:00
|
|
|
/**
|
|
|
|
* This makes the menu highlight follow the mouse.
|
|
|
|
* @remarks Originally called 'lightup'
|
|
|
|
*/
|
2013-09-07 07:00:34 +00:00
|
|
|
void MenuItem::lightUp(Common::Point cursorPos) {
|
2013-09-17 22:05:14 +00:00
|
|
|
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-07 07:00:34 +00:00
|
|
|
void MenuItem::select(byte which) {
|
2013-09-04 16:12:06 +00:00
|
|
|
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
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
(_dropdown->*_dropdown->_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;
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < _optionNum; i++) {
|
2013-09-04 16:12:06 +00:00
|
|
|
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)
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_sound->blip();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-10-28 06:32:15 +00:00
|
|
|
MenuBar::MenuBar() {
|
|
|
|
_menuNum = 0;
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown = nullptr;
|
2013-10-28 06:32:15 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void MenuBar::init(DropDownMenu *menu) {
|
|
|
|
_dropdown = menu;
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuNum = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 05:47:52 +00:00
|
|
|
void MenuBar::createMenuItem(char trig, Common::String title, char altTrig, MenuFunc setupFunc, MenuFunc chooseFunc) {
|
2014-03-03 21:38:39 +00:00
|
|
|
_menuItems[_menuNum].init(trig, altTrig, title, _menuNum, setupFunc, chooseFunc, _dropdown);
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuNum++;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::draw() {
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_graphics->drawMenuBar(kMenuBackgroundColor);
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
byte savecp = _dropdown->_vm->_cp;
|
|
|
|
_dropdown->_vm->_cp = 3;
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < _menuNum; i++)
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuItems[i].draw();
|
2013-07-23 10:34:58 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_dropdown->_vm->_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) {
|
2014-03-03 21:38:39 +00:00
|
|
|
if (_dropdown->_activeMenuItem._activeNow) {
|
|
|
|
_dropdown->_activeMenuItem.wipe(); // Get rid of menu.
|
|
|
|
if (_dropdown->_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();
|
2014-03-03 21:38:39 +00:00
|
|
|
(_dropdown->*_menuItems[which]._setupFunc)();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
void MenuBar::chooseMenuItem(int16 x) {
|
2013-09-17 22:05:14 +00:00
|
|
|
for (int i = 0; i < _menuNum; i++) {
|
2013-09-04 16:12:06 +00:00
|
|
|
if ((x > _menuItems[i]._xpos * 8) && (x < _menuItems[i]._xright * 8)) {
|
|
|
|
setupMenuItem(i);
|
2013-09-17 22:05:14 +00:00
|
|
|
break;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
2013-09-17 22:05:14 +00:00
|
|
|
}
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
DropDownMenu::DropDownMenu(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-10-28 06:32:15 +00:00
|
|
|
|
|
|
|
_menuActive = false;
|
|
|
|
_lastPerson = kPeopleNone;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::findWhatYouCanDoWithIt() {
|
2013-09-26 23:34:38 +00:00
|
|
|
switch (_vm->_thinks) {
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectWine:
|
|
|
|
case kObjectPotion:
|
|
|
|
case kObjectInk:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeDrink;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectBell:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeRing;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectChastity:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeWear;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectLute:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodePlay;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectMushroom:
|
|
|
|
case kObjectOnion:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeEat;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kObjectClothes:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeWear;
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = kVerbCodeExam; // Anything else.
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted) {
|
2013-09-27 19:57:24 +00:00
|
|
|
Color fontColor;
|
|
|
|
Color backgroundColor;
|
2013-09-04 18:57:25 +00:00
|
|
|
if (highlighted) {
|
2013-09-05 21:07:08 +00:00
|
|
|
fontColor = kColorWhite;
|
|
|
|
backgroundColor = kColorBlack;
|
2013-09-04 18:57:25 +00:00
|
|
|
} else {
|
2013-09-05 21:07:08 +00:00
|
|
|
fontColor = kColorBlack;
|
|
|
|
backgroundColor = kColorLightgray;
|
2013-09-04 18:57:25 +00:00
|
|
|
}
|
|
|
|
|
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-16 20:57:38 +00:00
|
|
|
for (uint i = 0; i < text.size(); i++) {
|
|
|
|
for (int j = 0; j < 8; j++) {
|
2013-09-05 06:11:27 +00:00
|
|
|
byte idx = text[i];
|
2013-09-26 23:34:38 +00:00
|
|
|
font[idx][j] = _vm->_font[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.
|
2013-09-29 17:03:52 +00:00
|
|
|
_vm->_graphics->wipeChar(x * 8 + i * 8, 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-28 13:08:41 +00:00
|
|
|
_vm->_graphics->drawNormalText(text, font, 8, x * 8, y, fontColor);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-08-11 12:06:15 +00:00
|
|
|
// Underline the selected character.
|
2013-09-15 16:37:14 +00:00
|
|
|
if ((trigger == 0) || !text.contains(trigger) )
|
2013-07-23 15:21:53 +00:00
|
|
|
return;
|
|
|
|
else {
|
2013-09-04 18:57:25 +00:00
|
|
|
byte i;
|
2013-09-06 21:51:04 +00:00
|
|
|
for (i = 0; text[i] != trigger; i++)
|
|
|
|
; // Search for the character in the string.
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-29 17:03:52 +00:00
|
|
|
_vm->_graphics->drawChar(ander, x * 8 + i * 8, 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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::bleep() {
|
2013-10-11 05:54:42 +00:00
|
|
|
_vm->_sound->playNote(177, 7);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::parseKey(char r, char re) {
|
2013-09-18 05:47:52 +00:00
|
|
|
#if 0
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
Common::String DropDownMenu::selectGender(byte x) {
|
2013-09-04 16:12:06 +00:00
|
|
|
if (x < 175)
|
|
|
|
return "im";
|
|
|
|
else
|
|
|
|
return "er";
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setupMenuGame() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
|
|
|
_activeMenuItem.setupOption("Help...", 'H', "f1", true);
|
2014-03-07 17:24:45 +00:00
|
|
|
_activeMenuItem.setupOption("Boss Key", 'B', "alt-B", true);
|
|
|
|
_activeMenuItem.setupOption("Untrash screen", 'U', "ctrl-f7", false);
|
2013-09-04 16:12:06 +00:00
|
|
|
_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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setupMenuFile() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
|
|
|
_activeMenuItem.setupOption("New game", 'N', "f4", true);
|
|
|
|
_activeMenuItem.setupOption("Load...", 'L', "^f3", true);
|
2013-09-26 23:34:38 +00:00
|
|
|
_activeMenuItem.setupOption("Save", 'S', "^f2", _vm->_alive);
|
|
|
|
_activeMenuItem.setupOption("Save As...", 'v', "", _vm->_alive);
|
2013-09-25 05:57:57 +00:00
|
|
|
_activeMenuItem.setupOption("DOS Shell", 'D', "alt-1", false);
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Quit", 'Q', "alt-X", true);
|
|
|
|
_activeMenuItem.display();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setupMenuAction() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
Common::String f5Does = _vm->f5Does();
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int 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-26 23:34:38 +00:00
|
|
|
if (_vm->_room == kRoomMap)
|
2013-09-08 10:06:08 +00:00
|
|
|
_activeMenuItem.setupOption("Journey thither", 'J', "f7", _vm->_animation->nearDoor());
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-09-08 10:06:08 +00:00
|
|
|
_activeMenuItem.setupOption("Open the door", 'O', "f7", _vm->_animation->nearDoor());
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Look around", 'L', "f8", true);
|
|
|
|
_activeMenuItem.setupOption("Inventory", 'I', "Tab", true);
|
2013-10-17 06:17:03 +00:00
|
|
|
if (_vm->_animation->_sprites[0]->_speedX == kWalk)
|
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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::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-24 19:24:52 +00:00
|
|
|
for (int i = kPeopleAvalot; i <= kPeopleWisewoman; i++) {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->getRoom((People)i) == _vm->_room) {
|
2013-10-01 21:15:53 +00:00
|
|
|
_activeMenuItem.setupOption(_vm->getName((People)i), getNameChar((People)i), "", true);
|
2013-09-15 16:16:46 +00:00
|
|
|
people += i;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
2013-09-15 23:15:47 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setupMenuObjects() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < kObjectNum; i++) {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_objects[i])
|
2013-10-01 21:15:53 +00:00
|
|
|
_activeMenuItem.setupOption(getThing(i + 1), getThingChar(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
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setupMenuWith() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.reset();
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_thinkThing) {
|
2013-09-04 16:12:06 +00:00
|
|
|
findWhatYouCanDoWithIt();
|
2013-09-01 15:15:55 +00:00
|
|
|
|
2013-10-01 19:04:37 +00:00
|
|
|
for (uint i = 0; i < _verbStr.size(); i++) {
|
2013-09-04 23:55:08 +00:00
|
|
|
char vbchar;
|
|
|
|
Common::String verb;
|
|
|
|
|
2013-10-01 19:04:37 +00:00
|
|
|
_vm->_parser->verbOpt(_verbStr[i], verb, vbchar);
|
2013-09-04 16:12:06 +00:00
|
|
|
_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-07 07:00:34 +00:00
|
|
|
|
2013-10-01 20:52:30 +00:00
|
|
|
if ((_lastPerson == kPeopleAvalot) || (_lastPerson == _vm->_parser->kNothing)
|
|
|
|
|| (_vm->getRoom(_lastPerson) != _vm->_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-10-01 20:52:30 +00:00
|
|
|
_activeMenuItem.setupOption(Common::String("Give to ") + _vm->getName(_lastPerson), 'G', "", true);
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = _verbStr + kVerbCodeGive;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Examine", 'x', "", true);
|
2013-09-26 23:34:38 +00:00
|
|
|
_activeMenuItem.setupOption(Common::String("Talk to h") + selectGender(_vm->_thinks), 'T', "", true);
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = Common::String(kVerbCodeExam) + kVerbCodeTalk;
|
2013-09-26 23:34:38 +00:00
|
|
|
switch (_vm->_thinks) {
|
2013-09-24 05:31:43 +00:00
|
|
|
case kPeopleGeida:
|
|
|
|
case kPeopleArkata:
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.setupOption("Kiss her", 'K', "", true);
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = _verbStr + kVerbCodeKiss;
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kPeopleDogfood:
|
2013-09-26 23:34:38 +00:00
|
|
|
_activeMenuItem.setupOption("Play his game", 'P', "", !_vm->_wonNim); // True if you HAVEN'T won.
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = _verbStr + kVerbCodePlay;
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kPeopleMalagauche: {
|
2013-09-26 23:34:38 +00:00
|
|
|
bool isSober = !_vm->_teetotal;
|
|
|
|
_activeMenuItem.setupOption("Buy some wine", 'w', "", !_vm->_objects[kObjectWine - 1]);
|
2013-09-04 16:12:06 +00:00
|
|
|
_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);
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = _verbStr + 101 + 100 + 102 + 103 + 104;
|
2013-09-15 23:15:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-24 05:31:43 +00:00
|
|
|
case kPeopleTrader:
|
2013-09-26 23:34:38 +00:00
|
|
|
_activeMenuItem.setupOption("Buy an onion", 'o', "", !_vm->_objects[kObjectOnion - 1]);
|
2013-10-01 19:04:37 +00:00
|
|
|
_verbStr = _verbStr + 105;
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-09-01 15:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.display();
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuGame() {
|
2013-09-04 16:12:06 +00:00
|
|
|
// Help, boss, untrash screen.
|
|
|
|
switch (_activeMenuItem._choiceNum) {
|
2013-07-01 16:14:48 +00:00
|
|
|
case 0:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeHelp);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeBoss);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-03-03 21:00:16 +00:00
|
|
|
_vm->_graphics->refreshScreen();
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeScore);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeInfo);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuFile() {
|
2013-09-04 16:12:06 +00:00
|
|
|
// 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-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeRestart);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
2013-09-15 23:15:47 +00:00
|
|
|
case 1:
|
2013-09-21 16:37:52 +00:00
|
|
|
if (!_vm->_parser->_realWords[1].empty())
|
|
|
|
_vm->_parser->_realWords[1].clear();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeLoad);
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-10-11 06:01:43 +00:00
|
|
|
// Case 2 is 'Save', Case 3 is 'Save As'. Both triggers ScummVM save screen.
|
2013-09-15 23:15:47 +00:00
|
|
|
case 2:
|
2013-10-11 06:01:43 +00:00
|
|
|
case 3:
|
2013-09-21 16:37:52 +00:00
|
|
|
if (!_vm->_parser->_realWords[1].empty())
|
|
|
|
_vm->_parser->_realWords[1].clear();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeSave);
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-07-01 16:14:48 +00:00
|
|
|
case 4:
|
2013-10-11 06:01:43 +00:00
|
|
|
// Command Prompt, disabled
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeQuit);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuAction() {
|
2013-09-04 16:12:06 +00:00
|
|
|
// Get up, pause game, open door, look, inventory, walk/run.
|
|
|
|
switch (_activeMenuItem._choiceNum) {
|
2013-09-24 20:36:57 +00:00
|
|
|
case 0: {
|
2013-09-24 19:24:52 +00:00
|
|
|
_vm->_parser->_person = kPeoplePardon;
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = _vm->_parser->kPardon;
|
2013-09-26 23:34:38 +00:00
|
|
|
Common::String f5Does = _vm->f5Does();
|
2013-10-07 00:18:09 +00:00
|
|
|
VerbCode verb = (VerbCode)(byte)f5Does[0];
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(verb);
|
2013-09-24 20:36:57 +00:00
|
|
|
}
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-07-01 16:14:48 +00:00
|
|
|
case 1:
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = _vm->_parser->kPardon;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodePause);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeOpen);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = _vm->_parser->kPardon;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeLook);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeInv);
|
2013-07-01 16:14:48 +00:00
|
|
|
break;
|
|
|
|
case 5: {
|
2013-10-14 17:10:23 +00:00
|
|
|
AnimationType *avvy = _vm->_animation->_sprites[0];
|
2013-10-17 06:17:03 +00:00
|
|
|
if (avvy->_speedX == kWalk)
|
|
|
|
avvy->_speedX = kRun;
|
2013-09-01 15:15:55 +00:00
|
|
|
else
|
2013-10-17 06:17:03 +00:00
|
|
|
avvy->_speedX = kWalk;
|
2013-09-08 10:06:08 +00:00
|
|
|
_vm->_animation->updateSpeed();
|
2013-09-15 23:15:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuObjects() {
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->thinkAbout(_vm->_objectList[_activeMenuItem._choiceNum], AvalancheEngine::kThing);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuPeople() {
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->thinkAbout(people[_activeMenuItem._choiceNum], AvalancheEngine::kPerson);
|
2013-10-01 20:52:30 +00:00
|
|
|
_lastPerson = (People)people[_activeMenuItem._choiceNum];
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::runMenuWith() {
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_parser->_thing = _vm->_thinks;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_thinkThing) {
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing += 49;
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2013-10-01 19:04:37 +00:00
|
|
|
if (_verbStr[_activeMenuItem._choiceNum] == kVerbCodeGive)
|
2013-10-01 20:52:30 +00:00
|
|
|
_vm->_parser->_person = _lastPerson;
|
2013-07-01 16:14:48 +00:00
|
|
|
else
|
2013-09-24 19:24:52 +00:00
|
|
|
_vm->_parser->_person = kPeoplePardon;
|
2013-07-01 16:14:48 +00:00
|
|
|
} else {
|
2013-10-01 19:04:37 +00:00
|
|
|
switch (_verbStr[_activeMenuItem._choiceNum]) {
|
2013-09-15 23:15:47 +00:00
|
|
|
case 100: // Beer
|
2013-10-11 06:06:16 +00:00
|
|
|
case 102: // Whisky
|
|
|
|
case 103: // Cider
|
|
|
|
_vm->_parser->_thing = _verbStr[_activeMenuItem._choiceNum];
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
2013-09-15 23:15:47 +00:00
|
|
|
case 101: // Wine
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = 50;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
2013-09-15 23:15:47 +00:00
|
|
|
case 104: // Mead
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = 107;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
2013-09-15 23:15:47 +00:00
|
|
|
case 105: // Onion (trader)
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = 67;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->callVerb(kVerbCodeBuy);
|
2013-07-01 16:14:48 +00:00
|
|
|
return;
|
2013-09-15 23:15:47 +00:00
|
|
|
default:
|
2013-09-24 19:24:52 +00:00
|
|
|
_vm->_parser->_person = (People)_vm->_parser->_thing;
|
2013-09-21 16:37:52 +00:00
|
|
|
_vm->_parser->_thing = Parser::kPardon;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_subjectNum = 0;
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-07 00:18:09 +00:00
|
|
|
_vm->callVerb((VerbCode)(byte)_verbStr[_activeMenuItem._choiceNum]);
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::setup() {
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuBar.init(this);
|
|
|
|
_activeMenuItem.init(this);
|
2013-07-01 16:14:48 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
_menuBar.createMenuItem('F', "File", '!', &Avalanche::DropDownMenu::setupMenuFile, &Avalanche::DropDownMenu::runMenuFile);
|
|
|
|
_menuBar.createMenuItem('G', "Game", 34, &Avalanche::DropDownMenu::setupMenuGame, &Avalanche::DropDownMenu::runMenuGame);
|
|
|
|
_menuBar.createMenuItem('A', "Action", 30, &Avalanche::DropDownMenu::setupMenuAction, &Avalanche::DropDownMenu::runMenuAction);
|
|
|
|
_menuBar.createMenuItem('O', "Objects", 24, &Avalanche::DropDownMenu::setupMenuObjects, &Avalanche::DropDownMenu::runMenuObjects);
|
|
|
|
_menuBar.createMenuItem('P', "People", 25, &Avalanche::DropDownMenu::setupMenuPeople, &Avalanche::DropDownMenu::runMenuPeople);
|
|
|
|
_menuBar.createMenuItem('W', "With", 17, &Avalanche::DropDownMenu::setupMenuWith, &Avalanche::DropDownMenu::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
|
|
|
}
|
|
|
|
|
2014-04-12 17:51:10 +00:00
|
|
|
void DropDownMenu::update() {
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->saveScreen();
|
2013-09-01 23:11:16 +00:00
|
|
|
|
2013-09-29 09:26:21 +00:00
|
|
|
Common::Point cursorPos = _vm->getMousePos();
|
2013-09-26 23:34:38 +00:00
|
|
|
while (!_activeMenuItem._activeNow && (cursorPos.y <= 21) && _vm->_holdLeftMouse) {
|
2013-09-04 16:12:06 +00:00
|
|
|
_menuBar.chooseMenuItem(cursorPos.x);
|
2013-09-07 07:00:34 +00:00
|
|
|
do
|
2013-09-01 23:11:16 +00:00
|
|
|
_vm->updateEvents();
|
2013-10-11 06:10:43 +00:00
|
|
|
while (_vm->_holdLeftMouse && !_vm->shouldQuit());
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-01 23:11:16 +00:00
|
|
|
while (!_vm->shouldQuit()) {
|
2013-09-07 07:00:34 +00:00
|
|
|
do {
|
2013-09-01 23:11:16 +00:00
|
|
|
_vm->updateEvents();
|
|
|
|
|
2013-09-28 08:11:21 +00:00
|
|
|
// We update the cursor's picture.
|
2013-09-01 23:11:16 +00:00
|
|
|
cursorPos = _vm->getMousePos();
|
|
|
|
// Change arrow...
|
|
|
|
if ((0 <= cursorPos.y) && (cursorPos.y <= 21))
|
2013-09-28 08:11:21 +00:00
|
|
|
_vm->_graphics->loadMouse(kCurUpArrow); // Up arrow
|
2013-09-01 23:11:16 +00:00
|
|
|
else if ((22 <= cursorPos.y) && (cursorPos.y <= 339)) {
|
2013-09-17 22:05:14 +00:00
|
|
|
if ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8) && (cursorPos.y > 21) && (cursorPos.y <= _activeMenuItem._fly * 2 + 1))
|
2013-09-28 08:11:21 +00:00
|
|
|
_vm->_graphics->loadMouse(kCurRightArrow); // Right-arrow
|
2013-09-01 23:11:16 +00:00
|
|
|
else
|
2013-09-28 08:11:21 +00:00
|
|
|
_vm->_graphics->loadMouse(kCurFletch); // Fletch
|
2013-09-01 23:11:16 +00:00
|
|
|
} else if ((340 <= cursorPos.y) && (cursorPos.y <= 399))
|
2013-09-28 08:11:21 +00:00
|
|
|
_vm->_graphics->loadMouse(kCurScrewDriver); // Screwdriver
|
2013-09-01 23:11:16 +00:00
|
|
|
|
2013-09-04 16:12:06 +00:00
|
|
|
_activeMenuItem.lightUp(cursorPos);
|
2013-09-01 23:11:16 +00:00
|
|
|
|
|
|
|
_vm->_graphics->refreshScreen();
|
2013-10-11 06:10:43 +00:00
|
|
|
} while (!_vm->_holdLeftMouse && !_vm->shouldQuit());
|
2013-09-01 23:11:16 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_holdLeftMouse) {
|
2013-09-01 23:11:16 +00:00
|
|
|
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)
|
2013-09-17 22:05:14 +00:00
|
|
|
&& (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-26 23:34:38 +00:00
|
|
|
_vm->_holdLeftMouse = false;
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->removeBackup();
|
2013-09-01 23:11:16 +00:00
|
|
|
return;
|
|
|
|
} // No "else"- clicking on menu has no effect (only releasing).
|
2013-09-07 07:00:34 +00:00
|
|
|
}
|
2013-09-01 23:11:16 +00:00
|
|
|
} else {
|
|
|
|
// Clicked on menu bar.
|
2013-09-04 16:12:06 +00:00
|
|
|
if (_activeMenuItem._activeNow) {
|
|
|
|
_activeMenuItem.wipe();
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->restoreScreen();
|
2013-09-07 07:00:34 +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-26 23:34:38 +00:00
|
|
|
_vm->_holdLeftMouse = false;
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->removeBackup();
|
2013-09-02 13:44:55 +00:00
|
|
|
return;
|
2013-09-02 18:09:44 +00:00
|
|
|
} else {
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_holdLeftMouse = true;
|
2013-09-02 18:09:44 +00:00
|
|
|
break;
|
2013-09-02 13:44:55 +00:00
|
|
|
}
|
2013-09-01 23:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-07 07:00:34 +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)
|
2013-09-17 22:05:14 +00:00
|
|
|
&& (cursorPos.y >= 12) && (cursorPos.y <= (_activeMenuItem._fly * 2 + 1)))) {
|
2013-09-02 10:53:01 +00:00
|
|
|
|
2013-09-17 22:05:14 +00:00
|
|
|
// We act only if the button is released over a menu item.
|
|
|
|
while (!_vm->shouldQuit()) {
|
|
|
|
cursorPos = _vm->getMousePos();
|
|
|
|
_activeMenuItem.lightUp(cursorPos);
|
|
|
|
_vm->_graphics->refreshScreen();
|
2013-09-02 10:53:01 +00:00
|
|
|
|
2013-09-17 22:05:14 +00:00
|
|
|
_vm->updateEvents();
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_vm->_holdLeftMouse)
|
2013-09-17 22:05:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-02 10:53:01 +00:00
|
|
|
|
2013-09-17 22:05:14 +00:00
|
|
|
uint16 which = (cursorPos.y - 26) / 20;
|
|
|
|
_activeMenuItem.select(which);
|
|
|
|
if (_activeMenuItem._options[which]._valid) { // If the menu item wasn't active, we do nothing.
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->removeBackup();
|
2013-09-17 22:05:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-01 23:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-05 09:05:03 +00:00
|
|
|
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->removeBackup();
|
2013-07-01 16:14:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
char DropDownMenu::getThingChar(byte which) {
|
2013-10-04 15:52:12 +00:00
|
|
|
static const char thingsChar[] = "WMBParCLguKeSnIohn"; // V=Vinegar
|
2013-10-01 21:15:53 +00:00
|
|
|
|
|
|
|
char result;
|
|
|
|
switch (which) {
|
|
|
|
case kObjectWine:
|
|
|
|
if (_vm->_wineState == 3)
|
|
|
|
result = 'V'; // Vinegar
|
|
|
|
else
|
2013-10-04 15:52:12 +00:00
|
|
|
result = thingsChar[which - 1];
|
2013-10-01 21:15:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-10-04 15:52:12 +00:00
|
|
|
result = thingsChar[which - 1];
|
2013-10-01 21:15:53 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
byte DropDownMenu::getNameChar(People whose) {
|
2013-10-04 15:52:12 +00:00
|
|
|
static const char ladChar[] = "ASCDMTRwLfgeIyPu";
|
|
|
|
static const char lassChar[] = "kG\0xB1o";
|
2013-10-01 21:15:53 +00:00
|
|
|
|
2013-10-25 06:10:38 +00:00
|
|
|
if (whose <= kPeopleJacques)
|
2013-10-04 15:52:12 +00:00
|
|
|
return ladChar[whose - kPeopleAvalot];
|
2013-10-25 06:10:38 +00:00
|
|
|
else if ((whose >= kPeopleArkata) && (whose <= kPeopleWisewoman))
|
2013-10-04 15:52:12 +00:00
|
|
|
return lassChar[whose - kPeopleArkata];
|
2013-10-25 06:10:38 +00:00
|
|
|
else
|
|
|
|
error("getName() - Unexpected character id %d", (byte) whose);
|
2013-10-01 21:15:53 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
Common::String DropDownMenu::getThing(byte which) {
|
2013-10-05 12:37:20 +00:00
|
|
|
static const char things[kObjectNum][20] = {
|
2013-10-01 21:15:53 +00:00
|
|
|
"Wine", "Money-bag", "Bodkin", "Potion", "Chastity belt",
|
|
|
|
"Crossbow bolt", "Crossbow", "Lute", "Pilgrim's badge", "Mushroom", "Key",
|
|
|
|
"Bell", "Scroll", "Pen", "Ink", "Clothes", "Habit", "Onion"
|
|
|
|
};
|
|
|
|
|
|
|
|
Common::String result;
|
|
|
|
switch (which) {
|
|
|
|
case kObjectWine:
|
|
|
|
switch (_vm->_wineState) {
|
|
|
|
case 1:
|
|
|
|
case 4:
|
2013-10-05 12:37:20 +00:00
|
|
|
result = Common::String(things[which - 1]);
|
2013-10-01 21:15:53 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
result = "Vinegar";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kObjectOnion:
|
|
|
|
if (_vm->_rottenOnion)
|
2013-10-05 12:37:20 +00:00
|
|
|
result = Common::String("rotten onion");
|
2013-10-01 21:15:53 +00:00
|
|
|
else
|
2013-10-05 12:37:20 +00:00
|
|
|
result = Common::String(things[which - 1]);
|
2013-10-01 21:15:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-10-05 12:37:20 +00:00
|
|
|
result = Common::String(things[which - 1]);
|
2013-10-01 21:15:53 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
bool DropDownMenu::isActive() {
|
2013-09-18 05:47:52 +00:00
|
|
|
return _menuActive;
|
|
|
|
}
|
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::init() {
|
2013-09-18 05:47:52 +00:00
|
|
|
_menuActive = false;
|
|
|
|
}
|
2013-10-01 20:52:30 +00:00
|
|
|
|
2014-03-03 21:38:39 +00:00
|
|
|
void DropDownMenu::resetVariables() {
|
2013-10-11 06:06:16 +00:00
|
|
|
_lastPerson = kPeoplePardon;
|
2013-10-01 20:52:30 +00:00
|
|
|
}
|
2013-07-01 16:14:48 +00:00
|
|
|
} // End of namespace Avalanche.
|