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

whiterandrek whiterandrek at gmail.com
Thu Jun 4 19:43:59 UTC 2020


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

Summary:
9f3f70c4cd PINK: removed redundant methods in HandlerMgr
3de5035018 PINK: use HandlerSequences instead of HandlerStartPage
ed05445ab1 PINK: moved HandlerTimerActions to handler.h/.cpp files


Commit: 9f3f70c4cdd514de6eac29a5ead10d0731e22969
    https://github.com/scummvm/scummvm/commit/9f3f70c4cdd514de6eac29a5ead10d0731e22969
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-06-04T22:30:45+03:00

Commit Message:
PINK: removed redundant methods in HandlerMgr

Changed paths:
    engines/pink/objects/actors/supporting_actor.cpp
    engines/pink/objects/handlers/handler_mgr.cpp
    engines/pink/objects/handlers/handler_mgr.h


diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp
index 9f37877818..d62f2ef762 100644
--- a/engines/pink/objects/actors/supporting_actor.cpp
+++ b/engines/pink/objects/actors/supporting_actor.cpp
@@ -48,11 +48,11 @@ void SupportingActor::toConsole() const {
 }
 
 bool SupportingActor::isLeftClickHandlers() const {
-	return _handlerMgr.isLeftClickHandler(this);
+	return _handlerMgr.findSuitableHandlerLeftClick(this);
 }
 
 bool SupportingActor::isUseClickHandlers(InventoryItem *item) const {
-	return _handlerMgr.isUseClickHandler(this, item->getName());
+	return _handlerMgr.findSuitableHandlerUseClick(this, item->getName());
 }
 
 void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
@@ -67,7 +67,7 @@ void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
 
 void SupportingActor::onMouseOverWithItem(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
 	Common::String item = itemName;
-	if (_handlerMgr.isUseClickHandler(this, itemName))
+	if (_handlerMgr.findSuitableHandlerUseClick(this, itemName))
 		item += kClickable;
 	cursorMgr->setCursor(kHoldingItemCursor, point, item);
 }
diff --git a/engines/pink/objects/handlers/handler_mgr.cpp b/engines/pink/objects/handlers/handler_mgr.cpp
index 2e9724f8a3..aeae730fe1 100644
--- a/engines/pink/objects/handlers/handler_mgr.cpp
+++ b/engines/pink/objects/handlers/handler_mgr.cpp
@@ -47,26 +47,6 @@ void HandlerMgr::toConsole() const {
 	}
 }
 
-bool HandlerMgr::isLeftClickHandler(const Actor *actor) const {
-	for (uint i = 0; i < _leftClickHandlers.size(); ++i) {
-		if (_leftClickHandlers[i]->isSuitable(actor))
-			return true;
-	}
-
-	return false;
-}
-
-bool HandlerMgr::isUseClickHandler(const Actor *actor, const Common::String &itemName) const {
-	for (uint i = 0; i < _useClickHandlers.size(); ++i) {
-		if (itemName == _useClickHandlers[i]->getInventoryItem() &&
-			_useClickHandlers[i]->isSuitable(actor))
-			return true;
-	}
-
-	return false;
-}
-
-
 void HandlerMgr::onTimerMessage(Actor *actor) {
 	Handler *handler = findSuitableHandlerTimer(actor);
 	if (handler)
@@ -80,14 +60,14 @@ void HandlerMgr::onLeftClickMessage(Actor *actor) {
 }
 
 void HandlerMgr::onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr) {
-	HandlerUseClick *handler = findSuitableHandlerUseClick(actor, item);
+	HandlerUseClick *handler = findSuitableHandlerUseClick(actor, item->getName());
 	assert(handler);
 	if (!handler->getRecepient().empty())
 		mgr->setItemOwner(handler->getRecepient(), item);
 	handler->handle(actor);
 }
 
-Handler *HandlerMgr::findSuitableHandlerTimer(Actor *actor) {
+Handler *HandlerMgr::findSuitableHandlerTimer(const Actor *actor) {
 	for (uint i = 0; i < _timerHandlers.size(); ++i) {
 		if (_timerHandlers[i]->isSuitable(actor))
 			return _timerHandlers[i];
@@ -96,7 +76,7 @@ Handler *HandlerMgr::findSuitableHandlerTimer(Actor *actor) {
 	return nullptr;
 }
 
-HandlerLeftClick *HandlerMgr::findSuitableHandlerLeftClick(Actor *actor) {
+HandlerLeftClick *HandlerMgr::findSuitableHandlerLeftClick(const Actor *actor) const {
 	for (uint i = 0; i < _leftClickHandlers.size(); ++i) {
 		if (_leftClickHandlers[i]->isSuitable(actor))
 			return _leftClickHandlers[i];
@@ -105,9 +85,9 @@ HandlerLeftClick *HandlerMgr::findSuitableHandlerLeftClick(Actor *actor) {
 	return nullptr;
 }
 
-HandlerUseClick *HandlerMgr::findSuitableHandlerUseClick(Actor *actor, InventoryItem *item) {
+HandlerUseClick *HandlerMgr::findSuitableHandlerUseClick(const Actor *actor, const Common::String &itemName) const {
 	for (uint i = 0; i < _useClickHandlers.size(); ++i) {
-		if (item->getName() == _useClickHandlers[i]->getInventoryItem() && _useClickHandlers[i]->isSuitable(actor))
+		if (itemName == _useClickHandlers[i]->getInventoryItem() && _useClickHandlers[i]->isSuitable(actor))
 			return _useClickHandlers[i];
 	}
 
diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h
index ea03baad94..533b33da0a 100644
--- a/engines/pink/objects/handlers/handler_mgr.h
+++ b/engines/pink/objects/handlers/handler_mgr.h
@@ -44,17 +44,15 @@ public:
 
 	void toConsole() const override;
 
-	bool isLeftClickHandler(const Actor *actor) const;
-	bool isUseClickHandler(const Actor *actor, const Common::String &itemName) const;
+	HandlerUseClick *findSuitableHandlerUseClick(const Actor *actor, const Common::String &itemName) const;
+	HandlerLeftClick *findSuitableHandlerLeftClick(const Actor *actor) const;
 
 	void onTimerMessage(Actor *actor);
 	void onLeftClickMessage(Actor *actor);
 	void onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr);
 
 private:
-	Handler *findSuitableHandlerTimer(Actor *actor);
-	HandlerLeftClick *findSuitableHandlerLeftClick(Actor *actor);
-	HandlerUseClick *findSuitableHandlerUseClick(Actor *actor, InventoryItem *item);
+	Handler *findSuitableHandlerTimer(const Actor *actor);
 
 	Array<HandlerLeftClick *> _leftClickHandlers;
 	Array<HandlerUseClick *> _useClickHandlers;


Commit: 3de503501819dd5e446c3c6012bd84f2661a3e31
    https://github.com/scummvm/scummvm/commit/3de503501819dd5e446c3c6012bd84f2661a3e31
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-06-04T22:41:39+03:00

Commit Message:
PINK: use HandlerSequences instead of HandlerStartPage

Changed paths:
    engines/pink/archive.cpp
    engines/pink/objects/handlers/handler.cpp
    engines/pink/objects/handlers/handler.h
    engines/pink/objects/pages/game_page.h


diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp
index f62344f918..f09bc4c3ae 100644
--- a/engines/pink/archive.cpp
+++ b/engines/pink/archive.cpp
@@ -148,12 +148,12 @@ static Object *createObject(int objectId) {
 	case kHandlerLeftClick:
 		return new HandlerLeftClick;
 	case kHandlerStartPage:
-		return new HandlerStartPage;
+		return new HandlerSequences(true, false);
 	case kHandlerTimer:
 	case kHandlerTimerActions:
 		return new HandlerTimerActions; // hack for Peril, but behavior is correct
 	case kHandlerTimerSequences:
-		return new HandlerSequences(true);
+		return new HandlerSequences(false, true);
 	case kHandlerUseClick:
 		return new HandlerUseClick;
 	case kInventoryActor:
diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp
index 3617325c8c..1f2f8fec55 100644
--- a/engines/pink/objects/handlers/handler.cpp
+++ b/engines/pink/objects/handlers/handler.cpp
@@ -86,36 +86,15 @@ void HandlerSequences::handle(Actor *actor) {
 	else
 		sequencer->authorSequence(sequence, false);
 
-	execute(sequence);
+	if (_startPage)
+		sequence->allowSkipping();
 }
 
-HandlerSequences::HandlerSequences(bool parallel) {
+HandlerSequences::HandlerSequences(bool startPage, bool parallel) {
+	_startPage = startPage;
 	_parallel = parallel;
 }
 
-void HandlerStartPage::execute(Sequence *sequence) {
-	sequence->allowSkipping();
-}
-
-void HandlerStartPage::toConsole() const {
-	debugC(6, kPinkDebugLoadingObjects, "HandlerStartPage:");
-
-	debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
-	for (uint i = 0; i < _sideEffects.size(); ++i) {
-		_sideEffects[i]->toConsole();
-	}
-
-	debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
-	for (uint i = 0; i < _conditions.size(); ++i) {
-		_conditions[i]->toConsole();
-	}
-
-	debugC(6, kPinkDebugLoadingObjects, "\tSequences:");
-	for (uint i = 0; i < _sequences.size(); ++i) {
-		debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _sequences[i].c_str());
-	}
-}
-
 void HandlerLeftClick::toConsole() const {
 	debugC(6, kPinkDebugLoadingObjects, "HandlerLeftClick:");
 
diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h
index c73f371c9c..1eacf386a5 100644
--- a/engines/pink/objects/handlers/handler.h
+++ b/engines/pink/objects/handlers/handler.h
@@ -52,32 +52,20 @@ class Sequence;
 
 class HandlerSequences : public Handler {
 public:
-	HandlerSequences(bool parallel = false);
+	HandlerSequences(bool startPage = false, bool parallel = false);
 
 	void deserialize(Archive &archive) override;
 	void handle(Actor *actor) override;
 
 protected:
-	virtual void execute(Sequence *sequence) {};
-
 	StringArray _sequences;
+	bool _startPage;
 	bool _parallel;
 };
 
-class HandlerStartPage : public HandlerSequences {
-public:
-	void toConsole() const override;
-
-private:
-	void execute(Sequence *sequence) override;
-};
-
 class HandlerLeftClick : public HandlerSequences {
 public:
 	void toConsole() const override;
-
-private:
-	void execute(Sequence *sequence) override {}
 };
 
 class HandlerUseClick : public HandlerSequences {
@@ -89,8 +77,6 @@ public:
 	const Common::String &getRecepient() const { return _recepient; }
 
 private:
-	void execute(Sequence *sequence) override {};
-
 	Common::String _inventoryItem;
 	Common::String _recepient;
 };
diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h
index 2db46bbc98..aaf2e86288 100644
--- a/engines/pink/objects/pages/game_page.h
+++ b/engines/pink/objects/pages/game_page.h
@@ -30,7 +30,7 @@
 namespace Pink {
 
 class CursorMgr;
-class HandlerStartPage;
+class HandlerSequences;
 
 class GamePage : public Page {
 public:
@@ -71,7 +71,7 @@ private:
 	CursorMgr *_cursorMgr;
 	WalkMgr *_walkMgr;
 	Sequencer *_sequencer;
-	Array<HandlerStartPage *> _handlers;
+	Array<HandlerSequences *> _handlers;
 	StringMap _variables;
 };
 


Commit: ed05445ab19dd0b0bda767f0ef3ce0b8296fafa9
    https://github.com/scummvm/scummvm/commit/ed05445ab19dd0b0bda767f0ef3ce0b8296fafa9
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-06-04T22:42:26+03:00

Commit Message:
PINK: moved HandlerTimerActions to handler.h/.cpp files

Changed paths:
  R engines/pink/objects/handlers/handler_timer.cpp
  R engines/pink/objects/handlers/handler_timer.h
    engines/pink/archive.cpp
    engines/pink/module.mk
    engines/pink/objects/handlers/handler.cpp
    engines/pink/objects/handlers/handler.h


diff --git a/engines/pink/archive.cpp b/engines/pink/archive.cpp
index f09bc4c3ae..cdae516b82 100644
--- a/engines/pink/archive.cpp
+++ b/engines/pink/archive.cpp
@@ -39,7 +39,6 @@
 #include "pink/objects/actors/pda_button_actor.h"
 #include "pink/objects/actors/supporting_actor.h"
 #include "pink/objects/handlers/handler.h"
-#include "pink/objects/handlers/handler_timer.h"
 #include "pink/objects/pages/game_page.h"
 #include "pink/objects/sequences/seq_timer.h"
 #include "pink/objects/sequences/sequence.h"
diff --git a/engines/pink/module.mk b/engines/pink/module.mk
index 80422cfd7d..f6941d30e9 100644
--- a/engines/pink/module.mk
+++ b/engines/pink/module.mk
@@ -38,7 +38,6 @@ MODULE_OBJS = \
 	objects/actors/supporting_actor.o \
 	objects/handlers/handler.o \
 	objects/handlers/handler_mgr.o \
-	objects/handlers/handler_timer.o \
 	objects/pages/game_page.o \
 	objects/pages/page.o \
 	objects/pages/pda_page.o \
diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp
index 1f2f8fec55..953f420f90 100644
--- a/engines/pink/objects/handlers/handler.cpp
+++ b/engines/pink/objects/handlers/handler.cpp
@@ -138,4 +138,39 @@ void HandlerUseClick::toConsole() const {
 	}
 }
 
+void HandlerTimerActions::deserialize(Archive &archive) {
+	Handler::deserialize(archive);
+	_actions.deserialize(archive);
+}
+
+void HandlerTimerActions::toConsole() const {
+	debugC(6, kPinkDebugLoadingObjects, "HandlerTimerActions:");
+
+	debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
+	for (uint i = 0; i < _sideEffects.size(); ++i) {
+		_sideEffects[i]->toConsole();
+	}
+
+	debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
+	for (uint i = 0; i < _conditions.size(); ++i) {
+		_conditions[i]->toConsole();
+	}
+
+	debugC(6, kPinkDebugLoadingObjects, "\tActions:");
+	for (uint i = 0; i < _actions.size(); ++i) {
+		debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _actions[i].c_str());
+	}
+}
+
+void HandlerTimerActions::handle(Actor *actor) {
+	Handler::handle(actor);
+	if (!actor->isPlaying() && !_actions.empty()) {
+		Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
+		uint index = rnd.getRandomNumber(_actions.size() - 1);
+		Action *action = actor->findAction(_actions[index]);
+		assert(action);
+		actor->setAction(action);
+	}
+}
+
 } // End of namespace Pink
diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h
index 1eacf386a5..b7997ff05a 100644
--- a/engines/pink/objects/handlers/handler.h
+++ b/engines/pink/objects/handlers/handler.h
@@ -81,6 +81,16 @@ private:
 	Common::String _recepient;
 };
 
+class HandlerTimerActions : public Handler {
+public:
+	void toConsole() const override;
+	void deserialize(Archive &archive) override;
+	void handle(Actor *actor) override;
+
+private:
+	StringArray _actions;
+};
+
 } // End of namespace Pink
 
 #endif
diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp
deleted file mode 100644
index 9be73473e7..0000000000
--- a/engines/pink/objects/handlers/handler_timer.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/* 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 "common/debug.h"
-
-#include "pink/archive.h"
-#include "pink/pink.h"
-#include "pink/objects/side_effect.h"
-#include "pink/objects/condition.h"
-#include "pink/objects/actors/lead_actor.h"
-#include "pink/objects/handlers/handler_timer.h"
-#include "pink/objects/pages/game_page.h"
-#include "pink/objects/sequences/sequence.h"
-#include "pink/objects/sequences/sequencer.h"
-
-namespace Pink {
-
-void HandlerTimerActions::deserialize(Archive &archive) {
-	Handler::deserialize(archive);
-	_actions.deserialize(archive);
-}
-
-void HandlerTimerActions::toConsole() const {
-	debugC(6, kPinkDebugLoadingObjects, "HandlerTimerActions:");
-
-	debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
-	for (uint i = 0; i < _sideEffects.size(); ++i) {
-		_sideEffects[i]->toConsole();
-	}
-
-	debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
-	for (uint i = 0; i < _conditions.size(); ++i) {
-		_conditions[i]->toConsole();
-	}
-
-	debugC(6, kPinkDebugLoadingObjects, "\tActions:");
-	for (uint i = 0; i < _actions.size(); ++i) {
-		debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _actions[i].c_str());
-	}
-}
-
-void HandlerTimerActions::handle(Actor *actor) {
-	Handler::handle(actor);
-	if (!actor->isPlaying() && !_actions.empty()) {
-		Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
-		uint index = rnd.getRandomNumber(_actions.size() - 1);
-		Action *action = actor->findAction(_actions[index]);
-		assert(action);
-		actor->setAction(action);
-	}
-}
-
-} // End of namespace Pink
diff --git a/engines/pink/objects/handlers/handler_timer.h b/engines/pink/objects/handlers/handler_timer.h
deleted file mode 100644
index 87ba98fa4f..0000000000
--- a/engines/pink/objects/handlers/handler_timer.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* 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 PINK_HANDLER_TIMER_H
-#define PINK_HANDLER_TIMER_H
-
-#include "pink/objects/handlers/handler.h"
-
-namespace Pink {
-
-class LeadActor;
-
-/*
-// This class has differences in games
-class HandlerTimer : public Handler {
-
-};
-*/
-
-//in Peril this is HandlerTimer
-class HandlerTimerActions : public Handler {
-public:
-	void toConsole() const override;
-	void deserialize(Archive &archive) override;
-	void handle(Actor *actor) override;
-
-private:
-	StringArray _actions;
-};
-
-} // End of namespace Pink
-
-#endif




More information about the Scummvm-git-logs mailing list