aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/duckman
diff options
context:
space:
mode:
authorjohndoe1232014-12-11 14:14:52 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8 (patch)
tree60c9d7eb972d42f7e6cdaf5d6cb169906f4e1c28 /engines/illusions/duckman
parenta078073e88c094c23e4eb51e5fb85e2cecc3ae9a (diff)
downloadscummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.tar.gz
scummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.tar.bz2
scummvm-rg350-36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8.zip
ILLUSIONS: Refactor the input system
Diffstat (limited to 'engines/illusions/duckman')
-rw-r--r--engines/illusions/duckman/duckman_dialog.cpp2
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp37
-rw-r--r--engines/illusions/duckman/illusions_duckman.h2
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.cpp19
4 files changed, 44 insertions, 16 deletions
diff --git a/engines/illusions/duckman/duckman_dialog.cpp b/engines/illusions/duckman/duckman_dialog.cpp
index b30a2be7b9..3e42955ac9 100644
--- a/engines/illusions/duckman/duckman_dialog.cpp
+++ b/engines/illusions/duckman/duckman_dialog.cpp
@@ -156,7 +156,7 @@ void DuckmanDialogSystem::updateDialogState() {
_vm->setCursorActorIndex(6, 1, 0);
}
- if (_vm->_input->pollButton(1)) {
+ if (_vm->_input->pollEvent(kEventLeftClick)) {
if (_vm->_cursor._currOverlappedControl) {
_vm->playSoundEffect(9);
*_vm->_cursor._op113_choiceOfsPtr = _vm->_cursor._currOverlappedControl->_actor->_choiceJumpOffs;
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index 52567f2c75..b861d7328e 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -113,6 +113,8 @@ Common::Error IllusionsEngine_Duckman::run() {
_dialogSys = new DuckmanDialogSystem(this);
+ initInput();
+
initUpdateFunctions();
_scriptOpcodes = new ScriptOpcodes_Duckman(this);
@@ -203,6 +205,29 @@ bool IllusionsEngine_Duckman::hasFeature(EngineFeature f) const {
*/
}
+void IllusionsEngine_Duckman::initInput() {
+ // TODO Check if these are correct...
+ _input->setInputEvent(kEventLeftClick, 0x01)
+ .addMouseButton(MOUSE_LEFT_BUTTON)
+ .addKey(Common::KEYCODE_RETURN);
+ _input->setInputEvent(kEventRightClick, 0x02)
+ .addMouseButton(MOUSE_RIGHT_BUTTON)
+ .addKey(Common::KEYCODE_BACKSPACE);
+ // 0x04 is unused
+ _input->setInputEvent(kEventInventory, 0x08)
+ .addKey(Common::KEYCODE_TAB);
+ _input->setInputEvent(kEventAbort, 0x10)
+ .addKey(Common::KEYCODE_ESCAPE);
+ _input->setInputEvent(kEventSkip, 0x20)
+ .addMouseButton(MOUSE_LEFT_BUTTON)
+ .addKey(Common::KEYCODE_SPACE);
+ _input->setInputEvent(kEventUp, 0x40)
+ .addKey(Common::KEYCODE_UP);
+ _input->setInputEvent(kEventDown, 0x80)
+ .addMouseButton(MOUSE_RIGHT_BUTTON)
+ .addKey(Common::KEYCODE_DOWN);
+}
+
#define UPDATEFUNCTION(priority, tag, callback) \
_updateFunctions->add(priority, tag, new Common::Functor1Mem<uint, int, IllusionsEngine_Duckman> \
(this, &IllusionsEngine_Duckman::callback));
@@ -301,7 +326,7 @@ void IllusionsEngine_Duckman::loadSpecialCode(uint32 resId) {
}
void IllusionsEngine_Duckman::unloadSpecialCode(uint32 resId) {
- //TODO?
+ delete _specialCode;
}
void IllusionsEngine_Duckman::notifyThreadId(uint32 &threadId) {
@@ -315,7 +340,7 @@ void IllusionsEngine_Duckman::notifyThreadId(uint32 &threadId) {
bool IllusionsEngine_Duckman::testMainActorFastWalk(Control *control) {
return
control->_objectId == _scriptResource->getMainActorObjectId() &&
- _input->pollButton(0x20);
+ _input->pollEvent(kEventSkip);
}
bool IllusionsEngine_Duckman::testMainActorCollision(Control *control) {
@@ -742,7 +767,7 @@ void IllusionsEngine_Duckman::leavePause(uint32 sceneId, uint32 threadId) {
}
void IllusionsEngine_Duckman::dumpActiveScenes(uint32 sceneId, uint32 threadId) {
- // TODO
+ // TODO?
}
void IllusionsEngine_Duckman::dumpCurrSceneFiles(uint32 sceneId, uint32 threadId) {
@@ -866,7 +891,7 @@ void IllusionsEngine_Duckman::updateGameState2() {
_cursor._currOverlappedControl = 0;
}
- if (_input->pollButton(1)) {
+ if (_input->pollEvent(kEventLeftClick)) {
if (_cursor._currOverlappedControl) {
runTriggerCause(_cursor._actorIndex, _cursor._objectId, _cursor._currOverlappedControl->_objectId);
} else {
@@ -877,7 +902,7 @@ void IllusionsEngine_Duckman::updateGameState2() {
else
runTriggerCause(_cursor._actorIndex, _cursor._objectId, 0x40003);
}
- } else if (_input->pollButton(2)) {
+ } else if (_input->pollEvent(kEventRightClick)) {
if (_cursor._actorIndex != 3 && _cursor._actorIndex != 10 && _cursor._actorIndex != 11 && _cursor._actorIndex != 12 && _cursor._actorIndex != 13) {
int newActorIndex = getCursorActorIndex();
if (newActorIndex != _cursor._actorIndex) {
@@ -889,7 +914,7 @@ void IllusionsEngine_Duckman::updateGameState2() {
startCursorSequence();
}
}
- } else if (_input->pollButton(8)) {
+ } else if (_input->pollEvent(kEventInventory)) {
if (_cursor._field14[0] == 1) {
runTriggerCause(1, 0, _scriptResource->getMainActorObjectId());
} else if (_cursor._field14[1] == 1) {
diff --git a/engines/illusions/duckman/illusions_duckman.h b/engines/illusions/duckman/illusions_duckman.h
index 7638c3a44d..5fda0d6d68 100644
--- a/engines/illusions/duckman/illusions_duckman.h
+++ b/engines/illusions/duckman/illusions_duckman.h
@@ -100,6 +100,8 @@ public:
ScreenShaker *_screenShaker;
+ void initInput();
+
void initUpdateFunctions();
int updateScript(uint flags);
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp
index 0e79774fd2..3f12209a84 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.cpp
+++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp
@@ -250,7 +250,7 @@ void ScriptOpcodes_Duckman::opEnterScene18(ScriptThread *scriptThread, OpCall &o
//static uint dsceneId = 0, dthreadId = 0;
//static uint dsceneId = 0x00010008, dthreadId = 0x00020029;//Beginning in Jac
-//static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;//Home front
+static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;//Home front
//static uint dsceneId = 0x0001000E, dthreadId = 0x0002007C;
//static uint dsceneId = 0x00010012, dthreadId = 0x0002009D;//Paramount
//static uint dsceneId = 0x00010020, dthreadId = 0x00020112;//Xmas
@@ -261,15 +261,16 @@ void ScriptOpcodes_Duckman::opEnterScene18(ScriptThread *scriptThread, OpCall &o
//static uint dsceneId = 0x00010036, dthreadId = 0x000201B5;
//static uint dsceneId = 0x00010039, dthreadId = 0x00020089;//Map
//static uint dsceneId = 0x0001003D, dthreadId = 0x000201E0;
-static uint dsceneId = 0x0001004B, dthreadId = 0x0002029B;
+//static uint dsceneId = 0x0001004B, dthreadId = 0x0002029B;
//static uint dsceneId = 0x0001005B, dthreadId = 0x00020341;
//static uint dsceneId = 0x00010010, dthreadId = 0x0002008A;
+//static uint dsceneId = 0x10002, dthreadId = 0x20001;//Debug menu, not supported
void ScriptOpcodes_Duckman::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(sceneId);
ARG_UINT32(threadId);
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
debug("changeScene(%08X, %08X)", sceneId, threadId);
@@ -291,7 +292,7 @@ void ScriptOpcodes_Duckman::opStartModalScene(ScriptThread *scriptThread, OpCall
ARG_SKIP(2);
ARG_UINT32(sceneId);
ARG_UINT32(threadId);
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
_vm->enterPause(_vm->getCurrentScene(), opCall._callerThreadId);
_vm->_talkItems->pauseByTag(_vm->getCurrentScene());
_vm->enterScene(sceneId, threadId);
@@ -299,7 +300,7 @@ void ScriptOpcodes_Duckman::opStartModalScene(ScriptThread *scriptThread, OpCall
}
void ScriptOpcodes_Duckman::opExitModalScene(ScriptThread *scriptThread, OpCall &opCall) {
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
if (_vm->_scriptResource->_properties.get(0x000E0027)) {
// TODO _vm->startScriptThread2(0x10002, 0x20001, 0);
opCall._result = kTSTerminate;
@@ -314,13 +315,13 @@ void ScriptOpcodes_Duckman::opExitModalScene(ScriptThread *scriptThread, OpCall
void ScriptOpcodes_Duckman::opEnterScene24(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(sceneId);
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
_vm->enterPause(_vm->getCurrentScene(), opCall._callerThreadId);
_vm->enterScene(sceneId, 0);
}
void ScriptOpcodes_Duckman::opLeaveScene24(ScriptThread *scriptThread, OpCall &opCall) {
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
_vm->dumpCurrSceneFiles(_vm->getCurrentScene(), opCall._callerThreadId);
_vm->exitScene();
_vm->leavePause(_vm->getCurrentScene(), opCall._callerThreadId);
@@ -797,7 +798,7 @@ void ScriptOpcodes_Duckman::opEnterScene(ScriptThread *scriptThread, OpCall &opC
void ScriptOpcodes_Duckman::opEnterCloseUpScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(sceneId);
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
_vm->enterPause(opCall._callerThreadId);
_vm->enterScene(sceneId, opCall._callerThreadId);
}
@@ -945,7 +946,7 @@ void ScriptOpcodes_Duckman::opChangeSceneAll(ScriptThread *scriptThread, OpCall
ARG_SKIP(2);
ARG_UINT32(sceneId);
ARG_UINT32(threadId);
- _vm->_input->discardButtons(0xFFFF);
+ _vm->_input->discardAllEvents();
_vm->_prevSceneId = _vm->getCurrentScene();
_vm->dumpActiveScenes(_vm->_globalSceneId, opCall._callerThreadId);
_vm->enterScene(sceneId, opCall._callerThreadId);