2014-10-06 12:50:05 +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.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-10-06 12:50:05 +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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-06 12:50:05 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on Labyrinth of Time code with assistance of
|
|
|
|
*
|
|
|
|
* Copyright (c) 1993 Terra Nova Development
|
|
|
|
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-12-08 20:39:30 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
|
2015-11-24 22:59:30 +00:00
|
|
|
#include "lab/lab.h"
|
2015-12-08 20:19:41 +00:00
|
|
|
|
|
|
|
#include "lab/dispman.h"
|
2016-01-15 18:56:15 +00:00
|
|
|
#include "lab/interface.h"
|
2015-12-08 19:46:13 +00:00
|
|
|
#include "lab/image.h"
|
2015-12-08 20:00:50 +00:00
|
|
|
#include "lab/utils.h"
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
namespace Lab {
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
#define CRUMBSWIDTH 24
|
|
|
|
#define CRUMBSHEIGHT 24
|
|
|
|
|
|
|
|
Interface::Interface(LabEngine *vm) : _vm(vm) {
|
|
|
|
_screenButtonList = nullptr;
|
|
|
|
_hitButton = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Button *Interface::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage) {
|
2015-12-13 17:36:56 +00:00
|
|
|
Button *button = new Button();
|
|
|
|
|
|
|
|
if (button) {
|
2015-12-13 19:15:24 +00:00
|
|
|
button->_x = _vm->_utils->vgaScaleX(x);
|
|
|
|
button->_y = y;
|
2015-12-16 21:27:32 +00:00
|
|
|
button->_buttonId = id;
|
2015-12-13 17:36:56 +00:00
|
|
|
button->_keyEquiv = key;
|
|
|
|
button->_image = image;
|
|
|
|
button->_altImage = altImage;
|
2015-12-13 19:15:24 +00:00
|
|
|
button->_isEnabled = true;
|
2015-12-13 17:36:56 +00:00
|
|
|
|
|
|
|
return button;
|
2014-10-06 12:50:05 +00:00
|
|
|
} else
|
2015-12-08 07:53:35 +00:00
|
|
|
return nullptr;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::freeButtonList(ButtonList *buttonList) {
|
2015-12-13 17:36:56 +00:00
|
|
|
for (ButtonList::iterator buttonIter = buttonList->begin(); buttonIter != buttonList->end(); ++buttonIter) {
|
|
|
|
Button *button = *buttonIter;
|
|
|
|
delete button->_image;
|
|
|
|
delete button->_altImage;
|
|
|
|
delete button;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
2015-12-06 20:50:41 +00:00
|
|
|
|
2015-12-13 17:36:56 +00:00
|
|
|
buttonList->clear();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::drawButtonList(ButtonList *buttonList) {
|
2015-12-13 17:36:56 +00:00
|
|
|
for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
|
2015-12-18 01:31:07 +00:00
|
|
|
toggleButton((*button), 1, true);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-13 19:15:24 +00:00
|
|
|
if (!(*button)->_isEnabled)
|
2015-12-18 01:31:07 +00:00
|
|
|
toggleButton((*button), 1, false);
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::toggleButton(Button *button, uint16 disabledPenColor, bool enable) {
|
2015-12-18 01:31:07 +00:00
|
|
|
if (!enable)
|
2015-12-26 13:26:33 +00:00
|
|
|
_vm->_graphics->checkerBoardEffect(disabledPenColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
|
2015-12-18 01:31:07 +00:00
|
|
|
else
|
|
|
|
button->_image->drawImage(button->_x, button->_y);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-18 01:31:07 +00:00
|
|
|
button->_isEnabled = enable;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
Button *Interface::checkNumButtonHit(Common::KeyCode key) {
|
2014-10-06 12:50:05 +00:00
|
|
|
uint16 gkey = key - '0';
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
if (!_screenButtonList)
|
2015-12-08 07:53:35 +00:00
|
|
|
return nullptr;
|
2015-12-06 20:50:41 +00:00
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
|
2015-12-13 17:36:56 +00:00
|
|
|
Button *button = *buttonItr;
|
2015-12-24 17:12:02 +00:00
|
|
|
if (!button->_isEnabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((gkey - 1 == button->_buttonId) || (gkey == 0 && button->_buttonId == 9) || (button->_keyEquiv != Common::KEYCODE_INVALID && key == button->_keyEquiv)) {
|
2015-12-13 19:15:24 +00:00
|
|
|
button->_altImage->drawImage(button->_x, button->_y);
|
2015-12-23 17:56:35 +00:00
|
|
|
_vm->_system->delayMillis(80);
|
2015-12-13 19:15:24 +00:00
|
|
|
button->_image->drawImage(button->_x, button->_y);
|
2015-12-13 17:36:56 +00:00
|
|
|
return button;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-13 13:04:00 +00:00
|
|
|
return nullptr;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
Button *Interface::checkButtonHit(Common::Point pos) {
|
|
|
|
if (!_screenButtonList)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
|
2016-01-14 21:35:02 +00:00
|
|
|
Button *button = *buttonItr;
|
|
|
|
Common::Rect buttonRect(button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
|
|
|
|
|
|
|
|
if (buttonRect.contains(pos) && button->_isEnabled) {
|
|
|
|
_hitButton = button;
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::handlePressedButton() {
|
|
|
|
if (!_hitButton)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
_vm->waitTOF();
|
|
|
|
_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
|
|
|
|
|
|
|
|
_hitButton = nullptr;
|
|
|
|
_vm->_graphics->screenUpdate();
|
|
|
|
}
|
2016-01-14 21:35:02 +00:00
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::attachButtonList(ButtonList *buttonList) {
|
2016-01-14 21:35:02 +00:00
|
|
|
_screenButtonList = buttonList;
|
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
Button *Interface::getButton(uint16 id) {
|
2016-01-14 21:35:02 +00:00
|
|
|
for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
|
|
|
|
Button *button = *buttonItr;
|
|
|
|
if (button->_buttonId == id)
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::mayShowCrumbIndicator() {
|
|
|
|
static byte dropCrumbsImageData[CRUMBSWIDTH * CRUMBSHEIGHT] = {
|
|
|
|
0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0,
|
|
|
|
0, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 0,
|
|
|
|
4, 7, 7, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 7, 7, 4,
|
|
|
|
4, 7, 4, 4, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 7, 4,
|
|
|
|
4, 7, 4, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 7, 4,
|
|
|
|
4, 7, 4, 0, 0, 3, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 4, 7, 4,
|
|
|
|
4, 7, 4, 0, 0, 0, 3, 3, 3, 4, 4, 4, 4, 4, 4, 0, 0, 3, 2, 3, 0, 4, 7, 4,
|
|
|
|
4, 7, 4, 0, 0, 0, 0, 0, 4, 7, 7, 7, 7, 7, 7, 4, 3, 2,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, 3, 2, 2, 2, 3, 0, 0, 4, 4, 7, 4,
|
|
|
|
0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 4,
|
|
|
|
0, 0, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 0,
|
|
|
|
0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_vm->getPlatform() != Common::kPlatformWindows)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_vm->_droppingCrumbs && _vm->isMainDisplay()) {
|
2021-08-26 19:07:59 +00:00
|
|
|
Image dropCrumbsImage(CRUMBSWIDTH, CRUMBSHEIGHT, dropCrumbsImageData, _vm, false);
|
2016-01-15 18:56:15 +00:00
|
|
|
|
|
|
|
dropCrumbsImage.drawMaskImage(612, 4);
|
|
|
|
}
|
|
|
|
}
|
2015-12-24 16:30:41 +00:00
|
|
|
|
2016-01-15 18:56:15 +00:00
|
|
|
void Interface::mayShowCrumbIndicatorOff() {
|
|
|
|
static byte dropCrumbsOffImageData[CRUMBSWIDTH * CRUMBSHEIGHT] = {
|
|
|
|
0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0,
|
|
|
|
0, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 0,
|
|
|
|
4, 8, 8, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 8, 8, 4,
|
|
|
|
4, 8, 4, 4, 0, 0, 3, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 8, 4,
|
|
|
|
4, 8, 4, 0, 0, 0, 3, 8, 3,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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 0, 0, 0, 0, 0, 4, 8, 4,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 0, 0, 0, 4, 8, 4,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 0, 0, 0, 4, 8, 4,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 8, 8, 3, 0, 0, 4, 4, 8, 4,
|
|
|
|
0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 4,
|
|
|
|
0, 0, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 0,
|
|
|
|
0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_vm->getPlatform() != Common::kPlatformWindows)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_vm->isMainDisplay()) {
|
2021-08-26 19:07:59 +00:00
|
|
|
Image dropCrumbsOffImage(CRUMBSWIDTH, CRUMBSHEIGHT, dropCrumbsOffImageData, _vm, false);
|
2016-01-15 18:56:15 +00:00
|
|
|
|
|
|
|
dropCrumbsOffImage.drawMaskImage(612, 4);
|
|
|
|
}
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Lab
|