2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 09:37:24 +00:00
|
|
|
// Game interface module
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/gfx.h"
|
|
|
|
#include "saga/actor.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2004-08-03 00:06:18 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/objectmap.h"
|
2005-01-28 12:54:09 +00:00
|
|
|
#include "saga/itedata.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/rscfile_mod.h"
|
2004-10-05 02:16:26 +00:00
|
|
|
#include "saga/scene.h"
|
2004-08-12 23:57:45 +00:00
|
|
|
#include "saga/script.h"
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/interface.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
static int verbTypeToTextStringsIdLUT[kVerbTypesMax] = {
|
|
|
|
-1,
|
|
|
|
kTextPickUp,
|
|
|
|
kTextLookAt,
|
|
|
|
kTextWalkTo,
|
|
|
|
kTextTalkTo,
|
|
|
|
kTextOpen,
|
|
|
|
kTextClose,
|
|
|
|
kTextGive,
|
|
|
|
kTextUse,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1
|
2004-04-12 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
|
2005-01-13 22:42:49 +00:00
|
|
|
byte *resource;
|
|
|
|
size_t resourceLength;
|
2004-04-12 21:40:49 +00:00
|
|
|
int result;
|
2005-01-13 22:42:49 +00:00
|
|
|
int i;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
if (_initialized) {
|
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-02-26 17:37:16 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 09:37:24 +00:00
|
|
|
// Load interface module resource file context
|
2004-12-22 13:09:47 +00:00
|
|
|
_interfaceContext = _vm->getFileContext(GAME_RESOURCEFILE, 0);
|
2004-11-15 03:03:48 +00:00
|
|
|
if (_interfaceContext == NULL) {
|
2005-01-13 22:42:49 +00:00
|
|
|
error("Interface::Interface(): unable to load resource");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
|
|
|
|
_mainPanel.buttons = _vm->getDisplayInfo().mainPanelButtons;
|
|
|
|
_mainPanel.buttonsCount = _vm->getDisplayInfo().mainPanelButtonsCount;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
for (i = 0; i < kVerbTypesMax; i++) {
|
|
|
|
_verbTypeToPanelButton[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _mainPanel.buttonsCount; i++) {
|
|
|
|
if (_mainPanel.buttons[i].type == kPanelButtonVerb) {
|
|
|
|
_verbTypeToPanelButton[_mainPanel.buttons[i].id] = &_mainPanel.buttons[i];
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
result = RSC_LoadResource(_interfaceContext, _vm->getResourceDescription()->mainPanelResourceId, &resource, &resourceLength);
|
|
|
|
if ((result != SUCCESS) || (resourceLength == 0)) {
|
|
|
|
error("Interface::Interface(): unable to load mainPanel resource");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_mainPanel.image,
|
|
|
|
&_mainPanel.imageLength, &_mainPanel.imageWidth, &_mainPanel.imageHeight);
|
|
|
|
|
|
|
|
RSC_FreeResource(resource);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
_conversePanel.buttons = _vm->getDisplayInfo().conversePanelButtons;
|
|
|
|
_conversePanel.buttonsCount = _vm->getDisplayInfo().conversePanelButtonsCount;
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
result = RSC_LoadResource(_interfaceContext, _vm->getResourceDescription()->conversePanelResourceId, &resource, &resourceLength);
|
|
|
|
if ((result != SUCCESS) || (resourceLength == 0)) {
|
|
|
|
error("Interface::Interface unable to load conversePanel resource");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_conversePanel.image,
|
|
|
|
&_conversePanel.imageLength, &_conversePanel.imageWidth, &_conversePanel.imageHeight);
|
|
|
|
RSC_FreeResource(resource);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
_optionPanel.buttons = _vm->getDisplayInfo().optionPanelButtons;
|
|
|
|
_optionPanel.buttonsCount = _vm->getDisplayInfo().optionPanelButtonsCount;
|
|
|
|
|
|
|
|
result = RSC_LoadResource(_interfaceContext, _vm->getResourceDescription()->optionPanelResourceId, &resource, &resourceLength);
|
|
|
|
if ((result != SUCCESS) || (resourceLength == 0)) {
|
|
|
|
error("Interface::Interface unable to load optionPanel resource");
|
|
|
|
}
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_optionPanel.image,
|
|
|
|
&_optionPanel.imageLength, &_optionPanel.imageWidth, &_optionPanel.imageHeight);
|
|
|
|
RSC_FreeResource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (_vm->_sprite->loadList(_vm->getResourceDescription()->mainPanelSpritesResourceId, _mainPanel.sprites) != SUCCESS) {
|
2005-01-13 22:42:49 +00:00
|
|
|
error("Interface::Interface(): Unable to load sprite list");
|
2005-01-09 15:07:49 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_vm->_sprite->loadList(_vm->getResourceDescription()->defaultPortraitsResourceId, _defPortraits) != SUCCESS) {
|
2005-01-13 22:42:49 +00:00
|
|
|
error("Interface::Interface(): Unable to load sprite list");
|
2005-01-09 15:07:49 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
_mainPanel.x = _vm->getDisplayInfo().mainPanelXOffset;
|
|
|
|
_mainPanel.y = _vm->getDisplayInfo().mainPanelYOffset;
|
2005-01-13 22:42:49 +00:00
|
|
|
_mainPanel.currentButton = NULL;
|
2005-04-22 14:11:04 +00:00
|
|
|
_inventoryUpButton = _mainPanel.getButton(_vm->getDisplayInfo().inventoryUpButtonIndex);
|
|
|
|
_inventoryDownButton = _mainPanel.getButton(_vm->getDisplayInfo().inventoryDownButtonIndex);
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
_conversePanel.x = _vm->getDisplayInfo().conversePanelXOffset;
|
|
|
|
_conversePanel.y = _vm->getDisplayInfo().conversePanelYOffset;
|
2005-01-13 22:42:49 +00:00
|
|
|
_conversePanel.currentButton = NULL;
|
2005-04-22 14:11:04 +00:00
|
|
|
_converseUpButton = _conversePanel.getButton(_vm->getDisplayInfo().converseUpButtonIndex);
|
|
|
|
_converseDownButton = _conversePanel.getButton(_vm->getDisplayInfo().converseDownButtonIndex);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-21 06:49:11 +00:00
|
|
|
_leftPortrait = 0;
|
|
|
|
_rightPortrait = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
_optionPanel.x = _vm->getDisplayInfo().optionPanelXOffset;
|
|
|
|
_optionPanel.y = _vm->getDisplayInfo().optionPanelYOffset;
|
|
|
|
_optionPanel.currentButton = NULL;
|
|
|
|
|
2005-01-07 00:57:43 +00:00
|
|
|
_active = false;
|
|
|
|
_panelMode = _lockedMode = kPanelNull;
|
|
|
|
_savedMode = -1;
|
2005-01-06 14:02:53 +00:00
|
|
|
_inMainMode = false;
|
2004-08-06 01:39:17 +00:00
|
|
|
*_statusText = 0;
|
2005-01-19 11:29:29 +00:00
|
|
|
_statusOnceColor = -1;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-11-07 14:15:41 +00:00
|
|
|
_inventoryCount = 0;
|
2005-04-22 14:11:04 +00:00
|
|
|
_inventoryPos = 0;
|
|
|
|
_inventoryStart = 0;
|
|
|
|
_inventoryEnd = 0;
|
|
|
|
_inventoryBox = 0;
|
2004-11-07 14:15:41 +00:00
|
|
|
_inventorySize = ITE_INVENTORY_SIZE;
|
2005-05-22 11:59:22 +00:00
|
|
|
_saveReminderState = 0;
|
2004-11-07 14:15:41 +00:00
|
|
|
|
|
|
|
_inventory = (uint16 *)calloc(_inventorySize, sizeof(uint16));
|
|
|
|
if (_inventory == NULL) {
|
2005-01-13 22:42:49 +00:00
|
|
|
error("Interface::Interface(): not enough memory");
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
_initialized = true;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
Interface::~Interface(void) {
|
2004-11-07 14:15:41 +00:00
|
|
|
free(_inventory);
|
2005-01-09 15:07:49 +00:00
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
_mainPanel.sprites.freeMem();
|
2005-01-09 15:07:49 +00:00
|
|
|
_defPortraits.freeMem();
|
|
|
|
_scenePortraits.freeMem();
|
2004-08-06 01:39:17 +00:00
|
|
|
_initialized = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Interface::activate() {
|
2005-01-07 00:57:43 +00:00
|
|
|
if (!_active) {
|
|
|
|
_active = true;
|
|
|
|
_vm->_script->_skipSpeeches = false;
|
2005-04-19 11:07:06 +00:00
|
|
|
_vm->_actor->_protagonist->targetObject = ID_NOTHING;
|
2005-01-07 00:57:43 +00:00
|
|
|
_vm->_gfx->showCursor(true);
|
|
|
|
unlockMode();
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_panelMode == kPanelMain){
|
|
|
|
_saveReminderState = 1;
|
|
|
|
}
|
2005-01-07 00:57:43 +00:00
|
|
|
draw();
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
int Interface::deactivate() {
|
2005-01-07 00:57:43 +00:00
|
|
|
if (_active) {
|
|
|
|
_active = false;
|
|
|
|
_vm->_gfx->showCursor(false);
|
|
|
|
lockMode();
|
|
|
|
setMode(kPanelNull);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-07 00:57:43 +00:00
|
|
|
void Interface::rememberMode() {
|
|
|
|
assert (_savedMode == -1);
|
|
|
|
|
|
|
|
_savedMode = _panelMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::restoreMode() {
|
|
|
|
assert (_savedMode != -1);
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-01-07 00:57:43 +00:00
|
|
|
_panelMode = _savedMode;
|
|
|
|
_savedMode = -1;
|
|
|
|
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::setMode(int mode, bool force) {
|
2005-01-07 00:57:43 +00:00
|
|
|
// TODO: Is this where we should hide/show the mouse cursor?
|
2005-01-06 14:02:53 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (mode == kPanelMain) {
|
|
|
|
_inMainMode = true;
|
|
|
|
_saveReminderState = 1; //TODO: blinking timeout
|
2005-01-09 23:41:22 +00:00
|
|
|
} else {
|
2005-05-22 11:59:22 +00:00
|
|
|
if (mode == kPanelConverse) {
|
|
|
|
_inMainMode = false;
|
|
|
|
}
|
|
|
|
_saveReminderState = 0;
|
2005-01-07 00:57:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This lets us to prevents actors to pop up during initial
|
|
|
|
// scene fade in.
|
|
|
|
if (_savedMode != -1 && !force) {
|
2005-05-22 11:59:22 +00:00
|
|
|
_savedMode = mode;
|
|
|
|
debug(0, "Saved mode: %d. my mode is %d", mode, _panelMode);
|
2005-01-06 14:49:47 +00:00
|
|
|
}
|
2005-01-07 00:57:43 +00:00
|
|
|
else
|
2005-05-22 11:59:22 +00:00
|
|
|
_panelMode = mode;
|
2005-01-13 22:42:49 +00:00
|
|
|
|
|
|
|
if (_panelMode == kPanelMain) {
|
|
|
|
_mainPanel.currentButton = NULL;
|
|
|
|
} else {
|
|
|
|
if (_panelMode == kPanelConverse) {
|
|
|
|
_conversePanel.currentButton = NULL;
|
2005-04-18 20:03:14 +00:00
|
|
|
converseDisplayText();
|
2005-05-22 11:59:22 +00:00
|
|
|
} else {
|
|
|
|
if (_panelMode == kPanelOption) {
|
|
|
|
_optionPanel.currentButton = NULL;
|
|
|
|
}
|
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2005-01-06 14:02:53 +00:00
|
|
|
|
2004-10-21 06:49:11 +00:00
|
|
|
draw();
|
|
|
|
}
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
bool Interface::processKeyCode(int keyCode) {
|
|
|
|
int i;
|
2005-04-22 14:11:04 +00:00
|
|
|
PanelButton *panelButton;
|
2005-01-13 22:42:49 +00:00
|
|
|
switch (_panelMode) {
|
|
|
|
case kPanelNull:
|
|
|
|
if (keyCode == 27) {// Esc
|
|
|
|
if (_vm->_scene->isInDemo()) {
|
|
|
|
_vm->_scene->skipScene();
|
|
|
|
} else {
|
|
|
|
_vm->_actor->abortAllSpeeches();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2005-05-22 11:59:22 +00:00
|
|
|
case kPanelOption:
|
|
|
|
//TODO: check input dialog keys
|
|
|
|
for (i = 0; i < _optionPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_optionPanel.buttons[i];
|
|
|
|
if (panelButton->keyChar == keyCode) {
|
|
|
|
setOption(panelButton);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-01-13 22:42:49 +00:00
|
|
|
case kPanelMain:
|
2005-04-22 14:11:04 +00:00
|
|
|
for (i = 0; i < _mainPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_mainPanel.buttons[i];
|
|
|
|
if (panelButton->keyChar == keyCode) {
|
|
|
|
if (panelButton->type == kPanelButtonVerb) {
|
|
|
|
_vm->_script->setVerb(panelButton->id);
|
|
|
|
}
|
|
|
|
if (panelButton->type == kPanelButtonArrow) {
|
|
|
|
inventoryChangePos(panelButton->id);
|
|
|
|
}
|
|
|
|
return true;
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-01-17 20:17:06 +00:00
|
|
|
case kPanelConverse:
|
|
|
|
switch (keyCode) {
|
|
|
|
case 'x':
|
2005-05-22 11:59:22 +00:00
|
|
|
setMode(kPanelMain);
|
2005-01-17 20:17:06 +00:00
|
|
|
// FIXME: puzzle
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'u':
|
|
|
|
converseChangePos(-1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
converseChangePos(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
converseSetPos(keyCode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::setStatusText(const char *text, int statusColor) {
|
|
|
|
assert(text != NULL);
|
|
|
|
assert(strlen(text) < STATUS_TEXT_LEN);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
strncpy(_statusText, text, STATUS_TEXT_LEN);
|
|
|
|
_statusOnceColor = statusColor;
|
|
|
|
drawStatusBar();
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-09 15:07:49 +00:00
|
|
|
int Interface::loadScenePortraits(int resourceId) {
|
|
|
|
_scenePortraits.freeMem();
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-05-10 17:40:58 +00:00
|
|
|
return _vm->_sprite->loadList(resourceId, _scenePortraits);
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
void Interface::drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton) {
|
|
|
|
PanelButton * rightButtonVerbPanelButton;
|
|
|
|
PanelButton * currentVerbPanelButton;
|
|
|
|
int textColor;
|
|
|
|
int spriteNumber;
|
|
|
|
Point point;
|
|
|
|
|
|
|
|
rightButtonVerbPanelButton = getPanelButtonByVerbType(_vm->_script->getRightButtonVerb());
|
|
|
|
currentVerbPanelButton = getPanelButtonByVerbType(_vm->_script->getCurrentVerb());
|
|
|
|
|
|
|
|
if (panelButton->state) {
|
|
|
|
textColor = _vm->getDisplayInfo().verbTextActiveColor;
|
|
|
|
} else {
|
|
|
|
if (panelButton == rightButtonVerbPanelButton) {
|
|
|
|
textColor = _vm->getDisplayInfo().verbTextActiveColor;
|
|
|
|
} else {
|
|
|
|
textColor = _vm->getDisplayInfo().verbTextColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panelButton == currentVerbPanelButton) {
|
|
|
|
spriteNumber = panelButton->downSpriteNumber;
|
|
|
|
} else {
|
|
|
|
spriteNumber = panelButton->upSpriteNumber;
|
|
|
|
}
|
|
|
|
point.x = _mainPanel.x + panelButton->xOffset;
|
|
|
|
point.y = _mainPanel.y + panelButton->yOffset;
|
|
|
|
|
|
|
|
_vm->_sprite->draw(backBuffer, _mainPanel.sprites, spriteNumber, point, 256);
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
drawVerbPanelText(backBuffer, panelButton, textColor, _vm->getDisplayInfo().verbTextShadowColor);
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::draw() {
|
2005-01-09 23:41:22 +00:00
|
|
|
SURFACE *backBuffer;
|
2005-01-13 22:42:49 +00:00
|
|
|
int i;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
Point leftPortraitPoint;
|
|
|
|
Point rightPortraitPoint;
|
2004-10-04 23:09:38 +00:00
|
|
|
Point origin;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
backBuffer = _vm->_gfx->getBackBuffer();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-07 21:13:26 +00:00
|
|
|
if (_vm->_scene->isInDemo() || _panelMode == kPanelFade)
|
2005-05-22 11:59:22 +00:00
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
drawStatusBar();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-02 20:29:27 +00:00
|
|
|
if (_panelMode == kPanelMain) {
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
origin.x = 0;
|
2005-01-13 22:42:49 +00:00
|
|
|
origin.y = _vm->getDisplayHeight() - _mainPanel.imageHeight;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
bufToSurface(backBuffer, _mainPanel.image, _mainPanel.imageWidth, _mainPanel.imageHeight, NULL, &origin);
|
|
|
|
for (i = 0; i < kVerbTypesMax; i++) {
|
|
|
|
if (_verbTypeToPanelButton[i] != NULL) {
|
2005-04-22 14:11:04 +00:00
|
|
|
drawVerbPanel(backBuffer, _verbTypeToPanelButton[i]);
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_panelMode == kPanelConverse) {
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
origin.x = 0;
|
|
|
|
origin.y = _vm->getDisplayHeight() - _mainPanel.imageHeight;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
bufToSurface(backBuffer, _conversePanel.image, _conversePanel.imageWidth,
|
|
|
|
_conversePanel.imageHeight, NULL, &origin);
|
|
|
|
|
|
|
|
converseDisplayTextLines(backBuffer);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 14:02:53 +00:00
|
|
|
if (_panelMode == kPanelMain || _panelMode == kPanelConverse ||
|
2005-01-09 23:41:22 +00:00
|
|
|
_lockedMode == kPanelMain || _lockedMode == kPanelConverse) {
|
2005-04-18 20:03:14 +00:00
|
|
|
leftPortraitPoint.x = _mainPanel.x + _vm->getDisplayInfo().leftPortraitXOffset;
|
|
|
|
leftPortraitPoint.y = _mainPanel.y + _vm->getDisplayInfo().leftPortraitYOffset;
|
2005-01-09 23:41:22 +00:00
|
|
|
_vm->_sprite->draw(backBuffer, _defPortraits, _leftPortrait, leftPortraitPoint, 256);
|
|
|
|
}
|
|
|
|
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (!_inMainMode && _vm->getDisplayInfo().rightPortraitXOffset >= 0) { //FIXME: should we change !_inMainMode to _panelMode == kPanelConverse ?
|
2005-04-18 20:03:14 +00:00
|
|
|
rightPortraitPoint.x = _mainPanel.x + _vm->getDisplayInfo().rightPortraitXOffset;
|
|
|
|
rightPortraitPoint.y = _mainPanel.y + _vm->getDisplayInfo().rightPortraitYOffset;
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-05-09 06:36:27 +00:00
|
|
|
// This looks like hack - particularly since it's only done for
|
|
|
|
// the right-side portrait - and perhaps it is! But as far as I
|
|
|
|
// can tell this is what the original engine does. And it keeps
|
|
|
|
// ITE from crashing when entering the Elk King's court.
|
|
|
|
|
|
|
|
if (_rightPortrait >= _scenePortraits.spriteCount)
|
|
|
|
_rightPortrait = 0;
|
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
_vm->_sprite->draw(backBuffer, _scenePortraits, _rightPortrait, rightPortraitPoint, 256);
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
drawInventory(backBuffer);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::drawOption() {
|
|
|
|
SURFACE *backBuffer;
|
|
|
|
int i;
|
|
|
|
Point origin;
|
|
|
|
|
|
|
|
backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
origin.x = _vm->getDisplayInfo().optionPanelXOffset;
|
|
|
|
origin.y = _vm->getDisplayInfo().optionPanelYOffset;
|
|
|
|
|
|
|
|
bufToSurface(backBuffer, _optionPanel.image, _optionPanel.imageWidth, _optionPanel.imageHeight, NULL, &origin);
|
|
|
|
|
|
|
|
for (i = 0; i < _optionPanel.buttonsCount; i++) {
|
|
|
|
drawOptionPanelButtonText(backBuffer, &_optionPanel.buttons[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleOptionUpdate(const Point& mousePoint) {
|
|
|
|
_optionPanel.currentButton = optionHitTest(mousePoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::handleOptionClick(const Point& mousePoint) {
|
|
|
|
_optionPanel.currentButton = optionHitTest(mousePoint);
|
|
|
|
|
|
|
|
if (_optionPanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setOption(_optionPanel.currentButton); //TODO: do it on mouse up
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::setOption(PanelButton *panelButton) {
|
|
|
|
switch (panelButton->keyChar) {
|
|
|
|
case 'c':
|
|
|
|
setMode(kPanelMain);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::update(const Point& mousePoint, int updateFlag) {
|
2005-02-26 17:37:16 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_vm->_scene->isInDemo() || _panelMode == kPanelFade) {
|
|
|
|
return;
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
if (_panelMode == kPanelMain) {
|
2005-01-15 23:46:43 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
2005-04-22 14:11:04 +00:00
|
|
|
bool lastWasPlayfield = _lastMousePoint.y < _vm->getSceneHeight();
|
2005-01-15 20:12:49 +00:00
|
|
|
if (mousePoint.y < _vm->getSceneHeight()) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (!lastWasPlayfield) {
|
2005-05-22 11:59:22 +00:00
|
|
|
handleMainUpdate(mousePoint);
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
2005-01-15 20:12:49 +00:00
|
|
|
_vm->_script->whichObject(mousePoint);
|
2005-01-13 22:42:49 +00:00
|
|
|
} else {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (lastWasPlayfield) {
|
2005-01-15 20:12:49 +00:00
|
|
|
_vm->_script->setNonPlayfieldVerb();
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
handleMainUpdate(mousePoint);
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2005-01-15 20:12:49 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
} else {
|
2005-01-15 20:12:49 +00:00
|
|
|
|
2005-01-15 23:46:43 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
2005-01-15 20:12:49 +00:00
|
|
|
if (mousePoint.y < _vm->getSceneHeight()) {
|
2005-02-26 17:37:16 +00:00
|
|
|
_vm->_script->playfieldClick(mousePoint, (updateFlag & UPDATE_LEFTBUTTONCLICK) != 0);
|
2005-01-15 20:12:49 +00:00
|
|
|
} else {
|
2005-05-22 11:59:22 +00:00
|
|
|
handleMainClick(mousePoint);
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_panelMode == kPanelConverse) {
|
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
|
|
|
|
handleConverseUpdate(mousePoint);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleConverseClick(mousePoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_panelMode == kPanelOption) {
|
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
|
|
|
|
handleOptionUpdate(mousePoint);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleOptionClick(mousePoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
_lastMousePoint = mousePoint;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::drawStatusBar() {
|
|
|
|
SURFACE *backBuffer;
|
2004-10-04 23:09:38 +00:00
|
|
|
Rect rect;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
int string_w;
|
2005-01-19 11:29:29 +00:00
|
|
|
int color;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
|
2004-11-25 07:18:35 +00:00
|
|
|
// Disable this for IHNM for now, since that game uses the full screen
|
|
|
|
// in some cases.
|
|
|
|
|
2005-01-11 21:10:36 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
2005-04-18 20:03:14 +00:00
|
|
|
return;
|
2004-11-25 07:18:35 +00:00
|
|
|
}
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 09:37:24 +00:00
|
|
|
// Erase background of status bar
|
2005-04-22 14:11:04 +00:00
|
|
|
rect.left = _vm->getDisplayInfo().statusXOffset;
|
|
|
|
rect.top = _vm->getDisplayInfo().statusYOffset;
|
|
|
|
rect.right = rect.left + _vm->getDisplayWidth();
|
|
|
|
rect.bottom = rect.top + _vm->getDisplayInfo().statusHeight;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-22 01:38:27 +00:00
|
|
|
drawRect(backBuffer, rect, _vm->getDisplayInfo().statusBGColor);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
string_w = _vm->_font->getStringWidth(SMALL_FONT_ID, _statusText, 0, 0);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-19 11:29:29 +00:00
|
|
|
if (_statusOnceColor == -1)
|
|
|
|
color = _vm->getDisplayInfo().statusTextColor;
|
|
|
|
else
|
|
|
|
color = _statusOnceColor;
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
_vm->_font->draw(SMALL_FONT_ID, backBuffer, _statusText, 0, _vm->getDisplayInfo().statusXOffset + (_vm->getDisplayInfo().statusWidth / 2) - (string_w / 2),
|
|
|
|
_vm->getDisplayInfo().statusYOffset + _vm->getDisplayInfo().statusTextY, color, 0, 0);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_saveReminderState > 0) {
|
|
|
|
rect.left = _vm->getDisplayInfo().saveReminderXOffset;
|
|
|
|
rect.top = _vm->getDisplayInfo().saveReminderYOffset;
|
|
|
|
|
|
|
|
rect.right = rect.left + _vm->getDisplayInfo().saveReminderWidth;
|
|
|
|
rect.bottom = rect.top + _vm->getDisplayInfo().saveReminderHeight;
|
|
|
|
_vm->_sprite->draw(backBuffer, _vm->_sprite->_mainSprites,
|
|
|
|
_saveReminderState == 1 ? _vm->getDisplayInfo().saveReminderFirstSpriteNumber : _vm->getDisplayInfo().saveReminderSecondSpriteNumber,
|
|
|
|
rect, 256);
|
|
|
|
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::handleMainClick(const Point& mousePoint) {
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
PanelButton *panelButton;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
panelButton = verbHitTest(mousePoint);
|
2005-01-13 22:42:49 +00:00
|
|
|
if (panelButton) {
|
|
|
|
_vm->_script->setVerb(panelButton->id);
|
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
|
|
|
|
panelButton = _mainPanel.hitTest(mousePoint, kPanelAllButtons);
|
|
|
|
|
|
|
|
if (panelButton != NULL) {
|
|
|
|
if (panelButton->type == kPanelButtonArrow) {
|
|
|
|
panelButton->state = 1;
|
|
|
|
converseChangePos(panelButton->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panelButton->type == kPanelButtonInventory) {
|
|
|
|
if (_vm->_script->_pointerObject != ID_NOTHING) {
|
|
|
|
_vm->_script->hitObject(_vm->leftMouseButtonPressed());
|
|
|
|
}
|
|
|
|
if (_vm->_script->_pendingVerb) {
|
|
|
|
_vm->_actor->_protagonist->currentAction = kActionWait;
|
|
|
|
_vm->_script->doVerb();
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
} else {
|
|
|
|
if (_saveReminderState > 0) {
|
|
|
|
Rect rect;
|
|
|
|
rect.left = _vm->getDisplayInfo().saveReminderXOffset;
|
|
|
|
rect.top = _vm->getDisplayInfo().saveReminderYOffset;
|
|
|
|
|
|
|
|
rect.right = rect.left + _vm->getDisplayInfo().saveReminderWidth;
|
|
|
|
rect.bottom = rect.top + _vm->getDisplayInfo().saveReminderHeight;
|
|
|
|
if (rect.contains(mousePoint)) {
|
|
|
|
setMode(kPanelOption);
|
|
|
|
}
|
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::handleMainUpdate(const Point& mousePoint) {
|
2005-01-13 22:42:49 +00:00
|
|
|
PanelButton *panelButton;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
panelButton = verbHitTest(mousePoint);
|
2005-01-13 22:42:49 +00:00
|
|
|
if (_mainPanel.currentButton != panelButton) {
|
|
|
|
if (_mainPanel.currentButton) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_mainPanel.currentButton->type == kPanelButtonVerb) {
|
|
|
|
setVerbState(_mainPanel.currentButton->id, 0);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
if (panelButton) {
|
2005-04-22 14:11:04 +00:00
|
|
|
setVerbState(panelButton->id, 1);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
if (panelButton) {
|
2005-04-22 14:11:04 +00:00
|
|
|
_mainPanel.currentButton = panelButton;
|
2005-01-13 22:42:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-11-07 14:15:41 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
|
|
|
|
if (!_vm->mouseButtonPressed()) { // remove pressed flag
|
2005-04-22 15:43:42 +00:00
|
|
|
if (_inventoryUpButton) {
|
|
|
|
_inventoryUpButton->state = 0;
|
|
|
|
_inventoryDownButton->state = 0;
|
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
panelButton = _mainPanel.hitTest(mousePoint, kPanelAllButtons);
|
|
|
|
|
2005-05-15 17:45:59 +00:00
|
|
|
bool changed = false;
|
2005-04-22 14:11:04 +00:00
|
|
|
|
2005-05-15 17:45:59 +00:00
|
|
|
if ((panelButton != NULL) && (panelButton->type == kPanelButtonArrow)) {
|
|
|
|
if (panelButton->state == 1) {
|
|
|
|
//TODO: insert timeout catchup
|
|
|
|
inventoryChangePos(panelButton->id);
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
} else {
|
|
|
|
_vm->_script->whichObject(mousePoint);
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
2005-05-15 17:45:59 +00:00
|
|
|
changed = changed || (panelButton != _mainPanel.currentButton);
|
2005-04-22 14:11:04 +00:00
|
|
|
_mainPanel.currentButton = panelButton;
|
|
|
|
if (changed) {
|
|
|
|
draw();
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
//inventory stuff
|
|
|
|
void Interface::inventoryChangePos(int chg) {
|
|
|
|
if ((chg < 0 && _inventoryStart + chg >= 0) ||
|
|
|
|
(chg > 0 && _inventoryStart < _inventoryEnd)) {
|
|
|
|
_inventoryStart += chg;
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::inventorySetPos(int key) {
|
|
|
|
_inventoryBox = key - '1';
|
|
|
|
_inventoryPos = _inventoryStart + _inventoryBox;
|
|
|
|
if (_inventoryPos >= _inventoryCount)
|
|
|
|
_inventoryPos = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::updateInventory(int pos) {
|
2005-04-22 15:26:50 +00:00
|
|
|
int cols = _vm->getDisplayInfo().inventoryColumns;
|
2005-04-22 14:11:04 +00:00
|
|
|
if (pos >= _inventoryCount) {
|
|
|
|
pos = _inventoryCount - 1;
|
|
|
|
}
|
|
|
|
if (pos < 0) {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
_inventoryStart = (pos - cols) / cols * cols;
|
|
|
|
if (_inventoryStart < 0) {
|
|
|
|
_inventoryStart = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_inventoryEnd = (_inventoryCount - 1 - cols) / cols * cols;
|
|
|
|
if (_inventoryEnd < 0) {
|
|
|
|
_inventoryEnd = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-12 15:11:32 +00:00
|
|
|
void Interface::addToInventory(int objectId) {
|
2005-04-21 01:30:07 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_inventoryCount >= _inventorySize) {
|
|
|
|
return;
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
|
|
|
|
for (int i = _inventoryCount; i > 0; i--) {
|
|
|
|
_inventory[i] = _inventory[i - 1];
|
|
|
|
}
|
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
_inventory[0] = objectId;
|
2005-04-22 14:11:04 +00:00
|
|
|
_inventoryCount++;
|
|
|
|
|
|
|
|
_inventoryPos = 0;
|
|
|
|
updateInventory(0);
|
|
|
|
|
|
|
|
draw();
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
void Interface::removeFromInventory(int objectId) {
|
|
|
|
int j = inventoryItemPosition(objectId);
|
2005-04-22 14:11:04 +00:00
|
|
|
if (j == -1) {
|
|
|
|
return;
|
|
|
|
}
|
2004-11-07 14:15:41 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
int i;
|
2004-11-07 14:15:41 +00:00
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
for (i = j; i < _inventoryCount - 1; i++) {
|
2005-04-22 14:11:04 +00:00
|
|
|
_inventory[i] = _inventory[i + 1];
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
|
|
|
|
--_inventoryCount;
|
|
|
|
_inventory[_inventoryCount] = 0;
|
|
|
|
updateInventory(j);
|
|
|
|
draw();
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
|
|
|
|
2005-04-21 01:30:07 +00:00
|
|
|
void Interface::clearInventory() {
|
|
|
|
for (int i = 0; i < _inventoryCount; i++)
|
|
|
|
_inventory[i] = 0;
|
|
|
|
|
|
|
|
_inventoryCount = 0;
|
2005-04-22 14:11:04 +00:00
|
|
|
updateInventory(0);
|
2005-04-21 01:30:07 +00:00
|
|
|
}
|
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
int Interface::inventoryItemPosition(int objectId) {
|
2005-04-20 23:42:19 +00:00
|
|
|
for (int i = 0; i < _inventoryCount; i++)
|
2005-04-23 12:34:35 +00:00
|
|
|
if (_inventory[i] == objectId)
|
2005-04-20 23:42:19 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
void Interface::drawInventory(SURFACE *backBuffer) {
|
2005-01-02 20:29:27 +00:00
|
|
|
if (_panelMode != kPanelMain)
|
2004-11-07 14:15:41 +00:00
|
|
|
return;
|
2005-04-22 14:11:04 +00:00
|
|
|
int i;
|
|
|
|
Rect rect;
|
|
|
|
int ci;
|
|
|
|
ObjectData *obj;
|
|
|
|
Point point;
|
|
|
|
ci = _inventoryStart;
|
|
|
|
if (_inventoryStart != 0) {
|
|
|
|
drawPanelButtonArrow(backBuffer, &_mainPanel, _inventoryUpButton);
|
|
|
|
}
|
|
|
|
if (_inventoryStart != _inventoryEnd) {
|
|
|
|
drawPanelButtonArrow(backBuffer, &_mainPanel, _inventoryDownButton);
|
2005-04-18 10:26:43 +00:00
|
|
|
}
|
2004-11-07 14:15:41 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
for (i = 0; i < _mainPanel.buttonsCount; i++) {
|
|
|
|
if (ci >= _inventoryCount) {
|
|
|
|
break;
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_mainPanel.buttons[i].type != kPanelButtonInventory) {
|
|
|
|
continue;
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
_mainPanel.calcPanelButtonRect(&_mainPanel.buttons[i], rect);
|
|
|
|
|
|
|
|
//4debug drawRect(backBuffer, rect, kITEColorWhite);
|
|
|
|
point.x = rect.left;
|
|
|
|
point.y = rect.top;
|
|
|
|
obj = _vm->_actor->getObj(_inventory[ci]);
|
|
|
|
_vm->_sprite->draw(backBuffer, _vm->_sprite->_mainSprites, obj->spriteListResourceId, rect, 256);
|
|
|
|
|
|
|
|
ci++;
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
void Interface::setVerbState(int verb, int state) {
|
|
|
|
PanelButton * panelButton = getPanelButtonByVerbType(verb);
|
2005-01-13 22:42:49 +00:00
|
|
|
if (state == 2) {
|
|
|
|
state = (_mainPanel.currentButton == panelButton) ? 1 : 0;
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
panelButton->state = state;
|
|
|
|
draw();
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 12:21:16 +00:00
|
|
|
void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) {
|
2005-05-22 13:49:45 +00:00
|
|
|
byte cornerColor = 0x8b;
|
|
|
|
byte frameColor = 0x0f;
|
|
|
|
byte fillColor = 0x96;
|
|
|
|
byte odl = 0x8a, our = 0x94, idl = 0x97, iur = 0x95;
|
|
|
|
int x = rect.left;
|
|
|
|
int y = rect.top;
|
|
|
|
int w = rect.width();
|
|
|
|
int h = rect.height();
|
|
|
|
int xe = rect.right - 1;
|
|
|
|
int ye = rect.bottom - 1;
|
|
|
|
|
|
|
|
((byte *)ds->getBasePtr(x, y))[0] = cornerColor;
|
|
|
|
((byte *)ds->getBasePtr(x, ye))[0] = cornerColor;
|
|
|
|
((byte *)ds->getBasePtr(xe, y))[0] = cornerColor;
|
|
|
|
((byte *)ds->getBasePtr(xe, ye))[0] = cornerColor;
|
|
|
|
ds->hLine(x + 1, y, x + 1 + w - 2, frameColor);
|
|
|
|
ds->hLine(x + 1, ye, x + 1 + w - 2, frameColor);
|
|
|
|
ds->vLine(x, y + 1, y + 1 + h - 2, frameColor);
|
|
|
|
ds->vLine(xe, y + 1, y + 1 + h - 2, frameColor);
|
|
|
|
|
|
|
|
if (down) {
|
|
|
|
SWAP(odl, our);
|
|
|
|
SWAP(idl, iur);
|
|
|
|
}
|
|
|
|
x++;
|
|
|
|
y++;
|
|
|
|
xe--;
|
|
|
|
ye--;
|
|
|
|
w -= 2;
|
|
|
|
h -= 2;
|
|
|
|
ds->vLine(x, y, y + h - 1, odl);
|
|
|
|
ds->hLine(x, ye, x + w - 1, odl);
|
|
|
|
ds->vLine(xe, y, y + h - 1, our);
|
|
|
|
ds->hLine(x + 1, y, x + 1 + w - 2, our);
|
|
|
|
|
|
|
|
x++;
|
|
|
|
y++;
|
|
|
|
xe--;
|
|
|
|
ye--;
|
|
|
|
w -= 2;
|
|
|
|
h -= 2;
|
|
|
|
((byte *)ds->getBasePtr(x, y))[0] = fillColor;
|
|
|
|
((byte *)ds->getBasePtr(xe, ye))[0] = fillColor;
|
|
|
|
ds->vLine(x, y + 1, y + 1 + h - 2, idl);
|
|
|
|
ds->hLine(x + 1, ye, x + 1 + w - 2, idl);
|
|
|
|
ds->vLine(xe, y, y + h - 1, iur);
|
|
|
|
ds->hLine(x + 1, y, x + 1 + w - 2, iur);
|
|
|
|
|
|
|
|
x++; y++;
|
|
|
|
w -= 2; h -= 2;
|
|
|
|
|
|
|
|
Common::Rect fill(x, y, x + w, y + h);
|
|
|
|
ds->fillRect(fill, fillColor);
|
2005-05-22 12:21:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton) {
|
|
|
|
const char *text;
|
|
|
|
int textWidth;
|
|
|
|
int textHeight;
|
|
|
|
Point point;
|
|
|
|
int textColor;
|
2005-05-22 12:21:16 +00:00
|
|
|
Rect rect;
|
2005-05-22 11:59:22 +00:00
|
|
|
//TODO: draw box!
|
|
|
|
|
|
|
|
text = _vm->getTextString(panelButton->id);
|
|
|
|
|
|
|
|
textWidth = _vm->_font->getStringWidth(MEDIUM_FONT_ID, text, 0, 0);
|
|
|
|
textHeight = _vm->_font->getHeight(MEDIUM_FONT_ID);
|
|
|
|
|
|
|
|
point.x = _optionPanel.x + panelButton->xOffset + (panelButton->width / 2) - (textWidth / 2);
|
|
|
|
point.y = _optionPanel.y + panelButton->yOffset + (panelButton->height / 2) - (textHeight / 2);
|
|
|
|
|
|
|
|
if (panelButton == _optionPanel.currentButton) {
|
|
|
|
textColor = _vm->getDisplayInfo().verbTextActiveColor; //TODO: create Option button colors constant
|
|
|
|
} else {
|
|
|
|
textColor = _vm->getDisplayInfo().verbTextColor; //TODO: create Option button colors constant
|
|
|
|
}
|
|
|
|
|
2005-05-22 12:21:16 +00:00
|
|
|
_optionPanel.calcPanelButtonRect(panelButton, rect);
|
|
|
|
drawButtonBox(ds, rect, panelButton->state > 0);
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
_vm->_font->draw(MEDIUM_FONT_ID, ds, text, 0, point.x , point.y, textColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton) {
|
|
|
|
Point point;
|
|
|
|
int spriteNumber;
|
|
|
|
|
|
|
|
if (panel->currentButton == panelButton) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (panelButton->state != 0) {
|
2005-04-18 20:03:14 +00:00
|
|
|
spriteNumber = panelButton->downSpriteNumber;
|
|
|
|
} else {
|
|
|
|
spriteNumber = panelButton->overSpriteNumber;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
spriteNumber = panelButton->upSpriteNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
point.x = panel->x + panelButton->xOffset;
|
|
|
|
point.y = panel->y + panelButton->yOffset;
|
|
|
|
|
|
|
|
_vm->_sprite->draw(ds, _vm->_sprite->_mainSprites, spriteNumber, point, 256);
|
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor) {
|
2005-01-13 22:42:49 +00:00
|
|
|
const char *text;
|
|
|
|
int textWidth;
|
|
|
|
Point point;
|
|
|
|
int textId;
|
|
|
|
|
|
|
|
textId = verbTypeToTextStringsIdLUT[panelButton->id];
|
|
|
|
|
|
|
|
if (textId == -1)
|
|
|
|
error("textId == -1");
|
|
|
|
|
|
|
|
text = _vm->getTextString(textId);
|
|
|
|
|
|
|
|
textWidth = _vm->_font->getStringWidth(SMALL_FONT_ID, text, 0, 0);
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
point.x = _mainPanel.x + panelButton->xOffset + (panelButton->width / 2) - (textWidth / 2);
|
|
|
|
point.y = _mainPanel.y + panelButton->yOffset + 1;
|
2005-01-13 22:42:49 +00:00
|
|
|
|
|
|
|
_vm->_font->draw(SMALL_FONT_ID, ds, text, 0, point.x , point.y, textColor, textShadowColor, (textShadowColor != 0) ? FONT_SHADOW : 0);
|
2005-01-09 23:41:22 +00:00
|
|
|
}
|
2005-01-18 10:45:36 +00:00
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
|
2005-01-10 22:51:01 +00:00
|
|
|
// Converse stuff
|
2005-01-18 10:45:36 +00:00
|
|
|
void Interface::converseInit(void) {
|
|
|
|
for (int i = 0; i < CONVERSE_MAX_TEXTS; i++)
|
|
|
|
_converseText[i].text = NULL;
|
|
|
|
converseClear();
|
|
|
|
}
|
2005-01-18 11:55:31 +00:00
|
|
|
|
2005-01-10 22:51:01 +00:00
|
|
|
void Interface::converseClear(void) {
|
|
|
|
for (int i = 0; i < CONVERSE_MAX_TEXTS; i++) {
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_converseText[i].text != NULL) {
|
2005-01-10 22:51:01 +00:00
|
|
|
free(_converseText[i].text);
|
2005-04-18 20:03:14 +00:00
|
|
|
_converseText[i].text = NULL;
|
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
_converseText[i].stringNum = -1;
|
|
|
|
_converseText[i].replyId = 0;
|
|
|
|
_converseText[i].replyFlags = 0;
|
|
|
|
_converseText[i].replyBit = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_converseTextCount = 0;
|
|
|
|
_converseStrCount = 0;
|
|
|
|
_converseStartPos = 0;
|
|
|
|
_converseEndPos = 0;
|
|
|
|
_conversePos = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Interface::converseAddText(const char *text, int replyId, byte replyFlags, int replyBit) {
|
|
|
|
int count = 0; // count how many pieces of text per string
|
2005-04-18 20:03:14 +00:00
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
byte c;
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
assert(strlen(text) < CONVERSE_MAX_WORK_STRING);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
strncpy(_converseWorkString, text, CONVERSE_MAX_WORK_STRING);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
while (1) {
|
2005-04-18 20:03:14 +00:00
|
|
|
len = strlen(_converseWorkString);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
for (i = len; i >= 0; i--) {
|
2005-04-18 20:03:14 +00:00
|
|
|
c = _converseWorkString[i];
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
if ((c == ' ' || c == '\0')
|
2005-04-18 20:03:14 +00:00
|
|
|
&& _vm->_font->getStringWidth(SMALL_FONT_ID, _converseWorkString, i, 0)
|
2005-01-10 22:51:01 +00:00
|
|
|
<= CONVERSE_MAX_TEXT_WIDTH)
|
|
|
|
break;
|
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
if (i < 0) {
|
2005-01-10 22:51:01 +00:00
|
|
|
return true;
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_converseTextCount == CONVERSE_MAX_TEXTS) {
|
2005-01-10 22:51:01 +00:00
|
|
|
return true;
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
_converseText[_converseTextCount].text = (char *)malloc(i + 1);
|
2005-04-18 20:03:14 +00:00
|
|
|
strncpy(_converseText[_converseTextCount].text, _converseWorkString, i);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
_converseText[_converseTextCount].text[i] = 0;
|
|
|
|
_converseText[_converseTextCount].textNum = count;
|
|
|
|
_converseText[_converseTextCount].stringNum = _converseStrCount;
|
|
|
|
_converseText[_converseTextCount].replyId = replyId;
|
|
|
|
_converseText[_converseTextCount].replyFlags = replyFlags;
|
|
|
|
_converseText[_converseTextCount].replyBit = replyBit;
|
|
|
|
|
|
|
|
_converseTextCount++;
|
|
|
|
count++;
|
|
|
|
|
|
|
|
if (len == i)
|
|
|
|
break;
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
strncpy(_converseWorkString, &_converseWorkString[i + 1], len - i);
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_converseStrCount++;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::converseDisplayText() {
|
|
|
|
int end;
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
_converseStartPos = 0;
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
end = _converseTextCount - CONVERSE_TEXT_LINES;
|
|
|
|
|
|
|
|
if (end < 0)
|
|
|
|
end = 0;
|
|
|
|
|
|
|
|
_converseEndPos = end;
|
2005-04-18 20:03:14 +00:00
|
|
|
draw();
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::converseSetTextLines(int row) {
|
|
|
|
int pos = row + _converseStartPos;
|
|
|
|
if (pos >= _converseTextCount)
|
|
|
|
pos = -1;
|
|
|
|
if (pos != _conversePos) {
|
|
|
|
_conversePos = pos;
|
|
|
|
draw();
|
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
void Interface::converseDisplayTextLines(SURFACE *ds) {
|
|
|
|
int relPos;
|
|
|
|
byte foregnd;
|
|
|
|
byte backgnd;
|
|
|
|
byte bulletForegnd;
|
|
|
|
byte bulletBackgnd;
|
|
|
|
const char *str;
|
|
|
|
char bullet[2] = {
|
|
|
|
(char)0xb7, 0
|
|
|
|
};
|
|
|
|
Rect rect(8, CONVERSE_TEXT_LINES * CONVERSE_TEXT_HEIGHT);
|
|
|
|
|
|
|
|
assert(_conversePanel.buttonsCount >= 6);
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
bulletForegnd = kITEColorGreen;
|
|
|
|
bulletBackgnd = kITEColorBlack;
|
|
|
|
|
|
|
|
rect.moveTo(_conversePanel.x + _conversePanel.buttons[0].xOffset,
|
|
|
|
_conversePanel.y + _conversePanel.buttons[0].yOffset);
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2005-04-22 01:38:27 +00:00
|
|
|
drawRect(ds, rect, kITEColorDarkGrey); //fill bullet place
|
2005-04-18 20:03:14 +00:00
|
|
|
|
2005-01-11 00:51:58 +00:00
|
|
|
for (int i = 0; i < CONVERSE_TEXT_LINES; i++) {
|
2005-04-18 20:03:14 +00:00
|
|
|
relPos = _converseStartPos + i;
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_converseTextCount <= relPos) {
|
|
|
|
break;
|
2005-01-11 00:51:58 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_conversePos >= 0 && _converseText[_conversePos].stringNum == _converseText[relPos].stringNum) {
|
|
|
|
foregnd = kITEColorBrightWhite;
|
|
|
|
backgnd = (!_vm->leftMouseButtonPressed()) ? kITEColorDarkGrey : kITEColorGrey;
|
|
|
|
} else {
|
|
|
|
foregnd = kITEColorBlue;
|
|
|
|
backgnd = kITEColorDarkGrey;
|
|
|
|
}
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
_conversePanel.calcPanelButtonRect(&_conversePanel.buttons[i], rect);
|
|
|
|
rect.left += 8;
|
2005-04-22 01:38:27 +00:00
|
|
|
drawRect(ds, rect, backgnd);
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
str = _converseText[relPos].text;
|
|
|
|
|
|
|
|
if (_converseText[relPos].textNum == 0) { // first entry
|
|
|
|
_vm->_font->draw(SMALL_FONT_ID, ds, bullet, 1,
|
|
|
|
rect.left - 6, rect.top, bulletForegnd, bulletBackgnd, FONT_SHADOW | FONT_DONTMAP);
|
2005-01-11 00:51:58 +00:00
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
_vm->_font->draw(SMALL_FONT_ID, ds, str, strlen(str),
|
|
|
|
rect.left + 1, rect.top, foregnd, kITEColorBlack, FONT_SHADOW);
|
2005-01-11 00:51:58 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_converseStartPos != 0) {
|
2005-04-22 14:11:04 +00:00
|
|
|
drawPanelButtonArrow(ds, &_conversePanel, _converseUpButton);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_converseStartPos != _converseEndPos) {
|
2005-04-22 14:11:04 +00:00
|
|
|
drawPanelButtonArrow(ds, &_conversePanel, _converseDownButton);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::converseChangePos(int chg) {
|
|
|
|
if ((chg < 0 && _converseStartPos + chg >= 0) ||
|
|
|
|
(chg > 0 && _converseStartPos < _converseEndPos)) {
|
|
|
|
_converseStartPos += chg;
|
2005-04-18 20:03:14 +00:00
|
|
|
draw();
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-17 20:17:06 +00:00
|
|
|
void Interface::converseSetPos(int key) {
|
2005-01-10 22:51:01 +00:00
|
|
|
Converse *ct;
|
2005-01-17 20:17:06 +00:00
|
|
|
int selection = key - '1';
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
if (selection >= _converseTextCount)
|
|
|
|
return;
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
converseSetTextLines(selection);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
ct = &_converseText[_conversePos];
|
2005-01-17 20:17:06 +00:00
|
|
|
|
2005-01-17 23:11:31 +00:00
|
|
|
_vm->_script->finishDialog(ct->replyId, ct->replyFlags, ct->replyBit);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
// FIXME: TODO: Puzzle
|
|
|
|
|
|
|
|
_conversePos = -1;
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
|
|
|
|
void Interface::handleConverseUpdate(const Point& mousePoint) {
|
|
|
|
bool changed;
|
|
|
|
|
|
|
|
PanelButton *last = _conversePanel.currentButton;
|
|
|
|
|
|
|
|
if (!_vm->mouseButtonPressed()) { // remove pressed flag
|
2005-04-22 15:43:42 +00:00
|
|
|
if (_converseUpButton) {
|
|
|
|
_converseUpButton->state = 0;
|
|
|
|
_converseDownButton->state = 0;
|
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_conversePanel.currentButton = converseHitTest(mousePoint);
|
|
|
|
changed = last != _conversePanel.currentButton;
|
|
|
|
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton == NULL) {
|
|
|
|
_conversePos = -1;
|
|
|
|
if (changed) {
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
|
|
|
|
converseSetTextLines(_conversePanel.currentButton->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonArrow) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_conversePanel.currentButton->state == 1) {
|
2005-04-18 20:03:14 +00:00
|
|
|
//TODO: insert timeout catchup
|
2005-04-22 14:11:04 +00:00
|
|
|
converseChangePos(_conversePanel.currentButton->id);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::handleConverseClick(const Point& mousePoint) {
|
|
|
|
_conversePanel.currentButton = converseHitTest(mousePoint);
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
|
|
|
|
converseSetPos(_conversePanel.currentButton->keyChar);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonArrow) {
|
2005-04-22 14:11:04 +00:00
|
|
|
_conversePanel.currentButton->state = 1;
|
|
|
|
converseChangePos(_conversePanel.currentButton->id);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-05-12 15:11:32 +00:00
|
|
|
void Interface::saveState(Common::File& out) {
|
|
|
|
out.writeUint16LE(_inventoryCount);
|
|
|
|
|
|
|
|
for (int i = 0; i < _inventoryCount; i++) {
|
|
|
|
out.writeUint16LE(_inventory[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::loadState(Common::File& in) {
|
|
|
|
_inventoryCount = in.readUint16LE();
|
|
|
|
|
|
|
|
for (int i = 0; i < _inventoryCount; i++) {
|
|
|
|
_inventory[i] = in.readUint16LE();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateInventory(0);
|
|
|
|
}
|
|
|
|
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|