2010-08-17 09:28:20 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Hugo Trilogy source code
|
|
|
|
*
|
|
|
|
* Copyright (c) 1989-1995 David P. Gray
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// mouse.cpp : Handle all mouse activity
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
|
|
|
|
#include "hugo/hugo.h"
|
2011-01-23 00:05:52 +00:00
|
|
|
#include "hugo/game.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
#include "hugo/mouse.h"
|
|
|
|
#include "hugo/schedule.h"
|
|
|
|
#include "hugo/display.h"
|
|
|
|
#include "hugo/inventory.h"
|
|
|
|
#include "hugo/route.h"
|
|
|
|
#include "hugo/util.h"
|
2010-10-21 17:09:57 +00:00
|
|
|
#include "hugo/object.h"
|
2011-01-25 00:32:48 +00:00
|
|
|
#include "hugo/text.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
namespace Hugo {
|
|
|
|
|
2011-02-20 10:33:17 +00:00
|
|
|
MouseHandler::MouseHandler(HugoEngine *vm) : _vm(vm), _hotspots(0) {
|
2011-02-08 20:52:26 +00:00
|
|
|
_leftButtonFl = false;
|
|
|
|
_rightButtonFl = false;
|
|
|
|
_jumpExitFl = false; // Can't jump to a screen exit
|
|
|
|
_mouseX = kXPix / 2;
|
|
|
|
_mouseY = kYPix / 2;
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::resetLeftButton() {
|
|
|
|
_leftButtonFl = false;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::resetRightButton() {
|
|
|
|
_rightButtonFl = false;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::setLeftButton() {
|
|
|
|
_leftButtonFl = true;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::setRightButton() {
|
|
|
|
_rightButtonFl = true;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::setJumpExitFl(bool fl) {
|
|
|
|
_jumpExitFl = fl;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::setMouseX(int x) {
|
|
|
|
_mouseX = x;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::setMouseY(int y) {
|
|
|
|
_mouseY = y;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
void MouseHandler::freeHotspots() {
|
|
|
|
free(_hotspots);
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
bool MouseHandler::getJumpExitFl() const {
|
|
|
|
return _jumpExitFl;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
int MouseHandler::getMouseX() const {
|
|
|
|
return _mouseX;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
int MouseHandler::getMouseY() const {
|
|
|
|
return _mouseY;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
int16 MouseHandler::getDirection(const int16 hotspotId) const {
|
|
|
|
return _hotspots[hotspotId].direction;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 21:43:38 +00:00
|
|
|
int16 MouseHandler::getHotspotActIndex(const int16 hotspotId) const {
|
|
|
|
return _hotspots[hotspotId].actIndex;
|
2011-02-18 21:24:32 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Shadow-blit supplied string into dib_a at cx,cy and add to display list
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void MouseHandler::cursorText(const char *buffer, const int16 cx, const int16 cy, const uif_t fontId, const int16 color) {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(1, kDebugMouse, "cursorText(%s, %d, %d, %d, %d)", buffer, cx, cy, fontId, color);
|
|
|
|
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_screen->loadFont(fontId);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// Find bounding rect for string
|
2010-10-21 17:09:57 +00:00
|
|
|
int16 sdx = _vm->_screen->stringLength(buffer);
|
2011-01-23 00:05:52 +00:00
|
|
|
int16 sdy = _vm->_screen->fontHeight() + 1; // + 1 for shadow
|
2011-01-09 10:16:55 +00:00
|
|
|
int16 sx, sy;
|
2011-01-23 00:05:52 +00:00
|
|
|
if (cx < kXPix / 2) {
|
|
|
|
sx = cx + kCursorNameOffX;
|
2011-02-08 20:52:26 +00:00
|
|
|
sy = (_vm->_inventory->getInventoryObjId() == -1) ? cy + kCursorNameOffY : cy + kCursorNameOffY - (_vm->_screen->fontHeight() + 1);
|
2011-01-09 10:16:55 +00:00
|
|
|
} else {
|
2011-01-23 00:05:52 +00:00
|
|
|
sx = cx - sdx - kCursorNameOffX / 2;
|
|
|
|
sy = cy + kCursorNameOffY;
|
2011-01-09 10:16:55 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// Display the string and add rect to display list
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_screen->shadowStr(sx, sy, buffer, _TBRIGHTWHITE);
|
2011-01-23 00:05:52 +00:00
|
|
|
_vm->_screen->displayList(kDisplayAdd, sx, sy, sdx, sdy);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Find the exit hotspot containing cx, cy.
|
|
|
|
* Return hotspot index or -1 if not found.
|
|
|
|
*/
|
2011-02-14 07:31:01 +00:00
|
|
|
int16 MouseHandler::findExit(const int16 cx, const int16 cy, byte screenId) {
|
|
|
|
debugC(2, kDebugMouse, "findExit(%d, %d, %d)", cx, cy, screenId);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-02-14 07:31:01 +00:00
|
|
|
for (int i = 0; _hotspots[i].screenIndex >= 0; i++) {
|
|
|
|
if (_hotspots[i].screenIndex == screenId) {
|
|
|
|
if (cx >= _hotspots[i].x1 && cx <= _hotspots[i].x2 && cy >= _hotspots[i].y1 && cy <= _hotspots[i].y2)
|
2010-10-03 08:08:42 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Process a mouse right click at coord cx, cy over object objid
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void MouseHandler::processRightClick(const int16 objId, const int16 cx, const int16 cy) {
|
2011-01-27 18:43:02 +00:00
|
|
|
debugC(1, kDebugMouse, "ProcessRightClick(%d, %d, %d)", objId, cx, cy);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-10-21 17:09:57 +00:00
|
|
|
status_t &gameStatus = _vm->getGameStatus();
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // Make sure user has control
|
2010-08-17 09:28:20 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-08 20:52:26 +00:00
|
|
|
int16 inventObjId = _vm->_inventory->getInventoryObjId();
|
2010-10-03 08:08:42 +00:00
|
|
|
bool foundFl = false; // TRUE if route found to object
|
2010-08-17 09:28:20 +00:00
|
|
|
// Check if this was over iconbar
|
2011-02-08 20:52:26 +00:00
|
|
|
if ((_vm->_inventory->getInventoryState() == kInventoryActive) && (cy < kInvDy + kDibOffY)) { // Clicked over iconbar object
|
|
|
|
if (inventObjId == -1)
|
2011-01-08 16:56:52 +00:00
|
|
|
_vm->_screen->selectInventoryObjId(objId);
|
2011-02-08 20:52:26 +00:00
|
|
|
else if (inventObjId == objId)
|
2011-01-08 16:56:52 +00:00
|
|
|
_vm->_screen->resetInventoryObjId();
|
2010-08-17 09:28:20 +00:00
|
|
|
else
|
2010-12-30 21:07:38 +00:00
|
|
|
_vm->_object->useObject(objId); // Use status.objid on object
|
2010-08-17 09:28:20 +00:00
|
|
|
} else { // Clicked over viewport object
|
2010-10-21 17:09:57 +00:00
|
|
|
object_t *obj = &_vm->_object->_objects[objId];
|
2010-10-03 08:08:42 +00:00
|
|
|
int16 x, y;
|
2010-08-17 09:28:20 +00:00
|
|
|
switch (obj->viewx) { // Where to walk to
|
|
|
|
case -1: // Walk to object position
|
2010-10-22 20:45:00 +00:00
|
|
|
if (_vm->_object->findObjectSpace(obj, &x, &y))
|
2011-01-23 00:05:52 +00:00
|
|
|
foundFl = _vm->_route->startRoute(kRouteGet, objId, x, y);
|
2010-10-03 08:08:42 +00:00
|
|
|
if (!foundFl) // Can't get there, try to use from here
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_object->useObject(objId);
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
case 0: // Immediate use
|
2010-12-30 21:07:38 +00:00
|
|
|
_vm->_object->useObject(objId); // Pick up or use object
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
default: // Walk to view point if possible
|
2011-01-23 00:05:52 +00:00
|
|
|
if (!_vm->_route->startRoute(kRouteGet, objId, obj->viewx, obj->viewy)) {
|
|
|
|
if (_vm->_hero->cycling == kCycleInvisible) // If invisible do
|
2010-12-30 21:07:38 +00:00
|
|
|
_vm->_object->useObject(objId); // immediate use
|
2010-08-17 09:28:20 +00:00
|
|
|
else
|
2011-03-21 12:07:23 +00:00
|
|
|
Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there
|
2010-08-17 11:00:29 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/** Process a left mouse click over:
|
2011-02-11 20:27:48 +00:00
|
|
|
* 1. An icon - show description
|
|
|
|
* 2. An object - walk to and show description
|
|
|
|
* 3. An icon scroll arrow - scroll the iconbar
|
|
|
|
* 4. Nothing - attempt to walk there
|
|
|
|
* 5. Exit - walk to exit hotspot
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int16 cy) {
|
2011-01-27 18:43:02 +00:00
|
|
|
debugC(1, kDebugMouse, "ProcessLeftClick(%d, %d, %d)", objId, cx, cy);
|
2010-10-03 08:08:42 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
int16 i, x, y;
|
|
|
|
object_t *obj;
|
|
|
|
|
2010-10-21 17:09:57 +00:00
|
|
|
status_t &gameStatus = _vm->getGameStatus();
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // Make sure user has control
|
2010-08-17 09:28:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (objId) {
|
|
|
|
case -1: // Empty space - attempt to walk there
|
2011-01-23 00:05:52 +00:00
|
|
|
_vm->_route->startRoute(kRouteSpace, 0, cx, cy);
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
2011-01-23 00:05:52 +00:00
|
|
|
case kLeftArrow: // A scroll arrow - scroll the iconbar
|
|
|
|
case kRightArrow:
|
2010-08-17 09:28:20 +00:00
|
|
|
// Scroll the iconbar and display results
|
2011-01-23 00:05:52 +00:00
|
|
|
_vm->_inventory->processInventory((objId == kLeftArrow) ? kInventoryActionLeft : kInventoryActionRight);
|
|
|
|
_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, kXPix, kInvDy, kXPix, _vm->_screen->getFrontBuffer(), 0, kDibOffY, kXPix);
|
|
|
|
_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, kXPix, kInvDy, kXPix, _vm->_screen->getBackBuffer(), 0, kDibOffY, kXPix);
|
|
|
|
_vm->_screen->displayList(kDisplayAdd, 0, kDibOffY, kXPix, kInvDy);
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
2011-01-23 00:05:52 +00:00
|
|
|
case kExitHotspot: // Walk to exit hotspot
|
2011-02-14 07:31:01 +00:00
|
|
|
i = findExit(cx, cy, *_vm->_screen_p);
|
|
|
|
x = _hotspots[i].viewx;
|
|
|
|
y = _hotspots[i].viewy;
|
2010-08-17 09:28:20 +00:00
|
|
|
if (x >= 0) { // Hotspot refers to an exit
|
|
|
|
// Special case of immediate exit
|
2011-02-08 20:52:26 +00:00
|
|
|
if (_jumpExitFl) {
|
2010-08-17 09:28:20 +00:00
|
|
|
// Get rid of iconbar if necessary
|
2011-02-08 20:52:26 +00:00
|
|
|
if (_vm->_inventory->getInventoryState() != kInventoryOff)
|
|
|
|
_vm->_inventory->setInventoryState(kInventoryUp);
|
2011-02-14 07:31:01 +00:00
|
|
|
_vm->_scheduler->insertActionList(_hotspots[i].actIndex);
|
2010-08-17 09:28:20 +00:00
|
|
|
} else { // Set up route to exit spot
|
2011-02-14 07:31:01 +00:00
|
|
|
if (_hotspots[i].direction == Common::KEYCODE_RIGHT)
|
2011-01-23 00:05:52 +00:00
|
|
|
x -= kHeroMaxWidth;
|
2011-02-14 07:31:01 +00:00
|
|
|
else if (_hotspots[i].direction == Common::KEYCODE_LEFT)
|
2011-01-23 00:05:52 +00:00
|
|
|
x += kHeroMaxWidth;
|
|
|
|
if (!_vm->_route->startRoute(kRouteExit, i, x, y))
|
2011-03-21 12:07:23 +00:00
|
|
|
Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get rid of any attached icon
|
2011-01-08 16:56:52 +00:00
|
|
|
_vm->_screen->resetInventoryObjId();
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: // Look at an icon or object
|
2010-10-21 17:09:57 +00:00
|
|
|
obj = &_vm->_object->_objects[objId];
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// Over iconbar - immediate description
|
2011-02-08 20:52:26 +00:00
|
|
|
if ((_vm->_inventory->getInventoryState() == kInventoryActive) && (cy < kInvDy + kDibOffY)) {
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_object->lookObject(obj);
|
2011-01-23 00:05:52 +00:00
|
|
|
} else {
|
2010-10-03 08:08:42 +00:00
|
|
|
bool foundFl = false; // TRUE if route found to object
|
2010-08-17 09:28:20 +00:00
|
|
|
switch (obj->viewx) { // Clicked over viewport object
|
|
|
|
case -1: // Walk to object position
|
2010-10-22 20:45:00 +00:00
|
|
|
if (_vm->_object->findObjectSpace(obj, &x, &y))
|
2011-01-23 00:05:52 +00:00
|
|
|
foundFl = _vm->_route->startRoute(kRouteLook, objId, x, y);
|
2010-10-03 08:08:42 +00:00
|
|
|
if (!foundFl) // Can't get there, immediate description
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_object->lookObject(obj);
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
case 0: // Immediate description
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->_object->lookObject(obj);
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
default: // Walk to view point if possible
|
2011-01-23 00:05:52 +00:00
|
|
|
if (!_vm->_route->startRoute(kRouteLook, objId, obj->viewx, obj->viewy)) {
|
|
|
|
if (_vm->_hero->cycling == kCycleInvisible) // If invisible do
|
|
|
|
_vm->_object->lookObject(obj); // immediate decription
|
2010-08-17 09:28:20 +00:00
|
|
|
else
|
2011-03-21 12:07:23 +00:00
|
|
|
Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there
|
2010-08-17 11:00:29 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Process mouse activity
|
|
|
|
*/
|
2010-08-17 09:28:20 +00:00
|
|
|
void MouseHandler::mouseHandler() {
|
|
|
|
debugC(2, kDebugMouse, "mouseHandler");
|
|
|
|
|
2011-01-19 18:02:53 +00:00
|
|
|
status_t &gameStatus = _vm->getGameStatus();
|
2011-02-08 20:52:26 +00:00
|
|
|
istate_t inventState = _vm->_inventory->getInventoryState();
|
|
|
|
if ((gameStatus.viewState != kViewPlay) && (inventState != kInventoryActive))
|
2011-01-19 18:02:53 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-08 20:52:26 +00:00
|
|
|
int16 cx = getMouseX();
|
|
|
|
int16 cy = getMouseY();
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-02-08 20:52:26 +00:00
|
|
|
// gameStatus.cx = cx; // Save cursor coords
|
|
|
|
// gameStatus.cy = cy;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// Don't process if outside client area
|
2011-01-23 00:05:52 +00:00
|
|
|
if ((cx < 0) || (cx > kXPix) || (cy < kDibOffY) || (cy > kViewSizeY + kDibOffY))
|
2010-08-17 09:28:20 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-03 08:08:42 +00:00
|
|
|
int16 objId = -1; // Current source object
|
2010-08-17 09:28:20 +00:00
|
|
|
// Process cursor over an object or icon
|
2011-02-08 20:52:26 +00:00
|
|
|
if (inventState == kInventoryActive) { // Check inventory icon bar first
|
2011-01-23 00:05:52 +00:00
|
|
|
objId = _vm->_inventory->processInventory(kInventoryActionGet, cx, cy);
|
2011-01-03 12:38:13 +00:00
|
|
|
} else {
|
|
|
|
if (cy < 5 && cy > 0) {
|
|
|
|
_vm->_topMenu->runModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 18:02:53 +00:00
|
|
|
if (!gameStatus.gameOverFl) {
|
2011-01-23 00:05:52 +00:00
|
|
|
if (objId == -1) // No match, check rest of view
|
2011-01-19 18:02:53 +00:00
|
|
|
objId = _vm->_object->findObject(cx, cy);
|
2011-01-23 00:05:52 +00:00
|
|
|
|
|
|
|
if (objId >= 0) { // Got a match
|
2011-01-19 18:02:53 +00:00
|
|
|
// Display object name next to cursor (unless CURSOR_NOCHAR)
|
|
|
|
// Note test for swapped hero name
|
2011-02-12 08:13:35 +00:00
|
|
|
const char *name = _vm->_text->getNoun(_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId].nounIndex, kCursorNameIndex);
|
2011-01-23 22:51:12 +00:00
|
|
|
if (name[0] != kCursorNochar)
|
2011-01-19 18:02:53 +00:00
|
|
|
cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);
|
|
|
|
|
|
|
|
// Process right click over object in view or iconbar
|
2011-02-08 20:52:26 +00:00
|
|
|
if (_rightButtonFl)
|
2011-01-19 18:02:53 +00:00
|
|
|
processRightClick(objId, cx, cy);
|
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-19 18:02:53 +00:00
|
|
|
// Process cursor over an exit hotspot
|
|
|
|
if (objId == -1) {
|
2011-02-14 07:31:01 +00:00
|
|
|
int i = findExit(cx, cy, *_vm->_screen_p);
|
|
|
|
if (i != -1 && _hotspots[i].viewx >= 0) {
|
2011-01-23 00:05:52 +00:00
|
|
|
objId = kExitHotspot;
|
2011-01-25 00:32:48 +00:00
|
|
|
cursorText(_vm->_text->getTextMouse(kMsExit), cx, cy, U_FONT8, _TBRIGHTWHITE);
|
2011-01-19 18:02:53 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Left click over icon, object or to move somewhere
|
2011-02-08 20:52:26 +00:00
|
|
|
if (_leftButtonFl)
|
2010-08-17 09:28:20 +00:00
|
|
|
processLeftClick(objId, cx, cy);
|
|
|
|
|
|
|
|
// Clear mouse click states
|
2011-02-08 20:52:26 +00:00
|
|
|
resetLeftButton();
|
|
|
|
resetRightButton();
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-02-18 07:11:55 +00:00
|
|
|
void MouseHandler::readHotspot(Common::ReadStream &in, hotspot_t &hotspot) {
|
|
|
|
hotspot.screenIndex = in.readSint16BE();
|
|
|
|
hotspot.x1 = in.readSint16BE();
|
|
|
|
hotspot.y1 = in.readSint16BE();
|
|
|
|
hotspot.x2 = in.readSint16BE();
|
|
|
|
hotspot.y2 = in.readSint16BE();
|
|
|
|
hotspot.actIndex = in.readUint16BE();
|
|
|
|
hotspot.viewx = in.readSint16BE();
|
|
|
|
hotspot.viewy = in.readSint16BE();
|
|
|
|
hotspot.direction = in.readSint16BE();
|
|
|
|
}
|
|
|
|
|
2011-02-14 07:31:01 +00:00
|
|
|
/**
|
|
|
|
* Load hotspots data from hugo.dat
|
|
|
|
*/
|
|
|
|
void MouseHandler::loadHotspots(Common::ReadStream &in) {
|
2011-02-18 07:11:55 +00:00
|
|
|
hotspot_t *wrkHotspots = 0;
|
|
|
|
hotspot_t tmp;
|
2011-02-14 07:31:01 +00:00
|
|
|
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
|
|
|
int numRows = in.readUint16BE();
|
|
|
|
if (varnt == _vm->_gameVariant)
|
2011-02-18 07:11:55 +00:00
|
|
|
_hotspots = wrkHotspots = (hotspot_t *)malloc(sizeof(hotspot_t) * numRows);
|
|
|
|
|
|
|
|
for (int i = 0; i < numRows; i++)
|
|
|
|
readHotspot(in, (varnt == _vm->_gameVariant) ? wrkHotspots[i] : tmp);
|
2011-02-14 07:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display hotspot boundaries for the current screen
|
|
|
|
*/
|
|
|
|
void MouseHandler::drawHotspots() const {
|
|
|
|
for (int i = 0; _hotspots[i].screenIndex >= 0; i++) {
|
|
|
|
hotspot_t *hotspot = &_hotspots[i];
|
|
|
|
if (hotspot->screenIndex == _vm->_hero->screenIndex)
|
|
|
|
_vm->_screen->drawRectangle(false, hotspot->x1, hotspot->y1, hotspot->x2, hotspot->y2, _TLIGHTRED);
|
|
|
|
}
|
|
|
|
}
|
2010-08-27 09:48:53 +00:00
|
|
|
} // End of namespace Hugo
|