diff options
author | johndoe123 | 2014-12-04 13:23:29 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | d6e2f61155f1e0e312391b76eded58c169046282 (patch) | |
tree | 048e509cd56dec7f628c9ceecea12b3ac1270076 /engines/illusions/duckman | |
parent | dec9ef3123dc2cf66983813fd58f4acff6806ce3 (diff) | |
download | scummvm-rg350-d6e2f61155f1e0e312391b76eded58c169046282.tar.gz scummvm-rg350-d6e2f61155f1e0e312391b76eded58c169046282.tar.bz2 scummvm-rg350-d6e2f61155f1e0e312391b76eded58c169046282.zip |
ILLUSIONS: Move Duckman dialog code to own file
Diffstat (limited to 'engines/illusions/duckman')
-rw-r--r-- | engines/illusions/duckman/duckman_dialog.cpp | 178 | ||||
-rw-r--r-- | engines/illusions/duckman/duckman_dialog.h | 51 | ||||
-rw-r--r-- | engines/illusions/duckman/illusions_duckman.cpp | 116 | ||||
-rw-r--r-- | engines/illusions/duckman/illusions_duckman.h | 14 |
4 files changed, 238 insertions, 121 deletions
diff --git a/engines/illusions/duckman/duckman_dialog.cpp b/engines/illusions/duckman/duckman_dialog.cpp new file mode 100644 index 0000000000..b0b74df839 --- /dev/null +++ b/engines/illusions/duckman/duckman_dialog.cpp @@ -0,0 +1,178 @@ +/* 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. + * + */ + +#include "illusions/duckman/illusions_duckman.h" +#include "illusions/duckman/duckman_dialog.h" +#include "illusions/actor.h" +#include "illusions/camera.h" +#include "illusions/cursor.h" +#include "illusions/dictionary.h" +#include "illusions/resources/fontresource.h" +#include "illusions/graphics.h" +#include "illusions/input.h" +#include "illusions/resources/actorresource.h" +#include "illusions/resources/backgroundresource.h" +#include "illusions/resources/midiresource.h" +#include "illusions/resources/scriptresource.h" +#include "illusions/resources/soundresource.h" +#include "illusions/resources/talkresource.h" +#include "illusions/resourcesystem.h" +#include "illusions/screen.h" +#include "illusions/screentext.h" +#include "illusions/scriptopcodes_duckman.h" +#include "illusions/scriptstack.h" +#include "illusions/sound.h" +#include "illusions/specialcode.h" +#include "illusions/textdrawer.h" +#include "illusions/thread.h" +#include "illusions/time.h" +#include "illusions/updatefunctions.h" + +#include "illusions/threads/abortablethread.h" +#include "illusions/threads/causethread_duckman.h" +#include "illusions/threads/scriptthread.h" +#include "illusions/threads/talkthread_duckman.h" +#include "illusions/threads/timerthread.h" + +#include "engines/util.h" + +namespace Illusions { + +// DuckmanDialogSystem + +DuckmanDialogSystem::DuckmanDialogSystem(IllusionsEngine_Duckman *vm) + : _vm(vm) { +} + +DuckmanDialogSystem::~DuckmanDialogSystem() { +} + +void DuckmanDialogSystem::addDialogItem(int16 choiceJumpOffs, uint32 sequenceId) { + DialogItem dialogItem; + dialogItem._choiceJumpOffs = choiceJumpOffs; + dialogItem._sequenceId = sequenceId; + _dialogItems.push_back(dialogItem); +} + +void DuckmanDialogSystem::startDialog(int16 *choiceOfsPtr, uint32 actorTypeId, uint32 callerThreadId) { + static const uint32 kDialogSequenceIds[] = { + 0, + 0x6049C, 0x6049C, 0x6047A, 0x6049D, + 0x60479, 0x6049E, 0x6049F, 0x60468 + }; + if (_dialogItems.size() == 1) { + *choiceOfsPtr = _dialogItems[0]._choiceJumpOffs; + _vm->notifyThreadId(callerThreadId); + } else { + if (!_vm->_cursor._control) { + Common::Point pos = _vm->getNamedPointPosition(0x70001); + _vm->_controls->placeActor(0x50001, pos, 0x60001, 0x40004, 0); + _vm->_cursor._control = _vm->_dict->getObjectControl(0x40004); + } + _vm->_cursor._control->appearActor(); + _vm->setCursorActorIndex(6, 1, 0); + + _vm->_cursor._gameState = 3; + _vm->_cursor._notifyThreadId30 = callerThreadId; + _vm->_cursor._dialogItemsCount = 0; + _vm->_cursor._overlappedObjectId = 0; + _vm->_cursor._op113_choiceOfsPtr = choiceOfsPtr; + _vm->_cursor._currOverlappedControl = 0; + + /* TODO? + if (!_vm->_input->getCursorMouseMode()) + _vm->_input->setMousePos((Point)0xBC0014); + */ + + _vm->_cursor._dialogItemsCount = _dialogItems.size(); + Common::Point placePt(20, 188); + + for (uint i = 1; i <= _dialogItems.size(); ++i) { + DialogItem &dialogItem = _dialogItems[_dialogItems.size() - i]; + _vm->_controls->placeDialogItem(i + 1, actorTypeId, dialogItem._sequenceId, placePt, dialogItem._choiceJumpOffs); + placePt.x += 40; + } + + Common::Point placePt2 = _vm->getNamedPointPosition(0x700C3); + _vm->_controls->placeActor(0x5006E, placePt2, kDialogSequenceIds[_dialogItems.size()], 0x40148, 0); + Control *control = _vm->_dict->getObjectControl(0x40148); + control->_flags |= 8; + _vm->playSoundEffect(8); + } + + _dialogItems.clear(); + +} + +void DuckmanDialogSystem::updateDialogState() { + Common::Point mousePos = _vm->_input->getCursorPosition(); + // TODO Handle keyboard input + _vm->_cursor._control->_actor->_position = mousePos; + mousePos = _vm->convertMousePos(mousePos); + + Control *currOverlappedControl = _vm->_cursor._currOverlappedControl; + Control *newOverlappedControl; + + if (_vm->_controls->getDialogItemAtPos(_vm->_cursor._control, mousePos, &newOverlappedControl)) { + if (currOverlappedControl != newOverlappedControl) { + newOverlappedControl->setActorIndex(2); + newOverlappedControl->startSequenceActor(newOverlappedControl->_actor->_sequenceId, 2, 0); + if (currOverlappedControl) { + currOverlappedControl->setActorIndex(1); + currOverlappedControl->startSequenceActor(currOverlappedControl->_actor->_sequenceId, 2, 0); + } + _vm->playSoundEffect(10); + _vm->startCursorSequence(); + _vm->setCursorActorIndex(6, 2, 0); + _vm->_cursor._currOverlappedControl = newOverlappedControl; + _vm->_cursor._overlappedObjectId = newOverlappedControl->_objectId; + } + } else if (currOverlappedControl) { + currOverlappedControl->setActorIndex(1); + currOverlappedControl->startSequenceActor(currOverlappedControl->_actor->_sequenceId, 2, 0); + _vm->playSoundEffect(10); + _vm->_cursor._currOverlappedControl = 0; + _vm->_cursor._overlappedObjectId = 0; + _vm->startCursorSequence(); + _vm->setCursorActorIndex(6, 1, 0); + } + + if (_vm->_input->pollButton(1)) { + if (_vm->_cursor._currOverlappedControl) { + _vm->playSoundEffect(9); + *_vm->_cursor._op113_choiceOfsPtr = _vm->_cursor._currOverlappedControl->_actor->_choiceJumpOffs; + _vm->_controls->destroyDialogItems(); + Control *control = _vm->_dict->getObjectControl(0x40148); + _vm->_controls->destroyControl(control); + _vm->notifyThreadId(_vm->_cursor._notifyThreadId30); + _vm->_cursor._notifyThreadId30 = 0; + _vm->_cursor._gameState = 2; + _vm->_cursor._dialogItemsCount = 0; + _vm->_cursor._overlappedObjectId = 0; + _vm->_cursor._op113_choiceOfsPtr = 0; + _vm->_cursor._control->disappearActor(); + } + } + +} + +} // End of namespace Illusions diff --git a/engines/illusions/duckman/duckman_dialog.h b/engines/illusions/duckman/duckman_dialog.h new file mode 100644 index 0000000000..9c7cfad484 --- /dev/null +++ b/engines/illusions/duckman/duckman_dialog.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +#ifndef ILLUSIONS_DUCKMAN_DUCKMAN_DIALOG_H +#define ILLUSIONS_DUCKMAN_DUCKMAN_DIALOG_H + +#include "illusions/illusions.h" +#include "common/algorithm.h" +#include "common/stack.h" + +namespace Illusions { + +struct DialogItem { + int16 _choiceJumpOffs; + uint32 _sequenceId; +}; + +class DuckmanDialogSystem { +public: + DuckmanDialogSystem(IllusionsEngine_Duckman *vm); + ~DuckmanDialogSystem(); + void addDialogItem(int16 choiceJumpOffs, uint32 sequenceId); + void startDialog(int16 *choiceOfsPtr, uint32 actorTypeId, uint32 callerThreadId); + void updateDialogState(); +public: + IllusionsEngine_Duckman *_vm; + Common::Array<DialogItem> _dialogItems; +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_DUCKMAN_DUCKMAN_DIALOG_H diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp index 2aa6d00372..17c930b3df 100644 --- a/engines/illusions/duckman/illusions_duckman.cpp +++ b/engines/illusions/duckman/illusions_duckman.cpp @@ -21,6 +21,7 @@ */ #include "illusions/duckman/illusions_duckman.h" +#include "illusions/duckman/duckman_dialog.h" #include "illusions/duckman/duckman_specialcode.h" #include "illusions/actor.h" #include "illusions/camera.h" @@ -109,6 +110,8 @@ Common::Error IllusionsEngine_Duckman::run() { _soundMan = new SoundMan(this); _fader = new Fader(); + + _dialogSys = new DuckmanDialogSystem(this); initUpdateFunctions(); @@ -167,6 +170,8 @@ Common::Error IllusionsEngine_Duckman::run() { delete _stack; delete _scriptOpcodes; + delete _dialogSys; + delete _fader; delete _soundMan; @@ -582,7 +587,7 @@ void IllusionsEngine_Duckman::cursorControlRoutine(Control *control, uint32 delt updateGameState2(); break; case 3: - updateDialogState(); + _dialogSys->updateDialogState(); break; case 4: // TODO ShellMgr_update(_cursor._control); @@ -1024,113 +1029,4 @@ uint32 IllusionsEngine_Duckman::runTriggerCause(uint32 verbId, uint32 objectId2, return tempThreadId; } -void IllusionsEngine_Duckman::addDialogItem(int16 choiceJumpOffs, uint32 sequenceId) { - DialogItem dialogItem; - dialogItem._choiceJumpOffs = choiceJumpOffs; - dialogItem._sequenceId = sequenceId; - _dialogItems.push_back(dialogItem); -} - -void IllusionsEngine_Duckman::startDialog(int16 *choiceOfsPtr, uint32 actorTypeId, uint32 callerThreadId) { - static const uint32 kDialogSequenceIds[] = { - 0, - 0x6049C, 0x6049C, 0x6047A, 0x6049D, - 0x60479, 0x6049E, 0x6049F, 0x60468 - }; - if (_dialogItems.size() == 1) { - *choiceOfsPtr = _dialogItems[0]._choiceJumpOffs; - notifyThreadId(callerThreadId); - } else { - if (!_cursor._control) { - Common::Point pos = getNamedPointPosition(0x70001); - _controls->placeActor(0x50001, pos, 0x60001, 0x40004, 0); - _cursor._control = _dict->getObjectControl(0x40004); - } - _cursor._control->appearActor(); - setCursorActorIndex(6, 1, 0); - - _cursor._gameState = 3; - _cursor._notifyThreadId30 = callerThreadId; - _cursor._dialogItemsCount = 0; - _cursor._overlappedObjectId = 0; - _cursor._op113_choiceOfsPtr = choiceOfsPtr; - _cursor._currOverlappedControl = 0; - - /* TODO? - if (!_input->getCursorMouseMode()) - _input->setMousePos((Point)0xBC0014); - */ - - _cursor._dialogItemsCount = _dialogItems.size(); - Common::Point placePt(20, 188); - - for (uint i = 1; i <= _dialogItems.size(); ++i) { - DialogItem &dialogItem = _dialogItems[_dialogItems.size() - i]; - _controls->placeDialogItem(i + 1, actorTypeId, dialogItem._sequenceId, placePt, dialogItem._choiceJumpOffs); - placePt.x += 40; - } - - Common::Point placePt2 = getNamedPointPosition(0x700C3); - _controls->placeActor(0x5006E, placePt2, kDialogSequenceIds[_dialogItems.size()], 0x40148, 0); - Control *control = _dict->getObjectControl(0x40148); - control->_flags |= 8; - playSoundEffect(8); - } - - _dialogItems.clear(); - -} - -void IllusionsEngine_Duckman::updateDialogState() { - Common::Point mousePos = _input->getCursorPosition(); - // TODO Handle keyboard input - _cursor._control->_actor->_position = mousePos; - mousePos = convertMousePos(mousePos); - - Control *currOverlappedControl = _cursor._currOverlappedControl; - Control *newOverlappedControl; - - if (_controls->getDialogItemAtPos(_cursor._control, mousePos, &newOverlappedControl)) { - if (currOverlappedControl != newOverlappedControl) { - newOverlappedControl->setActorIndex(2); - newOverlappedControl->startSequenceActor(newOverlappedControl->_actor->_sequenceId, 2, 0); - if (currOverlappedControl) { - currOverlappedControl->setActorIndex(1); - currOverlappedControl->startSequenceActor(currOverlappedControl->_actor->_sequenceId, 2, 0); - } - playSoundEffect(10); - startCursorSequence(); - setCursorActorIndex(6, 2, 0); - _cursor._currOverlappedControl = newOverlappedControl; - _cursor._overlappedObjectId = newOverlappedControl->_objectId; - } - } else if (currOverlappedControl) { - currOverlappedControl->setActorIndex(1); - currOverlappedControl->startSequenceActor(currOverlappedControl->_actor->_sequenceId, 2, 0); - playSoundEffect(10); - _cursor._currOverlappedControl = 0; - _cursor._overlappedObjectId = 0; - startCursorSequence(); - setCursorActorIndex(6, 1, 0); - } - - if (_input->pollButton(1)) { - if (_cursor._currOverlappedControl) { - playSoundEffect(9); - *_cursor._op113_choiceOfsPtr = _cursor._currOverlappedControl->_actor->_choiceJumpOffs; - _controls->destroyDialogItems(); - Control *control = _dict->getObjectControl(0x40148); - _controls->destroyControl(control); - notifyThreadId(_cursor._notifyThreadId30); - _cursor._notifyThreadId30 = 0; - _cursor._gameState = 2; - _cursor._dialogItemsCount = 0; - _cursor._overlappedObjectId = 0; - _cursor._op113_choiceOfsPtr = 0; - _cursor._control->disappearActor(); - } - } - -} - } // End of namespace Illusions diff --git a/engines/illusions/duckman/illusions_duckman.h b/engines/illusions/duckman/illusions_duckman.h index ce76d36020..7638c3a44d 100644 --- a/engines/illusions/duckman/illusions_duckman.h +++ b/engines/illusions/duckman/illusions_duckman.h @@ -31,6 +31,7 @@ namespace Illusions { class Dictionary; class ScriptStack; +class DuckmanDialogSystem; struct Cursor_Duckman { int _gameState; @@ -51,11 +52,6 @@ struct Cursor_Duckman { uint32 _field40; }; -struct DialogItem { - int16 _choiceJumpOffs; - uint32 _sequenceId; -}; - struct ScreenShakerPoint { int16 x, y; }; @@ -97,8 +93,8 @@ public: Cursor_Duckman _cursor; Control *_currWalkOverlappedControl; - - Common::Array<DialogItem> _dialogItems; + + DuckmanDialogSystem *_dialogSys; int _savedInventoryActorIndex; @@ -181,10 +177,6 @@ public: bool getTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &outThreadId); uint32 runTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId); - void addDialogItem(int16 choiceJumpOffs, uint32 sequenceId); - void startDialog(int16 *choiceOfsPtr, uint32 actorTypeId, uint32 callerThreadId); - void updateDialogState(); - }; } // End of namespace Illusions |