ScummVM API documentation
interaction.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_INTERACTION_H
26 #define PEGASUS_INTERACTION_H
27 
28 #include "pegasus/input.h"
29 #include "pegasus/util.h"
30 
31 namespace Pegasus {
32 
33 static const InteractionID kNoInteractionID = -1;
34 
35 class Neighborhood;
36 
37 class GameInteraction : public IDObject, public InputHandler {
38 public:
39  GameInteraction(const InteractionID id, Neighborhood *nextHandler);
40 
41  // If the interaction is open (_isInteracting == true), it's too late to do anything
42  // about it here.
43  ~GameInteraction() override {}
44 
45  // startInteraction and stopInteraction are called by the outside world to
46  // start and stop the interaction sequence.
47  // isInteracting returns a bool indicating whether or not the interaction
48  // is going.
49  void startInteraction() {
50  if (!isInteracting()) {
51  openInteraction();
52  initInteraction();
53  _isInteracting = true;
54  _savedHandler = InputHandler::setInputHandler(this);
55  }
56  }
57  void stopInteraction() {
58  if (isInteracting()) {
59  closeInteraction();
60  _isInteracting = false;
61  if (InputHandler::_inputHandler == this)
62  InputHandler::setInputHandler(_savedHandler);
63  }
64  }
65  void startOverInteraction() {
66  if (isInteracting())
67  resetInteraction();
68  }
69  bool isInteracting() const { return _isInteracting; }
70  Neighborhood *getOwner() const { return _owner; }
71 
72  virtual Common::Path getBriefingMovie() { return Common::Path(); }
73  virtual Common::Path getEnvScanMovie() { return Common::Path(); }
74  virtual long getNumHints() { return 0; }
75  virtual Common::Path getHintMovie(uint) { return Common::Path(); }
76  virtual bool canSolve() { return false; }
77 
78  virtual void setSoundFXLevel(const uint16) {}
79  virtual void setAmbienceLevel(const uint16) {}
80 
81  virtual void doSolve() {}
82 
83 protected:
84  // Subclasses override openInteraction and closeInteraction to perform
85  // specific initialization and cleanup. Override resetInteraction to
86  // "start the interaction over." resetInteraction is called only when
87  // the interaction is already open.
88  // These functions are only called in pairs, never two opens or closes
89  // in a row.
90  virtual void openInteraction() {}
91  virtual void initInteraction() {}
92  virtual void closeInteraction() {}
93  virtual void resetInteraction() {}
94 
95  InputHandler *_savedHandler;
96  Neighborhood *_owner;
97 
98 private:
99  // Private so that only StartInteraction and StopInteraction can touch it.
100  bool _isInteracting;
101 };
102 
103 } // End of namespace Pegasus
104 
105 #endif
Definition: neighborhood.h:111
Definition: path.h:52
Definition: util.h:38
Definition: interaction.h:37
Definition: input.h:410
Definition: ai_action.h:33