[Scummvm-git-logs] scummvm master -> aca4dc2720d9e2f1e112f70265fdf0b4dbdde321

whiterandrek whiterandrek at gmail.com
Fri May 22 08:41:52 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:
6ce60dbed7 PETKA: stop interfaces properly
aca4dc2720 PETKA: save load interface overrides start method


Commit: 6ce60dbed7b54c49d2a50c56552c0c62d38dfc8d
    https://github.com/scummvm/scummvm/commit/6ce60dbed7b54c49d2a50c56552c0c62d38dfc8d
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-22T11:11:08+03:00

Commit Message:
PETKA: stop interfaces properly

Changed paths:
    engines/petka/interfaces/interface.cpp
    engines/petka/interfaces/interface.h
    engines/petka/interfaces/map.cpp
    engines/petka/interfaces/panel.cpp
    engines/petka/interfaces/panel.h
    engines/petka/interfaces/save_load.cpp
    engines/petka/interfaces/save_load.h
    engines/petka/interfaces/sequence.cpp
    engines/petka/interfaces/startup.cpp
    engines/petka/interfaces/startup.h
    engines/petka/q_system.cpp


diff --git a/engines/petka/interfaces/interface.cpp b/engines/petka/interfaces/interface.cpp
index fbda8cf396..a032312f63 100644
--- a/engines/petka/interfaces/interface.cpp
+++ b/engines/petka/interfaces/interface.cpp
@@ -33,6 +33,11 @@ namespace Petka {
 Interface::Interface()
 	: _objUnderCursor(nullptr), _startIndex(0) {}
 
+void Interface::stop() {
+	setText(Common::U32String(""), 0, 0);
+	g_vm->videoSystem()->makeAllDirty();
+}
+
 void Interface::setText(const Common::U32String &text, uint16 textColor, uint16 outlineColor) {
 	removeTexts();
 	if (!text.empty())
diff --git a/engines/petka/interfaces/interface.h b/engines/petka/interfaces/interface.h
index 69b8c05c48..10b06c70f6 100644
--- a/engines/petka/interfaces/interface.h
+++ b/engines/petka/interfaces/interface.h
@@ -38,7 +38,7 @@ public:
 	virtual ~Interface() {}
 
 	virtual void start(int id) {};
-	virtual void stop() {};
+	virtual void stop();
 
 	virtual void onLeftButtonDown(const Common::Point p) {};
 	virtual void onRightButtonDown(const Common::Point p) {};
diff --git a/engines/petka/interfaces/map.cpp b/engines/petka/interfaces/map.cpp
index baca41aa67..4bda5f02c1 100644
--- a/engines/petka/interfaces/map.cpp
+++ b/engines/petka/interfaces/map.cpp
@@ -37,23 +37,24 @@ namespace Petka {
 const char *const mapName = "\xCA\xC0\xD0\xD2\xC0"; // КАРТА
 
 void InterfaceMap::start(int id) {
-	if (!g_vm->getQSystem()->_room->_showMap)
+	QSystem *sys = g_vm->getQSystem();
+	if (!sys->_room->_showMap)
 		return;
 
 	_objs.clear();
 
-	QObjectBG *bg = (QObjectBG *)g_vm->getQSystem()->findObject(mapName);
+	QObjectBG *bg = (QObjectBG *)sys->findObject(mapName);
 	_roomResID = bg->_resourceId;
 	_objs.push_back(bg);
 
-	const Common::Array<BGInfo> &infos = g_vm->getQSystem()->_mainInterface->_bgs;
+	const Common::Array<BGInfo> &infos = sys->_mainInterface->_bgs;
 
 	for (uint i = 0; i < infos.size(); ++i) {
 		if (infos[i].objId != bg->_id) {
 			continue;
 		}
 		for (uint j = 0; j < infos[i].attachedObjIds.size(); ++j) {
-			QMessageObject *obj = g_vm->getQSystem()->findObject(infos[i].attachedObjIds[j]);
+			QMessageObject *obj = sys->findObject(infos[i].attachedObjIds[j]);
 			FlicDecoder *flc = g_vm->resMgr()->loadFlic(obj->_resourceId);
 			flc->setFrame(1);
 			obj->_z = 1;
@@ -68,7 +69,7 @@ void InterfaceMap::start(int id) {
 		break;
 	}
 
-	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+	QObjectCursor *cursor = sys->_cursor.get();
 	_savedCursorId = cursor->_resourceId;
 	_savedCursorActionType = cursor->_actionType;
 
@@ -85,16 +86,24 @@ void InterfaceMap::start(int id) {
 }
 
 void InterfaceMap::stop() {
+	QSystem *sys = g_vm->getQSystem();
+	QObjectCursor *cursor = sys->_cursor.get();
+
 	if (_objUnderCursor)
 		((QMessageObject *)_objUnderCursor)->_isShown = false;
+
 	setText(Common::U32String(""), 0, 0);
 
-	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+	sys->_xOffset = _savedXOffset;
+	sys->_sceneWidth = _savedSceneWidth;
+
 	cursor->_resourceId = _savedCursorId;
 	cursor->_actionType = _savedCursorActionType;
 
-	g_vm->getQSystem()->_currInterface = g_vm->getQSystem()->_prevInterface;
-	g_vm->getQSystem()->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
+	sys->_currInterface = g_vm->getQSystem()->_prevInterface;
+	sys->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
+
+	Interface::stop();
 }
 
 void InterfaceMap::onLeftButtonDown(const Common::Point p) {
diff --git a/engines/petka/interfaces/panel.cpp b/engines/petka/interfaces/panel.cpp
index 1e020babcd..def71b2a4b 100644
--- a/engines/petka/interfaces/panel.cpp
+++ b/engines/petka/interfaces/panel.cpp
@@ -20,9 +20,6 @@
  *
  */
 
-#ifndef PETKA_STARTUP_H
-#define PETKA_STARTUP_H
-
 #include "common/config-manager.h"
 #include "common/system.h"
 
@@ -96,17 +93,18 @@ InterfacePanel::InterfacePanel() {
 void InterfacePanel::start(int id) {
 	readSettings();
 
+	QSystem *sys = g_vm->getQSystem();
 	QObjectBG *bg = (QObjectBG *)g_vm->getQSystem()->findObject(kPanelObjName);
 	_objs.push_back(bg);
-	g_vm->getQSystem()->update();
-	const Common::Array<BGInfo> &infos = g_vm->getQSystem()->_mainInterface->_bgs;
+	sys->update();
+	const Common::Array<BGInfo> &infos = sys->_mainInterface->_bgs;
 
 	for (uint i = 0; i < infos.size(); ++i) {
 		if (infos[i].objId != bg->_id) {
 			continue;
 		}
 		for (uint j = 0; j < infos[i].attachedObjIds.size(); ++j) {
-			QMessageObject *obj = g_vm->getQSystem()->findObject(infos[i].attachedObjIds[j]);
+			QMessageObject *obj = sys->findObject(infos[i].attachedObjIds[j]);
 			FlicDecoder *flc = g_vm->resMgr()->loadFlic(obj->_resourceId);
 			flc->setFrame(1);
 			obj->_z = 1;
@@ -122,15 +120,40 @@ void InterfacePanel::start(int id) {
 		break;
 	}
 
+	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+	_savedCursorType = cursor->_actionType;
+
 	initCursor(4901, 1, 1);
 
+	_savedSceneWidth = sys->_sceneWidth;
+	_savedXOffset = sys->_xOffset;
+
+	sys->_sceneWidth = 640;
+	sys->_xOffset = 0;
+
 	updateSliders();
 	updateSubtitles();
 
-	g_vm->getQSystem()->_currInterface = this;
+	sys->_currInterface = this;
 	g_vm->videoSystem()->makeAllDirty();
 }
 
+void InterfacePanel::stop() {
+	QSystem *sys = g_vm->getQSystem();
+	QObjectCursor *cursor = sys->_cursor.get();
+
+	sys->_xOffset = _savedXOffset;
+	sys->_sceneWidth = _savedSceneWidth;
+
+	cursor->_resourceId = _savedCursorRes;
+	cursor->_actionType = _savedCursorType;
+
+	sys->_currInterface = sys->_prevInterface;
+	sys->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
+
+	Interface::stop();
+}
+
 void InterfacePanel::onLeftButtonDown(const Common::Point p) {
 	int i = 0;
 	for (i = _objs.size() - 1; i > 0; --i) {
@@ -301,5 +324,3 @@ void InterfacePanel::applySettings() {
 }
 
 } // End of namespace Petka
-
-#endif
diff --git a/engines/petka/interfaces/panel.h b/engines/petka/interfaces/panel.h
index 46153607cd..76ffc4be8f 100644
--- a/engines/petka/interfaces/panel.h
+++ b/engines/petka/interfaces/panel.h
@@ -32,6 +32,7 @@ public:
 	InterfacePanel();
 
 	void start(int id) override;
+	void stop() override;
 
 	void onLeftButtonDown(const Common::Point p) override;
 	void onMouseMove(const Common::Point p) override;
@@ -46,6 +47,9 @@ private:
 public:
 	int _savedXOffset;
 	int _savedSceneWidth;
+	int _savedCursorType;
+	int _savedCursorRes;
+
 	int _subtitles;
 	int _speechFrame;
 	int _musicFrame;
diff --git a/engines/petka/interfaces/save_load.cpp b/engines/petka/interfaces/save_load.cpp
index ea15fd0c5a..69b7348545 100644
--- a/engines/petka/interfaces/save_load.cpp
+++ b/engines/petka/interfaces/save_load.cpp
@@ -47,29 +47,44 @@ InterfaceSaveLoad::InterfaceSaveLoad() {
 }
 
 void InterfaceSaveLoad::startSaveLoad(bool saveMode) {
+	QSystem *sys = g_vm->getQSystem();
+	QObjectCursor *cursor = sys->_cursor.get();
+
 	_loadMode = !saveMode;
-	QObjectBG *bg = (QObjectBG *)g_vm->getQSystem()->findObject("SAVELOAD");
+
+	QObjectBG *bg = (QObjectBG *)sys->findObject("SAVELOAD");
 	_objs.push_back(bg);
 	bg->_resourceId = kFirstSaveLoadPageId + _page + (_loadMode ? 0 : 5);
 
-	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
-	_objs.push_back(cursor);
+	_savedSceneWidth = sys->_sceneWidth;
+	_savedXOffset = sys->_xOffset;
+
+	sys->_sceneWidth = 640;
+	sys->_xOffset = 0;
+
 	_savedCursorId = cursor->_resourceId;
-	cursor->_resourceId = 4901;
-	cursor->_isShown = 1;
-	cursor->_animate = 0;
-	cursor->setCursorPos(cursor->_x, cursor->_y, 0);
+	_savedCursorType = cursor->_actionType;
+
+	initCursor(4901, 1, 0);
 
-	g_vm->getQSystem()->_currInterface = this;
+	sys->_currInterface = this;
 	g_vm->videoSystem()->makeAllDirty();
 }
 
 void InterfaceSaveLoad::stop() {
+	QSystem *sys = g_vm->getQSystem();
 	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+
+	sys->_xOffset = _savedXOffset;
+	sys->_sceneWidth = _savedSceneWidth;
+
 	cursor->_resourceId = _savedCursorId;
-	g_vm->getQSystem()->_currInterface = g_vm->getQSystem()->_prevInterface;
-	g_vm->getQSystem()->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
-	g_vm->videoSystem()->makeAllDirty();
+	cursor->_actionType = _savedCursorType;
+
+	sys->_currInterface = sys->_prevInterface;
+	sys->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
+
+	Interface::stop();
 }
 
 void InterfaceSaveLoad::onLeftButtonDown(const Common::Point p) {
diff --git a/engines/petka/interfaces/save_load.h b/engines/petka/interfaces/save_load.h
index 91fbe0ddb0..9dff8c6dab 100644
--- a/engines/petka/interfaces/save_load.h
+++ b/engines/petka/interfaces/save_load.h
@@ -44,7 +44,11 @@ private:
 private:
 	bool _loadMode;
 	uint _page;
+
+	int _savedXOffset;
+	int _savedSceneWidth;
 	int _savedCursorId;
+	int _savedCursorType;
 
 	Common::Rect _saveRects[6];
 	Common::Rect _nextPageRect;
diff --git a/engines/petka/interfaces/sequence.cpp b/engines/petka/interfaces/sequence.cpp
index 1f5f10496c..1b9dae0341 100644
--- a/engines/petka/interfaces/sequence.cpp
+++ b/engines/petka/interfaces/sequence.cpp
@@ -119,6 +119,7 @@ void InterfaceSequence::stop() {
 	g_system->getMixer()->pauseAll(false);
 
 	g_vm->getQSystem()->_currInterface = g_vm->getQSystem()->_mainInterface.get();
+	Interface::stop();
 }
 
 void InterfaceSequence::onLeftButtonDown(const Common::Point p) {
diff --git a/engines/petka/interfaces/startup.cpp b/engines/petka/interfaces/startup.cpp
index 29ef1389c6..3cf6e4fc38 100644
--- a/engines/petka/interfaces/startup.cpp
+++ b/engines/petka/interfaces/startup.cpp
@@ -132,4 +132,11 @@ void InterfaceStartup::onMouseMove(const Common::Point p) {
 	cursor->setCursorPos(p.x, p.y, 0);
 }
 
+void InterfaceStartup::stop() {
+	QObjectBG *bg = (QObjectBG *)g_vm->getQSystem()->findObject(kStartupObjName);
+	Common::String sound = g_vm->resMgr()->findSoundName(bg->_musicId);
+	g_vm->soundMgr()->removeSound(sound);
+	Interface::stop();
+}
+
 } // End of namespace Petka
diff --git a/engines/petka/interfaces/startup.h b/engines/petka/interfaces/startup.h
index ed239cc8b4..c70e00e28a 100644
--- a/engines/petka/interfaces/startup.h
+++ b/engines/petka/interfaces/startup.h
@@ -30,6 +30,7 @@ namespace Petka {
 class InterfaceStartup : public Interface {
 public:
 	void start(int id) override;
+	void stop() override;
 
 	void onLeftButtonDown(const Common::Point p) override;
 	void onMouseMove(const Common::Point p) override;
diff --git a/engines/petka/q_system.cpp b/engines/petka/q_system.cpp
index 147c1365ea..0c0c6a5ca9 100644
--- a/engines/petka/q_system.cpp
+++ b/engines/petka/q_system.cpp
@@ -45,7 +45,8 @@ namespace Petka {
 
 QSystem::QSystem()
 	: _cursor(nullptr), _case(nullptr), _star(nullptr), _petka(nullptr), _chapayev(nullptr),
-	_mainInterface(nullptr), _currInterface(nullptr), _prevInterface(nullptr), _isIniting(0) {}
+	_mainInterface(nullptr), _currInterface(nullptr), _prevInterface(nullptr), _isIniting(0),
+	_sceneWidth(640) {}
 
 QSystem::~QSystem() {
 


Commit: aca4dc2720d9e2f1e112f70265fdf0b4dbdde321
    https://github.com/scummvm/scummvm/commit/aca4dc2720d9e2f1e112f70265fdf0b4dbdde321
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-22T11:41:19+03:00

Commit Message:
PETKA: save load interface overrides start method

Changed paths:
    engines/petka/interfaces/panel.cpp
    engines/petka/interfaces/save_load.cpp
    engines/petka/interfaces/save_load.h


diff --git a/engines/petka/interfaces/panel.cpp b/engines/petka/interfaces/panel.cpp
index def71b2a4b..027a931ea0 100644
--- a/engines/petka/interfaces/panel.cpp
+++ b/engines/petka/interfaces/panel.cpp
@@ -166,7 +166,7 @@ void InterfacePanel::onLeftButtonDown(const Common::Point p) {
 		g_vm->loadPart(1);
 		break;
 	case kLoadButtonIndex:
-		g_vm->getQSystem()->_saveLoadInterface->startSaveLoad(0);
+		g_vm->getQSystem()->_saveLoadInterface->start(kLoadMode);
 		break;
 	case kContinueButtonIndex:
 		stop();
@@ -175,7 +175,7 @@ void InterfacePanel::onLeftButtonDown(const Common::Point p) {
 		g_system->quit();
 		break;
 	case kSaveButtonIndex:
-		g_vm->getQSystem()->_saveLoadInterface->startSaveLoad(1);
+		g_vm->getQSystem()->_saveLoadInterface->start(kSaveMode);
 		break;
 	case kSubtitleButtonIndex:
 		_subtitles = !_subtitles;
diff --git a/engines/petka/interfaces/save_load.cpp b/engines/petka/interfaces/save_load.cpp
index 69b7348545..4d273dbb2c 100644
--- a/engines/petka/interfaces/save_load.cpp
+++ b/engines/petka/interfaces/save_load.cpp
@@ -46,11 +46,11 @@ InterfaceSaveLoad::InterfaceSaveLoad() {
 	_prevPageRect = Common::Rect(10, 414, 38, 442);
 }
 
-void InterfaceSaveLoad::startSaveLoad(bool saveMode) {
+void InterfaceSaveLoad::start(int id) {
 	QSystem *sys = g_vm->getQSystem();
 	QObjectCursor *cursor = sys->_cursor.get();
 
-	_loadMode = !saveMode;
+	_loadMode = (id == kLoadMode);
 
 	QObjectBG *bg = (QObjectBG *)sys->findObject("SAVELOAD");
 	_objs.push_back(bg);
diff --git a/engines/petka/interfaces/save_load.h b/engines/petka/interfaces/save_load.h
index 9dff8c6dab..692cd5e195 100644
--- a/engines/petka/interfaces/save_load.h
+++ b/engines/petka/interfaces/save_load.h
@@ -27,11 +27,16 @@
 
 namespace Petka {
 
+enum {
+	kSaveMode,
+	kLoadMode
+};
+
 class InterfaceSaveLoad : public Interface {
 public:
 	InterfaceSaveLoad();
 
-	void startSaveLoad(bool saveMode);
+	void start(int id) override;
 	void stop() override;
 
 	void onLeftButtonDown(const Common::Point p) override;




More information about the Scummvm-git-logs mailing list