2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +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 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-04-12 21:40:49 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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"
|
2007-04-27 23:11:12 +00:00
|
|
|
#include "saga/displayinfo.h"
|
2005-08-10 13:56:51 +00:00
|
|
|
#include "saga/events.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-07-03 20:02:56 +00:00
|
|
|
#include "saga/isomap.h"
|
2005-01-28 12:54:09 +00:00
|
|
|
#include "saga/itedata.h"
|
2005-09-02 20:17:52 +00:00
|
|
|
#include "saga/music.h"
|
2005-05-23 02:23:34 +00:00
|
|
|
#include "saga/puzzle.h"
|
2005-07-03 20:02:56 +00:00
|
|
|
#include "saga/render.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"
|
2005-09-02 20:17:52 +00:00
|
|
|
#include "saga/sound.h"
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2008-12-22 14:13:15 +00:00
|
|
|
#include "saga/resource.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
|
|
|
|
2005-09-02 20:17:52 +00:00
|
|
|
#include "common/config-manager.h"
|
2005-07-03 20:02:56 +00:00
|
|
|
#include "common/system.h"
|
2005-05-29 20:57:45 +00:00
|
|
|
#include "common/timer.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2008-12-26 14:38:45 +00:00
|
|
|
static const int verbToTextIdITE[] = {
|
2008-12-26 13:50:12 +00:00
|
|
|
kTextWalkTo, kTextLookAt, kTextPickUp, kTextTalkTo,
|
|
|
|
kTextOpen, kTextClose, kTextUse, kTextGive
|
2004-04-12 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
2007-06-13 22:23:12 +00:00
|
|
|
// This maps the internally used string ITE IDs to the LUT strings loaded in IHNM
|
|
|
|
// i.e. id 12 (quit game button) maps to string 14 (Quit game)
|
|
|
|
// The comments are what the actual IHNM string is
|
|
|
|
// For the text string IDs, refer to saga.h, enum TextStringIds
|
2008-12-26 14:38:45 +00:00
|
|
|
static const int IHNMTextStringIdsLUT[56] = {
|
2007-06-13 22:23:12 +00:00
|
|
|
-1, // (Empty)
|
|
|
|
-1, // (Empty)
|
|
|
|
4, // Take
|
|
|
|
6, // Talk to
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
5, // Use
|
|
|
|
8, // Give
|
|
|
|
10, // Options
|
|
|
|
11, // Test
|
2008-08-01 14:03:20 +00:00
|
|
|
12, // Demo
|
2007-06-13 22:23:12 +00:00
|
|
|
13, // Help
|
|
|
|
14, // Quit Game
|
|
|
|
16, // Fast
|
|
|
|
18, // Slow
|
|
|
|
20, // On
|
|
|
|
21, // Off
|
|
|
|
15, // Continue Playing
|
|
|
|
22, // Load
|
|
|
|
23, // Save
|
|
|
|
24, // Game Options
|
|
|
|
25, // Reading Speed
|
|
|
|
26, // Music
|
|
|
|
27, // Sound
|
|
|
|
32, // Cancel
|
|
|
|
33, // Quit
|
|
|
|
34, // OK
|
|
|
|
17, // Mid
|
|
|
|
19, // Click
|
|
|
|
36, // 10%
|
|
|
|
37, // 20%
|
|
|
|
38, // 30%
|
|
|
|
39, // 40%
|
|
|
|
40, // 50%
|
|
|
|
41, // 60%
|
|
|
|
42, // 70%
|
|
|
|
43, // 80%
|
|
|
|
44, // 90%
|
|
|
|
45, // Max
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
28, // Voices
|
|
|
|
29, // Text
|
|
|
|
30, // Audio
|
|
|
|
31 // Both
|
|
|
|
};
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
Interface::Interface(SagaEngine *vm) : _vm(vm) {
|
2005-01-13 22:42:49 +00:00
|
|
|
byte *resource;
|
|
|
|
size_t resourceLength;
|
|
|
|
int i;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-05-01 09:37:24 +00:00
|
|
|
// Load interface module resource file context
|
2005-07-19 19:05:52 +00:00
|
|
|
_interfaceContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
|
2004-11-15 03:03:48 +00:00
|
|
|
if (_interfaceContext == NULL) {
|
2005-07-19 19:05:52 +00:00
|
|
|
error("Interface::Interface() resource context not found");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2007-06-13 15:31:45 +00:00
|
|
|
// Main panel
|
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
|
|
|
|
2006-01-13 20:20:01 +00:00
|
|
|
for (i = 0; i < kVerbTypeIdsMax; i++) {
|
2005-01-13 22:42:49 +00:00
|
|
|
_verbTypeToPanelButton[i] = NULL;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2008-12-21 23:43:12 +00:00
|
|
|
// Do nothing for SAGA2 games for now
|
|
|
|
if (_vm->isSaga2()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
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-07-19 19:05:52 +00:00
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->mainPanelResourceId, resource, resourceLength);
|
2005-01-13 22:42:49 +00:00
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_mainPanel.image,
|
|
|
|
&_mainPanel.imageLength, &_mainPanel.imageWidth, &_mainPanel.imageHeight);
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
free(resource);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-06-13 15:31:45 +00:00
|
|
|
// Converse panel
|
2005-04-18 20:03:14 +00:00
|
|
|
_conversePanel.buttons = _vm->getDisplayInfo().conversePanelButtons;
|
|
|
|
_conversePanel.buttonsCount = _vm->getDisplayInfo().conversePanelButtonsCount;
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->conversePanelResourceId, resource, resourceLength);
|
2005-01-13 22:42:49 +00:00
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_conversePanel.image,
|
|
|
|
&_conversePanel.imageLength, &_conversePanel.imageWidth, &_conversePanel.imageHeight);
|
2005-07-19 19:05:52 +00:00
|
|
|
free(resource);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-06-13 15:31:45 +00:00
|
|
|
// Option panel
|
2008-12-29 17:30:29 +00:00
|
|
|
if (!(_vm->getFeatures() & GF_NON_INTERACTIVE)) {
|
|
|
|
_optionPanel.buttons = _vm->getDisplayInfo().optionPanelButtons;
|
|
|
|
_optionPanel.buttonsCount = _vm->getDisplayInfo().optionPanelButtonsCount;
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2008-12-29 17:30:29 +00:00
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->optionPanelResourceId, resource, resourceLength);
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_optionPanel.image,
|
|
|
|
&_optionPanel.imageLength, &_optionPanel.imageWidth, &_optionPanel.imageHeight);
|
|
|
|
free(resource);
|
|
|
|
} else {
|
|
|
|
_optionPanel.buttons = NULL;
|
|
|
|
_optionPanel.buttonsCount = 0;
|
|
|
|
_optionPanel.sprites.spriteCount = 0;
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2009-01-02 16:52:38 +00:00
|
|
|
#ifdef ENABLE_IHNM
|
2007-06-13 15:31:45 +00:00
|
|
|
// Quit panel
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
2007-06-13 15:31:45 +00:00
|
|
|
_quitPanel.buttons = _vm->getDisplayInfo().quitPanelButtons;
|
|
|
|
_quitPanel.buttonsCount = _vm->getDisplayInfo().quitPanelButtonsCount;
|
|
|
|
|
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->warningPanelResourceId, resource, resourceLength);
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_quitPanel.image,
|
|
|
|
&_quitPanel.imageLength, &_quitPanel.imageWidth, &_quitPanel.imageHeight);
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
2007-06-17 02:59:56 +00:00
|
|
|
// Save panel
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
2007-06-17 02:59:56 +00:00
|
|
|
_savePanel.buttons = _vm->getDisplayInfo().savePanelButtons;
|
|
|
|
_savePanel.buttonsCount = _vm->getDisplayInfo().savePanelButtonsCount;
|
|
|
|
|
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->warningPanelResourceId, resource, resourceLength);
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_savePanel.image,
|
|
|
|
&_savePanel.imageLength, &_savePanel.imageWidth, &_savePanel.imageHeight);
|
|
|
|
free(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load panel
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
2007-06-17 02:59:56 +00:00
|
|
|
_loadPanel.buttons = _vm->getDisplayInfo().loadPanelButtons;
|
|
|
|
_loadPanel.buttonsCount = _vm->getDisplayInfo().loadPanelButtonsCount;
|
|
|
|
|
|
|
|
_vm->_resource->loadResource(_interfaceContext, _vm->getResourceDescription()->warningPanelResourceId, resource, resourceLength);
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &_loadPanel.image,
|
|
|
|
&_loadPanel.imageLength, &_loadPanel.imageWidth, &_loadPanel.imageHeight);
|
|
|
|
free(resource);
|
|
|
|
}
|
2009-01-02 16:52:38 +00:00
|
|
|
#endif
|
2007-06-17 02:59:56 +00:00
|
|
|
|
2007-06-13 15:31:45 +00:00
|
|
|
// Main panel sprites
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->mainPanelSpritesResourceId, _mainPanel.sprites);
|
2008-12-31 22:11:20 +00:00
|
|
|
if (!(_vm->getFeatures() & GF_NON_INTERACTIVE)) {
|
|
|
|
// Option panel sprites
|
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->optionPanelSpritesResourceId, _optionPanel.sprites);
|
|
|
|
// Save panel sprites
|
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->warningPanelSpritesResourceId, _savePanel.sprites);
|
|
|
|
// Load panel sprites
|
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->warningPanelSpritesResourceId, _loadPanel.sprites);
|
|
|
|
// Quit panel sprites
|
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->warningPanelSpritesResourceId, _quitPanel.sprites);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_sprite->loadList(_vm->getResourceDescription()->defaultPortraitsResourceId, _defPortraits);
|
2005-06-08 14:41:57 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-10-04 18:19:14 +00:00
|
|
|
setPortraitBgColor(0, 0, 0);
|
|
|
|
|
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);
|
2005-07-29 17:58:00 +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-05-28 11:06:55 +00:00
|
|
|
_optionSaveFileSlider = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFileSliderIndex);
|
|
|
|
_optionSaveFilePanel = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFilePanelIndex);
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
_quitPanel.x = _vm->getDisplayInfo().quitPanelXOffset;
|
|
|
|
_quitPanel.y = _vm->getDisplayInfo().quitPanelYOffset;
|
|
|
|
_quitPanel.imageWidth = _vm->getDisplayInfo().quitPanelWidth;
|
|
|
|
_quitPanel.imageHeight = _vm->getDisplayInfo().quitPanelHeight;
|
|
|
|
_quitPanel.buttons = _vm->getDisplayInfo().quitPanelButtons;
|
|
|
|
_quitPanel.buttonsCount = _vm->getDisplayInfo().quitPanelButtonsCount;
|
|
|
|
_quitPanel.currentButton = NULL;
|
|
|
|
|
|
|
|
_loadPanel.x = _vm->getDisplayInfo().loadPanelXOffset;
|
|
|
|
_loadPanel.y = _vm->getDisplayInfo().loadPanelYOffset;
|
|
|
|
_loadPanel.imageWidth = _vm->getDisplayInfo().loadPanelWidth;
|
|
|
|
_loadPanel.imageHeight = _vm->getDisplayInfo().loadPanelHeight;
|
|
|
|
_loadPanel.buttons = _vm->getDisplayInfo().loadPanelButtons;
|
|
|
|
_loadPanel.buttonsCount = _vm->getDisplayInfo().loadPanelButtonsCount;
|
|
|
|
_loadPanel.currentButton = NULL;
|
|
|
|
|
|
|
|
_savePanel.x = _vm->getDisplayInfo().savePanelXOffset;
|
|
|
|
_savePanel.y = _vm->getDisplayInfo().savePanelYOffset;
|
|
|
|
_savePanel.imageWidth = _vm->getDisplayInfo().savePanelWidth;
|
|
|
|
_savePanel.imageHeight = _vm->getDisplayInfo().savePanelHeight;
|
|
|
|
_savePanel.buttons = _vm->getDisplayInfo().savePanelButtons;
|
|
|
|
_savePanel.buttonsCount = _vm->getDisplayInfo().savePanelButtonsCount;
|
|
|
|
_saveEdit = _savePanel.getButton(_vm->getDisplayInfo().saveEditIndex);
|
|
|
|
_savePanel.currentButton = NULL;
|
|
|
|
|
2005-10-17 03:28:21 +00:00
|
|
|
_protectPanel.x = _vm->getDisplayInfo().protectPanelXOffset;
|
|
|
|
_protectPanel.y = _vm->getDisplayInfo().protectPanelYOffset;
|
|
|
|
_protectPanel.imageWidth = _vm->getDisplayInfo().protectPanelWidth;
|
|
|
|
_protectPanel.imageHeight = _vm->getDisplayInfo().protectPanelHeight;
|
|
|
|
_protectPanel.buttons = _vm->getDisplayInfo().protectPanelButtons;
|
|
|
|
_protectPanel.buttonsCount = _vm->getDisplayInfo().protectPanelButtonsCount;
|
|
|
|
_protectEdit = _protectPanel.getButton(_vm->getDisplayInfo().protectEditIndex);
|
|
|
|
_protectPanel.currentButton = NULL;
|
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
_active = true;
|
2005-01-07 00:57:43 +00:00
|
|
|
_panelMode = _lockedMode = kPanelNull;
|
|
|
|
_savedMode = -1;
|
2005-10-09 03:35:45 +00:00
|
|
|
_bossMode = -1;
|
2005-06-04 15:02:17 +00:00
|
|
|
_fadeMode = kNoFade;
|
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
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
_optionSaveFileTop = 0;
|
2005-05-29 15:39:35 +00:00
|
|
|
_optionSaveFileTitleNumber = 0;
|
2005-05-28 11:06:55 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-06-02 22:14:57 +00:00
|
|
|
_textInput = false;
|
2005-06-19 14:06:20 +00:00
|
|
|
_statusTextInput = false;
|
|
|
|
_statusTextInputState = kStatusTextInputFirstRun;
|
2005-10-04 23:38:19 +00:00
|
|
|
|
|
|
|
_disableAbortSpeeches = false;
|
2008-06-03 21:20:55 +00:00
|
|
|
|
|
|
|
// set save game reminder alarm
|
2008-12-25 20:53:59 +00:00
|
|
|
_vm->getTimerManager()->installTimerProc(&saveReminderCallback, TIMETOSAVE, this);
|
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-07-29 17:58:00 +00:00
|
|
|
|
2008-06-12 16:58:02 +00:00
|
|
|
free(_mainPanel.image);
|
|
|
|
free(_conversePanel.image);
|
|
|
|
free(_optionPanel.image);
|
|
|
|
free(_quitPanel.image);
|
|
|
|
free(_loadPanel.image);
|
|
|
|
free(_savePanel.image);
|
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
_mainPanel.sprites.freeMem();
|
2008-06-12 16:58:02 +00:00
|
|
|
_conversePanel.sprites.freeMem();
|
|
|
|
_optionPanel.sprites.freeMem();
|
|
|
|
_quitPanel.sprites.freeMem();
|
|
|
|
_loadPanel.sprites.freeMem();
|
|
|
|
_savePanel.sprites.freeMem();
|
|
|
|
_protectPanel.sprites.freeMem();
|
|
|
|
|
2005-01-09 15:07:49 +00:00
|
|
|
_defPortraits.freeMem();
|
|
|
|
_scenePortraits.freeMem();
|
2004-08-06 01:39:17 +00:00
|
|
|
}
|
|
|
|
|
2008-06-03 21:20:55 +00:00
|
|
|
void Interface::saveReminderCallback(void *refCon) {
|
|
|
|
((Interface *)refCon)->updateSaveReminder();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::updateSaveReminder() {
|
|
|
|
if (_active && _panelMode == kPanelMain) {
|
2008-09-24 22:44:01 +00:00
|
|
|
_saveReminderState = _saveReminderState % _vm->getDisplayInfo().saveReminderNumSprites + 1;
|
2008-06-03 21:20:55 +00:00
|
|
|
drawStatusBar();
|
2008-12-25 20:53:59 +00:00
|
|
|
_vm->getTimerManager()->removeTimerProc(&saveReminderCallback);
|
|
|
|
_vm->getTimerManager()->installTimerProc(&saveReminderCallback, ((_vm->getGameId() == GID_ITE) ? TIMETOBLINK_ITE : TIMETOBLINK_IHNM), this);
|
2008-06-03 21:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-06 01:39:17 +00:00
|
|
|
int Interface::activate() {
|
2005-01-07 00:57:43 +00:00
|
|
|
if (!_active) {
|
|
|
|
_active = true;
|
|
|
|
_vm->_script->_skipSpeeches = false;
|
2005-08-10 14:53:17 +00:00
|
|
|
_vm->_actor->_protagonist->_targetObject = ID_NOTHING;
|
2005-01-07 00:57:43 +00:00
|
|
|
unlockMode();
|
2007-07-28 01:04:59 +00:00
|
|
|
if (_panelMode == kPanelMain || _panelMode == kPanelChapterSelection) {
|
2007-07-30 16:16:22 +00:00
|
|
|
_saveReminderState = 1;
|
2008-12-21 15:59:05 +00:00
|
|
|
} else if (_panelMode == kPanelNull && _vm->getFeatures() & GF_IHNM_DEMO) {
|
2007-07-30 23:37:18 +00:00
|
|
|
_saveReminderState = 1;
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
2007-08-24 12:43:56 +00:00
|
|
|
_vm->_gfx->showCursor(true);
|
2005-01-07 00:57:43 +00:00
|
|
|
draw();
|
2008-12-09 21:09:45 +00:00
|
|
|
_vm->_render->setFullRefresh(true);
|
2005-01-07 00:57:43 +00:00
|
|
|
}
|
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;
|
|
|
|
lockMode();
|
|
|
|
setMode(kPanelNull);
|
|
|
|
}
|
2005-08-12 20:06:41 +00:00
|
|
|
_vm->_gfx->showCursor(false);
|
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() {
|
2007-08-25 19:21:43 +00:00
|
|
|
debug(1, "rememberMode(%d)", _panelMode);
|
2005-01-07 00:57:43 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_savedMode = _panelMode;
|
2005-01-07 00:57:43 +00:00
|
|
|
}
|
|
|
|
|
2007-06-17 01:00:06 +00:00
|
|
|
void Interface::restoreMode(bool draw_) {
|
|
|
|
debug(1, "restoreMode(%d)", _savedMode);
|
|
|
|
|
2007-07-31 17:41:10 +00:00
|
|
|
// If _savedMode is -1 by a race condition, set it to kPanelMain
|
|
|
|
if (_savedMode == -1)
|
|
|
|
_savedMode = kPanelMain;
|
|
|
|
|
2005-01-07 00:57:43 +00:00
|
|
|
_panelMode = _savedMode;
|
|
|
|
_savedMode = -1;
|
|
|
|
|
2007-06-17 01:00:06 +00:00
|
|
|
if (draw_)
|
|
|
|
draw();
|
2005-01-07 00:57:43 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
void Interface::setMode(int mode) {
|
2005-10-09 03:45:16 +00:00
|
|
|
debug(1, "Interface::setMode %i", mode);
|
2005-10-08 16:25:18 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (mode == kPanelMain) {
|
|
|
|
_inMainMode = true;
|
2008-09-24 22:44:01 +00:00
|
|
|
_saveReminderState = 1;
|
2007-06-16 08:27:53 +00:00
|
|
|
} else if (mode == kPanelChapterSelection) {
|
2007-07-30 16:16:22 +00:00
|
|
|
_saveReminderState = 1;
|
2007-07-28 12:26:40 +00:00
|
|
|
} else if (mode == kPanelNull) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getFeatures() & GF_IHNM_DEMO) {
|
2007-07-28 12:26:40 +00:00
|
|
|
_inMainMode = true;
|
2007-07-30 16:16:22 +00:00
|
|
|
_saveReminderState = 1;
|
|
|
|
}
|
2007-07-30 23:37:18 +00:00
|
|
|
} else if (mode == kPanelOption) {
|
2007-09-30 14:46:49 +00:00
|
|
|
// Show the cursor if it's hidden
|
|
|
|
_vm->_gfx->showCursor(true);
|
2005-01-09 23:41:22 +00:00
|
|
|
} else {
|
2005-05-22 11:59:22 +00:00
|
|
|
if (mode == kPanelConverse) {
|
|
|
|
_inMainMode = false;
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2007-07-30 16:16:22 +00:00
|
|
|
|
2007-07-30 23:37:18 +00:00
|
|
|
_saveReminderState = 0;
|
2005-01-07 00:57:43 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
_panelMode = mode;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-06-21 15:41:35 +00:00
|
|
|
switch (_panelMode) {
|
2005-07-03 20:02:56 +00:00
|
|
|
case kPanelMain:
|
2007-08-20 20:00:40 +00:00
|
|
|
// FIXME: Implement IHNM differences from ExecuteInventoryPanel for IHNM (though I believe they're already
|
|
|
|
// implemented)
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-07-03 20:02:56 +00:00
|
|
|
_mainPanel.currentButton = NULL;
|
|
|
|
break;
|
|
|
|
case kPanelConverse:
|
|
|
|
_conversePanel.currentButton = NULL;
|
|
|
|
converseDisplayText();
|
|
|
|
break;
|
|
|
|
case kPanelOption:
|
|
|
|
_optionPanel.currentButton = NULL;
|
|
|
|
_vm->fillSaveList();
|
|
|
|
calcOptionSaveSlider();
|
|
|
|
if (_optionSaveFileTitleNumber >= _vm->getDisplayInfo().optionSaveFileVisible) {
|
|
|
|
_optionSaveFileTitleNumber = _vm->getDisplayInfo().optionSaveFileVisible - 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kPanelLoad:
|
|
|
|
_loadPanel.currentButton = NULL;
|
|
|
|
break;
|
|
|
|
case kPanelQuit:
|
|
|
|
_quitPanel.currentButton = NULL;
|
|
|
|
break;
|
|
|
|
case kPanelSave:
|
|
|
|
_savePanel.currentButton = NULL;
|
|
|
|
_textInputMaxWidth = _saveEdit->width - 10;
|
|
|
|
_textInput = true;
|
|
|
|
_textInputStringLength = strlen(_textInputString);
|
|
|
|
_textInputPos = _textInputStringLength + 1;
|
|
|
|
break;
|
|
|
|
case kPanelMap:
|
|
|
|
mapPanelShow();
|
|
|
|
break;
|
2005-07-29 16:37:06 +00:00
|
|
|
case kPanelSceneSubstitute:
|
2005-07-29 17:42:33 +00:00
|
|
|
_vm->_render->setFlag(RF_DEMO_SUBST);
|
2005-07-29 16:37:06 +00:00
|
|
|
_vm->_gfx->getCurrentPal(_mapSavedPal);
|
|
|
|
break;
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelChapterSelection:
|
|
|
|
break;
|
2005-10-09 03:35:45 +00:00
|
|
|
case kPanelBoss:
|
|
|
|
_vm->_render->setFlag(RF_DEMO_SUBST);
|
|
|
|
break;
|
2005-10-17 03:28:21 +00:00
|
|
|
case kPanelProtect:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-08-02 01:04:44 +00:00
|
|
|
// This is used as the copy protection panel in ITE
|
|
|
|
_protectPanel.currentButton = NULL;
|
|
|
|
_textInputMaxWidth = _protectEdit->width - 10;
|
|
|
|
_textInput = true;
|
|
|
|
_textInputString[0] = 0;
|
|
|
|
_textInputStringLength = 0;
|
|
|
|
_textInputPos = _textInputStringLength + 1;
|
|
|
|
} else {
|
|
|
|
// In the IHNM demo, this panel mode is set by the scripts
|
|
|
|
// to flip through the pages of the help system
|
|
|
|
}
|
2005-10-17 03:28:21 +00:00
|
|
|
break;
|
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();
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_render->setFullRefresh(true);
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
bool Interface::processAscii(Common::KeyState keystate) {
|
2005-07-12 18:31:48 +00:00
|
|
|
// TODO: Checking for Esc and Enter below is a bit hackish, and
|
2008-05-26 11:10:46 +00:00
|
|
|
// probably only works with the English version. Maybe we should
|
|
|
|
// add a flag to the button so it can indicate if it's the default
|
|
|
|
// or cancel button?
|
2007-09-11 09:19:23 +00:00
|
|
|
uint16 ascii = keystate.ascii;
|
2005-01-13 22:42:49 +00:00
|
|
|
int i;
|
2005-04-22 14:11:04 +00:00
|
|
|
PanelButton *panelButton;
|
2005-06-19 14:06:20 +00:00
|
|
|
if (_statusTextInput) {
|
2007-09-11 09:19:23 +00:00
|
|
|
processStatusTextInput(keystate);
|
2005-06-19 14:06:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
2005-09-28 15:41:21 +00:00
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
switch (_panelMode) {
|
|
|
|
case kPanelNull:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE) {
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->_scene->isInIntro()) {
|
2005-01-13 22:42:49 +00:00
|
|
|
_vm->_scene->skipScene();
|
|
|
|
} else {
|
2005-10-04 23:38:19 +00:00
|
|
|
if (!_disableAbortSpeeches)
|
|
|
|
_vm->_actor->abortAllSpeeches();
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
2005-10-06 15:56:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-07-30 23:37:18 +00:00
|
|
|
|
2007-08-24 12:05:05 +00:00
|
|
|
if (_vm->_scene->isNonInteractiveIHNMDemoPart())
|
|
|
|
_vm->_scene->showIHNMDemoSpecialScreen();
|
2005-10-06 15:56:06 +00:00
|
|
|
break;
|
|
|
|
case kPanelCutaway:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE) {
|
2005-10-06 15:56:06 +00:00
|
|
|
if (!_disableAbortSpeeches)
|
|
|
|
_vm->_actor->abortAllSpeeches();
|
2005-10-04 23:59:09 +00:00
|
|
|
_vm->_scene->cutawaySkip();
|
2005-01-13 22:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-07-30 23:37:18 +00:00
|
|
|
|
2007-08-24 12:05:05 +00:00
|
|
|
if (_vm->_scene->isNonInteractiveIHNMDemoPart())
|
|
|
|
_vm->_scene->showIHNMDemoSpecialScreen();
|
2005-01-13 22:42:49 +00:00
|
|
|
break;
|
2005-10-07 15:36:28 +00:00
|
|
|
case kPanelVideo:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE) {
|
2005-10-07 15:36:28 +00:00
|
|
|
if (_vm->_scene->isInIntro()) {
|
|
|
|
_vm->_scene->skipScene();
|
|
|
|
} else {
|
|
|
|
if (!_disableAbortSpeeches)
|
|
|
|
_vm->_actor->abortAllSpeeches();
|
|
|
|
}
|
|
|
|
_vm->_scene->cutawaySkip();
|
2007-07-30 23:37:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-24 12:05:05 +00:00
|
|
|
if (_vm->_scene->isNonInteractiveIHNMDemoPart())
|
|
|
|
_vm->_scene->showIHNMDemoSpecialScreen();
|
2005-10-07 15:36:28 +00:00
|
|
|
break;
|
2005-05-22 11:59:22 +00:00
|
|
|
case kPanelOption:
|
2005-07-12 18:31:48 +00:00
|
|
|
// TODO: check input dialog keys
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE || keystate.keycode == Common::KEYCODE_RETURN) { // Esc or Enter
|
2005-05-28 11:06:55 +00:00
|
|
|
ascii = 'c'; //continue
|
|
|
|
}
|
2005-07-12 18:31:48 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
for (i = 0; i < _optionPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_optionPanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonOption) {
|
2005-05-28 11:06:55 +00:00
|
|
|
if (panelButton->ascii == ascii) {
|
2005-07-12 18:31:48 +00:00
|
|
|
setOption(panelButton);
|
2005-05-23 18:53:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-05-29 15:39:35 +00:00
|
|
|
case kPanelSave:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (_textInput && processTextInput(keystate)) {
|
2005-06-19 14:06:20 +00:00
|
|
|
return true;
|
2005-07-12 18:31:48 +00:00
|
|
|
}
|
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE) {
|
2005-07-12 18:31:48 +00:00
|
|
|
ascii = 'c'; // cancel
|
2007-09-11 09:19:23 +00:00
|
|
|
} else if (keystate.keycode == Common::KEYCODE_RETURN) { // Enter
|
2005-07-12 18:31:48 +00:00
|
|
|
ascii = 's'; // save
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _savePanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_savePanel.buttons[i];
|
|
|
|
if (panelButton->type == kPanelButtonSave) {
|
|
|
|
if (panelButton->ascii == ascii) {
|
|
|
|
setSave(panelButton);
|
|
|
|
return true;
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kPanelQuit:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE) {
|
2005-07-12 18:31:48 +00:00
|
|
|
ascii = 'c'; // cancel
|
2007-09-11 09:19:23 +00:00
|
|
|
} else if (keystate.keycode == Common::KEYCODE_RETURN) { // Enter
|
2005-07-12 18:31:48 +00:00
|
|
|
ascii = 'q'; // quit
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
2005-07-12 18:31:48 +00:00
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
for (i = 0; i < _quitPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_quitPanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonQuit) {
|
2005-05-29 15:39:35 +00:00
|
|
|
if (panelButton->ascii == ascii) {
|
2005-07-12 18:31:48 +00:00
|
|
|
setQuit(panelButton);
|
2005-05-29 15:39:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kPanelLoad:
|
|
|
|
for (i = 0; i < _loadPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_loadPanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonLoad) {
|
2005-05-29 15:39:35 +00:00
|
|
|
if (panelButton->ascii == ascii) {
|
2005-07-12 18:31:48 +00:00
|
|
|
setLoad(panelButton);
|
2005-05-29 15:39:35 +00:00
|
|
|
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];
|
2005-05-28 11:06:55 +00:00
|
|
|
if (panelButton->ascii == ascii) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (panelButton->type == kPanelButtonVerb) {
|
|
|
|
_vm->_script->setVerb(panelButton->id);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
if (panelButton->type == kPanelButtonArrow) {
|
|
|
|
inventoryChangePos(panelButton->id);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
return true;
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_o && keystate.flags == Common::KBD_CTRL) { // ctrl-o
|
2005-05-28 11:06:55 +00:00
|
|
|
if (_saveReminderState > 0) {
|
|
|
|
setMode(kPanelOption);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
break;
|
2005-01-17 20:17:06 +00:00
|
|
|
case kPanelConverse:
|
2005-05-28 11:06:55 +00:00
|
|
|
switch (ascii) {
|
2005-01-17 20:17:06 +00:00
|
|
|
case 'x':
|
2005-05-22 11:59:22 +00:00
|
|
|
setMode(kPanelMain);
|
2008-12-24 09:59:18 +00:00
|
|
|
if (_vm->_scene->isITEPuzzleScene())
|
2005-05-23 02:23:34 +00:00
|
|
|
_vm->_puzzle->exitPuzzle();
|
2005-01-17 20:17:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'u':
|
|
|
|
converseChangePos(-1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
converseChangePos(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
2007-06-12 19:45:39 +00:00
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
2008-12-24 09:59:18 +00:00
|
|
|
converseSetPos(ascii);
|
2007-06-12 19:45:39 +00:00
|
|
|
break;
|
2005-01-17 20:17:06 +00:00
|
|
|
}
|
2005-07-06 17:07:58 +00:00
|
|
|
break;
|
2005-07-03 20:02:56 +00:00
|
|
|
case kPanelMap:
|
|
|
|
mapPanelClean();
|
|
|
|
break;
|
2005-07-29 16:37:06 +00:00
|
|
|
case kPanelSceneSubstitute:
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_RETURN) {
|
2005-07-29 17:42:33 +00:00
|
|
|
_vm->_render->clearFlag(RF_DEMO_SUBST);
|
2005-07-29 16:37:06 +00:00
|
|
|
_vm->_gfx->setPalette(_mapSavedPal);
|
|
|
|
setMode(kPanelMain);
|
2005-07-29 17:42:33 +00:00
|
|
|
_vm->_script->setNoPendingVerb();
|
2005-07-29 16:37:06 +00:00
|
|
|
} else if (ascii == 'q' || ascii == 'Q') {
|
2008-07-11 01:09:48 +00:00
|
|
|
_vm->quitGame();
|
2005-07-29 16:37:06 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-10-09 03:35:45 +00:00
|
|
|
case kPanelBoss:
|
|
|
|
_vm->_render->clearFlag(RF_DEMO_SUBST);
|
|
|
|
keyBossExit();
|
|
|
|
break;
|
2005-10-17 03:28:21 +00:00
|
|
|
case kPanelProtect:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-09-11 09:19:23 +00:00
|
|
|
if (_textInput && processTextInput(keystate)) {
|
2007-08-02 01:04:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
2005-10-17 03:28:21 +00:00
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
if (keystate.keycode == Common::KEYCODE_ESCAPE || keystate.keycode == Common::KEYCODE_RETURN) {
|
2007-08-02 01:04:44 +00:00
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeRequest);
|
|
|
|
_vm->_interface->setMode(kPanelMain);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-08-02 01:04:44 +00:00
|
|
|
_protectHash = 0;
|
2005-10-17 03:28:21 +00:00
|
|
|
|
2007-08-02 01:04:44 +00:00
|
|
|
for (char *p = _textInputString; *p; p++)
|
|
|
|
_protectHash = (_protectHash << 1) + toupper(*p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// In the IHNM demo, this panel mode is set by the scripts
|
|
|
|
// to flip through the pages of the help system
|
2005-10-17 03:28:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-07-30 14:22:53 +00:00
|
|
|
case kPanelPlacard:
|
2009-01-02 16:52:38 +00:00
|
|
|
#ifdef ENABLE_IHNM
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
2007-07-30 14:22:53 +00:00
|
|
|
// Any keypress here returns the user back to the game
|
2008-12-21 15:59:05 +00:00
|
|
|
if (!(_vm->getFeatures() & GF_IHNM_DEMO)) {
|
2007-08-02 14:43:10 +00:00
|
|
|
_vm->_scene->clearPsychicProfile();
|
|
|
|
} else {
|
|
|
|
setMode(kPanelConverse);
|
|
|
|
_vm->_scene->_textList.clear();
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeDelay);
|
|
|
|
}
|
2007-07-30 14:22:53 +00:00
|
|
|
}
|
2009-01-02 16:52:38 +00:00
|
|
|
#endif
|
2007-07-30 14:22:53 +00:00
|
|
|
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) {
|
2008-12-24 09:59:18 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
|
|
|
// Don't show the status text for the IHNM chapter selection screens (chapter 8), or
|
|
|
|
// scene 0 (IHNM demo introduction)
|
|
|
|
if (_vm->_scene->currentChapterNumber() == 8 || _vm->_scene->currentSceneNumber() == 0)
|
|
|
|
return;
|
|
|
|
}
|
2007-07-28 00:33:09 +00:00
|
|
|
|
2007-06-02 15:21:42 +00:00
|
|
|
assert(text != NULL);
|
|
|
|
assert(strlen(text) < STATUS_TEXT_LEN);
|
|
|
|
|
2007-09-14 12:42:47 +00:00
|
|
|
if (_vm->_render->getFlags() & RF_MAP || _vm->_interface->getMode() == kPanelPlacard)
|
2005-07-29 16:37:06 +00:00
|
|
|
return;
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
strncpy(_statusText, text, STATUS_TEXT_LEN);
|
|
|
|
_statusOnceColor = statusColor;
|
2005-07-29 17:58:00 +00:00
|
|
|
drawStatusBar();
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
void Interface::loadScenePortraits(int resourceId) {
|
2005-01-09 15:07:49 +00:00
|
|
|
_scenePortraits.freeMem();
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_sprite->loadList(resourceId, _scenePortraits);
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawVerbPanel(PanelButton* panelButton) {
|
2005-04-22 14:11:04 +00:00
|
|
|
PanelButton * rightButtonVerbPanelButton;
|
|
|
|
PanelButton * currentVerbPanelButton;
|
2005-11-26 12:08:05 +00:00
|
|
|
KnownColor textColor;
|
2005-04-22 14:11:04 +00:00
|
|
|
int spriteNumber;
|
|
|
|
Point point;
|
|
|
|
|
|
|
|
rightButtonVerbPanelButton = getPanelButtonByVerbType(_vm->_script->getRightButtonVerb());
|
|
|
|
currentVerbPanelButton = getPanelButtonByVerbType(_vm->_script->getCurrentVerb());
|
|
|
|
|
|
|
|
if (panelButton->state) {
|
2005-11-26 12:08:05 +00:00
|
|
|
textColor = kKnownColorVerbTextActive;
|
2005-07-17 13:36:38 +00:00
|
|
|
} else if (panelButton == rightButtonVerbPanelButton) {
|
2005-11-26 12:08:05 +00:00
|
|
|
textColor = kKnownColorVerbTextActive;
|
2005-04-22 14:11:04 +00:00
|
|
|
} else {
|
2005-11-26 12:08:05 +00:00
|
|
|
textColor = kKnownColorVerbText;
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (panelButton == currentVerbPanelButton) {
|
|
|
|
spriteNumber = panelButton->downSpriteNumber;
|
|
|
|
} else {
|
|
|
|
spriteNumber = panelButton->upSpriteNumber;
|
|
|
|
}
|
|
|
|
point.x = _mainPanel.x + panelButton->xOffset;
|
|
|
|
point.y = _mainPanel.y + panelButton->yOffset;
|
|
|
|
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_mainPanel.sprites, spriteNumber, point, 256);
|
2005-04-22 14:11:04 +00:00
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
drawVerbPanelText(panelButton, textColor, kKnownColorVerbTextShadow);
|
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
|
|
|
Point leftPortraitPoint;
|
2005-07-29 17:58:00 +00:00
|
|
|
Point rightPortraitPoint;
|
2005-07-09 16:23:45 +00:00
|
|
|
Rect rect;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->_scene->isInIntro() || _fadeMode == kFadeOut)
|
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
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (_panelMode == kPanelMain || _panelMode == kPanelMap ||
|
2008-12-21 15:59:05 +00:00
|
|
|
(_panelMode == kPanelNull && _vm->getFeatures() & GF_IHNM_DEMO)) {
|
2005-07-29 17:58:00 +00:00
|
|
|
_mainPanel.getRect(rect);
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _mainPanel.image);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2008-12-06 13:35:27 +00:00
|
|
|
for (int i = 0; i < kVerbTypeIdsMax; i++) {
|
2005-01-13 22:42:49 +00:00
|
|
|
if (_verbTypeToPanelButton[i] != NULL) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawVerbPanel(_verbTypeToPanelButton[i]);
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
} else if (_panelMode == kPanelConverse) {
|
2005-07-17 13:36:38 +00:00
|
|
|
_conversePanel.getRect(rect);
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _conversePanel.image);
|
2008-12-06 14:24:40 +00:00
|
|
|
converseDisplayTextLines();
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 14:02:53 +00:00
|
|
|
if (_panelMode == kPanelMain || _panelMode == kPanelConverse ||
|
2007-07-28 12:26:40 +00:00
|
|
|
_lockedMode == kPanelMain || _lockedMode == kPanelConverse ||
|
2008-12-21 15:59:05 +00:00
|
|
|
(_panelMode == kPanelNull && _vm->getFeatures() & GF_IHNM_DEMO)) {
|
2005-06-08 14:41:57 +00:00
|
|
|
leftPortraitPoint.x = _mainPanel.x + _vm->getDisplayInfo().leftPortraitXOffset;
|
|
|
|
leftPortraitPoint.y = _mainPanel.y + _vm->getDisplayInfo().leftPortraitYOffset;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_defPortraits, _leftPortrait, leftPortraitPoint, 256);
|
2005-06-08 14:41:57 +00:00
|
|
|
}
|
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;
|
|
|
|
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_scenePortraits, _rightPortrait, rightPortraitPoint, 256);
|
2004-10-21 06:49:11 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
drawInventory();
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
void Interface::calcOptionSaveSlider() {
|
2005-05-31 20:08:46 +00:00
|
|
|
int totalFiles = _vm->getSaveFilesCount();
|
2005-07-29 17:58:00 +00:00
|
|
|
int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible;
|
2005-05-28 11:06:55 +00:00
|
|
|
int height = _optionSaveFileSlider->height;
|
2007-08-21 18:23:48 +00:00
|
|
|
int sliderHeight = 13; // IHNM's save file list slider has a fixed height
|
2005-05-28 11:06:55 +00:00
|
|
|
int pos;
|
|
|
|
|
|
|
|
if (totalFiles < visibleFiles) {
|
|
|
|
totalFiles = visibleFiles;
|
|
|
|
}
|
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-08-21 18:23:48 +00:00
|
|
|
// ITE's save file list slider has a dynamically computed height, depending on
|
|
|
|
// the number of save games
|
|
|
|
sliderHeight = visibleFiles * height / totalFiles;
|
|
|
|
}
|
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
if (sliderHeight < 7) {
|
|
|
|
sliderHeight = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (totalFiles - visibleFiles <= 0) {
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
pos = _optionSaveFileTop * (height - sliderHeight) / (totalFiles - visibleFiles);
|
|
|
|
}
|
|
|
|
_optionPanel.calcPanelButtonRect(_optionSaveFileSlider, _optionSaveRectTop);
|
|
|
|
_optionSaveRectBottom = _optionSaveRectSlider = _optionSaveRectTop;
|
|
|
|
|
|
|
|
_optionSaveRectTop.bottom = _optionSaveRectTop.top + pos;
|
|
|
|
_optionSaveRectTop.top++;
|
|
|
|
_optionSaveRectTop.right--;
|
|
|
|
|
|
|
|
_optionSaveRectSlider.top = _optionSaveRectTop.bottom;
|
|
|
|
_optionSaveRectSlider.bottom = _optionSaveRectSlider.top + sliderHeight;
|
|
|
|
|
|
|
|
_optionSaveRectBottom.top = _optionSaveRectSlider.bottom;
|
|
|
|
_optionSaveRectBottom.right--;
|
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawPanelText(InterfacePanel *panel, PanelButton *panelButton) {
|
2005-05-29 15:39:35 +00:00
|
|
|
const char *text;
|
|
|
|
int textWidth;
|
|
|
|
Rect rect;
|
2005-07-14 17:46:21 +00:00
|
|
|
Point textPoint;
|
2007-06-13 22:23:12 +00:00
|
|
|
KnownColor textShadowKnownColor = kKnownColorVerbTextShadow;
|
|
|
|
KnownFont textFont = kKnownFontMedium;
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2005-09-02 20:17:52 +00:00
|
|
|
// Button differs for CD version
|
2008-12-21 15:59:05 +00:00
|
|
|
if (panelButton->id == kTextReadingSpeed && _vm->getGameId() == GID_ITE && !(_vm->getFeatures() & GF_ITE_FLOPPY))
|
2005-09-02 20:17:52 +00:00
|
|
|
return;
|
2008-12-21 15:59:05 +00:00
|
|
|
if (panelButton->id == kTextShowDialog && _vm->getFeatures() & GF_ITE_FLOPPY)
|
2005-09-02 20:17:52 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-13 22:23:12 +00:00
|
|
|
text = _vm->getTextString(panelButton->id);
|
|
|
|
textFont = kKnownFontMedium;
|
|
|
|
textShadowKnownColor = kKnownColorVerbTextShadow;
|
|
|
|
} else {
|
2008-08-01 14:03:20 +00:00
|
|
|
if ((panelButton->id < 39 || panelButton->id > 50) && panelButton->id != kTextLoadSavedGame) {
|
2007-06-13 22:23:12 +00:00
|
|
|
// Read non-hardcoded strings from the LUT string table, loaded from the game
|
|
|
|
// data files
|
|
|
|
text = _vm->_script->_mainStrings.getString(IHNMTextStringIdsLUT[panelButton->id]);
|
2008-08-01 14:03:20 +00:00
|
|
|
} else if (panelButton->id == kTextLoadSavedGame) {
|
|
|
|
// a bit of a kludge, but it will do
|
|
|
|
text = _vm->getTextString(52);
|
2007-06-13 22:23:12 +00:00
|
|
|
} else {
|
|
|
|
// Hardcoded strings in IHNM are read from the ITE hardcoded strings
|
|
|
|
text = _vm->getTextString(panelButton->id);
|
|
|
|
}
|
|
|
|
textFont = kKnownFontVerb;
|
|
|
|
textShadowKnownColor = kKnownColorTransparent;
|
|
|
|
}
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
panel->calcPanelButtonRect(panelButton, rect);
|
|
|
|
if (panelButton->xOffset < 0) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2007-05-02 23:27:25 +00:00
|
|
|
textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal);
|
|
|
|
else
|
|
|
|
textWidth = _vm->_font->getStringWidth(kKnownFontVerb, text, 0, kFontNormal);
|
2005-05-29 15:39:35 +00:00
|
|
|
rect.left += 2 + (panel->imageWidth - 1 - textWidth) / 2;
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = rect.left;
|
|
|
|
textPoint.y = rect.top + 1;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
_vm->_font->textDraw(textFont, text, textPoint,
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(textShadowKnownColor), kFontShadow);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Interface::drawOption() {
|
2005-05-28 11:06:55 +00:00
|
|
|
const char *text;
|
|
|
|
int fontHeight;
|
2008-12-06 13:35:27 +00:00
|
|
|
uint idx;
|
2005-05-28 11:06:55 +00:00
|
|
|
int fgColor;
|
|
|
|
int bgColor;
|
|
|
|
Rect rect;
|
|
|
|
Rect rect2;
|
2005-05-23 18:53:36 +00:00
|
|
|
PanelButton *panelButton;
|
2005-07-14 17:46:21 +00:00
|
|
|
Point textPoint;
|
2007-05-06 17:18:11 +00:00
|
|
|
Point point;
|
2007-08-21 18:07:17 +00:00
|
|
|
Point sliderPoint;
|
2007-06-13 19:41:27 +00:00
|
|
|
int spritenum = 0;
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
_optionPanel.getRect(rect);
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _optionPanel.image);
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2008-12-06 13:35:27 +00:00
|
|
|
for (int i = 0; i < _optionPanel.buttonsCount; i++) {
|
2005-05-23 18:53:36 +00:00
|
|
|
panelButton = &_optionPanel.buttons[i];
|
2007-05-06 17:18:11 +00:00
|
|
|
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonOption) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonText(&_optionPanel, panelButton);
|
2007-06-13 19:41:27 +00:00
|
|
|
} else {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonText(&_optionPanel, panelButton, spritenum);
|
2007-06-13 19:41:27 +00:00
|
|
|
spritenum += 2; // 2 sprites per button (lit and unlit)
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-05-28 11:06:55 +00:00
|
|
|
if (panelButton->type == kPanelButtonOptionText) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelText(&_optionPanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-28 11:06:55 +00:00
|
|
|
|
2005-06-10 13:49:43 +00:00
|
|
|
if (_optionSaveRectTop.height() > 0) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(_optionSaveRectTop, kITEColorDarkGrey);
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(_optionSaveRectSlider, kSlider, _optionSaveFileSlider->state > 0);
|
2007-08-21 18:07:17 +00:00
|
|
|
} else {
|
|
|
|
panelButton = &_optionPanel.buttons[0];
|
|
|
|
sliderPoint.x = _optionPanel.x + panelButton->xOffset;
|
|
|
|
sliderPoint.y = _optionSaveRectSlider.top;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_optionPanel.sprites, 0 + _optionSaveFileSlider->state, sliderPoint, 256);
|
2007-08-21 18:07:17 +00:00
|
|
|
|
|
|
|
}
|
2005-05-28 11:06:55 +00:00
|
|
|
|
2005-06-10 13:49:43 +00:00
|
|
|
if (_optionSaveRectBottom.height() > 0) {
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(_optionSaveRectBottom, kITEColorDarkGrey);
|
2005-05-28 11:06:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect);
|
2005-05-29 15:39:35 +00:00
|
|
|
rect.top++;
|
2005-05-28 11:06:55 +00:00
|
|
|
rect2 = rect;
|
2005-11-19 12:41:23 +00:00
|
|
|
fontHeight = _vm->_font->getHeight(kKnownFontSmall);
|
2008-12-06 13:35:27 +00:00
|
|
|
for (uint j = 0; j < _vm->getDisplayInfo().optionSaveFileVisible; j++) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2007-08-18 01:59:18 +00:00
|
|
|
bgColor = kITEColorDarkGrey0C;
|
|
|
|
else
|
2007-12-11 22:40:39 +00:00
|
|
|
bgColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2005-05-28 11:06:55 +00:00
|
|
|
fgColor = kITEColorBrightWhite;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
idx = j + _optionSaveFileTop;
|
|
|
|
if (idx == _optionSaveFileTitleNumber) {
|
|
|
|
SWAP(bgColor, fgColor);
|
|
|
|
}
|
2005-05-31 20:08:46 +00:00
|
|
|
if (idx < _vm->getSaveFilesCount()) {
|
2005-05-28 11:06:55 +00:00
|
|
|
rect2.top = rect.top + j * (fontHeight + 1);
|
|
|
|
rect2.bottom = rect2.top + fontHeight;
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->fillRect(rect2, bgColor);
|
2005-05-31 20:08:46 +00:00
|
|
|
text = _vm->getSaveFile(idx)->name;
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = rect.left + 1;
|
|
|
|
textPoint.y = rect2.top;
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontSmall, text, textPoint, fgColor, 0, kFontNormal);
|
2007-06-17 02:59:56 +00:00
|
|
|
else
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontVerb, text, textPoint, fgColor, 0, kFontNormal);
|
2005-05-28 11:06:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
void Interface::drawQuit() {
|
|
|
|
Rect rect;
|
2005-05-23 18:53:36 +00:00
|
|
|
int i;
|
2005-05-29 15:39:35 +00:00
|
|
|
PanelButton *panelButton;
|
|
|
|
|
|
|
|
_quitPanel.getRect(rect);
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, false);
|
2007-06-13 15:31:45 +00:00
|
|
|
else
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _quitPanel.image);
|
2007-06-13 15:31:45 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
for (i = 0; i < _quitPanel.buttonsCount; i++) {
|
2005-05-29 15:39:35 +00:00
|
|
|
panelButton = &_quitPanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonQuit) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonText(&_quitPanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonQuitText) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelText(&_quitPanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleQuitUpdate(const Point& mousePoint) {
|
|
|
|
bool releasedButton;
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_quitPanel.currentButton = quitHitTest(mousePoint);
|
2005-05-29 15:39:35 +00:00
|
|
|
releasedButton = (_quitPanel.currentButton != NULL) && (_quitPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed());
|
|
|
|
|
|
|
|
if (!_vm->mouseButtonPressed()) {
|
|
|
|
_quitPanel.zeroAllButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (releasedButton) {
|
2005-07-29 17:58:00 +00:00
|
|
|
setQuit(_quitPanel.currentButton);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleQuitClick(const Point& mousePoint) {
|
|
|
|
_quitPanel.currentButton = quitHitTest(mousePoint);
|
|
|
|
|
|
|
|
_quitPanel.zeroAllButtonState();
|
|
|
|
|
|
|
|
if (_quitPanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_quitPanel.currentButton->state = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::setQuit(PanelButton *panelButton) {
|
|
|
|
_quitPanel.currentButton = NULL;
|
|
|
|
switch (panelButton->id) {
|
|
|
|
case kTextCancel:
|
|
|
|
setMode(kPanelOption);
|
|
|
|
break;
|
|
|
|
case kTextQuit:
|
2009-01-02 16:52:38 +00:00
|
|
|
#ifdef ENABLE_IHNM
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getFeatures() & GF_IHNM_DEMO)
|
2007-09-15 12:57:11 +00:00
|
|
|
_vm->_scene->creditsScene(); // display sales info for IHNM demo
|
|
|
|
else
|
2009-01-02 16:52:38 +00:00
|
|
|
#endif
|
2008-07-11 01:09:48 +00:00
|
|
|
_vm->quitGame();
|
2005-05-29 15:39:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::drawLoad() {
|
2005-05-28 11:06:55 +00:00
|
|
|
Rect rect;
|
2005-05-29 15:39:35 +00:00
|
|
|
int i;
|
|
|
|
PanelButton *panelButton;
|
|
|
|
|
|
|
|
_loadPanel.getRect(rect);
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, false);
|
2007-06-17 02:59:56 +00:00
|
|
|
else
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _loadPanel.image);
|
2007-06-17 02:59:56 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
for (i = 0; i < _loadPanel.buttonsCount; i++) {
|
2005-05-29 15:39:35 +00:00
|
|
|
panelButton = &_loadPanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonLoad) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonText(&_loadPanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonLoadText) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelText(&_loadPanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleLoadUpdate(const Point& mousePoint) {
|
|
|
|
bool releasedButton;
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_loadPanel.currentButton = loadHitTest(mousePoint);
|
2005-05-29 15:39:35 +00:00
|
|
|
releasedButton = (_loadPanel.currentButton != NULL) && (_loadPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed());
|
|
|
|
|
|
|
|
if (!_vm->mouseButtonPressed()) {
|
|
|
|
_loadPanel.zeroAllButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (releasedButton) {
|
2005-07-29 17:58:00 +00:00
|
|
|
setLoad(_loadPanel.currentButton);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleLoadClick(const Point& mousePoint) {
|
|
|
|
_loadPanel.currentButton = loadHitTest(mousePoint);
|
|
|
|
|
|
|
|
_loadPanel.zeroAllButtonState();
|
|
|
|
|
|
|
|
if (_loadPanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_loadPanel.currentButton->state = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::setLoad(PanelButton *panelButton) {
|
|
|
|
_loadPanel.currentButton = NULL;
|
|
|
|
switch (panelButton->id) {
|
2005-07-29 17:58:00 +00:00
|
|
|
case kTextOK:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-08-01 14:03:20 +00:00
|
|
|
setMode(kPanelMain);
|
|
|
|
} else {
|
|
|
|
if (_vm->getSaveFilesCount() > 0) {
|
|
|
|
if (_vm->isSaveListFull() || (_optionSaveFileTitleNumber > 0)) {
|
|
|
|
debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
|
|
|
|
setMode(kPanelMain);
|
|
|
|
_vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber));
|
2008-08-16 22:30:19 +00:00
|
|
|
_vm->syncSoundSettings();
|
2008-08-01 14:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kTextCancel:
|
|
|
|
// IHNM only
|
|
|
|
setMode(kPanelOption);
|
2005-05-29 15:39:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
void Interface::processStatusTextInput(Common::KeyState keystate) {
|
2005-06-19 14:06:20 +00:00
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
switch (keystate.keycode) {
|
|
|
|
case Common::KEYCODE_ESCAPE:
|
2005-06-19 14:06:20 +00:00
|
|
|
_statusTextInputState = kStatusTextInputAborted;
|
|
|
|
_statusTextInput = false;
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
|
|
|
break;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_RETURN:
|
2005-06-19 14:06:20 +00:00
|
|
|
_statusTextInputState = kStatusTextInputEntered;
|
|
|
|
_statusTextInput = false;
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
|
|
|
|
break;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_BACKSPACE:
|
2005-06-19 14:06:20 +00:00
|
|
|
if (_statusTextInputPos == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_statusTextInputPos--;
|
|
|
|
_statusTextInputString[_statusTextInputPos] = 0;
|
|
|
|
default:
|
|
|
|
if (_statusTextInputPos >= STATUS_TEXT_INPUT_MAX) {
|
|
|
|
break;
|
|
|
|
}
|
2007-09-11 09:19:23 +00:00
|
|
|
if (isalnum(keystate.ascii) || (keystate.ascii == ' ')) {
|
|
|
|
_statusTextInputString[_statusTextInputPos++] = keystate.ascii;
|
2005-06-19 14:06:20 +00:00
|
|
|
_statusTextInputString[_statusTextInputPos] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setStatusText(_statusTextInputString);
|
|
|
|
}
|
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
bool Interface::processTextInput(Common::KeyState keystate) {
|
2005-05-29 15:39:35 +00:00
|
|
|
char ch[2];
|
|
|
|
char tempString[SAVE_TITLE_SIZE];
|
|
|
|
uint tempWidth;
|
|
|
|
memset(tempString, 0, SAVE_TITLE_SIZE);
|
|
|
|
ch[1] = 0;
|
2007-08-26 15:57:30 +00:00
|
|
|
// IHNM has a smaller save title size than ITE. We only limit the save title size during text input
|
|
|
|
// in IHNM, to preserve backwards compatibility with older save games
|
2008-12-21 15:59:05 +00:00
|
|
|
uint save_title_size = _vm->getGameId() == GID_ITE ? SAVE_TITLE_SIZE : IHNM_SAVE_TITLE_SIZE;
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2007-09-11 09:19:23 +00:00
|
|
|
switch (keystate.keycode) {
|
|
|
|
case Common::KEYCODE_RETURN:
|
2005-07-12 18:31:48 +00:00
|
|
|
return false;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_ESCAPE:
|
2005-05-31 20:08:46 +00:00
|
|
|
_textInput = false;
|
|
|
|
break;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_BACKSPACE:
|
2005-05-29 20:57:45 +00:00
|
|
|
if (_textInputPos <= 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_textInputPos--;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_DELETE:
|
2005-05-29 20:57:45 +00:00
|
|
|
if (_textInputPos <= _textInputStringLength) {
|
|
|
|
if (_textInputPos != 1) {
|
2005-07-29 17:58:00 +00:00
|
|
|
strncpy(tempString, _textInputString, _textInputPos - 1);
|
2005-05-29 20:57:45 +00:00
|
|
|
}
|
|
|
|
if (_textInputPos != _textInputStringLength) {
|
|
|
|
strncat(tempString, &_textInputString[_textInputPos], _textInputStringLength - _textInputPos);
|
|
|
|
}
|
|
|
|
strcpy(_textInputString, tempString);
|
|
|
|
_textInputStringLength = strlen(_textInputString);
|
|
|
|
}
|
|
|
|
break;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_LEFT:
|
2005-05-29 20:57:45 +00:00
|
|
|
if (_textInputPos > 1) {
|
|
|
|
_textInputPos--;
|
|
|
|
}
|
|
|
|
break;
|
2007-09-11 09:19:23 +00:00
|
|
|
case Common::KEYCODE_RIGHT:
|
2005-05-29 20:57:45 +00:00
|
|
|
if (_textInputPos <= _textInputStringLength) {
|
|
|
|
_textInputPos++;
|
|
|
|
}
|
|
|
|
break;
|
2008-01-09 21:26:38 +00:00
|
|
|
case Common::KEYCODE_HOME:
|
|
|
|
_textInputPos = 1;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_END:
|
|
|
|
_textInputPos = _textInputStringLength + 1;
|
|
|
|
break;
|
2005-05-29 20:57:45 +00:00
|
|
|
default:
|
2008-11-29 18:01:16 +00:00
|
|
|
if (((keystate.ascii <= 255) && (isalnum(keystate.ascii))) || (keystate.ascii == ' ') ||
|
2007-09-11 09:19:23 +00:00
|
|
|
(keystate.ascii == '-') || (keystate.ascii == '_')) {
|
2007-08-25 17:10:31 +00:00
|
|
|
if (_textInputStringLength < save_title_size - 1) {
|
2007-09-11 09:19:23 +00:00
|
|
|
ch[0] = keystate.ascii;
|
2005-11-03 18:20:12 +00:00
|
|
|
tempWidth = _vm->_font->getStringWidth(kKnownFontSmall, ch, 0, kFontNormal);
|
|
|
|
tempWidth += _vm->_font->getStringWidth(kKnownFontSmall, _textInputString, 0, kFontNormal);
|
2005-05-29 20:57:45 +00:00
|
|
|
if (tempWidth > _textInputMaxWidth) {
|
2007-09-11 09:19:23 +00:00
|
|
|
break;
|
2005-05-29 20:57:45 +00:00
|
|
|
}
|
|
|
|
if (_textInputPos != 1) {
|
|
|
|
strncpy(tempString, _textInputString, _textInputPos - 1);
|
|
|
|
strcat(tempString, ch);
|
|
|
|
}
|
|
|
|
if ((_textInputStringLength == 0) || (_textInputPos == 1)) {
|
|
|
|
strcpy(tempString, ch);
|
|
|
|
}
|
|
|
|
if ((_textInputStringLength != 0) && (_textInputPos != _textInputStringLength)) {
|
|
|
|
strncat(tempString, &_textInputString[_textInputPos - 1], _textInputStringLength - _textInputPos + 1);
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-29 20:57:45 +00:00
|
|
|
strcpy(_textInputString, tempString);
|
|
|
|
_textInputStringLength = strlen(_textInputString);
|
|
|
|
_textInputPos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
2005-07-12 18:31:48 +00:00
|
|
|
return true;
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawTextInput(InterfacePanel *panel, PanelButton *panelButton) {
|
2005-07-14 17:46:21 +00:00
|
|
|
Point textPoint;
|
2005-05-29 15:39:35 +00:00
|
|
|
Rect rect;
|
|
|
|
char ch[2];
|
|
|
|
int fgColor;
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
ch[1] = 0;
|
|
|
|
panel->calcPanelButtonRect(panelButton, rect);
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kEdit, _textInput);
|
2005-07-29 17:58:00 +00:00
|
|
|
rect.left += 4;
|
2005-05-29 15:39:35 +00:00
|
|
|
rect.top += 4;
|
2005-11-19 12:41:23 +00:00
|
|
|
rect.setHeight(_vm->_font->getHeight(kKnownFontSmall));
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
i = 0;
|
2005-05-29 15:39:35 +00:00
|
|
|
while ((ch[0] = _textInputString[i++]) != 0) {
|
2005-11-03 18:20:12 +00:00
|
|
|
rect.setWidth(_vm->_font->getStringWidth(kKnownFontSmall, ch, 0, kFontNormal));
|
2005-05-29 15:39:35 +00:00
|
|
|
if ((i == _textInputPos) && _textInput) {
|
2007-08-18 01:59:18 +00:00
|
|
|
fgColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite));
|
2005-05-29 15:39:35 +00:00
|
|
|
} else {
|
2007-08-18 01:59:18 +00:00
|
|
|
fgColor = _vm->KnownColor2ColorId(kKnownColorWhite);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = rect.left;
|
|
|
|
textPoint.y = rect.top + 1;
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontSmall, ch, textPoint, fgColor, 0, kFontNormal);
|
2005-05-29 15:39:35 +00:00
|
|
|
rect.left += rect.width();
|
|
|
|
}
|
|
|
|
if (_textInput && (_textInputPos >= i)) {
|
|
|
|
ch[0] = ' ';
|
2005-11-03 18:20:12 +00:00
|
|
|
rect.setWidth(_vm->_font->getStringWidth(kKnownFontSmall, ch, 0, kFontNormal));
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite));
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::drawSave() {
|
|
|
|
Rect rect;
|
|
|
|
int i;
|
|
|
|
PanelButton *panelButton;
|
|
|
|
|
|
|
|
_savePanel.getRect(rect);
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, false);
|
2007-06-17 02:59:56 +00:00
|
|
|
else
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, _savePanel.image);
|
2007-06-17 02:59:56 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
for (i = 0; i < _savePanel.buttonsCount; i++) {
|
2005-05-29 15:39:35 +00:00
|
|
|
panelButton = &_savePanel.buttons[i];
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonSave) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonText(&_savePanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-06-10 13:49:43 +00:00
|
|
|
if (panelButton->type == kPanelButtonSaveText) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelText(&_savePanel, panelButton);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
drawTextInput(&_savePanel, _saveEdit);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
2005-10-17 03:28:21 +00:00
|
|
|
void Interface::drawProtect() {
|
|
|
|
Rect rect;
|
|
|
|
int i;
|
|
|
|
PanelButton *panelButton;
|
|
|
|
|
|
|
|
_protectPanel.getRect(rect);
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, false);
|
2005-10-17 03:28:21 +00:00
|
|
|
|
|
|
|
for (i = 0; i < _protectPanel.buttonsCount; i++) {
|
|
|
|
panelButton = &_protectPanel.buttons[i];
|
|
|
|
if (panelButton->type == kPanelButtonProtectText) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelText(&_protectPanel, panelButton);
|
2005-10-17 03:28:21 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-06 14:24:40 +00:00
|
|
|
drawTextInput(&_protectPanel, _protectEdit);
|
2005-10-17 03:28:21 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
void Interface::handleSaveUpdate(const Point& mousePoint) {
|
|
|
|
bool releasedButton;
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_savePanel.currentButton = saveHitTest(mousePoint);
|
2005-05-31 20:08:46 +00:00
|
|
|
|
|
|
|
validateSaveButtons();
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
releasedButton = (_savePanel.currentButton != NULL) &&
|
2005-05-29 15:39:35 +00:00
|
|
|
(_savePanel.currentButton->state > 0) && (!_vm->mouseButtonPressed());
|
|
|
|
|
|
|
|
if (!_vm->mouseButtonPressed()) {
|
|
|
|
_savePanel.zeroAllButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (releasedButton) {
|
2005-07-29 17:58:00 +00:00
|
|
|
setSave(_savePanel.currentButton);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleSaveClick(const Point& mousePoint) {
|
|
|
|
_savePanel.currentButton = saveHitTest(mousePoint);
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-31 20:08:46 +00:00
|
|
|
validateSaveButtons();
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_savePanel.zeroAllButtonState();
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
if (_savePanel.currentButton == NULL) {
|
|
|
|
_textInput = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_savePanel.currentButton->state = 1;
|
|
|
|
if (_savePanel.currentButton == _saveEdit) {
|
|
|
|
_textInput = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::setSave(PanelButton *panelButton) {
|
2005-05-31 20:08:46 +00:00
|
|
|
_savePanel.currentButton = NULL;
|
|
|
|
uint titleNumber;
|
|
|
|
char *fileName;
|
2005-05-29 15:39:35 +00:00
|
|
|
switch (panelButton->id) {
|
2005-05-31 20:08:46 +00:00
|
|
|
case kTextSave:
|
|
|
|
if (_textInputStringLength == 0 ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) {
|
|
|
|
if (_vm->locateSaveFile(_textInputString, titleNumber)) {
|
|
|
|
fileName = _vm->calcSaveFileName(_vm->getSaveFile(titleNumber)->slotNumber);
|
|
|
|
_vm->save(fileName, _textInputString);
|
|
|
|
_optionSaveFileTitleNumber = titleNumber;
|
|
|
|
} else {
|
|
|
|
fileName = _vm->calcSaveFileName(_vm->getNewSaveSlotNumber());
|
|
|
|
_vm->save(fileName, _textInputString);
|
|
|
|
_vm->fillSaveList();
|
|
|
|
calcOptionSaveSlider();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fileName = _vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
|
|
|
|
_vm->save(fileName, _textInputString);
|
|
|
|
}
|
2008-12-25 20:53:59 +00:00
|
|
|
_vm->getTimerManager()->removeTimerProc(&saveReminderCallback);
|
|
|
|
_vm->getTimerManager()->installTimerProc(&saveReminderCallback, TIMETOSAVE, this);
|
2008-09-24 22:44:01 +00:00
|
|
|
setSaveReminderState(1);
|
|
|
|
|
2005-08-11 16:13:10 +00:00
|
|
|
_textInput = false;
|
2005-05-31 20:08:46 +00:00
|
|
|
setMode(kPanelOption);
|
|
|
|
break;
|
|
|
|
case kTextCancel:
|
2005-08-11 16:13:10 +00:00
|
|
|
_textInput = false;
|
2005-05-31 20:08:46 +00:00
|
|
|
setMode(kPanelOption);
|
2005-05-29 15:39:35 +00:00
|
|
|
break;
|
2005-05-31 20:08:46 +00:00
|
|
|
}
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleOptionUpdate(const Point& mousePoint) {
|
|
|
|
int16 mouseY;
|
2005-07-29 17:58:00 +00:00
|
|
|
Rect rect;
|
2005-05-31 20:08:46 +00:00
|
|
|
int totalFiles = _vm->getSaveFilesCount();
|
2005-07-29 17:58:00 +00:00
|
|
|
int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible;
|
2005-05-29 15:39:35 +00:00
|
|
|
bool releasedButton;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
if (_vm->mouseButtonPressed()) {
|
|
|
|
if (_optionSaveFileSlider->state > 0) {
|
|
|
|
_optionPanel.calcPanelButtonRect(_optionSaveFileSlider, rect);
|
|
|
|
|
|
|
|
mouseY = mousePoint.y - rect.top -_optionSaveFileMouseOff;
|
|
|
|
|
|
|
|
if (totalFiles - visibleFiles <= 0) {
|
|
|
|
_optionSaveFileTop = 0;
|
|
|
|
} else {
|
|
|
|
_optionSaveFileTop = mouseY * (totalFiles - visibleFiles) /
|
|
|
|
(_optionSaveFileSlider->height - _optionSaveRectSlider.height());
|
|
|
|
}
|
|
|
|
|
2007-12-20 19:00:10 +00:00
|
|
|
_optionSaveFileTop = CLIP<uint>(_optionSaveFileTop, 0, _vm->getSaveFilesCount() - _vm->getDisplayInfo().optionSaveFileVisible);
|
2005-05-28 11:06:55 +00:00
|
|
|
calcOptionSaveSlider();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
_optionPanel.currentButton = optionHitTest(mousePoint);
|
2005-05-31 20:08:46 +00:00
|
|
|
|
|
|
|
validateOptionButtons();
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
releasedButton = (_optionPanel.currentButton != NULL) && (_optionPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed());
|
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
if (!_vm->mouseButtonPressed()) {
|
2005-05-29 15:39:35 +00:00
|
|
|
_optionPanel.zeroAllButtonState();
|
2005-05-23 18:53:36 +00:00
|
|
|
}
|
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
if (releasedButton) {
|
2005-07-29 17:58:00 +00:00
|
|
|
setOption(_optionPanel.currentButton);
|
2005-05-23 18:53:36 +00:00
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::handleOptionClick(const Point& mousePoint) {
|
2005-05-28 11:06:55 +00:00
|
|
|
Rect rect;
|
2005-05-22 11:59:22 +00:00
|
|
|
_optionPanel.currentButton = optionHitTest(mousePoint);
|
|
|
|
|
2005-05-31 20:08:46 +00:00
|
|
|
validateOptionButtons();
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
_optionPanel.zeroAllButtonState();
|
2005-05-23 18:53:36 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
if (_optionPanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
|
|
|
if (_optionPanel.currentButton == _optionSaveFileSlider) {
|
2005-05-28 11:06:55 +00:00
|
|
|
if ((_optionSaveRectTop.height() > 0) && (mousePoint.y < _optionSaveRectTop.bottom)) {
|
|
|
|
_optionSaveFileTop -= _vm->getDisplayInfo().optionSaveFileVisible;
|
|
|
|
} else {
|
|
|
|
if ((_optionSaveRectBottom.height() > 0) && (mousePoint.y >= _optionSaveRectBottom.top)) {
|
|
|
|
_optionSaveFileTop += _vm->getDisplayInfo().optionSaveFileVisible;
|
|
|
|
} else {
|
2005-05-31 20:08:46 +00:00
|
|
|
if (_vm->getDisplayInfo().optionSaveFileVisible < _vm->getSaveFilesCount()) {
|
2005-05-28 11:06:55 +00:00
|
|
|
_optionSaveFileMouseOff = mousePoint.y - _optionSaveRectSlider.top;
|
|
|
|
_optionPanel.currentButton->state = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2007-12-20 19:00:10 +00:00
|
|
|
_optionSaveFileTop = CLIP<uint>(_optionSaveFileTop, 0, _vm->getSaveFilesCount() - _vm->getDisplayInfo().optionSaveFileVisible);
|
2005-05-28 11:06:55 +00:00
|
|
|
calcOptionSaveSlider();
|
|
|
|
} else {
|
|
|
|
if (_optionPanel.currentButton == _optionSaveFilePanel) {
|
|
|
|
_optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect);
|
2005-11-19 12:41:23 +00:00
|
|
|
_optionSaveFileTitleNumber = (mousePoint.y - rect.top) / (_vm->_font->getHeight(kKnownFontSmall) + 1);
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
if (_optionSaveFileTitleNumber >= _vm->getDisplayInfo().optionSaveFileVisible) {
|
|
|
|
_optionSaveFileTitleNumber = _vm->getDisplayInfo().optionSaveFileVisible - 1;
|
|
|
|
}
|
|
|
|
_optionSaveFileTitleNumber += _optionSaveFileTop;
|
2005-05-31 20:08:46 +00:00
|
|
|
if (_optionSaveFileTitleNumber >= _vm->getSaveFilesCount()) {
|
|
|
|
_optionSaveFileTitleNumber = _vm->getSaveFilesCount() - 1;
|
2005-05-28 11:06:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_optionPanel.currentButton->state = 1;
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
void Interface::handleChapterSelectionUpdate(const Point& mousePoint) {
|
2005-10-09 01:20:46 +00:00
|
|
|
uint16 objectId;
|
2007-08-26 03:22:52 +00:00
|
|
|
int hitZoneIndex;
|
|
|
|
const HitZone * hitZone;
|
2005-10-09 01:18:26 +00:00
|
|
|
|
|
|
|
// FIXME: Original handled more object types here.
|
|
|
|
|
2005-10-09 01:20:46 +00:00
|
|
|
objectId = _vm->_actor->hitTest(mousePoint, true);
|
2005-10-09 01:18:26 +00:00
|
|
|
|
2007-08-26 03:22:52 +00:00
|
|
|
if (objectId == ID_NOTHING) {
|
|
|
|
hitZoneIndex = _vm->_scene->_objectMap->hitTest(mousePoint);
|
|
|
|
|
|
|
|
if ((hitZoneIndex != -1)) {
|
|
|
|
hitZone = _vm->_scene->_objectMap->getHitZone(hitZoneIndex);
|
|
|
|
objectId = hitZone->getHitZoneId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-09 01:18:26 +00:00
|
|
|
if (objectId != _vm->_script->_pointerObject) {
|
|
|
|
_vm->_script->_pointerObject = objectId;
|
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::handleChapterSelectionClick(const Point& mousePoint) {
|
|
|
|
int obj = _vm->_script->_pointerObject;
|
|
|
|
|
|
|
|
_vm->_actor->abortSpeech();
|
|
|
|
|
|
|
|
if (obj) {
|
|
|
|
int script = 0;
|
|
|
|
HitZone *hitZone;
|
|
|
|
ActorData *a;
|
|
|
|
ObjectData *o;
|
2005-08-10 14:11:22 +00:00
|
|
|
Event event;
|
2005-08-10 13:56:51 +00:00
|
|
|
|
|
|
|
switch (objectTypeId(obj)) {
|
|
|
|
case kGameObjectHitZone:
|
2007-08-26 03:22:52 +00:00
|
|
|
hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(obj));
|
2007-06-06 16:37:10 +00:00
|
|
|
|
|
|
|
if (hitZone == NULL)
|
|
|
|
return;
|
|
|
|
|
2007-08-26 03:22:52 +00:00
|
|
|
if (hitZone->getFlags() & kHitZoneEnabled)
|
2005-08-10 13:56:51 +00:00
|
|
|
script = hitZone->getScriptNumber();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kGameObjectActor:
|
|
|
|
a = _vm->_actor->getActor(obj);
|
2005-08-10 14:53:17 +00:00
|
|
|
script = a->_scriptEntrypointNumber;
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kGameObjectObject:
|
|
|
|
o = _vm->_actor->getObj(obj);
|
2005-08-10 14:53:17 +00:00
|
|
|
script = o->_scriptEntrypointNumber;
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (script > 0) {
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kScriptEvent;
|
|
|
|
event.op = kEventExecNonBlocking;
|
2005-08-10 13:56:51 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.param = _vm->_scene->getScriptModuleNumber();
|
|
|
|
event.param2 = script;
|
2006-01-13 20:20:01 +00:00
|
|
|
event.param3 = _vm->_script->getVerbType(kVerbUse); // Action
|
2005-08-10 13:56:51 +00:00
|
|
|
event.param4 = obj; // Object
|
|
|
|
event.param5 = 0; // With Object
|
|
|
|
event.param6 = obj; // Actor
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
|
|
|
|
void Interface::setOption(PanelButton *panelButton) {
|
2005-05-29 15:39:35 +00:00
|
|
|
_optionPanel.currentButton = NULL;
|
2005-05-28 11:06:55 +00:00
|
|
|
switch (panelButton->id) {
|
2005-09-02 20:17:52 +00:00
|
|
|
case kTextContinuePlaying:
|
|
|
|
ConfMan.flushToDisk();
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-16 08:27:53 +00:00
|
|
|
setMode(kPanelMain);
|
2007-07-30 23:37:18 +00:00
|
|
|
} else {
|
|
|
|
if (_vm->_scene->currentChapterNumber() == 8) {
|
|
|
|
setMode(kPanelChapterSelection);
|
2007-08-24 12:05:05 +00:00
|
|
|
} else if (_vm->_scene->isNonInteractiveIHNMDemoPart()) {
|
|
|
|
setMode(kPanelNull);
|
2007-07-30 23:37:18 +00:00
|
|
|
} else {
|
|
|
|
setMode(kPanelMain);
|
|
|
|
}
|
|
|
|
}
|
2005-09-02 20:17:52 +00:00
|
|
|
break;
|
|
|
|
case kTextQuitGame:
|
|
|
|
setMode(kPanelQuit);
|
|
|
|
break;
|
|
|
|
case kTextLoad:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-08-01 14:03:20 +00:00
|
|
|
if (_vm->getSaveFilesCount() > 0) {
|
|
|
|
if (_vm->isSaveListFull() || (_optionSaveFileTitleNumber > 0)) {
|
|
|
|
debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
|
|
|
|
setMode(kPanelMain);
|
|
|
|
_vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber));
|
2008-08-16 22:30:19 +00:00
|
|
|
_vm->syncSoundSettings();
|
2008-08-01 14:03:20 +00:00
|
|
|
}
|
2005-05-31 20:08:46 +00:00
|
|
|
}
|
2008-08-01 14:03:20 +00:00
|
|
|
} else {
|
|
|
|
setMode(kPanelLoad);
|
2005-09-02 20:17:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kTextSave:
|
2007-08-24 12:05:05 +00:00
|
|
|
// Disallow saving in the non-interactive part of the IHNM demo (original demo didn't support saving at all)
|
|
|
|
if (_vm->_scene->isNonInteractiveIHNMDemoPart())
|
|
|
|
return;
|
2007-07-30 23:37:18 +00:00
|
|
|
|
2005-09-02 20:17:52 +00:00
|
|
|
if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) {
|
|
|
|
_textInputString[0] = 0;
|
|
|
|
} else {
|
|
|
|
strcpy(_textInputString, _vm->getSaveFile(_optionSaveFileTitleNumber)->name);
|
|
|
|
}
|
|
|
|
setMode(kPanelSave);
|
|
|
|
break;
|
|
|
|
case kTextReadingSpeed:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE && !(_vm->getFeatures() & GF_ITE_FLOPPY)) {
|
2005-09-02 20:17:52 +00:00
|
|
|
_vm->_subtitlesEnabled = !_vm->_subtitlesEnabled;
|
2006-04-16 19:23:14 +00:00
|
|
|
ConfMan.setBool("subtitles", _vm->_subtitlesEnabled);
|
2005-09-02 20:17:52 +00:00
|
|
|
} else {
|
|
|
|
_vm->_readingSpeed = (_vm->_readingSpeed + 1) % 4;
|
2006-06-11 20:30:43 +00:00
|
|
|
_vm->setTalkspeed(_vm->_readingSpeed);
|
2005-09-02 20:17:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kTextMusic:
|
2008-09-05 13:02:03 +00:00
|
|
|
_vm->_musicVolume = _vm->_musicVolume + 25;
|
|
|
|
if (_vm->_musicVolume > 255) _vm->_musicVolume = 0;
|
|
|
|
_vm->_music->setVolume(_vm->_musicVolume, 1);
|
|
|
|
ConfMan.setInt("music_volume", _vm->_musicVolume);
|
2005-09-02 20:17:52 +00:00
|
|
|
break;
|
|
|
|
case kTextSound:
|
2008-09-05 13:02:03 +00:00
|
|
|
_vm->_soundVolume = _vm->_soundVolume + 25;
|
|
|
|
if (_vm->_soundVolume > 255) _vm->_soundVolume = 0;
|
2008-12-19 12:03:22 +00:00
|
|
|
ConfMan.setInt("sfx_volume", _vm->_soundVolume);
|
2008-07-21 19:15:28 +00:00
|
|
|
_vm->_sound->setVolume();
|
2005-09-02 20:17:52 +00:00
|
|
|
break;
|
2007-06-13 19:41:27 +00:00
|
|
|
case kTextVoices:
|
2007-12-23 02:33:58 +00:00
|
|
|
if (_vm->_voiceFilesExist) {
|
|
|
|
if (_vm->_subtitlesEnabled && _vm->_voicesEnabled) { // Both
|
|
|
|
_vm->_subtitlesEnabled = false; // Set it to "Audio"
|
|
|
|
_vm->_voicesEnabled = true; // Not necessary, just for completeness
|
|
|
|
} else if (!_vm->_subtitlesEnabled && _vm->_voicesEnabled) {
|
|
|
|
_vm->_subtitlesEnabled = true; // Set it to "Text"
|
|
|
|
_vm->_voicesEnabled = false;
|
|
|
|
} else if (_vm->_subtitlesEnabled && !_vm->_voicesEnabled) {
|
|
|
|
_vm->_subtitlesEnabled = true; // Set it to "Both"
|
|
|
|
_vm->_voicesEnabled = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_vm->_subtitlesEnabled = true; // Set it to "Text"
|
2007-06-13 19:41:27 +00:00
|
|
|
_vm->_voicesEnabled = false;
|
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-09-05 13:02:03 +00:00
|
|
|
_vm->_speechVolume = _vm->_speechVolume + 25;
|
|
|
|
if (_vm->_speechVolume > 255) _vm->_speechVolume = 0;
|
|
|
|
ConfMan.setInt("speech_volume", _vm->_speechVolume);
|
2008-07-21 19:15:28 +00:00
|
|
|
_vm->_sound->setVolume();
|
2007-06-13 19:41:27 +00:00
|
|
|
|
|
|
|
ConfMan.setBool("subtitles", _vm->_subtitlesEnabled);
|
|
|
|
ConfMan.setBool("voices", _vm->_voicesEnabled);
|
|
|
|
break;
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::update(const Point& mousePoint, int updateFlag) {
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-08-11 16:13:10 +00:00
|
|
|
if (!_active && _panelMode == kPanelNull && (updateFlag & UPDATE_MOUSECLICK))
|
|
|
|
_vm->_actor->abortSpeech();
|
|
|
|
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->_scene->isInIntro() || _fadeMode == kFadeOut || !_active) {
|
2007-07-31 00:18:45 +00:00
|
|
|
// When opening the psychic profile, or the options screen in the non-interactive part of the IHNM demo,
|
|
|
|
// the interface is locked (_active is false)
|
|
|
|
// Don't return in those cases, so that mouse actions can be processed
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-07-30 14:22:53 +00:00
|
|
|
return;
|
2007-10-27 17:55:50 +00:00
|
|
|
} else {
|
|
|
|
if (_panelMode == kPanelPlacard && (updateFlag & UPDATE_MOUSECLICK)) {
|
|
|
|
// the psychic profile or the special screen in IHNM demo is open, don't return
|
|
|
|
} else if (_panelMode == kPanelOption || _panelMode == kPanelQuit) {
|
|
|
|
// options/quit panel is open, set interface to active and don't return
|
|
|
|
_vm->_actor->abortSpeech(); // abort any speech being played
|
|
|
|
_active = true;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-19 14:06:20 +00:00
|
|
|
if (_statusTextInput) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
switch (_panelMode) {
|
|
|
|
case kPanelMain:
|
2005-01-15 23:46:43 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
2005-10-08 15:20:11 +00:00
|
|
|
bool lastWasPlayfield = _lastMousePoint.y < _vm->_scene->getHeight();
|
|
|
|
if (mousePoint.y < _vm->_scene->getHeight()) {
|
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-10-08 15:20:11 +00:00
|
|
|
if (mousePoint.y < _vm->_scene->getHeight()) {
|
2005-07-29 17:58:00 +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-08-10 13:56:51 +00:00
|
|
|
break;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelConverse:
|
2005-04-18 20:03:14 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
handleConverseUpdate(mousePoint);
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleConverseClick(mousePoint);
|
|
|
|
}
|
2005-06-19 23:41:40 +00:00
|
|
|
if (updateFlag & UPDATE_WHEELUP) {
|
|
|
|
converseChangePos(-1);
|
|
|
|
}
|
|
|
|
if (updateFlag & UPDATE_WHEELDOWN) {
|
|
|
|
converseChangePos(1);
|
|
|
|
}
|
2005-05-31 01:03:13 +00:00
|
|
|
|
2008-12-24 09:59:18 +00:00
|
|
|
if (_vm->_scene->isITEPuzzleScene()) {
|
2005-05-31 01:03:13 +00:00
|
|
|
_vm->_puzzle->handleClick(mousePoint);
|
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-04-18 20:03:14 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelOption:
|
2005-05-22 11:59:22 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
handleOptionUpdate(mousePoint);
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleOptionClick(mousePoint);
|
|
|
|
}
|
2005-06-19 23:41:40 +00:00
|
|
|
if (updateFlag & UPDATE_WHEELUP) {
|
|
|
|
if (_optionSaveFileTop)
|
|
|
|
_optionSaveFileTop--;
|
|
|
|
calcOptionSaveSlider();
|
|
|
|
}
|
|
|
|
if (updateFlag & UPDATE_WHEELDOWN) {
|
|
|
|
if (_optionSaveFileTop < _vm->getSaveFilesCount() - _vm->getDisplayInfo().optionSaveFileVisible)
|
|
|
|
_optionSaveFileTop++;
|
|
|
|
calcOptionSaveSlider();
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelQuit:
|
2005-05-29 15:39:35 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
handleQuitUpdate(mousePoint);
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleQuitClick(mousePoint);
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelLoad:
|
2005-05-29 15:39:35 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
|
|
|
|
handleLoadUpdate(mousePoint);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleLoadClick(mousePoint);
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-05-29 15:39:35 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelSave:
|
2005-05-29 15:39:35 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
|
|
|
|
handleSaveUpdate(mousePoint);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
handleSaveClick(mousePoint);
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelMap:
|
2005-07-03 20:02:56 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSECLICK)
|
|
|
|
mapPanelClean();
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
2005-07-03 20:02:56 +00:00
|
|
|
|
2005-08-10 13:56:51 +00:00
|
|
|
case kPanelSceneSubstitute:
|
2005-07-29 16:37:06 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
2005-07-29 17:42:33 +00:00
|
|
|
_vm->_render->clearFlag(RF_DEMO_SUBST);
|
2005-07-29 16:37:06 +00:00
|
|
|
_vm->_gfx->setPalette(_mapSavedPal);
|
|
|
|
setMode(kPanelMain);
|
2005-07-29 17:42:33 +00:00
|
|
|
_vm->_script->setNoPendingVerb();
|
2005-07-29 16:37:06 +00:00
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelChapterSelection:
|
|
|
|
if (updateFlag & UPDATE_MOUSEMOVE) {
|
|
|
|
handleChapterSelectionUpdate(mousePoint);
|
|
|
|
} else {
|
2007-06-16 19:11:55 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
|
|
|
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);
|
|
|
|
else
|
|
|
|
handleChapterSelectionClick(mousePoint);
|
|
|
|
}
|
2005-08-10 13:56:51 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-10-17 03:28:21 +00:00
|
|
|
|
|
|
|
case kPanelProtect:
|
|
|
|
// No mouse interaction
|
|
|
|
break;
|
|
|
|
|
2007-07-30 14:22:53 +00:00
|
|
|
case kPanelPlacard:
|
2009-01-02 16:52:38 +00:00
|
|
|
#ifdef ENABLE_IHNM
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM) {
|
2007-07-30 14:22:53 +00:00
|
|
|
// Any mouse click here returns the user back to the game
|
2007-08-02 14:43:10 +00:00
|
|
|
if (updateFlag & UPDATE_MOUSECLICK) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (!(_vm->getFeatures() & GF_IHNM_DEMO)) {
|
2007-08-02 14:43:10 +00:00
|
|
|
_vm->_scene->clearPsychicProfile();
|
|
|
|
} else {
|
|
|
|
setMode(kPanelConverse);
|
|
|
|
_vm->_scene->_textList.clear();
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeDelay);
|
|
|
|
}
|
|
|
|
}
|
2007-07-30 14:22:53 +00:00
|
|
|
}
|
2009-01-02 16:52:38 +00:00
|
|
|
#endif
|
2007-07-30 14:22:53 +00:00
|
|
|
break;
|
2007-07-30 23:37:18 +00:00
|
|
|
|
|
|
|
case kPanelNull:
|
2007-08-24 12:05:05 +00:00
|
|
|
if (_vm->_scene->isNonInteractiveIHNMDemoPart() && (updateFlag & UPDATE_MOUSECLICK))
|
|
|
|
_vm->_scene->showIHNMDemoSpecialScreen();
|
2007-07-30 23:37:18 +00:00
|
|
|
break;
|
2005-07-29 16:37:06 +00:00
|
|
|
}
|
|
|
|
|
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() {
|
2004-10-04 23:09:38 +00:00
|
|
|
Rect rect;
|
2005-07-14 17:46:21 +00:00
|
|
|
Point textPoint;
|
|
|
|
int stringWidth;
|
2005-01-19 11:29:29 +00:00
|
|
|
int color;
|
2007-12-11 22:40:39 +00:00
|
|
|
// The default colors in the Spanish version of IHNM are shifted by one
|
|
|
|
// Fixes bug #1848016 - "IHNM: Wrong Subtitles Color (Spanish)"
|
2008-12-21 15:59:05 +00:00
|
|
|
int offset = (_vm->getLanguage() == Common::ES_ESP) ? 1 : 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-05-11 13:10:13 +00:00
|
|
|
// Disable the status text in IHNM when the chapter is 8
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_IHNM && _vm->_scene->currentChapterNumber() == 8)
|
2005-10-11 02:51:17 +00:00
|
|
|
return;
|
|
|
|
|
2007-08-17 06:08:18 +00:00
|
|
|
// Don't draw the status bar while fading out
|
|
|
|
if (_fadeMode == kFadeOut)
|
|
|
|
return;
|
|
|
|
|
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;
|
2008-12-22 14:36:58 +00:00
|
|
|
rect.right = rect.left + _vm->getDisplayInfo().width;
|
2005-04-22 14:11:04 +00:00
|
|
|
rect.bottom = rect.top + _vm->getDisplayInfo().statusHeight;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(rect, _vm->getDisplayInfo().statusBGColor - offset);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-11-03 18:20:12 +00:00
|
|
|
stringWidth = _vm->_font->getStringWidth(kKnownFontSmall, _statusText, 0, kFontNormal);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-19 11:29:29 +00:00
|
|
|
if (_statusOnceColor == -1)
|
2007-12-11 22:40:39 +00:00
|
|
|
color = _vm->getDisplayInfo().statusTextColor - offset;
|
2005-01-19 11:29:29 +00:00
|
|
|
else
|
|
|
|
color = _statusOnceColor;
|
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = _vm->getDisplayInfo().statusXOffset + (_vm->getDisplayInfo().statusWidth - stringWidth) / 2;
|
|
|
|
textPoint.y = _vm->getDisplayInfo().statusYOffset + _vm->getDisplayInfo().statusTextY;
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontSmall, _statusText, textPoint, color, 0, kFontNormal);
|
2007-06-12 22:47:12 +00:00
|
|
|
else
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontVerb, _statusText, textPoint, color, 0, kFontNormal);
|
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;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
rect.right = rect.left + _vm->getDisplayInfo().saveReminderWidth;
|
|
|
|
rect.bottom = rect.top + _vm->getDisplayInfo().saveReminderHeight;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_vm->_sprite->_saveReminderSprites,
|
2008-09-24 22:44:01 +00:00
|
|
|
_vm->getDisplayInfo().saveReminderFirstSpriteNumber + _saveReminderState - 1,
|
2005-05-22 11:59:22 +00:00
|
|
|
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) {
|
2005-08-10 14:53:17 +00:00
|
|
|
_vm->_actor->_protagonist->_currentAction = kActionWait;
|
2005-04-22 14:11:04 +00:00
|
|
|
_vm->_script->doVerb();
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
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-07-29 17:58:00 +00:00
|
|
|
setVerbState(panelButton->id, 1);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-29 17:58:00 +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-07-29 17:58:00 +00:00
|
|
|
|
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) {
|
|
|
|
inventoryChangePos(panelButton->id);
|
|
|
|
}
|
|
|
|
changed = true;
|
|
|
|
} else {
|
2005-07-29 17:58:00 +00:00
|
|
|
_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();
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
//inventory stuff
|
|
|
|
void Interface::inventoryChangePos(int chg) {
|
2007-08-25 12:38:35 +00:00
|
|
|
// Arrows will scroll the inventory up or down up to 4 items
|
|
|
|
for (int i = 1; i <= 4; i++) {
|
|
|
|
if ((chg < 0 && _inventoryStart + chg >= 0) ||
|
|
|
|
(chg > 0 && _inventoryStart < _inventoryEnd)) {
|
|
|
|
_inventoryStart += chg;
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
2007-08-25 12:38:35 +00:00
|
|
|
}
|
|
|
|
draw();
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::inventorySetPos(int key) {
|
|
|
|
_inventoryBox = key - '1';
|
|
|
|
_inventoryPos = _inventoryStart + _inventoryBox;
|
|
|
|
if (_inventoryPos >= _inventoryCount)
|
2005-07-29 17:58:00 +00:00
|
|
|
_inventoryPos = -1;
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
_inventoryEnd = (_inventoryCount - 1 - cols) / cols * cols;
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_inventoryEnd < 0) {
|
|
|
|
_inventoryEnd = 0;
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
|
2005-05-12 15:11:32 +00:00
|
|
|
void Interface::addToInventory(int objectId) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_inventoryCount >= _inventorySize) {
|
|
|
|
return;
|
2004-11-07 14:15:41 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +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);
|
2005-07-17 13:36:38 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawInventory() {
|
2005-07-17 15:10:08 +00:00
|
|
|
if (!isInMainMode())
|
2004-11-07 14:15:41 +00:00
|
|
|
return;
|
2005-10-11 02:22:53 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
Rect rect;
|
2008-12-06 14:24:40 +00:00
|
|
|
int ci = _inventoryStart;
|
2005-04-22 14:11:04 +00:00
|
|
|
ObjectData *obj;
|
2008-12-06 14:24:40 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_inventoryStart != 0) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonArrow(&_mainPanel, _inventoryUpButton);
|
2005-04-22 14:11:04 +00:00
|
|
|
}
|
|
|
|
if (_inventoryStart != _inventoryEnd) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonArrow(&_mainPanel, _inventoryDownButton);
|
2005-04-18 10:26:43 +00:00
|
|
|
}
|
2004-11-07 14:15:41 +00:00
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
for (int i = 0; i < _mainPanel.buttonsCount; i++) {
|
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);
|
2005-07-18 14:37:55 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(rect, kITEColorDarkGrey);
|
2007-06-12 22:47:12 +00:00
|
|
|
else
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(rect, _vm->KnownColor2ColorId(kKnownColorBlack));
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-18 14:37:55 +00:00
|
|
|
if (ci < _inventoryCount) {
|
|
|
|
obj = _vm->_actor->getObj(_inventory[ci]);
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_vm->_sprite->_inventorySprites, obj->_spriteListResourceId, rect, 256);
|
2005-07-18 14:37:55 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-22 14:11:04 +00:00
|
|
|
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);
|
2006-01-13 20:20:01 +00:00
|
|
|
if (panelButton == NULL) return;
|
2005-01-13 22:42:49 +00:00
|
|
|
if (state == 2) {
|
|
|
|
state = (_mainPanel.currentButton == panelButton) ? 1 : 0;
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-22 14:11:04 +00:00
|
|
|
panelButton->state = state;
|
|
|
|
draw();
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
|
2005-05-28 11:06:55 +00:00
|
|
|
byte cornerColor;
|
|
|
|
byte frameColor;
|
|
|
|
byte fillColor;
|
|
|
|
byte solidColor;
|
|
|
|
byte odl, our, idl, iur;
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
switch (kind ) {
|
2005-07-12 18:31:48 +00:00
|
|
|
case kSlider:
|
2005-05-29 15:39:35 +00:00
|
|
|
cornerColor = 0x8b;
|
2007-06-13 22:23:12 +00:00
|
|
|
frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2005-05-29 15:39:35 +00:00
|
|
|
fillColor = kITEColorLightBlue96;
|
|
|
|
odl = kITEColorDarkBlue8a;
|
|
|
|
our = kITEColorLightBlue92;
|
|
|
|
idl = 0x89;
|
|
|
|
iur = 0x94;
|
|
|
|
solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
|
|
|
|
break;
|
2005-07-12 18:31:48 +00:00
|
|
|
case kEdit:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-08-23 13:34:28 +00:00
|
|
|
cornerColor = frameColor = fillColor = kITEColorLightBlue96;
|
|
|
|
our = kITEColorDarkBlue8a;
|
|
|
|
odl = kITEColorLightBlue94;
|
|
|
|
solidColor = down ? kITEColorBlue : kITEColorDarkGrey0C;
|
2005-05-29 15:39:35 +00:00
|
|
|
} else {
|
2007-12-11 22:40:39 +00:00
|
|
|
cornerColor = frameColor = fillColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
|
|
|
our = odl = solidColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2005-05-29 15:39:35 +00:00
|
|
|
}
|
2007-08-23 13:34:28 +00:00
|
|
|
iur = 0x97;
|
|
|
|
idl = 0x95;
|
2005-05-29 15:39:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cornerColor = 0x8b;
|
2007-12-20 19:17:00 +00:00
|
|
|
frameColor = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2005-05-29 15:39:35 +00:00
|
|
|
solidColor = fillColor = kITEColorLightBlue96;
|
|
|
|
odl = kITEColorDarkBlue8a;
|
|
|
|
our = kITEColorLightBlue94;
|
|
|
|
idl = 0x97;
|
|
|
|
iur = 0x95;
|
|
|
|
if (down) {
|
|
|
|
SWAP(odl, our);
|
|
|
|
SWAP(idl, iur);
|
|
|
|
}
|
|
|
|
break;
|
2005-05-28 11:06:55 +00:00
|
|
|
}
|
|
|
|
|
2005-05-22 13:49:45 +00:00
|
|
|
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;
|
|
|
|
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->setPixelColor(x, y, cornerColor);
|
|
|
|
_vm->_gfx->setPixelColor(x, ye, cornerColor);
|
|
|
|
_vm->_gfx->setPixelColor(xe, y, cornerColor);
|
|
|
|
_vm->_gfx->setPixelColor(xe, ye, cornerColor);
|
2009-03-07 19:24:31 +00:00
|
|
|
_vm->_gfx->hLine(x + 1, y, x + w - 2, frameColor);
|
|
|
|
_vm->_gfx->hLine(x + 1, ye, x + w - 2, frameColor);
|
|
|
|
_vm->_gfx->vLine(x, y + 1, y + h - 2, frameColor);
|
|
|
|
_vm->_gfx->vLine(xe, y + 1, y + h - 2, frameColor);
|
2005-05-22 13:49:45 +00:00
|
|
|
|
|
|
|
x++;
|
|
|
|
y++;
|
|
|
|
xe--;
|
|
|
|
ye--;
|
|
|
|
w -= 2;
|
|
|
|
h -= 2;
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->vLine(x, y, y + h - 1, odl);
|
|
|
|
_vm->_gfx->hLine(x, ye, x + w - 1, odl);
|
|
|
|
_vm->_gfx->vLine(xe, y, y + h - 2, our);
|
|
|
|
_vm->_gfx->hLine(x + 1, y, x + 1 + w - 2, our);
|
2005-05-22 13:49:45 +00:00
|
|
|
|
|
|
|
x++;
|
|
|
|
y++;
|
|
|
|
xe--;
|
|
|
|
ye--;
|
|
|
|
w -= 2;
|
|
|
|
h -= 2;
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->setPixelColor(x, y, fillColor);
|
|
|
|
_vm->_gfx->setPixelColor(xe, ye, fillColor);
|
|
|
|
_vm->_gfx->vLine(x, y + 1, y + 1 + h - 2, idl);
|
|
|
|
_vm->_gfx->hLine(x + 1, ye, x + 1 + w - 2, idl);
|
|
|
|
_vm->_gfx->vLine(xe, y, y + h - 2, iur);
|
|
|
|
_vm->_gfx->hLine(x + 1, y, x + 1 + w - 2, iur);
|
2005-05-22 13:49:45 +00:00
|
|
|
|
|
|
|
x++; y++;
|
|
|
|
w -= 2; h -= 2;
|
|
|
|
|
|
|
|
Common::Rect fill(x, y, x + w, y + h);
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->fillRect(fill, solidColor);
|
2008-12-07 18:49:35 +00:00
|
|
|
_vm->_render->addDirtyRect(rect);
|
2005-05-22 12:21:16 +00:00
|
|
|
}
|
|
|
|
|
2006-06-11 20:30:43 +00:00
|
|
|
static const int readingSpeeds[] = { kTextClick, kTextSlow, kTextMid, kTextFast };
|
2005-09-02 20:17:52 +00:00
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawPanelButtonText(InterfacePanel *panel, PanelButton *panelButton, int spritenum) {
|
2005-05-22 11:59:22 +00:00
|
|
|
const char *text;
|
2005-05-28 11:06:55 +00:00
|
|
|
int textId;
|
2005-05-22 11:59:22 +00:00
|
|
|
int textWidth;
|
|
|
|
int textHeight;
|
|
|
|
Point point;
|
2007-06-13 19:41:27 +00:00
|
|
|
Point texturePoint;
|
2005-11-26 12:08:05 +00:00
|
|
|
KnownColor textColor;
|
2005-05-22 12:21:16 +00:00
|
|
|
Rect rect;
|
2007-06-13 19:41:27 +00:00
|
|
|
int litButton = 0;
|
2007-06-13 22:23:12 +00:00
|
|
|
KnownColor textShadowKnownColor = kKnownColorVerbTextShadow;
|
|
|
|
KnownFont textFont = kKnownFontMedium;
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-05-28 11:06:55 +00:00
|
|
|
textId = panelButton->id;
|
2006-07-14 13:33:58 +00:00
|
|
|
switch (panelButton->id) {
|
2005-08-16 19:04:51 +00:00
|
|
|
case kTextReadingSpeed:
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE && !(_vm->getFeatures() & GF_ITE_FLOPPY)) {
|
2005-09-02 20:17:52 +00:00
|
|
|
if (_vm->_subtitlesEnabled)
|
|
|
|
textId = kTextOn;
|
|
|
|
else
|
|
|
|
textId = kTextOff;
|
|
|
|
} else {
|
|
|
|
textId = readingSpeeds[_vm->_readingSpeed];
|
|
|
|
}
|
2005-08-16 19:04:51 +00:00
|
|
|
break;
|
|
|
|
case kTextMusic:
|
2005-09-02 20:17:52 +00:00
|
|
|
if (_vm->_musicVolume)
|
2008-09-05 13:02:03 +00:00
|
|
|
textId = kText10Percent + _vm->_musicVolume / 25 - 1;
|
2005-09-02 20:17:52 +00:00
|
|
|
else
|
|
|
|
textId = kTextOff;
|
2005-08-16 19:04:51 +00:00
|
|
|
break;
|
|
|
|
case kTextSound:
|
2005-09-02 20:17:52 +00:00
|
|
|
if (_vm->_soundVolume)
|
2008-09-05 13:02:03 +00:00
|
|
|
textId = kText10Percent + _vm->_soundVolume / 25 - 1;
|
2005-09-02 20:17:52 +00:00
|
|
|
else
|
|
|
|
textId = kTextOff;
|
2005-08-16 19:04:51 +00:00
|
|
|
break;
|
2007-06-13 19:41:27 +00:00
|
|
|
case kTextVoices:
|
|
|
|
if (_vm->_subtitlesEnabled && _vm->_voicesEnabled)
|
|
|
|
textId = kTextBoth;
|
|
|
|
else if (_vm->_subtitlesEnabled && !_vm->_voicesEnabled)
|
|
|
|
textId = kTextText;
|
|
|
|
else if (!_vm->_subtitlesEnabled && _vm->_voicesEnabled)
|
|
|
|
textId = kTextAudio;
|
|
|
|
break;
|
2005-05-28 11:06:55 +00:00
|
|
|
}
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-13 22:23:12 +00:00
|
|
|
text = _vm->getTextString(textId);
|
|
|
|
textFont = kKnownFontMedium;
|
|
|
|
textShadowKnownColor = kKnownColorVerbTextShadow;
|
2007-05-02 17:12:30 +00:00
|
|
|
textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal);
|
|
|
|
textHeight = _vm->_font->getHeight(kKnownFontMedium);
|
|
|
|
} else {
|
2007-09-30 14:46:49 +00:00
|
|
|
if (textId < 39 || textId > 50) {
|
2007-06-13 22:23:12 +00:00
|
|
|
// Read non-hardcoded strings from the LUT string table, loaded from the game
|
|
|
|
// data files
|
|
|
|
text = _vm->_script->_mainStrings.getString(IHNMTextStringIdsLUT[textId]);
|
|
|
|
} else {
|
|
|
|
// Hardcoded strings in IHNM are read from the ITE hardcoded strings
|
|
|
|
text = _vm->getTextString(textId);
|
|
|
|
}
|
|
|
|
|
|
|
|
textFont = kKnownFontVerb;
|
|
|
|
textShadowKnownColor = kKnownColorTransparent;
|
2007-05-02 17:12:30 +00:00
|
|
|
textWidth = _vm->_font->getStringWidth(kKnownFontVerb, text, 0, kFontNormal);
|
|
|
|
textHeight = _vm->_font->getHeight(kKnownFontVerb);
|
|
|
|
}
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
point.x = panel->x + panelButton->xOffset + (panelButton->width / 2) - (textWidth / 2);
|
|
|
|
point.y = panel->y + panelButton->yOffset + (panelButton->height / 2) - (textHeight / 2);
|
2005-05-22 11:59:22 +00:00
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
if (panelButton == panel->currentButton) {
|
2005-11-26 12:08:05 +00:00
|
|
|
textColor = kKnownColorVerbTextActive;
|
2005-05-22 11:59:22 +00:00
|
|
|
} else {
|
2005-11-26 12:08:05 +00:00
|
|
|
textColor = kKnownColorVerbText;
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 15:39:35 +00:00
|
|
|
panel->calcPanelButtonRect(panelButton, rect);
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, panelButton->state > 0);
|
2007-06-13 19:41:27 +00:00
|
|
|
} else {
|
|
|
|
litButton = panelButton->state > 0;
|
|
|
|
|
|
|
|
if (panel == &_optionPanel) {
|
2007-08-21 18:07:17 +00:00
|
|
|
texturePoint.x = _optionPanel.x + panelButton->xOffset - 1;
|
|
|
|
texturePoint.y = _optionPanel.y + panelButton->yOffset - 1;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_optionPanel.sprites, spritenum + 2 + litButton, texturePoint, 256);
|
2007-06-13 19:41:27 +00:00
|
|
|
} else if (panel == &_quitPanel) {
|
2007-08-21 18:07:17 +00:00
|
|
|
texturePoint.x = _quitPanel.x + panelButton->xOffset - 3;
|
|
|
|
texturePoint.y = _quitPanel.y + panelButton->yOffset - 3;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_quitPanel.sprites, litButton, texturePoint, 256);
|
2007-06-17 02:59:56 +00:00
|
|
|
} else if (panel == &_savePanel) {
|
2007-08-21 18:07:17 +00:00
|
|
|
texturePoint.x = _savePanel.x + panelButton->xOffset - 3;
|
|
|
|
texturePoint.y = _savePanel.y + panelButton->yOffset - 3;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_savePanel.sprites, litButton, texturePoint, 256);
|
2007-08-21 18:07:17 +00:00
|
|
|
// Input text box sprite
|
|
|
|
texturePoint.x = _savePanel.x + _saveEdit->xOffset - 2;
|
|
|
|
texturePoint.y = _savePanel.y + _saveEdit->yOffset - 2;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_savePanel.sprites, 2, texturePoint, 256);
|
2007-06-17 02:59:56 +00:00
|
|
|
} else if (panel == &_loadPanel) {
|
2007-08-21 18:07:17 +00:00
|
|
|
texturePoint.x = _loadPanel.x + panelButton->xOffset - 3;
|
|
|
|
texturePoint.y = _loadPanel.y + panelButton->yOffset - 3;
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_loadPanel.sprites, litButton, texturePoint, 256);
|
2007-06-13 19:41:27 +00:00
|
|
|
} else {
|
|
|
|
// revert to default behavior
|
2008-12-06 14:24:40 +00:00
|
|
|
drawButtonBox(rect, kButton, panelButton->state > 0);
|
2007-06-13 19:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-22 12:21:16 +00:00
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(textFont, text, point,
|
2007-06-13 22:23:12 +00:00
|
|
|
_vm->KnownColor2ColorId(textColor), _vm->KnownColor2ColorId(textShadowKnownColor), kFontShadow);
|
2005-05-22 11:59:22 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawPanelButtonArrow(InterfacePanel *panel, PanelButton *panelButton) {
|
2005-04-18 20:03:14 +00:00
|
|
|
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;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
point.x = panel->x + panelButton->xOffset;
|
|
|
|
point.y = panel->y + panelButton->yOffset;
|
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_vm->_sprite->_mainSprites, spriteNumber, point, 256);
|
2007-06-05 13:19:47 +00:00
|
|
|
else
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_vm->_sprite->_arrowSprites, spriteNumber, point, 256);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::drawVerbPanelText(PanelButton *panelButton, KnownColor textKnownColor, KnownColor textShadowKnownColor) {
|
2005-01-13 22:42:49 +00:00
|
|
|
const char *text;
|
|
|
|
int textWidth;
|
|
|
|
Point point;
|
|
|
|
int textId;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2008-12-26 13:50:12 +00:00
|
|
|
textId = verbToTextIdITE[panelButton->id - 1];
|
2005-10-10 02:02:58 +00:00
|
|
|
text = _vm->getTextString(textId);
|
2008-01-27 19:47:41 +00:00
|
|
|
} else {
|
2008-12-26 13:50:12 +00:00
|
|
|
textId = panelButton->id;
|
2005-10-10 02:02:58 +00:00
|
|
|
text = _vm->_script->_mainStrings.getString(textId + 1);
|
2005-11-26 12:08:05 +00:00
|
|
|
textShadowKnownColor = kKnownColorTransparent;
|
2005-10-10 02:02:58 +00:00
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
|
2005-11-03 18:20:12 +00:00
|
|
|
textWidth = _vm->_font->getStringWidth(kKnownFontVerb, text, 0, kFontNormal);
|
2005-01-13 22:42:49 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2005-10-10 17:23:28 +00:00
|
|
|
point.x = _mainPanel.x + panelButton->xOffset + 1 + (panelButton->width - 1 - textWidth) / 2;
|
|
|
|
point.y = _mainPanel.y + panelButton->yOffset + 1;
|
|
|
|
} else {
|
|
|
|
point.x = _mainPanel.x + panelButton->xOffset + 1 + (panelButton->width - textWidth) / 2;
|
|
|
|
point.y = _mainPanel.y + panelButton->yOffset + 12;
|
|
|
|
}
|
2005-01-13 22:42:49 +00:00
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontVerb, text, point,
|
|
|
|
_vm->KnownColor2ColorId(textKnownColor), _vm->KnownColor2ColorId(textShadowKnownColor),
|
2008-12-06 14:24:40 +00:00
|
|
|
(textShadowKnownColor != kKnownColorTransparent) ? kFontShadow : kFontNormal);
|
2005-01-09 23:41:22 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +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;
|
|
|
|
}
|
|
|
|
|
2007-06-10 00:36:01 +00:00
|
|
|
bool Interface::converseAddText(const char *text, int strId, int replyId, byte replyFlags, int replyBit) {
|
2005-10-11 17:39:31 +00:00
|
|
|
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];
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-12 22:47:12 +00:00
|
|
|
if ((c == ' ' || c == '\0') && (_vm->_font->getStringWidth(kKnownFontSmall, _converseWorkString, i, kFontNormal) <= _vm->getDisplayInfo().converseMaxTextWidth))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if ((c == ' ' || c == '\0') && (_vm->_font->getStringWidth(kKnownFontVerb, _converseWorkString, i, kFontNormal) <= _vm->getDisplayInfo().converseMaxTextWidth))
|
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
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
|
|
|
|
2007-06-10 00:36:01 +00:00
|
|
|
_converseText[_converseTextCount].strId = strId;
|
2005-01-10 22:51:01 +00:00
|
|
|
_converseText[_converseTextCount].text[i] = 0;
|
|
|
|
_converseText[_converseTextCount].textNum = count;
|
2005-10-11 17:39:31 +00:00
|
|
|
_converseText[_converseTextCount].stringNum = _converseStrCount;
|
|
|
|
_converseText[_converseTextCount].replyId = replyId;
|
|
|
|
_converseText[_converseTextCount].replyFlags = replyFlags;
|
|
|
|
_converseText[_converseTextCount].replyBit = replyBit;
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
_converseTextCount++;
|
|
|
|
count++;
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
if (len == i)
|
2005-01-10 22:51:01 +00:00
|
|
|
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() {
|
2005-07-29 17:58:00 +00:00
|
|
|
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
|
|
|
|
2005-08-10 18:27:18 +00:00
|
|
|
end = _converseTextCount - _vm->getDisplayInfo().converseTextLines;
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-12-06 14:24:40 +00:00
|
|
|
void Interface::converseDisplayTextLines() {
|
2005-04-18 20:03:14 +00:00
|
|
|
int relPos;
|
|
|
|
byte foregnd;
|
|
|
|
byte backgnd;
|
|
|
|
byte bulletForegnd;
|
|
|
|
byte bulletBackgnd;
|
|
|
|
const char *str;
|
|
|
|
char bullet[2] = {
|
2005-07-29 17:58:00 +00:00
|
|
|
(char)0xb7, 0
|
2005-04-18 20:03:14 +00:00
|
|
|
};
|
2005-08-10 18:27:18 +00:00
|
|
|
Rect rect(8, _vm->getDisplayInfo().converseTextLines * _vm->getDisplayInfo().converseTextHeight);
|
2005-07-14 17:46:21 +00:00
|
|
|
Point textPoint;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
assert(_conversePanel.buttonsCount >= 6);
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-12 22:47:12 +00:00
|
|
|
bulletForegnd = kITEColorGreen;
|
|
|
|
bulletBackgnd = kITEColorBlack;
|
|
|
|
} else {
|
2007-12-20 19:17:00 +00:00
|
|
|
bulletForegnd = _vm->KnownColor2ColorId(kKnownColorBrightWhite);
|
|
|
|
bulletBackgnd = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2007-06-12 22:47:12 +00:00
|
|
|
bullet[0] = '>'; // different bullet in IHNM
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
|
|
|
rect.moveTo(_conversePanel.x + _conversePanel.buttons[0].xOffset,
|
2005-04-18 20:03:14 +00:00
|
|
|
_conversePanel.y + _conversePanel.buttons[0].yOffset);
|
2005-01-11 00:51:58 +00:00
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(rect, kITEColorDarkGrey); //fill bullet place
|
2007-06-12 22:47:12 +00:00
|
|
|
else
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(rect, _vm->KnownColor2ColorId(kKnownColorBlack)); //fill bullet place
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-08-10 18:27:18 +00:00
|
|
|
for (int i = 0; i < _vm->getDisplayInfo().converseTextLines; 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) {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-12 22:47:12 +00:00
|
|
|
foregnd = kITEColorBrightWhite;
|
|
|
|
backgnd = (!_vm->leftMouseButtonPressed()) ? kITEColorDarkGrey : kITEColorGrey;
|
|
|
|
} else {
|
2007-12-20 19:17:00 +00:00
|
|
|
foregnd = _vm->KnownColor2ColorId(kKnownColorVerbTextActive);
|
|
|
|
backgnd = _vm->KnownColor2ColorId(kKnownColorVerbTextActive);
|
2007-06-12 22:47:12 +00:00
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
} else {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE) {
|
2007-06-12 22:47:12 +00:00
|
|
|
foregnd = kITEColorBlue;
|
|
|
|
backgnd = kITEColorDarkGrey;
|
|
|
|
} else {
|
2007-12-20 19:17:00 +00:00
|
|
|
foregnd = _vm->KnownColor2ColorId(kKnownColorBrightWhite);
|
|
|
|
backgnd = _vm->KnownColor2ColorId(kKnownColorBlack);
|
2007-06-12 22:47:12 +00:00
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
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;
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRect(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
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = rect.left - 6;
|
|
|
|
textPoint.y = rect.top;
|
|
|
|
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontSmall, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap));
|
2007-06-12 22:47:12 +00:00
|
|
|
else
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontVerb, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap));
|
2005-01-11 00:51:58 +00:00
|
|
|
}
|
2005-07-14 17:46:21 +00:00
|
|
|
textPoint.x = rect.left + 1;
|
|
|
|
textPoint.y = rect.top;
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontSmall, str, textPoint, foregnd, kITEColorBlack, kFontShadow);
|
2007-06-12 22:47:12 +00:00
|
|
|
else
|
2008-12-06 14:24:40 +00:00
|
|
|
_vm->_font->textDraw(kKnownFontVerb, str, textPoint, foregnd, _vm->KnownColor2ColorId(kKnownColorBlack), kFontShadow);
|
2005-01-11 00:51:58 +00:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_converseStartPos != 0) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonArrow(&_conversePanel, _converseUpButton);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_converseStartPos != _converseEndPos) {
|
2008-12-06 14:24:40 +00:00
|
|
|
drawPanelButtonArrow(&_conversePanel, _converseDownButton);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::converseChangePos(int chg) {
|
2007-08-25 12:49:03 +00:00
|
|
|
// Arrows will scroll the converse panel or down up to 4 conversation options
|
|
|
|
for (int i = 1; i <= 4; i++) {
|
|
|
|
if ((chg < 0 && _converseStartPos + chg >= 0) ||
|
|
|
|
(chg > 0 && _converseStartPos < _converseEndPos)) {
|
|
|
|
_converseStartPos += chg;
|
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
}
|
2007-08-25 12:49:03 +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
|
|
|
|
2007-06-10 00:36:01 +00:00
|
|
|
_vm->_script->finishDialog(ct->strId, ct->replyId, ct->replyFlags, ct->replyBit);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2008-12-24 09:59:18 +00:00
|
|
|
if (_vm->_scene->isITEPuzzleScene())
|
2005-05-23 02:23:34 +00:00
|
|
|
_vm->_puzzle->handleReply(ct->replyId);
|
2005-01-10 22:51:01 +00:00
|
|
|
|
|
|
|
_conversePos = -1;
|
|
|
|
}
|
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
|
|
|
|
void Interface::handleConverseUpdate(const Point& mousePoint) {
|
|
|
|
bool changed;
|
|
|
|
|
|
|
|
PanelButton *last = _conversePanel.currentButton;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
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;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
|
|
|
|
if (_conversePanel.currentButton == NULL) {
|
|
|
|
_conversePos = -1;
|
|
|
|
if (changed) {
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
|
|
|
|
converseSetTextLines(_conversePanel.currentButton->id);
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonArrow) {
|
2005-04-22 14:11:04 +00:00
|
|
|
if (_conversePanel.currentButton->state == 1) {
|
|
|
|
converseChangePos(_conversePanel.currentButton->id);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
draw();
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::handleConverseClick(const Point& mousePoint) {
|
|
|
|
_conversePanel.currentButton = converseHitTest(mousePoint);
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
|
2005-05-28 11:06:55 +00:00
|
|
|
converseSetPos(_conversePanel.currentButton->ascii);
|
2005-04-18 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_conversePanel.currentButton->type == kPanelButtonArrow) {
|
2005-04-22 14:11:04 +00:00
|
|
|
_conversePanel.currentButton->state = 1;
|
|
|
|
converseChangePos(_conversePanel.currentButton->id);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-04-18 20:03:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
void Interface::saveState(Common::OutSaveFile *out) {
|
|
|
|
out->writeUint16LE(_inventoryCount);
|
2005-05-12 15:11:32 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < _inventoryCount; i++) {
|
2005-05-23 18:53:36 +00:00
|
|
|
out->writeUint16LE(_inventory[i]);
|
2005-05-12 15:11:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
void Interface::loadState(Common::InSaveFile *in) {
|
|
|
|
_inventoryCount = in->readUint16LE();
|
2005-05-12 15:11:32 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < _inventoryCount; i++) {
|
2005-05-23 18:53:36 +00:00
|
|
|
_inventory[i] = in->readUint16LE();
|
2005-05-12 15:11:32 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-12 15:11:32 +00:00
|
|
|
updateInventory(0);
|
|
|
|
}
|
|
|
|
|
2005-07-03 20:02:56 +00:00
|
|
|
void Interface::mapPanelShow() {
|
2005-07-10 15:25:30 +00:00
|
|
|
int i;
|
2005-07-03 20:02:56 +00:00
|
|
|
byte *resource;
|
|
|
|
size_t resourceLength, imageLength;
|
2005-07-09 16:23:45 +00:00
|
|
|
Rect rect;
|
2005-07-03 20:02:56 +00:00
|
|
|
byte *image;
|
|
|
|
int imageWidth, imageHeight;
|
|
|
|
const byte *pal;
|
2005-07-09 16:23:45 +00:00
|
|
|
PalEntry cPal[PAL_ENTRIES];
|
2005-07-03 20:02:56 +00:00
|
|
|
|
|
|
|
_vm->_gfx->showCursor(false);
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
rect.left = rect.top = 0;
|
2005-07-03 20:02:56 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
_vm->_resource->loadResource(_interfaceContext,
|
2005-08-13 01:05:59 +00:00
|
|
|
_vm->_resource->convertResourceId(RID_ITE_TYCHO_MAP), resource, resourceLength);
|
2005-07-19 19:05:52 +00:00
|
|
|
if (resourceLength == 0) {
|
|
|
|
error("Interface::mapPanelShow() unable to load Tycho map resource");
|
2005-07-03 20:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(_mapSavedPal);
|
|
|
|
|
2005-07-10 15:25:30 +00:00
|
|
|
for (i = 0; i < 6 ; i++) {
|
2005-07-05 15:15:35 +00:00
|
|
|
_vm->_gfx->palToBlack(_mapSavedPal, 0.2 * i);
|
2005-07-03 20:02:56 +00:00
|
|
|
_vm->_render->drawScene();
|
|
|
|
_vm->_system->delayMillis(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_render->setFlag(RF_MAP);
|
|
|
|
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &image, &imageLength, &imageWidth, &imageHeight);
|
|
|
|
pal = _vm->getImagePal(resource, resourceLength);
|
|
|
|
|
2005-07-10 15:25:30 +00:00
|
|
|
for (i = 0; i < PAL_ENTRIES; i++) {
|
2005-07-03 20:02:56 +00:00
|
|
|
cPal[i].red = *pal++;
|
|
|
|
cPal[i].green = *pal++;
|
2005-07-29 17:58:00 +00:00
|
|
|
cPal[i].blue = *pal++;
|
2005-07-03 20:02:56 +00:00
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
rect.setWidth(imageWidth);
|
|
|
|
rect.setHeight(imageHeight);
|
|
|
|
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, image);
|
2005-07-03 20:02:56 +00:00
|
|
|
|
|
|
|
// Evil Evil
|
2005-07-10 15:25:30 +00:00
|
|
|
for (i = 0; i < 6 ; i++) {
|
2005-07-05 15:15:35 +00:00
|
|
|
_vm->_gfx->blackToPal(cPal, 0.2 * i);
|
2005-07-03 20:02:56 +00:00
|
|
|
_vm->_render->drawScene();
|
|
|
|
_vm->_system->delayMillis(5);
|
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
free(resource);
|
2005-07-03 20:02:56 +00:00
|
|
|
free(image);
|
|
|
|
|
|
|
|
setSaveReminderState(false);
|
|
|
|
|
|
|
|
_mapPanelCrossHairState = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::mapPanelClean() {
|
2005-07-09 16:23:45 +00:00
|
|
|
PalEntry pal[PAL_ENTRIES];
|
2005-07-10 15:25:30 +00:00
|
|
|
int i;
|
2005-07-03 20:02:56 +00:00
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(pal);
|
|
|
|
|
2005-07-10 15:25:30 +00:00
|
|
|
for (i = 0; i < 6 ; i++) {
|
2005-07-05 15:15:35 +00:00
|
|
|
_vm->_gfx->palToBlack(pal, 0.2 * i);
|
2005-07-03 20:02:56 +00:00
|
|
|
_vm->_render->drawScene();
|
|
|
|
_vm->_system->delayMillis(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_render->clearFlag(RF_MAP);
|
|
|
|
setMode(kPanelMain);
|
|
|
|
|
|
|
|
_vm->_gfx->showCursor(true);
|
|
|
|
_vm->_render->drawScene();
|
|
|
|
|
2005-07-10 15:25:30 +00:00
|
|
|
for (i = 0; i < 6 ; i++) {
|
2005-07-05 15:15:35 +00:00
|
|
|
_vm->_gfx->blackToPal(_mapSavedPal, 0.2 * i);
|
2005-07-03 20:02:56 +00:00
|
|
|
_vm->_render->drawScene();
|
|
|
|
_vm->_system->delayMillis(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Interface::mapPanelDrawCrossHair() {
|
|
|
|
_mapPanelCrossHairState = !_mapPanelCrossHairState;
|
|
|
|
|
|
|
|
Point mapPosition = _vm->_isoMap->getMapPosition();
|
2008-12-22 14:36:58 +00:00
|
|
|
Rect screen(_vm->getDisplayInfo().width, _vm->_scene->getHeight());
|
2005-07-03 20:02:56 +00:00
|
|
|
|
|
|
|
if (screen.contains(mapPosition)) {
|
2008-12-12 14:23:02 +00:00
|
|
|
_vm->_sprite->draw(_vm->_sprite->_mainSprites,
|
2008-05-26 11:10:46 +00:00
|
|
|
_mapPanelCrossHairState? RID_ITE_SPR_CROSSHAIR : RID_ITE_SPR_CROSSHAIR + 1,
|
2005-07-03 20:02:56 +00:00
|
|
|
mapPosition, 256);
|
|
|
|
}
|
|
|
|
}
|
2005-01-10 22:51:01 +00:00
|
|
|
|
2005-10-09 03:35:45 +00:00
|
|
|
void Interface::keyBoss() {
|
2008-12-21 15:59:05 +00:00
|
|
|
if (_vm->getGameId() == GID_ITE)
|
2005-10-09 03:35:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (_bossMode != -1 || _fadeMode != kNoFade)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_sound->pauseVoice();
|
|
|
|
_vm->_sound->pauseSound();
|
|
|
|
_vm->_music->pause();
|
|
|
|
|
|
|
|
int i;
|
|
|
|
byte *resource;
|
|
|
|
size_t resourceLength, imageLength;
|
|
|
|
Rect rect;
|
|
|
|
byte *image;
|
|
|
|
int imageWidth, imageHeight;
|
|
|
|
const byte *pal;
|
|
|
|
PalEntry cPal[PAL_ENTRIES];
|
|
|
|
|
|
|
|
_vm->_gfx->showCursor(false);
|
|
|
|
|
2005-10-10 02:48:23 +00:00
|
|
|
rect.left = rect.top = 0;
|
2005-10-09 03:35:45 +00:00
|
|
|
|
|
|
|
_vm->_resource->loadResource(_interfaceContext, RID_IHNM_BOSS_SCREEN, resource, resourceLength);
|
|
|
|
if (resourceLength == 0) {
|
|
|
|
error("Interface::bossKey() unable to load Boss image resource");
|
|
|
|
}
|
|
|
|
|
|
|
|
_bossMode = _panelMode;
|
|
|
|
setMode(kPanelBoss);
|
|
|
|
|
|
|
|
_vm->decodeBGImage(resource, resourceLength, &image, &imageLength, &imageWidth, &imageHeight);
|
|
|
|
rect.setWidth(imageWidth);
|
|
|
|
rect.setHeight(imageHeight);
|
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(_mapSavedPal);
|
|
|
|
pal = _vm->getImagePal(resource, resourceLength);
|
|
|
|
|
2007-10-28 04:42:22 +00:00
|
|
|
cPal[0].red = 0;
|
|
|
|
cPal[0].green = 0;
|
|
|
|
cPal[0].blue = 0;
|
|
|
|
|
|
|
|
for (i = 1; i < PAL_ENTRIES; i++) {
|
|
|
|
cPal[i].red = 128;
|
|
|
|
cPal[i].green = 128;
|
|
|
|
cPal[i].blue = 128;
|
2005-10-09 03:35:45 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 18:23:34 +00:00
|
|
|
_vm->_gfx->drawRegion(rect, image);
|
2005-10-09 03:35:45 +00:00
|
|
|
|
|
|
|
_vm->_gfx->setPalette(cPal);
|
|
|
|
|
|
|
|
free(resource);
|
|
|
|
free(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Interface::keyBossExit() {
|
|
|
|
PalEntry pal[PAL_ENTRIES];
|
|
|
|
|
|
|
|
_vm->_sound->resumeVoice();
|
|
|
|
_vm->_sound->resumeSound();
|
|
|
|
_vm->_music->resume();
|
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(pal);
|
|
|
|
|
|
|
|
_vm->_gfx->palToBlack(pal, 1);
|
|
|
|
setMode(_bossMode);
|
|
|
|
|
|
|
|
_vm->_render->drawScene();
|
|
|
|
|
|
|
|
_vm->_gfx->blackToPal(_mapSavedPal, 1);
|
|
|
|
|
2005-10-09 03:45:16 +00:00
|
|
|
_vm->_gfx->showCursor(true);
|
|
|
|
|
2005-10-09 03:35:45 +00:00
|
|
|
_bossMode = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|