ScummVM API documentation
game.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 TETRAEDGE_GAME_GAME_H
23 #define TETRAEDGE_GAME_GAME_H
24 
25 #include "common/types.h"
26 #include "common/serializer.h"
27 #include "common/str.h"
28 #include "common/random.h"
29 
30 #include "tetraedge/game/documents_browser.h"
31 #include "tetraedge/game/inventory.h"
32 #include "tetraedge/game/inventory_menu.h"
33 #include "tetraedge/game/in_game_scene.h"
34 #include "tetraedge/game/notifier.h"
35 #include "tetraedge/game/game_sound.h"
36 #include "tetraedge/game/question2.h"
37 #include "tetraedge/game/dialog2.h"
38 #include "tetraedge/te/te_lua_gui.h"
39 #include "tetraedge/te/te_music.h"
40 #include "tetraedge/te/te_vector2s32.h"
41 
42 namespace Tetraedge {
43 
44 class TeLuaThread;
45 
46 class Game {
47 public:
48  Game();
49  virtual ~Game();
50 
51  struct YieldedCallback {
52  TeLuaThread *_luaThread;
53  Common::String _luaParam;
54  Common::String _luaParam2;
55  Common::String _luaFnName;
56  // Note: original game long, and int fields.. unused?
57  };
58 
59  void addNoScale2Child(TeLayout *layout);
60  virtual void addToBag(const Common::String &objname) = 0;
61 
62  virtual bool changeWarp(const Common::String &zone, const Common::String &scene, bool fadeFlag) = 0;
63 
64  void closeDialogs();
65 
66  virtual void draw() = 0;
67  virtual void enter() = 0; // will load game if _loadName is set.
68  // Note: game uses ILayouts here..
69  static TeI3DObject2 *findLayoutByName(TeLayout *parent, const Common::String &name);
70  static TeSpriteLayout *findSpriteLayoutByName(TeLayout *parent, const Common::String &name);
71 
72  virtual void finishGame() = 0;
73  virtual void initLoadedBackupData() = 0;
74  bool isDocumentOpened();
75  bool isMouse() { return false; }
76  bool isMoviePlaying();
77  bool launchDialog(const Common::String &param_1, uint param_2, const Common::String &charname,
78  const Common::String &animfile, float animblend);
79  virtual void leave(bool flag) = 0;
80 
81  // Not in original. Load unlocked artwork from ScummVM config.
82  virtual void loadUnlockedArtwork() {};
83 
84  //void pauseMovie(); // Unused
85  //void pauseSounds() {}; // Unused, does nothing?
86  bool playMovie(const Common::Path &vidPath, const Common::Path &musicPath, float volume = 1.0f);
87  void playSound(const Common::String &name, int param_2, float volume);
88  void removeNoScale2Child(TeLayout *layout);
89  void resumeMovie();
90  void resumeSounds() {}; // does nothing?
91  void saveBackup(const Common::String &saveName);
92  bool setBackground(const Common::Path &name);
93  void setCurrentObjectSprite(const Common::Path &spritePath);
94  bool showMarkers(bool val);
95  bool startAnimation(const Common::String &animName, int loopcount, bool reversed);
96  // void startAnimationPart(const Common::String &param_1, int param_2, int param_3, int param_4, bool param_5) {}; // Unused.
97  void stopSound(const Common::String &name);
98  Common::Error syncGame(Common::Serializer &s); // Basically replaces saveBackup from original..
99  virtual void update() = 0;
100 
101  InventoryMenu &inventoryMenu() { return _inventoryMenu; }
102  Inventory &inventory() { return _inventory; }
103  DocumentsBrowser &documentsBrowser() { return _documentsBrowser; }
104  bool entered() const { return _entered; }
105  bool running() const { return _running; }
106  void setRunning(bool val) { _running = val; }
107  bool luaShowOwnerError() const { return _luaShowOwnerError; }
108 
109  bool _returnToMainMenu;
110  bool _firstInventory;
111 
112  const Common::String &currentZone() const { return _currentZone; }
113  const Common::String &currentScene() const { return _currentScene; }
114  TeLuaScript &luaScript() { return _luaScript; }
115  TeLuaContext &luaContext() { return _luaContext; }
116  InGameScene &scene() { return _scene; }
117  Dialog2 &dialog2() { return _dialog2; }
118  Question2 &question2() { return _question2; }
119  TeLuaGUI &forGui() { return _forGui; }
120  TeLuaGUI &inGameGui() { return _inGameGui; }
121  bool hasLoadName() const { return !_loadName.empty(); }
122  void setLoadName(const Common::String &loadName) { _loadName = loadName; }
123 
124  bool onAnswered(const Common::String &val);
125  virtual bool onDialogFinished(const Common::String &val) = 0;
126  virtual bool onFinishedLoadingBackup(const Common::String &val) { return false; }
127  bool onInventoryButtonValidated();
128  bool onLockVideoButtonValidated();
129  bool onMouseMove(const Common::Point &pt);
130  bool onSkipVideoButtonValidated();
131  virtual bool onVideoFinished() = 0;
132 
133 protected:
134  bool _luaShowOwnerError;
135  bool _running;
136  bool _entered;
137 
138  //TeLuaGUI _gui1; // Never used.
139  TeLuaGUI _setAnimGui;
140  TeLuaGUI _forGui;
141  TeLuaGUI _inGameGui;
142 
143  Inventory _inventory;
144  InventoryMenu _inventoryMenu;
145 
146  InGameScene _scene;
147 
148  Common::String _loadName;
149 
150  Common::String _currentScene;
151  Common::String _currentZone;
152  Common::String _prevSceneName;
153 
154  Common::Array<GameSound *> _gameSounds;
155 
156  static const int NUM_OBJECTS_TAKEN_IDS = 5;
157  static const char *OBJECTS_TAKEN_IDS[NUM_OBJECTS_TAKEN_IDS];
158  bool _objectsTakenBits[NUM_OBJECTS_TAKEN_IDS];
159  int _objectsTakenVal;
160 
161  TeTimer _playedTimer;
162  TeTimer _walkTimer;
163  TeLuaScript _luaScript;
164  TeLuaContext _luaContext;
165  TeLuaScript _gameEnterScript;
166  TeMusic _videoMusic;
167  Notifier _notifier;
168  DocumentsBrowser _documentsBrowser;
169 
170  Question2 _question2;
171  Dialog2 _dialog2;
172 
173  int _dialogsTold;
174 
175  TeLayout *_noScaleLayout2;
176 
177 };
178 
179 } // end namespace Tetraedge
180 
181 #endif // TETRAEDGE_GAME_GAME_H
Definition: game.h:46
Definition: str.h:59
Definition: detection.h:27
Definition: error.h:84
Definition: array.h:52
Definition: te_lua_gui.h:51
Definition: path.h:52
Definition: inventory.h:34
Definition: serializer.h:79
Definition: te_timer.h:33
Definition: question2.h:31
Definition: inventory_menu.h:29
Definition: notifier.h:29
Definition: dialog2.h:33
Definition: te_lua_script.h:33
Definition: te_layout.h:35
Definition: rect.h:45
Definition: te_lua_context.h:42
Definition: te_music.h:35
Definition: te_i_3d_object2.h:27
Definition: te_sprite_layout.h:30
Definition: te_lua_thread.h:36
Definition: in_game_scene.h:48
Definition: documents_browser.h:31