[Scummvm-git-logs] scummvm master -> 66d63000c84b542f0d6e49f4bcd69dd7f34cb5a7

whiterandrek whiterandrek at gmail.com
Mon May 25 13:15:39 UTC 2020


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5b4311bf8e PETKA: stop the world when case is opened
261e760cc9 PETKA: fixed rendering cursor
fb4fed1c70 PETKA: fixed finding object by point
66d63000c8 PETKA: changes to dialog system


Commit: 5b4311bf8e71dcf85bea0cd07fe30ab73296dde4
    https://github.com/scummvm/scummvm/commit/5b4311bf8e71dcf85bea0cd07fe30ab73296dde4
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T16:14:36+03:00

Commit Message:
PETKA: stop the world when case is opened

Changed paths:
    engines/petka/video.cpp


diff --git a/engines/petka/video.cpp b/engines/petka/video.cpp
index 5242af131f..093e2b72b0 100644
--- a/engines/petka/video.cpp
+++ b/engines/petka/video.cpp
@@ -47,7 +47,7 @@ void VideoSystem::update() {
 	Interface *interface = g_vm->getQSystem()->_currInterface;
 	uint32 time = g_system->getMillis();
 	if (interface) {
-		for (uint i = 0; i < interface->_objs.size(); ++i) {
+		for (uint i = interface->_startIndex; i < interface->_objs.size(); ++i) {
 			interface->_objs[i]->update(time - _time);
 		}
 


Commit: 261e760cc91be9e40ef9e80c033d0236553c3160
    https://github.com/scummvm/scummvm/commit/261e760cc91be9e40ef9e80c033d0236553c3160
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T16:14:36+03:00

Commit Message:
PETKA: fixed rendering cursor

Changed paths:
    engines/petka/objects/object_cursor.cpp


diff --git a/engines/petka/objects/object_cursor.cpp b/engines/petka/objects/object_cursor.cpp
index 06c6b026eb..5ddf0f2847 100644
--- a/engines/petka/objects/object_cursor.cpp
+++ b/engines/petka/objects/object_cursor.cpp
@@ -58,7 +58,14 @@ void QObjectCursor::draw() {
 	const Graphics::Surface *frame = flc->getCurrentFrame();
 	if (frame) {
 		Graphics::Surface *s = frame->convertTo(g_system->getScreenFormat(), flc->getPalette());
-	    g_vm->videoSystem()->transBlitFrom(*s, flc->getBounds(), Common::Point(_x, _y), flc->getTransColor(s->format));
+		Common::Rect destRect(flc->getBounds());
+		destRect.translate(_x, _y);
+		destRect.clip(640, 480);
+
+		Common::Rect srcRect(destRect);
+		srcRect.translate(-_x, -_y);
+
+		g_vm->videoSystem()->transBlitFrom(*s, srcRect, destRect, flc->getTransColor(s->format));
 		s->free();
 		delete s;
 	}


Commit: fb4fed1c70e840c363cdb68e395dbe794b124b85
    https://github.com/scummvm/scummvm/commit/fb4fed1c70e840c363cdb68e395dbe794b124b85
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T16:14:36+03:00

Commit Message:
PETKA: fixed finding object by point

Changed paths:
    engines/petka/objects/object.cpp


diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index d17a16c6d1..5b4d4785a7 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -418,7 +418,11 @@ bool QObject::isInPoint(int x, int y) {
 	if (flc) {
 		if (!flc->getBounds().contains(x - _x, y - _y))
 			return false;
-		return *(const byte *)flc->getCurrentFrame()->getBasePtr(x - _x - flc->getPos().x, y - _y - flc->getPos().y) != 0;
+		const Graphics::Surface *s = flc->getCurrentFrame();
+		if (s->format.bytesPerPixel == 1)
+			return *(const byte*)flc->getCurrentFrame()->getBasePtr(x - _x - flc->getPos().x, y - _y - flc->getPos().y) != 0;
+		if (s->format.bytesPerPixel == 2)
+			return *(const uint16*)flc->getCurrentFrame()->getBasePtr(x - _x - flc->getPos().x, y - _y - flc->getPos().y) != flc->getTransColor(s->format);
 	}
 	return false;
 }


Commit: 66d63000c84b542f0d6e49f4bcd69dd7f34cb5a7
    https://github.com/scummvm/scummvm/commit/66d63000c84b542f0d6e49f4bcd69dd7f34cb5a7
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T16:14:36+03:00

Commit Message:
PETKA: changes 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/interfaces/main.cpp
    engines/petka/objects/object.cpp
    engines/petka/objects/text.cpp


diff --git a/engines/petka/big_dialogue.cpp b/engines/petka/big_dialogue.cpp
index c7608fb7d7..c54dfe0aba 100644
--- a/engines/petka/big_dialogue.cpp
+++ b/engines/petka/big_dialogue.cpp
@@ -147,12 +147,12 @@ const Common::U32String *BigDialogue::getSpeechInfo(int *talkerId, const char **
 	return nullptr;
 }
 
-const DialogHandler *BigDialogue::findHandler(uint objId, uint opcode, bool *res) const {
+const DialogHandler *BigDialogue::findHandler(uint objId, uint opcode, bool *fallback) const {
 	if (opcode == kEnd || opcode == kHalf) {
 		return nullptr;
 	}
-	if (res) {
-		*res = false;
+	if (fallback) {
+		*fallback = false;
 	}
 	for (uint i = 0; i < _objDialogs.size(); ++i) {
 		if (_objDialogs[i].objId == objId) {
@@ -166,8 +166,8 @@ const DialogHandler *BigDialogue::findHandler(uint objId, uint opcode, bool *res
 			}
 			for (uint j = 0; j < _objDialogs[i].handlers.size(); ++j) {
 				if (_objDialogs[i].handlers[j].opcode == kFallback) {
-					if (res)
-						*res = true;
+					if (fallback)
+						*fallback = true;
 					return &_objDialogs[i].handlers[j];
 				}
 
@@ -179,8 +179,8 @@ const DialogHandler *BigDialogue::findHandler(uint objId, uint opcode, bool *res
 			continue;
 		for (uint j = 0; j < _objDialogs[i].handlers.size(); ++j) {
 			if (_objDialogs[i].handlers[j].opcode == opcode) {
-				if (res)
-					*res = true;
+				if (fallback)
+					*fallback = true;
 				return &_objDialogs[i].handlers[j];
 			}
 		}
@@ -188,7 +188,7 @@ const DialogHandler *BigDialogue::findHandler(uint objId, uint opcode, bool *res
 	return nullptr;
 }
 
-void BigDialogue::setHandler(uint objId, uint opcode, int index) {
+void BigDialogue::setHandler(uint objId, uint opcode) {
 	loadSpeechesInfo();
 	const DialogHandler *h = findHandler(objId, opcode, nullptr);
 	if (h) {
@@ -388,10 +388,7 @@ void BigDialogue::next(int choice) {
 			if (processed)
 				_currOp += 1;
 			else {
-				g_vm->getQSystem()->_mainInterface->_dialog.sendMsg(kSaid);
-				g_vm->getQSystem()->_mainInterface->_dialog._isUserMsg = 1;
-				g_vm->getQSystem()->_mainInterface->_dialog.restoreCursor();
-				g_vm->getQSystem()->addMessage(g_vm->getQSystem()->_chapayev->_id, kUserMsg, _currOp->userMsg.arg);
+				g_vm->getQSystem()->_mainInterface->_dialog.startUserMsg(_currOp->userMsg.arg);
 			}
 			return;
 		default:
diff --git a/engines/petka/big_dialogue.h b/engines/petka/big_dialogue.h
index 1707a1cd20..8b3573540c 100644
--- a/engines/petka/big_dialogue.h
+++ b/engines/petka/big_dialogue.h
@@ -112,8 +112,8 @@ public:
 
 	void next(int choice = -1);
 
-	const DialogHandler *findHandler(uint objId, uint opcode, bool *res) const;
-	void setHandler(uint objId, uint opcode, int index);
+	const DialogHandler *findHandler(uint objId, uint opcode, bool *fallback) const;
+	void setHandler(uint objId, uint opcode);
 
 	const Common::U32String *getSpeechInfo(int *talkerId, const char **soundName, int unk);
 
diff --git a/engines/petka/interfaces/dialog_interface.cpp b/engines/petka/interfaces/dialog_interface.cpp
index fedfa97ebc..1d11475e57 100644
--- a/engines/petka/interfaces/dialog_interface.cpp
+++ b/engines/petka/interfaces/dialog_interface.cpp
@@ -26,6 +26,7 @@
 #include "petka/interfaces/main.h"
 #include "petka/petka.h"
 #include "petka/objects/object_cursor.h"
+#include "petka/objects/heroes.h"
 #include "petka/q_system.h"
 #include "petka/big_dialogue.h"
 #include "petka/sound.h"
@@ -37,23 +38,21 @@ namespace Petka {
 DialogInterface::DialogInterface() {
 	_state = kIdle;
 	_id = -1;
-	_field24 = 0;
-	_isUserMsg = 0;
-	_afterUserMsg = 0;
+	_isUserMsg = false;
+	_afterUserMsg = false;
 	_talker = nullptr;
 	_sender = nullptr;
-	_hasSound = 0;
-	_firstTime = 1;
+	_hasSound = false;
+	_firstTime = true;
 }
 
 void DialogInterface::start(uint id, QMessageObject *sender) {
 	_id = id;
-	_hasSound = 0;
-	_field24 = 0;
-	_isUserMsg = 0;
-	_afterUserMsg = 0;
+	_hasSound = false;
+	_isUserMsg = false;
+	_afterUserMsg = false;
 	_talker = nullptr;
-	_firstTime = 1;
+	_firstTime = true;
 	_state = kIdle;
 	_sender = sender;
 	_soundName.clear();
@@ -105,7 +104,7 @@ void DialogInterface::next(int choice) {
 	if (_isUserMsg)
 		return;
 	if (_firstTime)
-		_firstTime = 0;
+		_firstTime = false;
 	else
 		g_vm->getBigDialogue()->next(choice);
 
@@ -189,4 +188,35 @@ void DialogInterface::end() {
 	_sender = nullptr;
 }
 
+void DialogInterface::endUserMsg() {
+	_isUserMsg = false;
+	next(-1);
+}
+
+void DialogInterface::startUserMsg(uint16 arg) {
+	sendMsg(kSaid);
+	_isUserMsg = true;
+	restoreCursor();
+	g_vm->getQSystem()->addMessage(g_vm->getQSystem()->_chapayev->_id, kUserMsg, arg);
+}
+
+bool DialogInterface::isActive() {
+	return _state != kIdle;
+}
+
+void DialogInterface::setSender(QMessageObject *sender) {
+	_sender = sender;
+}
+
+Sound *DialogInterface::findSound() {
+	if (!_hasSound)
+		return nullptr;
+	return g_vm->soundMgr()->findSound(_soundName);
+}
+
+void DialogInterface::removeSound() {
+	g_vm->soundMgr()->removeSound(_soundName);
+	_soundName.clear();
+}
+
 } // End of namespace Petka
diff --git a/engines/petka/interfaces/dialog_interface.h b/engines/petka/interfaces/dialog_interface.h
index 12db12c025..ff180e3fdb 100644
--- a/engines/petka/interfaces/dialog_interface.h
+++ b/engines/petka/interfaces/dialog_interface.h
@@ -27,7 +27,9 @@
 
 namespace Petka {
 
-enum State {
+class Sound;
+
+enum DialogState {
 	kPlaying = 1,
 	kMenu = 2,
 	kIdle = 3
@@ -40,31 +42,38 @@ public:
 	DialogInterface();
 
 	void start(uint id, QMessageObject *sender);
+	void next(int choice);
+	void end();
 
-	void initCursor();
-	void restoreCursor();
+	void startUserMsg(uint16 arg);
+	void endUserMsg();
 
-	void next(int choice);
+	Sound *findSound();
+	void removeSound();
+
+	bool isActive();
 
+	void setSender(QMessageObject *sender);
+
+private:
 	void sendMsg(uint16 opcode);
-	void end();
+	void initCursor();
+	void restoreCursor();
 
-public:
-	int _isUserMsg;
-	int _afterUserMsg;
-	int _hasSound;
-	int _firstTime;
+private:
+	bool _isUserMsg;
+	bool _afterUserMsg;
+	bool _hasSound;
+	bool _firstTime;
 	int _id;
-	int _state;
-	int _field24;
+	DialogState _state;
 	Common::String _soundName;
+	QMessageObject *_talker;
+	QMessageObject *_sender;
 	int16 _savedCursorActType;
 	int16 _savedCursorId;
 	bool _wasCursorShown;
 	bool _wasCursorAnim;
-	QMessageObject *_talker;
-	QMessageObject *_sender;
-
 };
 
 } // End of namespace Petka
diff --git a/engines/petka/interfaces/main.cpp b/engines/petka/interfaces/main.cpp
index 7b92573cce..69cf150927 100644
--- a/engines/petka/interfaces/main.cpp
+++ b/engines/petka/interfaces/main.cpp
@@ -252,7 +252,7 @@ void InterfaceMain::onMouseMove(const Common::Point p) {
 	cursor->_animate = _objUnderCursor != nullptr;
 	cursor->setCursorPos(p.x, p.y, true);
 
-	if (prevObj != _objUnderCursor && _objUnderCursor && _dialog._state == kIdle) {
+	if (prevObj != _objUnderCursor && _objUnderCursor && !_dialog.isActive()) {
 		Graphics::PixelFormat fmt = g_system->getScreenFormat();
 		QMessageObject *obj = (QMessageObject *)_objUnderCursor;
 		if (!obj->_nameOnScreen.empty()) {
@@ -260,7 +260,7 @@ void InterfaceMain::onMouseMove(const Common::Point p) {
 		} else {
 			setText(Common::convertToU32String(obj->_name.c_str(), Common::kWindows1251), fmt.RGBToColor(0x80, 0, 0), fmt.RGBToColor(0xA, 0xA, 0xA));
 		}
-	} else if (prevObj && !_objUnderCursor && _dialog._state == kIdle) {
+	} else if (prevObj && !_objUnderCursor && !_dialog.isActive()) {
 		setText(Common::U32String(""), 0, 0);
 	}
 }
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 5b4d4785a7..730c50695a 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -120,10 +120,10 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			(r->senderId != -1 && r->senderId != msg.sender->_id)) {
 			continue;
 		}
-		bool res;
-		if (g_vm->getBigDialogue()->findHandler(_id, msg.opcode, &res) && res == 0) {
-			g_vm->getBigDialogue()->setHandler(_id, msg.opcode, -1);
-			g_vm->getQSystem()->_mainInterface->_dialog._sender = this;
+		bool fallback;
+		if (g_vm->getBigDialogue()->findHandler(_id, msg.opcode, &fallback) && !fallback) {
+			g_vm->getBigDialogue()->setHandler(_id, msg.opcode);
+			g_vm->getQSystem()->_mainInterface->_dialog.setSender(this);
 		}
 		for (uint j = 0; j < r->messages.size(); ++j) {
 			QMessage &rMsg = r->messages[j];
@@ -195,8 +195,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			break;
 		}
 		case kContinue:
-			g_vm->getQSystem()->_mainInterface->_dialog._isUserMsg = 0;
-			g_vm->getQSystem()->_mainInterface->_dialog.next(-1);
+			g_vm->getQSystem()->_mainInterface->_dialog.endUserMsg();
 			break;
 		case kCursor:
 			if (msg.arg1 == 0xffff) {
@@ -376,8 +375,6 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			break;
 		}
 	} else {
-		g_vm->getBigDialogue()->setHandler(_id, msg.opcode, -1);
-		g_vm->getQSystem()->_mainInterface->_dialog._sender = this;
 		for (uint i = 0; i < _reactions.size(); ++i) {
 			QReaction &r = _reactions[i];
 			if (r.opcode != msg.opcode ||
@@ -391,6 +388,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 				g_dialogReaction->messages.push_back(r.messages[j]);
 			}
 		}
+		g_vm->getBigDialogue()->setHandler(_id, msg.opcode);
 		g_vm->getQSystem()->_mainInterface->_dialog.start(msg.arg1, this);
 	}
 
diff --git a/engines/petka/objects/text.cpp b/engines/petka/objects/text.cpp
index 4a34970190..168113391b 100644
--- a/engines/petka/objects/text.cpp
+++ b/engines/petka/objects/text.cpp
@@ -105,9 +105,9 @@ void QTextPhrase::draw() {
 void QTextPhrase::update(int time) {
 	DialogInterface &dialog = g_vm->getQSystem()->_mainInterface->_dialog;
 	_time += time;
-	if (dialog._hasSound) {
-		Sound *sound = g_vm->soundMgr()->findSound(dialog._soundName);
-		if (sound && !sound->isPlaying()) {
+	Sound *sound = dialog.findSound();
+	if (sound) {
+		if (!sound->isPlaying()) {
 			_time = 0;
 			dialog.next(-1);
 		}
@@ -119,8 +119,7 @@ void QTextPhrase::update(int time) {
 
 void QTextPhrase::onClick(int x, int y) {
 	DialogInterface &dialog = g_vm->getQSystem()->_mainInterface->_dialog;
-	g_vm->soundMgr()->removeSound(dialog._soundName);
-	dialog._soundName.clear();
+	dialog.removeSound();
 	dialog.next(-1);
 }
 




More information about the Scummvm-git-logs mailing list