[Scummvm-git-logs] scummvm master -> 15f71d76aedad7b56f4829087d2311a7defb0cfd
whiterandrek
whiterandrek at gmail.com
Sun May 17 10:47:19 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fc4ad2319b PETKA: implemented text rendering on map
15f71d76ae PETKA: more fixes to dialog system
Commit: fc4ad2319b380b8205ab95473da65f47e76498dd
https://github.com/scummvm/scummvm/commit/fc4ad2319b380b8205ab95473da65f47e76498dd
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-17T13:46:15+03:00
Commit Message:
PETKA: implemented text rendering on map
Changed paths:
engines/petka/interfaces/map.cpp
diff --git a/engines/petka/interfaces/map.cpp b/engines/petka/interfaces/map.cpp
index c30d79db2e..c2a4872ecb 100644
--- a/engines/petka/interfaces/map.cpp
+++ b/engines/petka/interfaces/map.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/system.h"
+
#include "petka/q_manager.h"
#include "petka/flc.h"
#include "petka/petka.h"
@@ -82,7 +84,7 @@ void InterfaceMap::start() {
void InterfaceMap::stop() {
if (_objUnderCursor)
((QMessageObject *)_objUnderCursor)->_isShown = false;
- //setText("", 0xFFFFC0, 0xA0A0A);
+ setText(Common::U32String(""), 0, 0);
QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
cursor->_resourceId = _savedCursorId;
@@ -102,6 +104,7 @@ void InterfaceMap::onLeftButtonDown(const Common::Point p) {
}
void InterfaceMap::onMouseMove(const Common::Point p) {
+ QVisibleObject *oldObj = _objUnderCursor;
_objUnderCursor = nullptr;
bool found = false;
@@ -131,6 +134,18 @@ void InterfaceMap::onMouseMove(const Common::Point p) {
cursor->_animate = _objUnderCursor != nullptr;
cursor->_isShown = true;
cursor->setCursorPos(p.x, p.y, 0);
+
+ if (_objUnderCursor != oldObj && _objUnderCursor) {
+ Graphics::PixelFormat fmt = g_system->getScreenFormat();
+ QMessageObject *obj = (QMessageObject *)_objUnderCursor;
+ if (!obj->_nameOnScreen.empty()) {
+ setText(obj->_nameOnScreen, fmt.RGBToColor(0xFF, 0xFF, 0xC0), fmt.RGBToColor(0xA, 0xA, 0xA));
+ } else {
+ setText(obj->_name, fmt.RGBToColor(0, 0, 0x80), fmt.RGBToColor(0xA, 0xA, 0xA));
+ }
+ } else if (oldObj && !_objUnderCursor) {
+ setText(Common::U32String(""), 0, 0);
+ }
}
} // End of namespace Petka
Commit: 15f71d76aedad7b56f4829087d2311a7defb0cfd
https://github.com/scummvm/scummvm/commit/15f71d76aedad7b56f4829087d2311a7defb0cfd
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-17T13:46:44+03:00
Commit Message:
PETKA: more fixes to dialog system
Changed paths:
engines/petka/big_dialogue.cpp
engines/petka/big_dialogue.h
engines/petka/interfaces/dialog_interface.cpp
engines/petka/interfaces/dialog_interface.h
engines/petka/objects/object.cpp
diff --git a/engines/petka/big_dialogue.cpp b/engines/petka/big_dialogue.cpp
index 8c952a9319..7a15678b6c 100644
--- a/engines/petka/big_dialogue.cpp
+++ b/engines/petka/big_dialogue.cpp
@@ -206,8 +206,8 @@ uint BigDialogue::opcode() {
case kOperationPlay:
case kOperationCircle:
return kOpcodePlay;
- case kOperation9:
- return kOpcode4;
+ case kOperationUserMessage:
+ return kOpcodeUserMessage;
default:
next();
break;
@@ -229,13 +229,13 @@ void BigDialogue::load(Common::ReadStream *s) {
_ops[i].menu.bits = (byte)op;
_ops[i].menu.bitField = (uint16)(op >> 8);
break;
- case kOperationMenuRet:
- _ops[i].menuRet.opIndex = (uint16)op;
- _ops[i].menuRet.bit = (byte)(op >> 16);
+ case kOperationDisableMenuItem:
+ _ops[i].disableMenuItem.opIndex = (uint16)op;
+ _ops[i].disableMenuItem.bit = (byte)(op >> 16);
break;
- case kOperation5:
- _ops[i].op5.opIndex = (uint16)op;
- _ops[i].op5.bit = (byte)(op >> 16);
+ case kOperationEnableMenuItem:
+ _ops[i].enableMenuItem.opIndex = (uint16)op;
+ _ops[i].enableMenuItem.bit = (byte)(op >> 16);
break;
case kOperationReturn:
break;
@@ -246,8 +246,8 @@ void BigDialogue::load(Common::ReadStream *s) {
_ops[i].circle.count = (uint16)op;
_ops[i].circle.curr = (byte)(op >> 16);
break;
- case kOperation9:
- _ops[i].op9.arg = (uint16)op;
+ case kOperationUserMessage:
+ _ops[i].userMsg.arg = (uint16)op;
break;
default:
break;
@@ -267,13 +267,13 @@ void BigDialogue::save(Common::WriteStream *s) {
s->writeUint16LE(_ops[i].menu.bitField);
s->writeByte(kOperationMenu);
break;
- case kOperationMenuRet:
- s->writeUint16LE(_ops[i].menuRet.opIndex);
- s->writeUint16LE(MKTAG16(_ops[i].menuRet.bit, kOperationMenuRet));
+ case kOperationDisableMenuItem:
+ s->writeUint16LE(_ops[i].disableMenuItem.opIndex);
+ s->writeUint16LE(MKTAG16(_ops[i].disableMenuItem.bit, kOperationDisableMenuItem));
break;
- case kOperation5:
- s->writeUint16LE(_ops[i].op5.opIndex);
- s->writeUint16LE(MKTAG16(_ops[i].op5.bit, kOperation5));
+ case kOperationEnableMenuItem:
+ s->writeUint16LE(_ops[i].enableMenuItem.opIndex);
+ s->writeUint16LE(MKTAG16(_ops[i].enableMenuItem.bit, kOperationEnableMenuItem));
break;
case kOperationReturn:
s->writeUint32LE(MKTAG(0, 0, 0, kOperationReturn));
@@ -286,9 +286,9 @@ void BigDialogue::save(Common::WriteStream *s) {
s->writeUint16LE(_ops[i].circle.count);
s->writeUint16LE(MKTAG16(_ops[i].circle.curr, kOperationPlay));
break;
- case kOperation9:
- s->writeUint16LE(_ops[i].op9.arg);
- s->writeUint16LE(MKTAG16(0, kOperation9));
+ case kOperationUserMessage:
+ s->writeUint16LE(_ops[i].userMsg.arg);
+ s->writeUint16LE(MKTAG16(0, kOperationUserMessage));
break;
default:
break;
@@ -341,14 +341,14 @@ void BigDialogue::next(int choice) {
processed = false;
break;
}
- case kOperationMenuRet:
- _ops[_currOp->menuRet.opIndex].menu.bitField &= ~(1 << _currOp->menuRet.bit); // disable menu item
- checkMenu(_currOp->menuRet.opIndex);
+ case kOperationDisableMenuItem:
+ _ops[_currOp->disableMenuItem.opIndex].menu.bitField &= ~(1 << _currOp->disableMenuItem.bit); // disable menu item
+ checkMenu(_currOp->disableMenuItem.opIndex);
_currOp += 1;
processed = false;
break;
- case kOperation5:
- _ops[_currOp->op5.opIndex].menu.bitField |= (1 << _currOp->op5.bit); // enable menu item ???
+ case kOperationEnableMenuItem:
+ _ops[_currOp->enableMenuItem.opIndex].menu.bitField |= (1 << _currOp->enableMenuItem.bit);
_currOp += 1;
processed = false;
break;
@@ -371,14 +371,14 @@ void BigDialogue::next(int choice) {
}
processed = false;
break;
- case kOperation9:
+ case kOperationUserMessage:
if (processed)
_currOp += 1;
else {
g_vm->getQSystem()->_mainInterface->_dialog.sendMsg(kSaid);
- g_vm->getQSystem()->_mainInterface->_dialog._field4 = 1;
+ g_vm->getQSystem()->_mainInterface->_dialog._isUserMsg = 1;
g_vm->getQSystem()->_mainInterface->_dialog.restoreCursorState();
- g_vm->getQSystem()->addMessage(g_vm->getQSystem()->_chapayev->_id, kUserMsg, _currOp->op9.arg);
+ g_vm->getQSystem()->addMessage(g_vm->getQSystem()->_chapayev->_id, kUserMsg, _currOp->userMsg.arg);
}
return;
default:
diff --git a/engines/petka/big_dialogue.h b/engines/petka/big_dialogue.h
index 42a7d189fb..1707a1cd20 100644
--- a/engines/petka/big_dialogue.h
+++ b/engines/petka/big_dialogue.h
@@ -32,19 +32,19 @@ enum {
kOpcodePlay = 1,
kOpcodeMenu,
kOpcodeEnd,
- kOpcode4
+ kOpcodeUserMessage
};
enum {
kOperationBreak = 1,
kOperationMenu,
kOperationGoTo,
- kOperationMenuRet,
- kOperation5,
+ kOperationDisableMenuItem,
+ kOperationEnableMenuItem,
kOperationReturn,
kOperationPlay,
kOperationCircle,
- kOperation9
+ kOperationUserMessage
};
struct Operation {
@@ -59,11 +59,11 @@ struct Operation {
struct {
uint16 opIndex;
byte bit;
- } menuRet;
+ } disableMenuItem;
struct {
uint16 opIndex;
byte bit;
- } op5;
+ } enableMenuItem;
struct {
uint16 messageIndex;
} play;
@@ -73,7 +73,7 @@ struct Operation {
} circle;
struct {
uint16 arg;
- } op9;
+ } userMsg;
};
byte type;
};
diff --git a/engines/petka/interfaces/dialog_interface.cpp b/engines/petka/interfaces/dialog_interface.cpp
index a9b612c91d..5d9cf1ace0 100644
--- a/engines/petka/interfaces/dialog_interface.cpp
+++ b/engines/petka/interfaces/dialog_interface.cpp
@@ -33,26 +33,26 @@
namespace Petka {
DialogInterface::DialogInterface() {
- _field18 = 3;
- _field14 = -1;
+ _state = kIdle;
+ _id = -1;
_field24 = 0;
- _field4 = 0;
- _field8 = 0;
+ _isUserMsg = 0;
+ _afterUserMsg = 0;
_talker = nullptr;
_sender = nullptr;
_hasSound = 0;
- _field10 = 1;
+ _firstTime = 1;
}
-void DialogInterface::start(uint a, QMessageObject *sender) {
- _field14 = a;
+void DialogInterface::start(uint id, QMessageObject *sender) {
+ _id = id;
_hasSound = 0;
_field24 = 0;
- _field4 = 0;
- _field8 = 0;
+ _isUserMsg = 0;
+ _afterUserMsg = 0;
_talker = nullptr;
- _field10 = 1;
- _field18 = 3;
+ _firstTime = 1;
+ _state = kIdle;
_sender = sender;
_soundName.clear();
saveCursorState();
@@ -77,54 +77,85 @@ void DialogInterface::restoreCursorState() {
}
void DialogInterface::next(int choice) {
- const char *soundName = nullptr;
- if (_field14 == -1 || (choice == -1 && _field18 == 2))
+ if (_id == -1)
return;
- if (_field18 == -1)
+
+ if ((choice == -1 && _state == kMenu) || (choice != -1 && _state == kPlaying))
return;
- int talkerId = -1;
- if (choice == -1 && !_field8) {
- g_vm->getBigDialogue()->getSpeechInfo(&talkerId, &soundName, -1);
+
+ QSystem *qsys = g_vm->getQSystem();
+ BigDialogue *bigDialog = g_vm->getBigDialogue();
+
+ const char *soundName = nullptr;
+ int prevTalkerId = -1;
+
+ if (choice == -1 && !_afterUserMsg) {
+ bigDialog->getSpeechInfo(&prevTalkerId, &soundName, -1);
}
- _field8 = _field4;
- g_vm->getQSystem()->_cursor.get()->_isShown = 0;
- if (_field4)
+ _afterUserMsg = _isUserMsg;
+
+ qsys->_cursor->_isShown = 0;
+ if (_isUserMsg)
return;
- if (_field10)
- _field10 = 0;
+ if (_firstTime)
+ _firstTime = 0;
else
g_vm->getBigDialogue()->next(choice);
+
switch (g_vm->getBigDialogue()->opcode()) {
case kOpcodePlay: {
- int talkerId2;
- const Common::U32String *text = g_vm->getBigDialogue()->getSpeechInfo(&talkerId2, &soundName, -1);
+ int currTalkerId;
+ const Common::U32String *text = bigDialog->getSpeechInfo(&currTalkerId, &soundName, -1);
g_vm->soundMgr()->removeSound(_soundName);
- if (talkerId != talkerId2) {
+ if (prevTalkerId != currTalkerId) {
sendMsg(kSaid);
}
_soundName = g_vm->getSpeechPath() + soundName;
Sound *s = g_vm->soundMgr()->addSound(_soundName, Audio::Mixer::kSpeechSoundType);
if (s) {
+ // todo pan
s->play(0);
}
_hasSound = s != nullptr;
- _talker = g_vm->getQSystem()->findObject(talkerId2);
- if (talkerId != talkerId2) {
+ _talker = qsys->findObject(currTalkerId);
+ if (prevTalkerId != currTalkerId) {
sendMsg(kSay);
}
- g_vm->getQSystem()->_mainInterface->setTextPhrase(*text, _talker->_dialogColor, g_vm->_system->getScreenFormat().RGBToColor(0x7F, 0, 0));
- _field18 = 1;
+ qsys->_mainInterface->setTextPhrase(*text, _talker->_dialogColor, g_system->getScreenFormat().RGBToColor(0x7F, 0, 0));
+ _state = kPlaying;
break;
}
- case kOpcodeMenu:
+ case kOpcodeMenu: {
+ g_vm->soundMgr()->removeSound(_soundName);
+ _soundName.clear();
+ if (_talker) {
+ sendMsg(kSaid);
+ _talker = nullptr;
+ }
+ uint count = bigDialog->choicesCount();
+ if (count == 0)
+ break;
+
+ Common::Array<Common::U32String> choices;
+ for (uint i = 0; i < count; ++i) {
+ int id;
+ choices.push_back(*bigDialog->getSpeechInfo(&id, &soundName, -1));
+ }
+ qsys->_mainInterface->setTextChoice(choices, 0xFFFF, g_system->getScreenFormat().RGBToColor(0xFF, 0, 0));
+
+ qsys->_cursor->_isShown = 1;
+ _state = kMenu;
break;
+ }
case kOpcodeEnd:
end();
break;
- case kOpcode4:
+ case kOpcodeUserMessage:
+ qsys->_mainInterface->setTextPhrase(Common::U32String(""), 0, 0);
g_vm->soundMgr()->removeSound(_soundName);
+ _soundName.clear();
_talker = nullptr;
- _field18 = 1;
+ _state = kPlaying;
break;
default:
break;
@@ -141,8 +172,8 @@ void DialogInterface::end() {
g_vm->soundMgr()->removeSound(_soundName);
sendMsg(kSaid);
_talker = nullptr;
- _field18 = 3;
- _field14 = -1;
+ _state = kIdle;
+ _id = -1;
restoreCursorState();
if (g_dialogReaction)
processSavedReaction(&g_dialogReaction, _sender);
diff --git a/engines/petka/interfaces/dialog_interface.h b/engines/petka/interfaces/dialog_interface.h
index c146ee754c..8a63c1a8c9 100644
--- a/engines/petka/interfaces/dialog_interface.h
+++ b/engines/petka/interfaces/dialog_interface.h
@@ -27,13 +27,19 @@
namespace Petka {
+enum State {
+ kPlaying = 1,
+ kMenu = 2,
+ kIdle = 3
+};
+
class QMessageObject;
class DialogInterface {
public:
DialogInterface();
- void start(uint a, QMessageObject *sender);
+ void start(uint id, QMessageObject *sender);
void saveCursorState();
void restoreCursorState();
@@ -44,12 +50,12 @@ public:
void end();
public:
- int _field4;
- int _field8;
+ int _isUserMsg;
+ int _afterUserMsg;
int _hasSound;
- int _field10;
- int _field14;
- int _field18;
+ int _firstTime;
+ int _id;
+ int _state;
int _field24;
Common::String _soundName;
int16 _savedCursorActType;
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 36a3da0b75..4a4dae0f1e 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -193,7 +193,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
break;
}
case kContinue:
- g_vm->getQSystem()->_mainInterface->_dialog._field4 = 0;
+ g_vm->getQSystem()->_mainInterface->_dialog._isUserMsg = 0;
g_vm->getQSystem()->_mainInterface->_dialog.next(-1);
break;
case kCursor:
More information about the Scummvm-git-logs
mailing list