ScummVM API documentation
action.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  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef LASTEXPRESS_ACTION_H
23 #define LASTEXPRESS_ACTION_H
24 
25 #include "lastexpress/shared.h"
26 
27 #include "common/array.h"
28 #include "common/func.h"
29 #include "common/system.h"
30 
31 namespace LastExpress {
32 
33 #define DECLARE_ACTION(name) \
34  SceneIndex action_##name(const SceneHotspot &hotspot) const
35 
36 #define ADD_ACTION(name) \
37  _actions.push_back(new Functor1MemConst<const SceneHotspot &, SceneIndex, Action>(this, &Action::action_##name));
38 
39 #define IMPLEMENT_ACTION(name) \
40  SceneIndex Action::action_##name(const SceneHotspot &hotspot) const { \
41  debugC(6, kLastExpressDebugLogic, "Hotspot action: " #name "%s", hotspot.toString().c_str());
42 
43 class LastExpressEngine;
44 class SceneHotspot;
45 
46 class Action {
47 public:
48  Action(LastExpressEngine *engine);
49  ~Action();
50 
51  // Hotspot action
52  SceneIndex processHotspot(const SceneHotspot &hotspot);
53 
54  // Cursor
55  CursorStyle getCursor(const SceneHotspot &hotspot) const;
56 
57  // Animation
58  void playAnimation(EventIndex index, bool debugMode = false) const;
59 
60  // Compartment action
61  bool handleOtherCompartment(ObjectIndex object, bool doPlaySound, bool doLoadScene) const;
62 
63 private:
65 
66  LastExpressEngine *_engine;
68 
69  // Each action is of the form action_<name>(SceneHotspot *hotspot)
70  // - a pointer to each action is added to the _actions array
71  // - processHotspot simply calls the proper function given by the hotspot->action value
72  //
73  // Note: even though there are 44 actions, only 41 are used in processHotspot
74 
75  DECLARE_ACTION(inventory);
76  DECLARE_ACTION(savePoint);
77  DECLARE_ACTION(playSound);
78  DECLARE_ACTION(playMusic);
79  DECLARE_ACTION(knock);
80  DECLARE_ACTION(compartment);
81  DECLARE_ACTION(playSounds);
82  DECLARE_ACTION(playAnimation);
83  DECLARE_ACTION(openCloseObject);
84  DECLARE_ACTION(setModel);
85  DECLARE_ACTION(setItem);
86  DECLARE_ACTION(knockInside);
87  DECLARE_ACTION(pickItem);
88  DECLARE_ACTION(dropItem);
89  DECLARE_ACTION(enterCompartment);
90  DECLARE_ACTION(leanOutWindow);
91  DECLARE_ACTION(almostFall);
92  DECLARE_ACTION(climbInWindow);
93  DECLARE_ACTION(climbLadder);
94  DECLARE_ACTION(climbDownTrain);
95  DECLARE_ACTION(kronosSanctum);
96  DECLARE_ACTION(escapeBaggage);
97  DECLARE_ACTION(enterBaggage);
98  DECLARE_ACTION(bombPuzzle);
99  DECLARE_ACTION(27);
100  DECLARE_ACTION(kronosConcert);
101  DECLARE_ACTION(29);
102  DECLARE_ACTION(catchBeetle);
103  DECLARE_ACTION(exitCompartment);
104  DECLARE_ACTION(outsideTrain);
105  DECLARE_ACTION(firebirdPuzzle);
106  DECLARE_ACTION(openMatchBox);
107  DECLARE_ACTION(openBed);
108  DECLARE_ACTION(dialog);
109  DECLARE_ACTION(eggBox);
110  DECLARE_ACTION(39);
111  DECLARE_ACTION(bed);
112  DECLARE_ACTION(playMusicChapter);
113  DECLARE_ACTION(playMusicChapterSetupTrain);
114  DECLARE_ACTION(switchChapter);
115  DECLARE_ACTION(44);
116 
117  // Special dummy function
118  DECLARE_ACTION(dummy);
119 
120  // Helpers
121  void pickGreenJacket(bool process) const;
122  void pickScarf(bool process) const;
123  void pickCorpse(ObjectLocation bedPosition, bool process) const;
124  void dropCorpse(bool process) const;
125 
126  void playCompartmentSoundEvents(ObjectIndex object) const;
127 };
128 
129 } // End of namespace LastExpress
130 
131 #endif // LASTEXPRESS_ACTION_H
Definition: lastexpress.h:69
Definition: array.h:52
Definition: animation.h:45
Definition: func.h:437
Definition: action.h:46
Definition: scene.h:82