mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 03:40:25 +00:00
ILLUSIONS: Move Duckman dialog code to own file
This commit is contained in:
parent
dec9ef3123
commit
d6e2f61155
178
engines/illusions/duckman/duckman_dialog.cpp
Normal file
178
engines/illusions/duckman/duckman_dialog.cpp
Normal file
@ -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
|
51
engines/illusions/duckman/duckman_dialog.h
Normal file
51
engines/illusions/duckman/duckman_dialog.h
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -11,6 +11,7 @@ MODULE_OBJS := \
|
||||
cursor.o \
|
||||
detection.o \
|
||||
dictionary.o \
|
||||
duckman/duckman_dialog.o \
|
||||
duckman/duckman_inventory.o \
|
||||
duckman/duckman_specialcode.o \
|
||||
duckman/illusions_duckman.o \
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "illusions/duckman/illusions_duckman.h"
|
||||
#include "illusions/duckman/duckman_dialog.h"
|
||||
#include "illusions/scriptopcodes_duckman.h"
|
||||
#include "illusions/actor.h"
|
||||
#include "illusions/camera.h"
|
||||
@ -716,13 +717,13 @@ void ScriptOpcodes_Duckman::opAddDialogItem(ScriptThread *scriptThread, OpCall &
|
||||
ARG_INT16(choiceJumpOffs);
|
||||
ARG_UINT32(sequenceId);
|
||||
if (index && (_vm->_scriptResource->_blockCounters.getC0(index) & 0x40))
|
||||
_vm->addDialogItem(choiceJumpOffs, sequenceId);
|
||||
_vm->_dialogSys->addDialogItem(choiceJumpOffs, sequenceId);
|
||||
}
|
||||
|
||||
void ScriptOpcodes_Duckman::opStartDialog(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
ARG_SKIP(2);
|
||||
ARG_UINT32(actorTypeId);
|
||||
_vm->startDialog(&_vm->_menuChoiceOfs, actorTypeId, opCall._callerThreadId);
|
||||
_vm->_dialogSys->startDialog(&_vm->_menuChoiceOfs, actorTypeId, opCall._callerThreadId);
|
||||
}
|
||||
|
||||
void ScriptOpcodes_Duckman::opJumpToDialogChoice(ScriptThread *scriptThread, OpCall &opCall) {
|
||||
|
Loading…
Reference in New Issue
Block a user