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_LASTEXPRESS_H
24 #define LASTEXPRESS_LASTEXPRESS_H
25 
26 #include "lastexpress/debug.h"
27 #include "lastexpress/eventhandler.h"
28 
29 #include "common/random.h"
30 
31 #include "engines/engine.h"
32 
33 #include "graphics/pixelformat.h"
34 
35 struct ADGameDescription;
36 
37 /**
38  * This is the namespace of the LastExpress engine.
39  *
40  * Status of this engine:
41  *  The game is playable but still very buggy and missing crucial functionality:
42  *    - Resources: classes for the resource formats used by the game are mostly
43  *      complete (subtitles integration/cursor transparency are missing)
44  *    - Display: basic graphic manager functionality is implemented (transitions
45  *      and dirty rects handling are missing)
46  *    - Menu/Navigation: menu is done and navigation/hotspot handling are also
47  *      mostly implemented (with remaining bugs)
48  *    - Logic: all the hardcoded AI logic has been implemented, as well as the
49  *      shared entity code for drawing/handling of entities.
50  *    - Sound: most of the sound queue functionality is still missing
51  *    - Savegame: almost all the savegame code is still missing.
52  *
53  * Maintainers:
54  *  littleboy, jvprat, clone2727
55  *
56  * Supported games:
57  *  - The Last Express
58  */
59 namespace LastExpress {
60 
61 class Cursor;
62 class Font;
63 class GraphicsManager;
64 class Logic;
65 class Menu;
66 class ResourceManager;
67 class SceneManager;
68 class SoundManager;
69 
70 class LastExpressEngine : public Engine {
71 protected:
72 	// Engine APIs
73 	Common::Error run() override;
74 	bool hasFeature(EngineFeature f) const override;
75 
76 public:
77 	LastExpressEngine(OSystem *syst, const ADGameDescription *gd);
78 	~LastExpressEngine() override;
79 
80 	// Misc
getRandom()81 	Common::RandomSource& getRandom() {return _random; }
82 
83 	// Game
getCursor()84 	Cursor          *getCursor()          const { return _cursor; }
getFont()85 	Font            *getFont()            const { return _font; }
getGameLogic()86 	Logic           *getGameLogic()       const { return _logic; }
getGameMenu()87 	Menu            *getGameMenu()        const { return _menu; }
88 
89 	// Managers
getGraphicsManager()90 	GraphicsManager *getGraphicsManager() const { return _graphicsMan; }
getResourceManager()91 	ResourceManager *getResourceManager() const { return _resMan; }
getSceneManager()92 	SceneManager    *getSceneManager()    const { return _sceneMan; }
getSoundManager()93 	SoundManager    *getSoundManager()    const { return _soundMan; }
94 
95 	// Event handling
96 	bool handleEvents();
97 	void pollEvents();
98 
99 	void backupEventHandlers();
100 	void restoreEventHandlers();
101 	void setEventHandlers(EventHandler::EventFunction *eventMouse, EventHandler::EventFunction *eventTick);
102 
103 	bool isDemo() const;
104 
105 	// Frame Counter
106 	// TODO: all callers could use _system->getMillis() directly without extra conversions
107 	uint32 getFrameCounter() const;
108 
109 private:
110 	const ADGameDescription *_gameDescription;
111 	Graphics::PixelFormat _pixelFormat;
112 
113 	// Misc
114 	Debugger *_debugger;
115 	Common::RandomSource _random;
116 
117 	// Game
118 	Cursor *_cursor;
119 	Font   *_font;
120 	Logic  *_logic;
121 	Menu   *_menu;
122 
123 	// Frame counter
124 	uint32 _lastFrameCount;
125 
126 	// Managers
127 	GraphicsManager *_graphicsMan;
128 	ResourceManager *_resMan;
129 	SceneManager    *_sceneMan;
130 	SoundManager    *_soundMan;
131 
132 	// Event handlers
133 	EventHandler::EventFunction *_eventMouse;
134 	EventHandler::EventFunction *_eventTick;
135 
136 	EventHandler::EventFunction *_eventMouseBackup;
137 	EventHandler::EventFunction *_eventTickBackup;
138 };
139 
140 } // End of namespace LastExpress
141 
142 #endif // LASTEXPRESS_LASTEXPRESS_H
143