From d205ac2e2737b97741f1cde09b320538dcbef98e Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 26 Sep 2011 23:04:20 -0400 Subject: PEGASUS: Add the GameInteraction class --- engines/pegasus/interaction.h | 110 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 engines/pegasus/interaction.h (limited to 'engines/pegasus/interaction.h') diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h new file mode 100755 index 0000000000..b54c59ea38 --- /dev/null +++ b/engines/pegasus/interaction.h @@ -0,0 +1,110 @@ +/* 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. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios, Inc. + * + * 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 PEGASUS_INTERACTION_H +#define PEGASUS_INTERACTION_H + +#include "pegasus/input.h" +#include "pegasus/util.h" + +namespace Pegasus { + +static const tInteractionID kNoInteractionID = -1; + +class Neighborhood; + +class GameInteraction : public IDObject, public InputHandler { +public: + GameInteraction(const tInteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) { + _isInteracting = false; + _savedHandler = 0; + _owner = nextHandler; + } + + // If the interaction is open (_isInteracting == true), it's too late to do anything + // about it here. + virtual ~GameInteraction() {} + + // startInteraction and stopInteraction are called by the outside world to + // start and stop the interaction sequence. + // isInteracting returns a bool indicating whether or not the interaction + // is going. + void startInteraction() { + if (!isInteracting()) { + openInteraction(); + initInteraction(); + _isInteracting = true; + _savedHandler = InputHandler::setInputHandler(this); + } + } + void stopInteraction() { + if (isInteracting()) { + closeInteraction(); + _isInteracting = false; + if (InputHandler::_inputHandler == this) + InputHandler::setInputHandler(_savedHandler); + } + } + void startOverInteraction() { + if (isInteracting()) + resetInteraction(); + } + bool isInteracting() const { return _isInteracting; } + Neighborhood *getOwner() const { return _owner; } + + virtual Common::String getBriefingMovie() { return ""; } + virtual Common::String getEnvScanMovie() { return ""; } + virtual long getNumHints() { return 0; } + virtual Common::String getHintMovie(uint) { return ""; } + virtual bool canSolve() { return false; } + + virtual void setSoundFXLevel(const uint16) {} + virtual void setAmbienceLevel(const uint16) {} + + virtual void doSolve() {} + +protected: + // Subclasses override openInteraction and closeInteraction to perform + // specific initialization and cleanup. Override resetInteraction to + // "start the interaction over." resetInteraction is called only when + // the interaction is already open. + // These functions are only called in pairs, never two opens or closes + // in a row. + virtual void openInteraction() {} + virtual void initInteraction() {} + virtual void closeInteraction() {} + virtual void resetInteraction() {} + + InputHandler *_savedHandler; + Neighborhood *_owner; + +private: + // Private so that only StartInteraction and StopInteraction can touch it. + bool _isInteracting; +}; + +} // End of namespace Pegasus + +#endif -- cgit v1.2.3 From 12efb47b536d2f663c9cde2739a1fd40599da669 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 16 Dec 2011 14:17:50 -0500 Subject: PEGASUS: Remove t prefix from typedefs Some other minor cleanup too --- engines/pegasus/interaction.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/pegasus/interaction.h') diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h index b54c59ea38..b1318563ac 100755 --- a/engines/pegasus/interaction.h +++ b/engines/pegasus/interaction.h @@ -31,13 +31,13 @@ namespace Pegasus { -static const tInteractionID kNoInteractionID = -1; +static const InteractionID kNoInteractionID = -1; class Neighborhood; class GameInteraction : public IDObject, public InputHandler { public: - GameInteraction(const tInteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) { + GameInteraction(const InteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) { _isInteracting = false; _savedHandler = 0; _owner = nextHandler; -- cgit v1.2.3 From 983bd16bb78b1a6aa8872f2086dbcbca6954f2fb Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 3 Apr 2012 15:23:08 -0400 Subject: PEGASUS: Fix file permissions --- engines/pegasus/interaction.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 engines/pegasus/interaction.h (limited to 'engines/pegasus/interaction.h') diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h old mode 100755 new mode 100644 -- cgit v1.2.3 From a6c6c74350bb673c178d9756a1625ca128d24f21 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:10:32 +0200 Subject: PEGASUS: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//' --- engines/pegasus/interaction.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/pegasus/interaction.h') diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h index b1318563ac..293ee6be83 100644 --- a/engines/pegasus/interaction.h +++ b/engines/pegasus/interaction.h @@ -79,10 +79,10 @@ public: virtual long getNumHints() { return 0; } virtual Common::String getHintMovie(uint) { return ""; } virtual bool canSolve() { return false; } - + virtual void setSoundFXLevel(const uint16) {} virtual void setAmbienceLevel(const uint16) {} - + virtual void doSolve() {} protected: @@ -96,10 +96,10 @@ protected: virtual void initInteraction() {} virtual void closeInteraction() {} virtual void resetInteraction() {} - + InputHandler *_savedHandler; Neighborhood *_owner; - + private: // Private so that only StartInteraction and StopInteraction can touch it. bool _isInteracting; -- cgit v1.2.3