ScummVM
engine.cpp
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 #define FORBIDDEN_SYMBOL_EXCEPTION_getcwd
24 
25 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
26 #define WIN32_LEAN_AND_MEAN
27 #include <windows.h>
28 #include <direct.h>
29 #endif
30 
31 #include "engines/engine.h"
32 #include "engines/dialogs.h"
33 #include "engines/util.h"
34 
35 #include "common/config-manager.h"
36 #include "common/events.h"
37 #include "common/file.h"
38 #include "common/system.h"
39 #include "common/str.h"
40 #include "common/error.h"
41 #include "common/list.h"
42 #include "common/memstream.h"
43 #include "common/scummsys.h"
44 #include "common/taskbar.h"
45 #include "common/textconsole.h"
46 #include "common/translation.h"
47 #include "common/singleton.h"
48 
50 #include "base/version.h"
51 
52 #include "gui/gui-manager.h"
53 #include "gui/debugger.h"
54 #include "gui/dialog.h"
55 #include "gui/message.h"
56 
57 #include "audio/mixer.h"
58 
59 #include "graphics/cursorman.h"
60 #include "graphics/fontman.h"
61 #include "graphics/pixelformat.h"
62 #include "image/bmp.h"
63 
64 #ifdef USE_TTS
65 #include "common/text-to-speech.h"
66 #endif
67 
68 #ifdef _WIN32_WCE
69 extern bool isSmartphone();
70 #endif
71 
72 // FIXME: HACK for error()
74 
75 // Output formatter for debug() and error() which invokes
76 // the errorString method of the active engine, if any.
77 static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize) {
78  if (g_engine) {
79  g_engine->errorString(src, dst, dstSize);
80  } else {
81  Common::strlcpy(dst, src, dstSize);
82  }
83 }
84 
85 static void defaultErrorHandler(const char *msg) {
86  // Unless this error -originated- within the debugger itself, we
87  // now invoke the debugger, if available / supported.
88  if (g_engine) {
89  GUI::Debugger *debugger = g_engine->getDebugger();
90 #ifdef _WIN32_WCE
91  if (isSmartphone())
92  debugger = 0;
93 #endif
94 
95 #if defined(USE_TASKBAR)
97 #endif
98 
99  if (debugger && !debugger->isActive()) {
100  debugger->attach(msg);
101  debugger->onFrame();
102  }
103 
104 
105 #if defined(USE_TASKBAR)
107 #endif
108 
109  }
110 }
111 
112 // Chained games manager
113 
115  clear();
116 }
117 
119  _chainedGames.clear();
120 }
121 
122 void ChainedGamesManager::push(const Common::String target, const int slot) {
123  Game game;
124  game.target = target;
125  game.slot = slot;
126  _chainedGames.push(game);
127 }
128 
129 bool ChainedGamesManager::pop(Common::String &target, int &slot) {
130  if (_chainedGames.empty()) {
131  return false;
132  }
133  Game game = _chainedGames.pop();
134  target = game.target;
135  slot = game.slot;
136  return true;
137 }
138 
139 namespace Common {
141 }
142 
144  : _system(syst),
145  _mixer(_system->getMixer()),
146  _timer(_system->getTimerManager()),
147  _eventMan(_system->getEventManager()),
148  _saveFileMan(_system->getSavefileManager()),
149  _targetName(ConfMan.getActiveDomainName()),
150  _pauseLevel(0),
151  _pauseStartTime(0),
152  _saveSlotToLoad(-1),
153  _engineStartTime(_system->getMillis()),
154  _mainMenuDialog(NULL) {
155 
156  g_engine = this;
159 
160  // FIXME: Get rid of the following again. It is only here
161  // temporarily. We really should never run with a non-working Mixer,
162  // so ought to handle this at a much earlier stage. If we *really*
163  // want to support systems without a working mixer, then we need
164  // more work. E.g. we could modify the Mixer to immediately drop any
165  // streams passed to it. This way, at least we don't crash because
166  // heaps of (sound) memory get allocated but never freed. Of course,
167  // there still would be problems with many games...
168  if (!_mixer->isReady())
169  warning("Sound initialization failed. This may cause severe problems in some games");
170 
171  // Setup a dummy cursor and palette, so that all engines can use
172  // CursorMan.replace without having any headaches about memory leaks.
173  //
174  // If an engine only used CursorMan.replaceCursor and no cursor has
175  // been setup before, then replaceCursor just uses pushCursor. This
176  // means that that the engine's cursor is never again removed from
177  // CursorMan. Hence we setup a fake cursor here and remove it again
178  // in the destructor.
179  CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0);
180  // Note: Using this dummy palette will actually disable cursor
181  // palettes till the user enables it again.
182  CursorMan.pushCursorPalette(NULL, 0, 0);
183 }
184 
186  _mixer->stopAll();
187 
188  delete _mainMenuDialog;
189  g_engine = NULL;
190 
191  // Remove our cursors again to prevent memory leaks
192  CursorMan.popCursor();
193  CursorMan.popCursorPalette();
194 }
195 
196 void Engine::initializePath(const Common::FSNode &gamePath) {
197  SearchMan.addDirectory(gamePath.getPath(), gamePath, 0, 4);
198 }
199 
201  const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain();
202 
203  // Any global or command line settings already have been applied at the time
204  // we get here, so we only do something if the game domain overrides those
205  // values
206  if (gameDomain) {
207  if (gameDomain->contains("aspect_ratio"))
209 
210  if (gameDomain->contains("fullscreen"))
212 
213  if (gameDomain->contains("filtering"))
215 
216  if (gameDomain->contains("stretch_mode"))
217  g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
218  }
219 }
220 
221 // Please leave the splash screen in working order for your releases, even if they're commercial.
222 // This is a proper and good way to show your appreciation for our hard work over these years.
223 bool splash = false;
224 
225 #include "logo_data.h"
226 
227 void splashScreen() {
229 
230  Image::BitmapDecoder bitmap;
231 
232  if (!bitmap.loadStream(stream)) {
233  warning("Error loading logo file");
234  return;
235  }
236 
238 
239  // Fill with orange
242  screen.fillRect(Common::Rect(screen.w, screen.h), screen.format.ARGBToColor(0xff, 0xcc, 0x66, 0x00));
243 
244  // Load logo
245  Graphics::Surface *logo = bitmap.getSurface()->convertTo(g_system->getOverlayFormat(), bitmap.getPalette());
246  int lx = MAX((g_system->getOverlayWidth() - logo->w) / 2, 0);
247  int ly = MAX((g_system->getOverlayHeight() - logo->h) / 2, 0);
248 
249  // Print version information
251  int w = font->getStringWidth(gScummVMVersionDate);
252  int x = g_system->getOverlayWidth() - w - 5; // lx + logo->w - w + 5;
253  int y = g_system->getOverlayHeight() - font->getFontHeight() - 5; //ly + logo->h + 5;
254  font->drawString(&screen, gScummVMVersionDate, x, y, w, screen.format.ARGBToColor(0xff, 0, 0, 0));
255 
256  g_system->copyRectToOverlay(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
257  screen.free();
258 
259  // Draw logo
260  int lw = MIN<uint16>(logo->w, g_system->getOverlayWidth() - lx);
261  int lh = MIN<uint16>(logo->h, g_system->getOverlayHeight() - ly);
262 
263  g_system->copyRectToOverlay(logo->getPixels(), logo->pitch, lx, ly, lw, lh);
264  logo->free();
265  delete logo;
266 
268 
269  // Delay 0.6 secs
270  uint time0 = g_system->getMillis();
271  Common::Event event;
272  while (time0 + 600 > g_system->getMillis()) {
273  g_system->delayMillis(10);
274  }
276 
277  splash = true;
278 }
279 
281  g_system->initSizeHint(modes);
282 }
283 
285 
287 
288  initCommonGFX();
289 #ifdef USE_RGB_COLOR
290  if (format)
291  g_system->initSize(width, height, format);
292  else {
294  g_system->initSize(width, height, &bestFormat);
295  }
296 #else
297  g_system->initSize(width, height);
298 #endif
299 
301 
302  if (!splash && !GUI::GuiManager::instance()._launched)
303  splashScreen();
304 
305  if (gfxError == OSystem::kTransactionSuccess)
306  return;
307 
308  // Error out on size switch failure
309  if (gfxError & OSystem::kTransactionSizeChangeFailed) {
311  message = Common::String::format(_("Could not switch to resolution '%dx%d'."), width, height);
312 
313  GUIErrorMessage(message);
314  error("%s", message.c_str());
315  }
316 
317  // Just show warnings then these occur:
318 #ifdef USE_RGB_COLOR
320  Common::String message = _("Could not initialize color format.");
321 
322  GUI::MessageDialog dialog(message);
323  dialog.runModal();
324  }
325 #endif
326 
327  if (gfxError & OSystem::kTransactionModeSwitchFailed) {
329  message = Common::String::format(_("Could not switch to video mode '%s'."), ConfMan.get("gfx_mode").c_str());
330 
331  GUI::MessageDialog dialog(message);
332  dialog.runModal();
333  }
334 
337  message = Common::String::format(_("Could not switch to stretch mode '%s'."), ConfMan.get("stretch_mode").c_str());
338 
339  GUI::MessageDialog dialog(message);
340  dialog.runModal();
341  }
342 
344  GUI::MessageDialog dialog(_("Could not apply aspect ratio setting."));
345  dialog.runModal();
346  }
347 
348  if (gfxError & OSystem::kTransactionFullscreenFailed) {
349  GUI::MessageDialog dialog(_("Could not apply fullscreen setting."));
350  dialog.runModal();
351  }
352 
353  if (gfxError & OSystem::kTransactionFilteringFailed) {
354  GUI::MessageDialog dialog(_("Could not apply filtering setting."));
355  dialog.runModal();
356  }
357 }
358 
368 #ifdef USE_RGB_COLOR
369  for (Common::List<Graphics::PixelFormat>::const_iterator i = backend.begin(); i != backend.end(); ++i) {
370  for (Common::List<Graphics::PixelFormat>::const_iterator j = frontend.begin(); j != frontend.end(); ++j) {
371  if (*i == *j)
372  return *i;
373  }
374  }
375 #endif
377 }
378 
379 
382  initGraphics(width, height, &format);
383 }
384 
385 void initGraphics(int width, int height) {
387  initGraphics(width, height, &format);
388 }
389 
390 void GUIErrorMessage(const Common::String &msg) {
391  g_system->setWindowCaption("Error");
393  initCommonGFX();
394  g_system->initSize(320, 200);
397  dialog.runModal();
398  } else {
399  error("%s", msg.c_str());
400  }
401 }
402 
403 void GUIErrorMessageFormat(const char *fmt, ...) {
404  Common::String msg;
405 
406  va_list va;
407  va_start(va, fmt);
408  msg = Common::String::vformat(fmt, va);
409  va_end(va);
410 
411  GUIErrorMessage(msg);
412 }
413 
415 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
416  // It is a known bug under Windows that games that play CD audio cause
417  // ScummVM to crash if the data files are read from the same CD. Check
418  // if this appears to be the case and issue a warning.
419 
420  // If we can find a compressed audio track, then it should be ok even
421  // if it's running from CD.
422 
423 #ifdef USE_VORBIS
424  if (Common::File::exists("track1.ogg") ||
425  Common::File::exists("track01.ogg"))
426  return;
427 #endif
428 #ifdef USE_FLAC
429  if (Common::File::exists("track1.fla") ||
430  Common::File::exists("track1.flac") ||
431  Common::File::exists("track01.fla") ||
432  Common::File::exists("track01.flac"))
433  return;
434 #endif
435 #ifdef USE_MAD
436  if (Common::File::exists("track1.mp3") ||
437  Common::File::exists("track01.mp3"))
438  return;
439 #endif
440 
441  char buffer[MAXPATHLEN];
442  int i;
443 
444  const Common::FSNode gameDataDir(ConfMan.get("path"));
445 
446  if (gameDataDir.getPath().empty()) {
447  // That's it! I give up!
448  if (getcwd(buffer, MAXPATHLEN) == NULL)
449  return;
450  } else
451  Common::strlcpy(buffer, gameDataDir.getPath().c_str(), sizeof(buffer));
452 
453  for (i = 0; i < MAXPATHLEN - 1; i++) {
454  if (buffer[i] == '\\')
455  break;
456  }
457 
458  buffer[i + 1] = 0;
459 
460  if (GetDriveType(buffer) == DRIVE_CDROM) {
462  _("You appear to be playing this game directly\n"
463  "from the CD. This is known to cause problems,\n"
464  "and it is therefore recommended that you copy\n"
465  "the data files to your hard disk instead.\n"
466  "See the README file for details."), _("OK"));
467  dialog.runModal();
468  } else {
469  // If we reached here, the game has audio tracks,
470  // it's not ran from the CD and the tracks have not
471  // been ripped.
473  _("This game has audio tracks in its disk. These\n"
474  "tracks need to be ripped from the disk using\n"
475  "an appropriate CD audio extracting tool in\n"
476  "order to listen to the game's music.\n"
477  "See the README file for details."), _("OK"));
478  dialog.runModal();
479  }
480 #endif
481 }
482 
483 bool Engine::shouldPerformAutoSave(int lastSaveTime) {
484  const int diff = _system->getMillis() - lastSaveTime;
485  const int autosavePeriod = ConfMan.getInt("autosave_period");
486  return autosavePeriod != 0 && diff > autosavePeriod * 1000;
487 }
488 
489 void Engine::errorString(const char *buf1, char *buf2, int size) {
490  Common::strlcpy(buf2, buf1, size);
491 }
492 
494  assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
495 
496  if (pause)
497  _pauseLevel++;
498  else
499  _pauseLevel--;
500 
501  if (_pauseLevel == 1 && pause) {
503  pauseEngineIntern(true);
504  } else if (_pauseLevel == 0) {
505  pauseEngineIntern(false);
507  _pauseStartTime = 0;
508  }
509 }
510 
512  // By default, just (un)pause all digital sounds
513  _mixer->pauseAll(pause);
514 }
515 
517  if (!_mainMenuDialog)
518  _mainMenuDialog = new MainMenuDialog(this);
519 #ifdef USE_TTS
520  Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
521  ttsMan->pushState();
522  g_gui.initTextToSpeech();
523 #endif
524 
525  setGameToLoadSlot(-1);
526 
528 
529  // Load savegame after main menu execution
530  // (not from inside the menu loop to avoid
531  // mouse cursor glitches and similar bugs,
532  // e.g. #2822778).
533  if (_saveSlotToLoad >= 0) {
535  if (status.getCode() != Common::kNoError) {
536  Common::String failMessage = Common::String::format(_("Failed to load saved game (%s)! "
537  "Please consult the README for basic information, and for "
538  "instructions on how to obtain further assistance."), status.getDesc().c_str());
539  GUI::MessageDialog dialog(failMessage);
540  dialog.runModal();
541  }
542  }
543 
545 #ifdef USE_TTS
546  ttsMan->popState();
547 #endif
548 }
549 
551  if (ConfMan.getBool("enable_unsupported_game_warning")) {
552  GUI::MessageDialog alert(_("WARNING: The game you are about to start is"
553  " not yet fully supported by ScummVM. As such, it is likely to be"
554  " unstable, and any saved game you make might not work in future"
555  " versions of ScummVM."), _("Start anyway"), _("Cancel"));
556  return alert.runModal() == GUI::kMessageOK;
557  }
558  return true;
559 }
560 
562  if (!_pauseLevel)
563  return _system->getMillis() - _engineStartTime;
564  else
566 }
567 
569  const uint32 currentTime = _system->getMillis();
570 
571  // We need to reset the pause start time here in case the engine is already
572  // paused to avoid any incorrect play time counting.
573  if (_pauseLevel > 0)
574  _pauseStartTime = currentTime;
575 
576  _engineStartTime = currentTime - time;
577 }
578 
580  pauseEngine(true);
581  int result = dialog.runModal();
582  pauseEngine(false);
583 
584  return result;
585 }
586 
588  _saveSlotToLoad = slot;
589 }
590 
592  // Sync the engine with the config manager
593  int soundVolumeMusic = ConfMan.getInt("music_volume");
594  int soundVolumeSFX = ConfMan.getInt("sfx_volume");
595  int soundVolumeSpeech = ConfMan.getInt("speech_volume");
596 
597  bool mute = false;
598  if (ConfMan.hasKey("mute"))
599  mute = ConfMan.getBool("mute");
600 
601  // We need to handle the speech mute separately here. This is because the
602  // engine code should be able to rely on all speech sounds muted when the
603  // user specified subtitles only mode, which results in "speech_mute" to
604  // be set to "true". The global mute setting has precedence over the
605  // speech mute setting though.
606  bool speechMute = mute;
607  if (!speechMute)
608  speechMute = ConfMan.getBool("speech_mute");
609 
614 
619 }
620 
622 #ifdef ENABLE_KEYMAPPER
623  _eventMan->getKeymapper()->cleanupGameKeymaps();
624 #endif
625 }
626 
628  // Mute will be set to true by default here. This has two reasons:
629  // - if the game already has an "mute" config entry, it will be overwritten anyway.
630  // - if it does not have a "mute" config entry, the sound is unmuted currently and should be muted now.
631  bool mute = true;
632 
633  if (ConfMan.hasKey("mute")) {
634  mute = !ConfMan.getBool("mute");
635  }
636 
637  ConfMan.setBool("mute", mute);
638 
640 }
641 
643  // Do nothing by default
644  return Common::kNoError;
645 }
646 
648  // Do not allow loading by default
649  return false;
650 }
651 
653  // Do nothing by default
654  return Common::kNoError;
655 }
656 
658  // Do not allow saving by default
659  return false;
660 }
661 
663  Common::Event event;
664 
665  event.type = Common::EVENT_QUIT;
667 }
668 
671  return (eventMan->shouldQuit() || eventMan->shouldRTL());
672 }
673 
674 /*
675 EnginePlugin *Engine::getMetaEnginePlugin() const {
676  return EngineMan.findPlugin(ConfMan.get("engineid"));
677 }
678 
679 */
static bool warnUserAboutUnsupportedGame()
Display a warning to the user that the game is not fully supported.
Definition: engine.cpp:550
virtual void initializePath(const Common::FSNode &gamePath)
Init SearchMan according to the game path.
Definition: engine.cpp:196
static String static String vformat(const char *fmt, va_list args)
Print formatted data into a String object.
Definition: str.cpp:646
Graphics::PixelFormat findCompatibleFormat(const Common::List< Graphics::PixelFormat > &backend, const Common::List< Graphics::PixelFormat > &frontend)
Determines the first matching format between two lists.
Definition: engine.cpp:367
static const byte font[][5]
virtual void pauseEngineIntern(bool pause)
Actual implementation of pauseEngine by subclasses.
Definition: engine.cpp:511
#define g_gui
Definition: gui-manager.h:50
virtual void pushEvent(const Event &event)=0
Pushes a "fake" event into the event queue.
Failed switching aspect ratio correction mode.
Definition: system.h:812
Simple string class for ScummVM.
Definition: str.h:49
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format=nullptr)=0
Set the size and color format of the virtual screen.
Data structure for an event.
Definition: events.h:147
virtual int shouldRTL() const =0
Should we return to the launcher?
unsigned int uint32
Definition: cdtypes.h:26
virtual void attach(const char *entry=0)
&#39;Attach&#39; the debugger.
Definition: debugger.cpp:157
virtual Graphics::PixelFormat getOverlayFormat() const =0
Returns the pixel format description of the overlay.
Internal interface to the QuickTime audio decoder.
#define getcwd(a, b)
Definition: forbidden.h:305
Failed setting the filtering mode.
Definition: system.h:817
Singleton class which manages chained games.
Definition: engine.h:355
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)=0
Blit a graphics buffer to the overlay.
virtual void setFeatureState(Feature f, bool enable)
En-/disable the specified feature.
Definition: system.h:452
#define assert(s)
Definition: portdefs.h:77
virtual void stopAll()=0
Stop all currently playing sounds.
void splashScreen()
Definition: engine.cpp:227
iterator end()
Definition: list.h:218
void setErrorOutputFormatter(OutputFormatter f)
Set the output formatter used by error().
Definition: textconsole.cpp:33
static int message(lua_State *L)
Definition: lua-script.cpp:965
virtual bool setStretchMode(int mode)
Switch to the specified stretch mode.
Definition: system.h:707
void warning(const char *s,...)
Definition: textconsole.cpp:49
Simple message dialog ("alert box"): presents a text message in a dialog with up to two buttons...
Definition: message.h:42
ErrorCode getCode() const
Get the error code of this error.
Definition: error.h:103
static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize)
Definition: engine.cpp:77
t_T & front()
Returns a reference to the first element of the list.
Definition: list.h:147
int y
Definition: dialogs.cpp:409
iterator begin()
Definition: list.h:210
virtual int runModal()
Definition: dialog.cpp:72
static const BdfFontData desc
void GUIErrorMessageFormat(const char *fmt,...)
Definition: engine.cpp:403
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
Definition: util.h:66
byte logo_data[]
Definition: logo_data.h:27
Everything fine (use EQUAL check for this one!)
Definition: system.h:811
virtual void syncSoundSettings()
Notify the engine that the sound settings in the config manager may have changed and that it hence sh...
Definition: engine.cpp:591
Audio::Mixer * _mixer
Definition: engine.h:60
void setErrorHandler(ErrorHandler handler)
Set a callback that is invoked by error() after the error message has been printed, but before the application is terminated.
Definition: textconsole.cpp:39
void initGraphics(int width, int height, const Graphics::PixelFormat *format)
Definition: engine.cpp:284
void fillRect(Common::Rect r, uint32 color)
Fill a rect with a given color.
Definition: surface.cpp:228
virtual void pauseAll(bool paused)=0
Pause/unpause all sounds, including all regular and permanent channels.
Definition: engine.h:57
OSystem * g_system
The global OSystem instance.
Definition: system.cpp:40
virtual bool isReady() const =0
Is the mixer ready and setup? This may not be the case on systems which don&#39;t support digital sound o...
virtual void updateScreen()=0
Flush the whole screen, that is render the current content of the screen framebuffer to the display...
PixelFormat format
The pixel format of the surface.
Definition: surface.h:77
Common::Queue< Game > _chainedGames
Definition: engine.h:362
#define MAXPATHLEN
Definition: scummsys.h:411
uint16 height
Definition: thumbnail.cpp:41
uint32 getTotalPlayTime() const
Get the total play time.
Definition: engine.cpp:561
void create(uint16 width, uint16 height, const PixelFormat &format)
Allocate memory for the pixel data of the surface.
Definition: surface.cpp:65
virtual ~Engine()
Definition: engine.cpp:185
static bool shouldQuit()
Return whether the ENGINE should quit respectively should return to the launcher. ...
Definition: engine.cpp:669
int getMillis(bool skipRecord)
Definition: dsmain.cpp:2276
virtual bool canLoadGameStateCurrently()
Indicates whether a game state can be loaded.
Definition: engine.cpp:647
static void quitGame()
Request the engine to quit.
Definition: engine.cpp:662
#define SearchMan
Shortcut for accessing the search manager.
Definition: archive.h:277
String getPath() const
Return a string representation of the file which is suitable for archiving (i.e.
Definition: fs.cpp:111
virtual void muteSoundType(SoundType type, bool mute)=0
Set the mute state for a given sound type.
virtual void clearError()
Clears the error notification.
Definition: taskbar.h:136
static bool exists(const String &filename)
Checks if a given file exists in any of the current default paths, as defined by SearchMan.
Definition: file.cpp:90
This class implements a dynamically sized container, which can be accessed similar to a regular C++ a...
Definition: array.h:45
uint32 _pauseStartTime
The time when the pause was started.
Definition: engine.h:84
OSystem * _system
Definition: engine.h:59
uint16 w
The width of the surface.
Definition: surface.h:53
Control aspect ratio correction.
Definition: system.h:312
#define DECLARE_SINGLETON(T)
Note that you need to use this macro from the Common namespace.
Definition: singleton.h:101
char screen[320 *200]
Definition: gfxModule.cpp:39
Engine * g_engine
Definition: engine.cpp:73
virtual uint32 getMillis(bool skipRecord=false)=0
Get the number of milliseconds since the program was started.
const char * c_str() const
Definition: str.h:208
size_t strlcpy(char *dst, const char *src, size_t size)
Copy up to size - 1 characters from src to dst and also zero terminate the result.
Definition: str.cpp:1010
Failed setting the stretch mode.
Definition: system.h:818
Failed setting the color format.
Definition: system.h:816
TransactionError
This type is able to save the different errors which can happen while changing GFX config values insi...
Definition: system.h:810
virtual Common::Error loadGameState(int slot)
Load a game state.
Definition: engine.cpp:642
virtual Common::TaskbarManager * getTaskbarManager()
Returns the TaskbarManager, used to handle progress bars, icon overlay, tasks and recent items list o...
Definition: system.h:1332
virtual int shouldQuit() const =0
Should the application terminate? Set to true if we received an EVENT_QUIT.
static PixelFormat createFormatCLUT8()
Definition: pixelformat.h:162
virtual void setWindowCaption(const char *caption)
Set a window caption or any other comparable status display to the given value.
Definition: system.h:1280
Simple memory based &#39;stream&#39;, which implements the ReadStream interface for a plain memory block...
Definition: memstream.h:36
virtual void deinitKeymap()
Definition: engine.cpp:621
The EventManager provides user input events to the client code.
Definition: events.h:435
Common::EventManager * getEventManager()
Return the event manager singleton.
Definition: system.h:1133
virtual void initSizeHint(const Graphics::ModeList &modes)
Send a list of graphics modes to the backend so it can make a decision about the best way to set up t...
Definition: system.h:766
int pause(lua_State *L)
virtual GUI::Debugger * getDebugger()
Return the engine&#39;s debugger instance, if any.
Definition: engine.h:182
uint32 ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) const
Definition: pixelformat.h:191
Instances of this class represent a distinct font, with a built-in renderer.
Definition: font.h:52
void free()
Release the memory used by the pixels memory of this surface.
Definition: surface.cpp:79
void GUIErrorMessage(const Common::String &msg)
Initializes graphics and shows error message.
Definition: engine.cpp:390
virtual int getFontHeight() const =0
Query the height of the font.
virtual void notifyError()
Notifies the user an error occurred through the taskbar icon.
Definition: taskbar.h:131
uint16 pitch
The number of bytes a pixel line has.
Definition: surface.h:65
If supported this flag can be used to switch between unfiltered and filtered graphics modes...
Definition: system.h:318
Bitmap * bitmap
unsigned int uint
Definition: scummsys.h:440
Failed switching the screen dimensions (initSize)
Definition: system.h:815
virtual Common::List< Graphics::PixelFormat > getSupportedFormats() const =0
Returns a list of all pixel formats supported by the backend.
void setTotalPlayTime(uint32 time=0)
Set the game time counter to the specified time.
Definition: engine.cpp:568
void push(const Common::String target, const int slot=-1)
Definition: engine.cpp:122
#define CursorMan
Definition: cursorman.h:225
No error occurred.
Definition: error.h:45
virtual TransactionError endGFXTransaction()
End (and thereby commit) the current GFX transaction.
Definition: system.h:827
EXT_C time_t time(time_t *dummy)
Engine(OSystem *syst)
Definition: engine.cpp:143
virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size)
Prepare an error string, which is printed by the error() function.
Definition: engine.cpp:489
Simple class for handling a rectangular zone.
Definition: rect.h:95
#define NULL
Definition: gba_nds_fat.c:34
An Error instance pairs an error code with string description providing more details about the error...
Definition: error.h:77
const void * getPixels() const
Return a pointer to the pixel data.
Definition: surface.h:90
If supported, this feature flag can be used to switch between windowed and fullscreen mode...
Definition: system.h:297
uint16 width
Definition: thumbnail.cpp:41
Failed switching the GFX graphics mode (setGraphicsMode)
Definition: system.h:814
static GuiManager & instance()
Definition: singleton.h:66
An arbitrary graphics surface, which can be the target (or source) of blit operations, font rendering, etc.
Definition: surface.h:42
bool shouldPerformAutoSave(int lastSaveTime)
Indicate whether an autosave should be performed.
Definition: engine.cpp:483
Graphics::Surface * convertTo(const PixelFormat &dstFormat, const byte *palette=0) const
Convert the data to another pixel format.
Definition: surface.cpp:423
bool pop(Common::String &target, int &slot)
Definition: engine.cpp:129
A pixel format description.
Definition: pixelformat.h:136
uint16 h
The height of the surface.
Definition: surface.h:58
virtual int16 getOverlayHeight()=0
Return the height of the overlay.
void pauseEngine(bool pause)
Pause or resume the engine.
Definition: engine.cpp:493
const char * gScummVMVersionDate
Definition: version.cpp:68
const String & getDesc() const
Get the description of this error.
Definition: error.h:98
int getStringWidth(const Common::String &str) const
Compute and return the width the string str has when rendered using this font.
Definition: font.cpp:351
virtual int runDialog(GUI::Dialog &dialog)
Definition: engine.cpp:579
#define size
Definition: cdaudio.cpp:50
Interface for ScummVM backends.
Definition: system.h:113
virtual Common::Error saveGameState(int slot, const Common::String &desc)
Save a game state.
Definition: engine.cpp:652
void initCommonGFX()
Setup the backend&#39;s graphics mode.
Definition: engine.cpp:200
Failed switching fullscreen mode.
Definition: system.h:813
static void defaultErrorHandler(const char *msg)
Definition: engine.cpp:85
virtual void showOverlay()=0
Activate the overlay mode.
#define ConfMan
Shortcut for accessing the configuration manager.
void NORETURN_PRE error(const char *s,...)
Definition: textconsole.cpp:67
Common::EventManager * _eventMan
Definition: engine.h:64
void openMainMenuDialog()
Run the Global Main Menu Dialog.
Definition: engine.cpp:516
int _saveSlotToLoad
Save slot selected via global main menu.
Definition: engine.h:97
virtual int16 getOverlayWidth()=0
Return the width of the overlay.
#define _(str)
Definition: translation.h:234
FSNode, short for "File System Node", provides an abstraction for file paths, allowing for portable f...
Definition: fs.h:58
char fmt[4]
Definition: cdaudio.cpp:55
virtual void onFrame()
The onFrame() method should be invoked by the engine at regular intervals (usually once per main loop...
Definition: debugger.cpp:172
void checkCD()
On some systems, check if the game appears to be run from CD.
Definition: engine.cpp:414
int32 _engineStartTime
The time when the engine was started.
Definition: engine.h:90
GUI::Dialog * _mainMenuDialog
Definition: engine.h:67
virtual void setVolumeForSoundType(SoundType type, int volume)=0
Set the volume for the given sound type.
virtual bool canSaveGameStateCurrently()
Indicates whether a game state can be saved.
Definition: engine.cpp:657
bool contains(const String &key) const
T MAX(T a, T b)
Definition: util.h:50
void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align=kTextAlignLeft, int deltax=0, bool useEllipsis=true) const
Definition: font.cpp:367
static String format(const char *fmt,...) GCC_PRINTF(1
Print formatted data into a String object.
Definition: str.cpp:634
static int dialog(lua_State *L)
Definition: lua-script.cpp:929
bool isSmartphone()
Definition: wince-sdl.cpp:143
virtual void flipMute()
Flip mute all sound option.
Definition: engine.cpp:627
virtual void beginGFXTransaction()
Begin a new GFX transaction, which is a sequence of GFX mode changes.
Definition: system.h:799
EventType type
The type of the event.
Definition: events.h:150
void initGraphicsModes(const Graphics::ModeList &modes)
Sends a list of graphics modes to the backend so it can make a decision about the best way to set up ...
Definition: engine.cpp:280
Common::String target
Definition: engine.h:358
bool splash
Definition: engine.cpp:223
int _pauseLevel
The pause level, 0 means &#39;running&#39;, a positive value indicates how often the engine has been paused (...
Definition: engine.h:79
bool isActive() const
Return true if the debugger is currently active (i.e.
Definition: debugger.h:74
#define FontMan
Shortcut for accessing the font manager.
Definition: fontman.h:124
virtual void delayMillis(uint msecs)=0
Delay/sleep for the specified amount of milliseconds.
void setGameToLoadSlot(int slot)
Sets the game slot for a savegame to be loaded after global main menu execution.
Definition: engine.cpp:587
virtual void hideOverlay()=0
Deactivate the overlay mode.
PixelFormat format
Definition: thumbnail.cpp:42