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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef LASTEXPRESS_ACTION_H
24 #define LASTEXPRESS_ACTION_H
25 
26 #include "lastexpress/shared.h"
27 
28 #include "common/array.h"
29 #include "common/func.h"
30 #include "common/system.h"
31 
32 namespace LastExpress {
33 
34 #define DECLARE_ACTION(name) \
35 	SceneIndex action_##name(const SceneHotspot &hotspot) const
36 
37 #define ADD_ACTION(name) \
38 	_actions.push_back(new Functor1MemConst<const SceneHotspot &, SceneIndex, Action>(this, &Action::action_##name));
39 
40 #define IMPLEMENT_ACTION(name) \
41 	SceneIndex Action::action_##name(const SceneHotspot &hotspot) const { \
42 	debugC(6, kLastExpressDebugLogic, "Hotspot action: " #name "%s", hotspot.toString().c_str());
43 
44 class LastExpressEngine;
45 class SceneHotspot;
46 
47 class Action {
48 public:
49 	Action(LastExpressEngine *engine);
50 	~Action();
51 
52 	// Hotspot action
53 	SceneIndex processHotspot(const SceneHotspot &hotspot);
54 
55 	// Cursor
56 	CursorStyle getCursor(const SceneHotspot &hotspot) const;
57 
58 	// Animation
59 	void playAnimation(EventIndex index, bool debugMode = false) const;
60 
61 	// Compartment action
62 	bool handleOtherCompartment(ObjectIndex object, bool doPlaySound, bool doLoadScene) const;
63 
64 private:
65 	typedef Common::Functor1<const SceneHotspot &, SceneIndex> ActionFunctor;
66 
67 	LastExpressEngine *_engine;
68 	Common::Array<ActionFunctor *> _actions;
69 
70 	// Each action is of the form action_<name>(SceneHotspot *hotspot)
71 	//   - a pointer to each action is added to the _actions array
72 	//   - processHotspot simply calls the proper function given by the hotspot->action value
73 	//
74 	// Note: even though there are 44 actions, only 41 are used in processHotspot
75 
76 	DECLARE_ACTION(inventory);
77 	DECLARE_ACTION(savePoint);
78 	DECLARE_ACTION(playSound);
79 	DECLARE_ACTION(playMusic);
80 	DECLARE_ACTION(knock);
81 	DECLARE_ACTION(compartment);
82 	DECLARE_ACTION(playSounds);
83 	DECLARE_ACTION(playAnimation);
84 	DECLARE_ACTION(openCloseObject);
85 	DECLARE_ACTION(setModel);
86 	DECLARE_ACTION(setItem);
87 	DECLARE_ACTION(knockInside);
88 	DECLARE_ACTION(pickItem);
89 	DECLARE_ACTION(dropItem);
90 	DECLARE_ACTION(enterCompartment);
91 	DECLARE_ACTION(leanOutWindow);
92 	DECLARE_ACTION(almostFall);
93 	DECLARE_ACTION(climbInWindow);
94 	DECLARE_ACTION(climbLadder);
95 	DECLARE_ACTION(climbDownTrain);
96 	DECLARE_ACTION(kronosSanctum);
97 	DECLARE_ACTION(escapeBaggage);
98 	DECLARE_ACTION(enterBaggage);
99 	DECLARE_ACTION(bombPuzzle);
100 	DECLARE_ACTION(27);
101 	DECLARE_ACTION(kronosConcert);
102 	DECLARE_ACTION(29);
103 	DECLARE_ACTION(catchBeetle);
104 	DECLARE_ACTION(exitCompartment);
105 	DECLARE_ACTION(outsideTrain);
106 	DECLARE_ACTION(firebirdPuzzle);
107 	DECLARE_ACTION(openMatchBox);
108 	DECLARE_ACTION(openBed);
109 	DECLARE_ACTION(dialog);
110 	DECLARE_ACTION(eggBox);
111 	DECLARE_ACTION(39);
112 	DECLARE_ACTION(bed);
113 	DECLARE_ACTION(playMusicChapter);
114 	DECLARE_ACTION(playMusicChapterSetupTrain);
115 	DECLARE_ACTION(switchChapter);
116 	DECLARE_ACTION(44);
117 
118 	// Special dummy function
119 	DECLARE_ACTION(dummy);
120 
121 	// Helpers
122 	void pickGreenJacket(bool process) const;
123 	void pickScarf(bool process) const;
124 	void pickCorpse(ObjectLocation bedPosition, bool process) const;
125 	void dropCorpse(bool process) const;
126 
127 	void playCompartmentSoundEvents(ObjectIndex object) const;
128 };
129 
130 } // End of namespace LastExpress
131 
132 #endif // LASTEXPRESS_ACTION_H
133