ScummVM
glk.h
Go to the documentation of this file.
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 GLK_GLK_H
24 #define GLK_GLK_H
25 
26 #include "common/scummsys.h"
27 #include "common/random.h"
28 #include "common/system.h"
29 #include "common/serializer.h"
30 #include "engines/engine.h"
31 #include "glk/debugger.h"
32 #include "glk/glk_types.h"
33 #include "glk/streams.h"
34 #include "glk/pc_speaker.h"
35 
36 namespace Glk {
37 
38 class Clipboard;
39 class Blorb;
40 class Conf;
41 class Events;
42 class Pictures;
43 class Screen;
44 class Selection;
45 class Sounds;
46 class Streams;
47 class Windows;
48 
50  kDebugCore = 1 << 0,
51  kDebugScripts = 1 << 1,
52  kDebugGraphics = 1 << 2,
53  kDebugSound = 1 << 3
54 };
55 
56 
57 #define GLK_SAVEGAME_VERSION 1
58 
66 };
67 
71 class GlkEngine : public Engine {
72 private:
76  void initialize();
77 protected:
83  bool _quitFlag;
84 
85  // Engine APIs
86  virtual Common::Error run();
87 
91  virtual bool hasFeature(EngineFeature f) const override;
92 
96  virtual void initGraphicsMode();
97 
101  virtual Screen *createScreen();
102 
107  return new Debugger();
108  }
109 
113  virtual void runGame() = 0;
114 public:
128 
129  gidispatch_rock_t(*gli_register_obj)(void *obj, uint objclass);
130  void(*gli_unregister_obj)(void *obj, uint objclass, gidispatch_rock_t objrock);
131  gidispatch_rock_t(*gli_register_arr)(void *array, uint len, const char *typecode);
132  void(*gli_unregister_arr)(void *array, uint len, const char *typecode, gidispatch_rock_t objrock);
133 public:
134  GlkEngine(OSystem *syst, const GlkGameDescription &gameDesc);
135  virtual ~GlkEngine();
136 
140  virtual bool canLoadGameStateCurrently() override {
141  return true;
142  }
143 
147  virtual bool canSaveGameStateCurrently() override {
148  return true;
149  }
150 
154  Common::Language getLanguage() const { return _gameDescription._language; };
155 
159  virtual InterpreterType getInterpreterType() const = 0;
160 
164  const Common::String &getGameID() const { return _gameDescription._gameId; }
165 
169  const Common::String &getGameMD5() const { return _gameDescription._md5; }
170 
174  const Common::String &getFilename() const { return _gameDescription._filename; }
175 
179  uint getOptions() const { return _gameDescription._options; }
180 
184  const Common::String &getTargetName() const {
185  return _targetName;
186  }
187 
192  return Common::String::format("%s.%.3u", getTargetName().c_str(), slot);
193  }
194 
199 
204 
208  virtual Common::Error loadGameState(int slot) override;
209 
213  virtual Common::Error saveGameState(int slot, const Common::String &desc) override;
214 
218  virtual Common::Error readSaveData(Common::SeekableReadStream *rs) = 0;
219 
224  virtual Common::Error writeGameData(Common::WriteStream *ws) = 0;
225 
229  virtual void syncSoundSettings() override;
230 
234  void beep();
235 
239  uint getRandomNumber(uint max) { return _random.getRandomNumber(max); }
240 
244  void setRandomNumberSeed(uint seed) { _random.setSeed(seed); }
245 
249  void quitGame() {
250  _quitFlag = true;
252  }
253 
257  bool shouldQuit() const {
258  return _quitFlag || Engine::shouldQuit();
259  }
260 };
261 
262 extern GlkEngine *g_vm;
263 
264 } // End of namespace Glk
265 
266 #endif
void run()
Definition: main.cpp:1377
Blorb * _blorb
Definition: glk.h:115
Common::String _md5
Definition: glk.h:64
Common::Language _language
Definition: glk.h:61
Simple string class for ScummVM.
Definition: str.h:49
int _loadSaveSlot
Definition: glk.h:80
bool _copySelect
Definition: glk.h:126
Sounds * _sounds
Definition: glk.h:124
Pictures manager.
Definition: picture.h:89
uint getRandomNumber(uint max)
Generates a random unsigned integer in the interval [0, max].
Definition: random.cpp:46
Streams * _streams
Definition: glk.h:123
Screen class.
bool _terminated
Definition: glk.h:127
Conf * _conf
Definition: glk.h:117
void setSeed(uint32 seed)
Definition: random.cpp:42
static const BdfFontData desc
EngineFeature
A feature in this context means an ability of the engine which can be either available or not...
Definition: engine.h:107
void setRandomNumberSeed(uint seed)
Set a random number seed.
Definition: glk.h:244
Common::Language getLanguage() const
Returns the language.
Definition: glk.h:154
#define f(col, lum)
Blorb file manager.
Definition: blorb.h:83
Platform
List of game platforms.
Definition: platform.h:38
Main windows manager.
Definition: windows.h:51
Definition: engine.h:57
Common::String getSaveName(uint slot) const
Return the filename for a given save slot.
Definition: glk.h:191
Simple random number generator.
Definition: random.h:36
TODO: vital to document this core class properly!!! For both users and implementors.
Definition: file.h:39
bool _quitFlag
Definition: glk.h:83
static bool shouldQuit()
Return whether the ENGINE should quit respectively should return to the launcher. ...
Definition: engine.cpp:669
static void quitGame()
Request the engine to quit.
Definition: engine.cpp:662
Clipboard * _clipboard
Definition: glk.h:116
static void(WINAPI *_SHIdleTimerReset)(void)
Debugger * _debugger
Definition: glk.h:118
const Common::String & getGameID() const
Returns the game&#39;s Id.
Definition: glk.h:164
Events manager.
Definition: events.h:163
Overall manager for selecting areas on the screen, copying to/from the clipboard, and managing hyperl...
Definition: selection.h:101
GlkDebugChannels
Definition: glk.h:49
Screen surface class.
Definition: screen.h:44
bool shouldQuit() const
Returns true if the game should be quit.
Definition: glk.h:257
Base class for the different interpreters.
Definition: glk.h:71
virtual bool canSaveGameStateCurrently() override
Returns true if the game can be saved.
Definition: glk.h:147
Contains the necessary data structures andfunctions for adding to andreferring to the ID table(a very...
Definition: adrift.cpp:28
Sound manager.
Definition: sound.h:97
unsigned int uint
Definition: scummsys.h:440
Language
List of game language.
Definition: language.h:35
Generic interface for a writable data stream.
Definition: stream.h:64
GlkEngine * g_vm
Definition: glk.cpp:46
An Error instance pairs an error code with string description providing more details about the error...
Definition: error.h:77
static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels)
Definition: main.cpp:156
virtual Debugger * createDebugger()
Creates a debugger instance.
Definition: glk.h:106
uint getRandomNumber(uint max)
Get a random number.
Definition: glk.h:239
const Common::String & getGameMD5() const
Returns the game&#39;s md5.
Definition: glk.h:169
uint getOptions() const
Returns any options returned with the game&#39;s detection entry.
Definition: glk.h:179
AIStateDef seed[]
Definition: ai-init.cpp:558
Screen * _screen
Definition: glk.h:121
void saveGame(Common::WriteStream *saveFile)
Definition: save.cpp:129
PCSpeaker * _pcSpeaker
Definition: glk.h:82
Interface for ScummVM backends.
Definition: system.h:113
const Common::String & getTargetName() const
Return the game engine&#39;s target name.
Definition: glk.h:184
const GlkGameDescription _gameDescription
Definition: glk.h:78
void quitGame()
Flags to quit the game.
Definition: glk.h:249
Common::String _gameId
Definition: glk.h:60
Common::String _filename
Definition: glk.h:63
Pictures * _pictures
Definition: glk.h:120
bool loadGame(const Common::String &fname)
Definition: loadsave.cpp:176
Common::RandomSource _random
Definition: glk.h:79
InterpreterType
List of the different sub-engines the engine will likely eventually support.
Definition: glk_types.h:37
virtual bool canLoadGameStateCurrently() override
Returns true if a savegame can be loaded.
Definition: glk.h:140
Streams manager.
Definition: streams.h:580
static String format(const char *fmt,...) GCC_PRINTF(1
Print formatted data into a String object.
Definition: str.cpp:634
Acts as interface to and from the system&#39;s clipboard storage.
Definition: selection.h:41
Windows * _windows
Definition: glk.h:125
Common::File _gameFile
Definition: glk.h:81
Interface for a seekable & readable data stream.
Definition: stream.h:561
Selection * _selection
Definition: glk.h:122
Engine configuration.
Definition: conf.h:35
const Common::String & getFilename() const
Returns the primary filename for the game.
Definition: glk.h:174
Events * _events
Definition: glk.h:119
Common::Platform _platform
Definition: glk.h:62