[Scummvm-git-logs] scummvm master -> 24ae76a72e1b2b8d78b0a477f8caa911c2483f3b
whiterandrek
whiterandrek at gmail.com
Mon May 25 15:21:22 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
24ae76a72e PETKA: moved global dialog reaction to class
Commit: 24ae76a72e1b2b8d78b0a477f8caa911c2483f3b
https://github.com/scummvm/scummvm/commit/24ae76a72e1b2b8d78b0a477f8caa911c2483f3b
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T18:19:49+03:00
Commit Message:
PETKA: moved global dialog reaction to class
Changed paths:
engines/petka/interfaces/dialog_interface.cpp
engines/petka/interfaces/dialog_interface.h
engines/petka/objects/object.cpp
engines/petka/objects/object.h
diff --git a/engines/petka/interfaces/dialog_interface.cpp b/engines/petka/interfaces/dialog_interface.cpp
index 1d11475e57..4b0a91359c 100644
--- a/engines/petka/interfaces/dialog_interface.cpp
+++ b/engines/petka/interfaces/dialog_interface.cpp
@@ -42,10 +42,15 @@ DialogInterface::DialogInterface() {
_afterUserMsg = false;
_talker = nullptr;
_sender = nullptr;
+ _reaction = nullptr;
_hasSound = false;
_firstTime = true;
}
+DialogInterface::~DialogInterface() {
+ delete _reaction;
+}
+
void DialogInterface::start(uint id, QMessageObject *sender) {
_id = id;
_hasSound = false;
@@ -183,8 +188,8 @@ void DialogInterface::end() {
_id = -1;
g_vm->getQSystem()->_currInterface->removeTexts();
restoreCursor();
- if (g_dialogReaction)
- processSavedReaction(&g_dialogReaction, _sender);
+ if (_reaction)
+ processSavedReaction(&_reaction, _sender);
_sender = nullptr;
}
@@ -219,4 +224,10 @@ void DialogInterface::removeSound() {
_soundName.clear();
}
+void DialogInterface::setReaction(QReaction *reaction, bool deletePrev) {
+ if (deletePrev)
+ delete _reaction;
+ _reaction = reaction;
+}
+
} // End of namespace Petka
diff --git a/engines/petka/interfaces/dialog_interface.h b/engines/petka/interfaces/dialog_interface.h
index ff180e3fdb..ecf3f90621 100644
--- a/engines/petka/interfaces/dialog_interface.h
+++ b/engines/petka/interfaces/dialog_interface.h
@@ -27,19 +27,20 @@
namespace Petka {
-class Sound;
-
enum DialogState {
kPlaying = 1,
kMenu = 2,
kIdle = 3
};
+class Sound;
class QMessageObject;
+class QReaction;
class DialogInterface {
public:
DialogInterface();
+ ~DialogInterface();
void start(uint id, QMessageObject *sender);
void next(int choice);
@@ -54,6 +55,7 @@ public:
bool isActive();
void setSender(QMessageObject *sender);
+ void setReaction(QReaction *reaction, bool deletePrev = false);
private:
void sendMsg(uint16 opcode);
@@ -70,6 +72,7 @@ private:
Common::String _soundName;
QMessageObject *_talker;
QMessageObject *_sender;
+ QReaction *_reaction;
int16 _savedCursorActType;
int16 _savedCursorId;
bool _wasCursorShown;
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 730c50695a..19938635b1 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -43,8 +43,6 @@
namespace Petka {
-QReaction *g_dialogReaction = nullptr; // FIXME
-
QVisibleObject::QVisibleObject()
: _resourceId(-1), _z(240) {}
@@ -74,12 +72,14 @@ void processSavedReaction(QReaction **reaction, QMessageObject *sender) {
g_vm->getQSystem()->addMessage(msg.objId, msg.opcode, msg.arg1, msg.arg2, msg.arg3, 0, sender);
bool processed = true;
switch (msg.opcode) {
- case kDialog:
- g_dialogReaction = new QReaction();
+ case kDialog: {
+ QReaction *dialogReaction = new QReaction();
for (uint j = i + 1; j < r->messages.size(); ++j) {
- g_dialogReaction->messages.push_back(r->messages[j]);
+ dialogReaction->messages.push_back(r->messages[j]);
}
+ g_vm->getQSystem()->_mainInterface->_dialog.setReaction(dialogReaction);
break;
+ }
case kPlay: {
QMessageObject *obj = g_vm->getQSystem()->findObject(msg.objId);
obj->_reaction = new QReaction();
@@ -143,13 +143,14 @@ void QMessageObject::processMessage(const QMessage &msg) {
rMsg.sender);
bool processed = true;
switch (rMsg.opcode) {
- case kDialog:
- delete g_dialogReaction;
- g_dialogReaction = new QReaction();
+ case kDialog: {
+ QReaction *reaction = new QReaction();
for (uint z = j + 1; z < r->messages.size(); ++z) {
- g_dialogReaction->messages.push_back(r->messages[z]);
+ reaction->messages.push_back(r->messages[z]);
}
+ g_vm->getQSystem()->_mainInterface->_dialog.setReaction(reaction, true);
break;
+ }
case kPlay: {
QMessageObject *obj = g_vm->getQSystem()->findObject(rMsg.objId);
delete obj->_reaction;
@@ -382,11 +383,11 @@ void QMessageObject::processMessage(const QMessage &msg) {
(r.senderId != -1 && r.senderId != msg.sender->_id)) {
continue;
}
- delete g_dialogReaction;
- g_dialogReaction = new QReaction();
+ QReaction *reaction = new QReaction();
for (uint j = 0; j < r.messages.size(); ++j) {
- g_dialogReaction->messages.push_back(r.messages[j]);
+ reaction->messages.push_back(r.messages[j]);
}
+ g_vm->getQSystem()->_mainInterface->_dialog.setReaction(reaction, true);
}
g_vm->getBigDialogue()->setHandler(_id, msg.opcode);
g_vm->getQSystem()->_mainInterface->_dialog.start(msg.arg1, this);
diff --git a/engines/petka/objects/object.h b/engines/petka/objects/object.h
index 3f70d1c622..225d0b4a18 100644
--- a/engines/petka/objects/object.h
+++ b/engines/petka/objects/object.h
@@ -98,8 +98,6 @@ public:
void onMouseMove(int x, int y) override;
};
-extern QReaction *g_dialogReaction;
-
} // End of namespace Petka
#endif
More information about the Scummvm-git-logs
mailing list