aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-08-30 10:27:20 +0000
committerNicola Mettifogo2008-08-30 10:27:20 +0000
commit0a387bca12797b63432aeecedd262a5433389b83 (patch)
tree2bd04fc59133c42234a0dd906d17685cb2fdbc26
parent4e7205af360e3325871f1e27547ea92a3bad4cee (diff)
downloadscummvm-rg350-0a387bca12797b63432aeecedd262a5433389b83.tar.gz
scummvm-rg350-0a387bca12797b63432aeecedd262a5433389b83.tar.bz2
scummvm-rg350-0a387bca12797b63432aeecedd262a5433389b83.zip
Moved mouse cursor loading/handling to Input class.
svn-id: r34206
-rw-r--r--engines/parallaction/disk.h4
-rw-r--r--engines/parallaction/gui_br.cpp2
-rw-r--r--engines/parallaction/gui_ns.cpp4
-rw-r--r--engines/parallaction/input.cpp162
-rw-r--r--engines/parallaction/input.h28
-rw-r--r--engines/parallaction/parallaction.cpp7
-rw-r--r--engines/parallaction/parallaction.h28
-rw-r--r--engines/parallaction/parallaction_br.cpp71
-rw-r--r--engines/parallaction/parallaction_ns.cpp35
-rw-r--r--engines/parallaction/saveload.cpp2
-rw-r--r--engines/parallaction/staticres.cpp2
11 files changed, 176 insertions, 169 deletions
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index 2923f239d4..45a2b9d2ef 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -29,10 +29,12 @@
#define PATH_LEN 200
#include "common/fs.h"
-
#include "common/file.h"
+
#include "graphics/surface.h"
+#include "parallaction/graphics.h"
+
namespace Parallaction {
class Table;
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index 064f6f7fa5..6d1facf885 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -230,7 +230,7 @@ public:
_vm->_gfx->setItemFrame(id, 0);
}
_selection = -1;
- _vm->setArrowCursor();
+ _vm->_input->setArrowCursor();
_vm->_input->setMouseState(MOUSE_ENABLED_SHOW);
}
diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp
index b53d591bff..7d429e188f 100644
--- a/engines/parallaction/gui_ns.cpp
+++ b/engines/parallaction/gui_ns.cpp
@@ -178,7 +178,7 @@ public:
uint id = _vm->_gfx->createLabel(_vm->_introFont, "SELECT LANGUAGE", 1);
_vm->_gfx->showLabel(id, 60, 30);
- _vm->setArrowCursor();
+ _vm->_input->setArrowCursor();
}
};
@@ -556,7 +556,7 @@ public:
cleanup();
- _vm->setArrowCursor();
+ _vm->_input->setArrowCursor();
_vm->_input->setMouseState(MOUSE_ENABLED_SHOW);
_state = CHOICE;
}
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index e3c13bbbcb..c14c512a26 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -31,6 +31,58 @@
namespace Parallaction {
+#define MOUSEARROW_WIDTH_NS 16
+#define MOUSEARROW_HEIGHT_NS 16
+
+#define MOUSECOMBO_WIDTH_NS 32 // sizes for cursor + selected inventory item
+#define MOUSECOMBO_HEIGHT_NS 32
+
+struct MouseComboProperties {
+ int _xOffset;
+ int _yOffset;
+ int _width;
+ int _height;
+};
+/*
+// TODO: improve NS's handling of normal cursor before merging cursor code.
+MouseComboProperties _mouseComboProps_NS = {
+ 7, // combo x offset (the icon from the inventory will be rendered from here)
+ 7, // combo y offset (ditto)
+ 32, // combo (arrow + icon) width
+ 32 // combo (arrow + icon) height
+};
+*/
+MouseComboProperties _mouseComboProps_BR = {
+ 8, // combo x offset (the icon from the inventory will be rendered from here)
+ 8, // combo y offset (ditto)
+ 68, // combo (arrow + icon) width
+ 68 // combo (arrow + icon) height
+};
+
+Input::Input(Parallaction *vm) : _vm(vm) {
+ _gameType = _vm->getGameType();
+ _transCurrentHoverItem = 0;
+ _hasDelayedAction = false; // actived when the character needs to move before taking an action
+ _mouseState = MOUSE_DISABLED;
+ _activeItem._index = 0;
+ _activeItem._id = 0;
+ _mouseButtons = 0;
+ _delayedActionZone = nullZonePtr;
+
+ initCursors();
+}
+
+Input::~Input() {
+ if (_gameType == GType_Nippon) {
+ delete _mouseArrow;
+ }
+
+ delete _comboArrow;
+ delete _dinoCursor;
+ delete _dougCursor;
+ delete _donnaCursor;
+}
+
// FIXME: the engine has 3 event loops. The following routine hosts the main one,
// and it's called from 8 different places in the code. There exist 2 more specialised
// loops which could possibly be merged into this one with some effort in changing
@@ -131,8 +183,6 @@ int Input::updateGameInput() {
int event = kEvNone;
- readInput();
-
if (!isMouseEnabled() ||
(_engineFlags & kEngineWalking) ||
(_engineFlags & kEngineChangeLocation)) {
@@ -162,20 +212,14 @@ int Input::updateGameInput() {
int Input::updateInput() {
int event = kEvNone;
+ readInput();
switch (_inputMode) {
- case kInputModeComment:
- case kInputModeDialogue:
- case kInputModeMenu:
- readInput();
- break;
-
case kInputModeGame:
event = updateGameInput();
break;
case kInputModeInventory:
- readInput();
updateInventoryInput();
break;
}
@@ -214,7 +258,7 @@ void Input::takeAction(ZonePtr z) {
void Input::walkTo(const Common::Point &dest) {
stopHovering();
- _vm->setArrowCursor();
+ setArrowCursor();
_vm->_char.scheduleWalk(dest.x, dest.y);
}
@@ -270,7 +314,7 @@ bool Input::translateGameInput() {
}
_vm->beep();
- _vm->setArrowCursor();
+ setArrowCursor();
return true;
}
@@ -286,7 +330,7 @@ void Input::enterInventoryMode() {
_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
_engineFlags |= kEngineDragging;
} else {
- _vm->setArrowCursor();
+ setArrowCursor();
}
}
@@ -321,12 +365,12 @@ void Input::exitInventoryMode() {
_vm->closeInventory();
if (pos == -1) {
- _vm->setArrowCursor();
+ setArrowCursor();
} else {
const InventoryItem *item = _vm->getInventoryItem(pos);
if (item->_index != 0) {
_activeItem._id = item->_id;
- _vm->setInventoryCursor(item->_index);
+ setInventoryCursor(item->_index);
}
}
_vm->resumeJobs();
@@ -374,4 +418,94 @@ bool Input::isMouseEnabled() {
return (_mouseState == MOUSE_ENABLED_SHOW) || (_mouseState == MOUSE_ENABLED_HIDE);
}
+
+void Input::initCursors() {
+
+ switch (_gameType) {
+ case GType_Nippon:
+ _comboArrow = _vm->_disk->loadPointer("pointer");
+ _mouseArrow = new Cnv(1, MOUSEARROW_WIDTH_NS, MOUSEARROW_HEIGHT_NS, _resMouseArrow_NS);
+ break;
+
+ case GType_BRA:
+ if (_vm->getPlatform() == Common::kPlatformPC) {
+ _dinoCursor = _vm->_disk->loadPointer("pointer1");
+ _dougCursor = _vm->_disk->loadPointer("pointer2");
+ _donnaCursor = _vm->_disk->loadPointer("pointer3");
+
+ Graphics::Surface *surf = new Graphics::Surface;
+ surf->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, 1);
+ _comboArrow = new SurfaceToFrames(surf);
+
+ // TODO: choose the pointer depending on the active character
+ // For now, we pick Donna's
+ _mouseArrow = _donnaCursor;
+ } else {
+ // TODO: Where are the Amiga cursors?
+ _mouseArrow = 0;
+ }
+ break;
+
+ default:
+ warning("Input::initCursors: unknown gametype");
+ }
+
+}
+
+void Input::setArrowCursor() {
+
+ switch (_gameType) {
+ case GType_Nippon:
+ debugC(1, kDebugInput, "setting mouse cursor to arrow");
+ // this stuff is needed to avoid artifacts with labels and selected items when switching cursors
+ stopHovering();
+ _activeItem._id = 0;
+ _vm->_system->setMouseCursor(_mouseArrow->getData(0), MOUSEARROW_WIDTH_NS, MOUSEARROW_HEIGHT_NS, 0, 0, 0);
+ break;
+
+ case GType_BRA: {
+ if (_vm->getPlatform() == Common::kPlatformAmiga)
+ return;
+
+ Common::Rect r;
+ _mouseArrow->getRect(0, r);
+ _vm->_system->setMouseCursor(_mouseArrow->getData(0), r.width(), r.height(), 0, 0, 0);
+ _vm->_system->showMouse(true);
+ _activeItem._id = 0;
+ break;
+ }
+
+ default:
+ warning("Input::setArrowCursor: unknown gametype");
+ }
+
+}
+
+void Input::setInventoryCursor(ItemName name) {
+ assert(name > 0);
+
+ switch (_gameType) {
+ case GType_Nippon: {
+ byte *v8 = _comboArrow->getData(0);
+ // FIXME: destination offseting is not clear
+ _vm->_inventoryRenderer->drawItem(name, v8 + 7 * MOUSECOMBO_WIDTH_NS + 7, MOUSECOMBO_WIDTH_NS);
+ _vm->_system->setMouseCursor(v8, MOUSECOMBO_WIDTH_NS, MOUSECOMBO_HEIGHT_NS, 0, 0, 0);
+ break;
+ }
+
+ case GType_BRA: {
+ byte *src = _mouseArrow->getData(0);
+ byte *dst = _comboArrow->getData(0);
+ memcpy(dst, src, _comboArrow->getSize(0));
+ // FIXME: destination offseting is not clear
+ _vm->_inventoryRenderer->drawItem(name, dst + _mouseComboProps_BR._yOffset * _mouseComboProps_BR._width + _mouseComboProps_BR._xOffset, _mouseComboProps_BR._width);
+ _vm->_system->setMouseCursor(dst, _mouseComboProps_BR._width, _mouseComboProps_BR._height, 0, 0, 0);
+ }
+
+ default:
+ warning("Input::setInventoryCursor: unknown gametype");
+ }
+
+}
+
} // namespace Parallaction
diff --git a/engines/parallaction/input.h b/engines/parallaction/input.h
index 1110e1da87..e7d20c0d2e 100644
--- a/engines/parallaction/input.h
+++ b/engines/parallaction/input.h
@@ -74,6 +74,17 @@ class Input {
void enterInventoryMode();
void exitInventoryMode();
+ int _gameType;
+
+ static byte _resMouseArrow_NS[256];
+ Frames *_mouseArrow;
+ Frames *_comboArrow;
+ Frames *_dinoCursor;
+ Frames *_dougCursor;
+ Frames *_donnaCursor;
+
+ void initCursors();
+
public:
enum {
kInputModeGame = 0,
@@ -84,18 +95,8 @@ public:
};
- Input(Parallaction *vm) : _vm(vm) {
- _transCurrentHoverItem = 0;
- _hasDelayedAction = false; // actived when the character needs to move before taking an action
- _mouseState = MOUSE_DISABLED;
- _activeItem._index = 0;
- _activeItem._id = 0;
- _mouseButtons = 0;
- _delayedActionZone = nullZonePtr;
- }
-
- virtual ~Input() { }
-
+ Input(Parallaction *vm);
+ virtual ~Input();
void getCursorPos(Common::Point& p) {
p = _mousePos;
@@ -118,6 +119,9 @@ public:
void setMouseState(MouseTriState state);
MouseTriState getMouseState();
bool isMouseEnabled();
+
+ void setArrowCursor();
+ void setInventoryCursor(ItemName name);
};
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 3d2bb979d6..b8795871a3 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -100,8 +100,6 @@ Parallaction::~Parallaction() {
cleanupGui();
- delete _comboArrow;
-
delete _localFlagNames;
delete _gfx;
delete _soundMan;
@@ -134,6 +132,7 @@ int Parallaction::init() {
initInventory(); // needs to be pushed into subclass
+ // this needs _disk to be already setup
_input = new Input(this);
_gfx = new Gfx(this);
@@ -301,13 +300,13 @@ void Parallaction::processInput(int event) {
case kEvSaveGame:
_input->stopHovering();
saveGame();
- setArrowCursor();
+ _input->setArrowCursor();
break;
case kEvLoadGame:
_input->stopHovering();
loadGame();
- setArrowCursor();
+ _input->setArrowCursor();
break;
}
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 32ddb9f90a..ba4a3b8c21 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -90,10 +90,6 @@ enum {
kEvLoadGame = 4000
};
-enum {
- kCursorArrow = -1
-};
-
enum ParallactionGameType {
GType_Nippon = 1,
GType_BRA
@@ -104,7 +100,6 @@ struct PARALLACTIONGameDescription;
-extern uint16 _mouseButtons;
extern char _password[8];
extern uint16 _score;
extern uint16 _language;
@@ -302,7 +297,6 @@ public:
Common::RandomSource _rnd;
Debugger *_debugger;
- Frames *_comboArrow;
protected: // data
@@ -337,9 +331,6 @@ public:
virtual void callFunction(uint index, void* parm) { }
- virtual void setArrowCursor() = 0;
- virtual void setInventoryCursor(ItemName name) = 0;
-
virtual void parseLocation(const char* name) = 0;
void updateDoor(ZonePtr z, bool close);
@@ -455,7 +446,6 @@ public:
void switchBackground(const char* background, const char* mask);
void showSlide(const char *name, int x = 0, int y = 0);
- void setArrowCursor();
// TODO: this should be private!!!!!!!
bool _inTestResult;
@@ -479,19 +469,12 @@ private:
void changeCharacter(const char *name);
void runPendingZones();
- void setInventoryCursor(ItemName name);
-
-
void doLoadGame(uint16 slot);
void doSaveGame(uint16 slot, const char* name);
int buildSaveFileList(Common::StringList& l);
int selectSaveFile(uint16 arg_0, const char* caption, const char* button);
void initResources();
- void initCursors();
-
- static byte _resMouseArrow[256];
- byte *_mouseArrow;
static const Callable _dosCallables[25];
static const Callable _amigaCallables[25];
@@ -599,7 +582,6 @@ public:
uint32 _zoneFlags[NUM_LOCATIONS][NUM_ZONES];
void startPart(uint part);
- void setArrowCursor();
private:
LocationParser_br *_locationParser;
ProgramParser_br *_programParser;
@@ -607,9 +589,6 @@ private:
void initResources();
void initFonts();
void freeFonts();
-
- void setInventoryCursor(ItemName name);
-
void changeLocation(char *location);
void runPendingZones();
@@ -617,13 +596,6 @@ private:
void freePart();
void freeLocation();
- void initCursors();
-
- Frames *_dinoCursor;
- Frames *_dougCursor;
- Frames *_donnaCursor;
- Frames *_mouseArrow;
-
static const char *_partNames[];
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 1030fee8dc..25f541bdb2 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -32,27 +32,6 @@
namespace Parallaction {
-struct MouseComboProperties {
- int _xOffset;
- int _yOffset;
- int _width;
- int _height;
-};
-/*
-// TODO: improve NS's handling of normal cursor before merging cursor code.
-MouseComboProperties _mouseComboProps_NS = {
- 7, // combo x offset (the icon from the inventory will be rendered from here)
- 7, // combo y offset (ditto)
- 32, // combo (arrow + icon) width
- 32 // combo (arrow + icon) height
-};
-*/
-MouseComboProperties _mouseComboProps_BR = {
- 8, // combo x offset (the icon from the inventory will be rendered from here)
- 8, // combo y offset (ditto)
- 68, // combo (arrow + icon) width
- 68 // combo (arrow + icon) height
-};
const char *Parallaction_br::_partNames[] = {
"PART0",
@@ -96,7 +75,6 @@ int Parallaction_br::init() {
initResources();
initFonts();
- initCursors();
_locationParser = new LocationParser_br(this);
_locationParser->init();
_programParser = new ProgramParser_br(this);
@@ -119,10 +97,6 @@ int Parallaction_br::init() {
Parallaction_br::~Parallaction_br() {
freeFonts();
-
- delete _dinoCursor;
- delete _dougCursor;
- delete _donnaCursor;
}
void Parallaction_br::callFunction(uint index, void* parm) {
@@ -170,26 +144,6 @@ void Parallaction_br::freeFonts() {
return;
}
-void Parallaction_br::initCursors() {
-
- if (getPlatform() == Common::kPlatformPC) {
- _dinoCursor = _disk->loadPointer("pointer1");
- _dougCursor = _disk->loadPointer("pointer2");
- _donnaCursor = _disk->loadPointer("pointer3");
-
- Graphics::Surface *surf = new Graphics::Surface;
- surf->create(_mouseComboProps_BR._width, _mouseComboProps_BR._height, 1);
- _comboArrow = new SurfaceToFrames(surf);
-
- // TODO: choose the pointer depending on the active character
- // For now, we pick Donna's
- _mouseArrow = _donnaCursor;
- } else {
- // TODO: Where are the Amiga cursors?
- _mouseArrow = 0;
- }
-
-}
void Parallaction_br::initPart() {
@@ -365,30 +319,5 @@ void Parallaction_br::changeCharacter(const char *name) {
}
-void Parallaction_br::setArrowCursor() {
- // FIXME: Where are the Amiga cursors?
- if (getPlatform() == Common::kPlatformAmiga)
- return;
-
- Common::Rect r;
- _mouseArrow->getRect(0, r);
-
- _system->setMouseCursor(_mouseArrow->getData(0), r.width(), r.height(), 0, 0, 0);
- _system->showMouse(true);
-
- _input->_activeItem._id = 0;
-}
-
-void Parallaction_br::setInventoryCursor(ItemName name) {
- assert(name > 0);
-
- byte *src = _mouseArrow->getData(0);
- byte *dst = _comboArrow->getData(0);
- memcpy(dst, src, _comboArrow->getSize(0));
-
- // FIXME: destination offseting is not clear
- _inventoryRenderer->drawItem(name, dst + _mouseComboProps_BR._yOffset * _mouseComboProps_BR._width + _mouseComboProps_BR._xOffset, _mouseComboProps_BR._width);
- _system->setMouseCursor(dst, _mouseComboProps_BR._width, _mouseComboProps_BR._height, 0, 0, 0);
-}
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 61f2859e8a..7c3dcc7222 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -35,12 +35,6 @@
namespace Parallaction {
-#define MOUSEARROW_WIDTH 16
-#define MOUSEARROW_HEIGHT 16
-
-#define MOUSECOMBO_WIDTH 32 // sizes for cursor + selected inventory item
-#define MOUSECOMBO_HEIGHT 32
-
LocationName::LocationName() {
_buf = 0;
_hasSlide = false;
@@ -135,7 +129,6 @@ int Parallaction_ns::init() {
initResources();
initFonts();
- initCursors();
_locationParser = new LocationParser_ns(this);
_locationParser->init();
_programParser = new ProgramParser_ns(this);
@@ -181,32 +174,6 @@ void Parallaction_ns::freeFonts() {
}
-void Parallaction_ns::initCursors() {
- _comboArrow = _disk->loadPointer("pointer");
- _mouseArrow = _resMouseArrow;
-}
-
-void Parallaction_ns::setArrowCursor() {
-
- debugC(1, kDebugInput, "setting mouse cursor to arrow");
-
- // this stuff is needed to avoid artifacts with labels and selected items when switching cursors
- _input->stopHovering();
- _input->_activeItem._id = 0;
-
- _system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
-}
-
-void Parallaction_ns::setInventoryCursor(ItemName name) {
- assert(name > 0);
-
- byte *v8 = _comboArrow->getData(0);
-
- // FIXME: destination offseting is not clear
- _inventoryRenderer->drawItem(name, v8 + 7 * MOUSECOMBO_WIDTH + 7, MOUSECOMBO_WIDTH);
- _system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0);
-}
-
void Parallaction_ns::callFunction(uint index, void* parm) {
assert(index < 25); // magic value 25 is maximum # of callables for Nippon Safes
@@ -287,7 +254,7 @@ void Parallaction_ns::changeLocation(char *location) {
_zoneTrap = nullZonePtr;
- setArrowCursor();
+ _input->setArrowCursor();
_gfx->showGfxObj(_char._ani->gfxobj, false);
_location._animations.remove(_char._ani);
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index 25cf3c8cf0..d616230baa 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -392,7 +392,7 @@ bool Parallaction_ns::loadGame() {
GUI::TimedMessageDialog dialog("Loading game...", 1500);
dialog.runModal();
- setArrowCursor();
+ _input->setArrowCursor();
return true;
}
diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp
index 09353f0466..071495e8f1 100644
--- a/engines/parallaction/staticres.cpp
+++ b/engines/parallaction/staticres.cpp
@@ -29,7 +29,7 @@
namespace Parallaction {
-byte Parallaction_ns::_resMouseArrow[256] = {
+byte Input::_resMouseArrow_NS[256] = {
0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00,
0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00,
0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00,