2009-06-24 23:58:30 +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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "draci/draci.h"
|
|
|
|
#include "draci/mouse.h"
|
2009-06-25 11:02:10 +00:00
|
|
|
#include "draci/barchive.h"
|
2009-06-24 23:58:30 +00:00
|
|
|
|
|
|
|
namespace Draci {
|
|
|
|
|
|
|
|
Mouse::Mouse(DraciEngine *vm) {
|
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
|
|
|
_lButton = false;
|
|
|
|
_rButton = false;
|
2009-06-25 15:08:49 +00:00
|
|
|
_cursorType = kNormalCursor;
|
2009-06-24 23:58:30 +00:00
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mouse::handleEvent(Common::Event event) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2009-10-04 20:08:11 +00:00
|
|
|
debugC(6, kDraciGeneralDebugLevel, "Left button down (x: %u y: %u)", _x, _y);
|
|
|
|
_lButton = true;
|
2009-06-24 23:58:30 +00:00
|
|
|
break;
|
2009-07-07 15:21:41 +00:00
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2009-06-25 18:06:35 +00:00
|
|
|
debugC(6, kDraciGeneralDebugLevel, "Left button up (x: %u y: %u)", _x, _y);
|
2009-10-01 16:47:34 +00:00
|
|
|
// Don't set _lButton to false, because some touchpads generate
|
|
|
|
// down and up at such a quick succession, that they will
|
|
|
|
// cancel each other in the same call of handleEvents(). Let
|
|
|
|
// the game clear this flag by calling lButtonSet() instead.
|
2009-06-24 23:58:30 +00:00
|
|
|
break;
|
2009-07-07 15:21:41 +00:00
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
debugC(6, kDraciGeneralDebugLevel, "Right button down (x: %u y: %u)", _x, _y);
|
|
|
|
_rButton = true;
|
|
|
|
break;
|
2009-07-07 15:21:41 +00:00
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
debugC(6, kDraciGeneralDebugLevel, "Right button up (x: %u y: %u)", _x, _y);
|
|
|
|
break;
|
2009-07-07 15:21:41 +00:00
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2009-08-17 18:23:05 +00:00
|
|
|
debugC(6, kDraciGeneralDebugLevel, "Mouse move (x: %u y: %u)", _x, _y);
|
|
|
|
_x = (uint16) event.mouse.x;
|
|
|
|
_y = (uint16) event.mouse.y;
|
2009-09-30 10:45:14 +00:00
|
|
|
break;
|
2009-07-07 15:21:41 +00:00
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mouse::cursorOn() {
|
|
|
|
CursorMan.showMouse(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mouse::cursorOff() {
|
|
|
|
CursorMan.showMouse(false);
|
|
|
|
}
|
|
|
|
|
2009-09-25 08:13:39 +00:00
|
|
|
bool Mouse::isCursorOn() const {
|
2009-08-06 04:48:43 +00:00
|
|
|
return CursorMan.isVisible();
|
|
|
|
}
|
|
|
|
|
2009-06-24 23:58:30 +00:00
|
|
|
void Mouse::setPosition(uint16 x, uint16 y) {
|
|
|
|
_vm->_system->warpMouse(x, y);
|
|
|
|
}
|
|
|
|
|
2009-06-25 15:08:49 +00:00
|
|
|
void Mouse::setCursorType(CursorType cur) {
|
|
|
|
_cursorType = cur;
|
2009-08-09 03:58:03 +00:00
|
|
|
|
2009-09-28 03:51:23 +00:00
|
|
|
const BAFile *f;
|
2009-08-09 03:58:03 +00:00
|
|
|
f = _vm->_iconsArchive->getFile(_cursorType);
|
|
|
|
|
|
|
|
Sprite sp(f->_data, f->_length, 0, 0, true);
|
|
|
|
CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);
|
2009-09-30 16:04:21 +00:00
|
|
|
CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(),
|
2009-09-30 10:45:14 +00:00
|
|
|
sp.getWidth() / 2, sp.getHeight() / 2);
|
2009-08-09 03:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Mouse::loadItemCursor(int itemID, bool highlighted) {
|
2009-09-28 03:51:23 +00:00
|
|
|
const BAFile *f;
|
2009-08-09 20:33:58 +00:00
|
|
|
f = _vm->_itemImagesArchive->getFile(2 * itemID + highlighted);
|
2009-06-25 11:02:10 +00:00
|
|
|
|
2009-07-04 18:35:08 +00:00
|
|
|
Sprite sp(f->_data, f->_length, 0, 0, true);
|
2009-06-25 11:02:10 +00:00
|
|
|
CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);
|
2009-09-30 16:04:21 +00:00
|
|
|
CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(),
|
2009-09-30 10:45:14 +00:00
|
|
|
sp.getWidth() / 2, sp.getHeight() / 2);
|
2009-06-24 23:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|