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(__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 #include "engines/metaengine.h"
35 
36 #include "common/config-manager.h"
37 #include "common/events.h"
38 #include "common/file.h"
39 #include "common/system.h"
40 #include "common/str.h"
41 #include "common/error.h"
42 #include "common/list.h"
43 #include "common/memstream.h"
44 #include "common/savefile.h"
45 #include "common/scummsys.h"
46 #include "common/taskbar.h"
47 #include "common/textconsole.h"
48 #include "common/translation.h"
49 #include "common/singleton.h"
50 
53 #include "base/version.h"
54 
55 #include "gui/gui-manager.h"
56 #include "gui/debugger.h"
57 #include "gui/dialog.h"
58 #include "gui/message.h"
59 #include "gui/saveload.h"
60 
61 #include "audio/mixer.h"
62 
63 #include "graphics/cursorman.h"
64 #include "graphics/fontman.h"
65 #include "graphics/pixelformat.h"
66 #include "image/bmp.h"
67 
68 #ifdef USE_TTS
69 #include "common/text-to-speech.h"
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) {
90 
91 #if defined(USE_TASKBAR)
93 #endif
94 
95  if (debugger && !debugger->isActive()) {
96  debugger->attach(msg);
97  debugger->onFrame();
98  }
99 
100 
101 #if defined(USE_TASKBAR)
103 #endif
104 
105  }
106 }
107 
108 // Chained games manager
109 
111  clear();
112 }
113 
115  _chainedGames.clear();
116 }
117 
118 void ChainedGamesManager::push(const Common::String target, const int slot) {
119  Game game;
120  game.target = target;
121  game.slot = slot;
122  _chainedGames.push(game);
123 }
124 
125 bool ChainedGamesManager::pop(Common::String &target, int &slot) {
126  if (_chainedGames.empty()) {
127  return false;
128  }
129  Game game = _chainedGames.pop();
130  target = game.target;
131  slot = game.slot;
132  return true;
133 }
134 
135 namespace Common {
137 }
138 
140  : _system(syst),
141  _mixer(_system->getMixer()),
142  _timer(_system->getTimerManager()),
143  _eventMan(_system->getEventManager()),
144  _saveFileMan(_system->getSavefileManager()),
145  _targetName(ConfMan.getActiveDomainName()),
146  _pauseLevel(0),
147  _pauseStartTime(0),
148  _saveSlotToLoad(-1),
149  _engineStartTime(_system->getMillis()),
150  _mainMenuDialog(NULL),
151  _debugger(NULL),
152  _autosaveInterval(ConfMan.getInt("autosave_period")),
153  _lastAutosaveTime(_system->getMillis()) {
154 
155  g_engine = this;
158 
159  // FIXME: Get rid of the following again. It is only here
160  // temporarily. We really should never run with a non-working Mixer,
161  // so ought to handle this at a much earlier stage. If we *really*
162  // want to support systems without a working mixer, then we need
163  // more work. E.g. we could modify the Mixer to immediately drop any
164  // streams passed to it. This way, at least we don't crash because
165  // heaps of (sound) memory get allocated but never freed. Of course,
166  // there still would be problems with many games...
167  if (!_mixer->isReady())
168  warning("Sound initialization failed. This may cause severe problems in some games");
169 
170  // Setup a dummy cursor and palette, so that all engines can use
171  // CursorMan.replace without having any headaches about memory leaks.
172  //
173  // If an engine only used CursorMan.replaceCursor and no cursor has
174  // been setup before, then replaceCursor just uses pushCursor. This
175  // means that that the engine's cursor is never again removed from
176  // CursorMan. Hence we setup a fake cursor here and remove it again
177  // in the destructor.
178  CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0);
179  // Note: Using this dummy palette will actually disable cursor
180  // palettes till the user enables it again.
181  CursorMan.pushCursorPalette(NULL, 0, 0);
182 }
183 
185  _mixer->stopAll();
186 
187  delete _debugger;
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"))
208  g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
209 
210  if (gameDomain->contains("fullscreen"))
211  g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
212 
213  if (gameDomain->contains("filtering"))
214  g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("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() {
228  Common::MemoryReadStream stream(logo_data, ARRAYSIZE(logo_data));
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
250  const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
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 
273  // We must poll an event in order to have the window shown at least on Mac
275 
276  while (time0 + 600 > g_system->getMillis()) {
277  g_system->delayMillis(10);
278  }
280 
281  splash = true;
282 }
283 
285  g_system->initSizeHint(modes);
286 }
287 
289 
291 
292  initCommonGFX();
293 #ifdef USE_RGB_COLOR
294  if (format)
296  else {
298  g_system->initSize(width, height, &bestFormat);
299  }
300 #else
302 #endif
303 
305 
306  if (!splash && !GUI::GuiManager::instance()._launched)
307  splashScreen();
308 
309  if (gfxError == OSystem::kTransactionSuccess)
310  return;
311 
312  // Error out on size switch failure
313  if (gfxError & OSystem::kTransactionSizeChangeFailed) {
315  message = Common::String::format(_("Could not switch to resolution '%dx%d'."), width, height);
316 
318  error("%s", message.c_str());
319  }
320 
321  // Just show warnings then these occur:
322 #ifdef USE_RGB_COLOR
324  Common::String message = _("Could not initialize color format.");
325 
327  dialog.runModal();
328  }
329 #endif
330 
331  if (gfxError & OSystem::kTransactionModeSwitchFailed) {
333  message = Common::String::format(_("Could not switch to video mode '%s'."), ConfMan.get("gfx_mode").c_str());
334 
336  dialog.runModal();
337  }
338 
341  message = Common::String::format(_("Could not switch to stretch mode '%s'."), ConfMan.get("stretch_mode").c_str());
342 
344  dialog.runModal();
345  }
346 
348  GUI::MessageDialog dialog(_("Could not apply aspect ratio setting."));
349  dialog.runModal();
350  }
351 
352  if (gfxError & OSystem::kTransactionFullscreenFailed) {
353  GUI::MessageDialog dialog(_("Could not apply fullscreen setting."));
354  dialog.runModal();
355  }
356 
357  if (gfxError & OSystem::kTransactionFilteringFailed) {
358  GUI::MessageDialog dialog(_("Could not apply filtering setting."));
359  dialog.runModal();
360  }
361 }
362 
372 #ifdef USE_RGB_COLOR
373  for (Common::List<Graphics::PixelFormat>::const_iterator i = backend.begin(); i != backend.end(); ++i) {
374  for (Common::List<Graphics::PixelFormat>::const_iterator j = frontend.begin(); j != frontend.end(); ++j) {
375  if (*i == *j)
376  return *i;
377  }
378  }
379 #endif
381 }
382 
383 
387 }
388 
389 void initGraphics(int width, int height) {
392 }
393 
394 void GUIErrorMessage(const Common::String &msg) {
395  g_system->setWindowCaption("Error");
397  initCommonGFX();
398  g_system->initSize(320, 200);
401  dialog.runModal();
402  } else {
403  error("%s", msg.c_str());
404  }
405 }
406 
407 void GUIErrorMessageFormat(const char *fmt, ...) {
408  Common::String msg;
409 
410  va_list va;
411  va_start(va, fmt);
412  msg = Common::String::vformat(fmt, va);
413  va_end(va);
414 
415  GUIErrorMessage(msg);
416 }
417 
419 #if defined(WIN32) && !defined(__SYMBIAN32__)
420  // It is a known bug under Windows that games that play CD audio cause
421  // ScummVM to crash if the data files are read from the same CD. Check
422  // if this appears to be the case and issue a warning.
423 
424  // If we can find a compressed audio track, then it should be ok even
425  // if it's running from CD.
426 
427 #ifdef USE_VORBIS
428  if (Common::File::exists("track1.ogg") ||
429  Common::File::exists("track01.ogg"))
430  return;
431 #endif
432 #ifdef USE_FLAC
433  if (Common::File::exists("track1.fla") ||
434  Common::File::exists("track1.flac") ||
435  Common::File::exists("track01.fla") ||
436  Common::File::exists("track01.flac"))
437  return;
438 #endif
439 #ifdef USE_MAD
440  if (Common::File::exists("track1.mp3") ||
441  Common::File::exists("track01.mp3"))
442  return;
443 #endif
444 
445  char buffer[MAXPATHLEN];
446  int i;
447 
448  const Common::FSNode gameDataDir(ConfMan.get("path"));
449 
450  if (gameDataDir.getPath().empty()) {
451  // That's it! I give up!
452  if (getcwd(buffer, MAXPATHLEN) == NULL)
453  return;
454  } else
455  Common::strlcpy(buffer, gameDataDir.getPath().c_str(), sizeof(buffer));
456 
457  for (i = 0; i < MAXPATHLEN - 1; i++) {
458  if (buffer[i] == '\\')
459  break;
460  }
461 
462  buffer[i + 1] = 0;
463 
464  if (GetDriveType(buffer) == DRIVE_CDROM) {
466  _("You appear to be playing this game directly\n"
467  "from the CD. This is known to cause problems,\n"
468  "and it is therefore recommended that you copy\n"
469  "the data files to your hard disk instead.\n"
470  "See the README file for details."), _("OK"));
471  dialog.runModal();
472  } else {
473  // If we reached here, the game has audio tracks,
474  // it's not ran from the CD and the tracks have not
475  // been ripped.
477  _("This game has audio tracks in its disk. These\n"
478  "tracks need to be ripped from the disk using\n"
479  "an appropriate CD audio extracting tool in\n"
480  "order to listen to the game's music.\n"
481  "See the README file for details."), _("OK"));
482  dialog.runModal();
483  }
484 #endif
485 }
486 
488  const int diff = _system->getMillis() - _lastAutosaveTime;
489 
490  if (_autosaveInterval != 0 && diff > (_autosaveInterval * 1000)) {
491  // Save the autosave
493  }
494 }
495 
497  if (_autosaveInterval != 0) {
498  bool saveFlag = canSaveAutosaveCurrently();
499 
500  if (saveFlag) {
501  // First check for an existing savegame in the slot, and if present, if it's an autosave
504  saveFlag = desc.getSaveSlot() == -1 || desc.isAutosave();
505  }
506 
507  if (saveFlag && saveGameState(getAutosaveSlot(), _("Autosave"), true).getCode() != Common::kNoError) {
508  // Couldn't autosave at the designated time
509  g_system->displayMessageOnOSD(_("Error occurred making autosave"));
510  saveFlag = false;
511  }
512 
513  if (!saveFlag) {
514  // Set the next autosave interval to be in 5 minutes, rather than whatever
515  // full autosave interval the user has selected
516  _lastAutosaveTime = _system->getMillis() + (5 * 60 * 1000) - _autosaveInterval;
517  return;
518  }
519  }
520 
521  // Reset the last autosave time
523 }
524 
525 void Engine::errorString(const char *buf1, char *buf2, int size) {
526  Common::strlcpy(buf2, buf1, size);
527 }
528 
530  assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel));
531 
532  if (pause)
533  _pauseLevel++;
534  else
535  _pauseLevel--;
536 
537  if (_pauseLevel == 1 && pause) {
539  pauseEngineIntern(true);
540  } else if (_pauseLevel == 0) {
541  pauseEngineIntern(false);
543  _pauseStartTime = 0;
544  }
545 }
546 
548  // By default, just (un)pause all digital sounds
550 }
551 
553  if (!_mainMenuDialog)
554  _mainMenuDialog = new MainMenuDialog(this);
555 #ifdef USE_TTS
557  ttsMan->pushState();
558  g_gui.initTextToSpeech();
559 #endif
560 
561  setGameToLoadSlot(-1);
562 
564 
565  // Load savegame after main menu execution
566  // (not from inside the menu loop to avoid
567  // mouse cursor glitches and similar bugs,
568  // e.g. #2822778).
569  if (_saveSlotToLoad >= 0) {
571  if (status.getCode() != Common::kNoError) {
572  Common::String failMessage = Common::String::format(_("Failed to load saved game (%s)! "
573  "Please consult the README for basic information, and for "
574  "instructions on how to obtain further assistance."), status.getDesc().c_str());
575  GUI::MessageDialog dialog(failMessage);
576  dialog.runModal();
577  }
578  }
579 
581 #ifdef USE_TTS
582  ttsMan->popState();
583 #endif
584 }
585 
587  if (ConfMan.getBool("enable_unsupported_game_warning")) {
588  GUI::MessageDialog alert(_("WARNING: The game you are about to start is"
589  " not yet fully supported by ScummVM. As such, it is likely to be"
590  " unstable, and any saved game you make might not work in future"
591  " versions of ScummVM."), _("Start anyway"), _("Cancel"));
592  return alert.runModal() == GUI::kMessageOK;
593  }
594  return true;
595 }
596 
598  if (!_pauseLevel)
599  return _system->getMillis() - _engineStartTime;
600  else
602 }
603 
605  const uint32 currentTime = _system->getMillis();
606 
607  // We need to reset the pause start time here in case the engine is already
608  // paused to avoid any incorrect play time counting.
609  if (_pauseLevel > 0)
610  _pauseStartTime = currentTime;
611 
612  _engineStartTime = currentTime - time;
613 }
614 
616  pauseEngine(true);
617  int result = dialog.runModal();
618  pauseEngine(false);
619 
620  return result;
621 }
622 
624  _saveSlotToLoad = slot;
625 }
626 
628  // Sync the engine with the config manager
629  int soundVolumeMusic = ConfMan.getInt("music_volume");
630  int soundVolumeSFX = ConfMan.getInt("sfx_volume");
631  int soundVolumeSpeech = ConfMan.getInt("speech_volume");
632 
633  bool mute = false;
634  if (ConfMan.hasKey("mute"))
635  mute = ConfMan.getBool("mute");
636 
637  // We need to handle the speech mute separately here. This is because the
638  // engine code should be able to rely on all speech sounds muted when the
639  // user specified subtitles only mode, which results in "speech_mute" to
640  // be set to "true". The global mute setting has precedence over the
641  // speech mute setting though.
642  bool speechMute = mute;
643  if (!speechMute)
644  speechMute = ConfMan.getBool("speech_mute");
645 
650 
655 }
656 
658  // Mute will be set to true by default here. This has two reasons:
659  // - if the game already has an "mute" config entry, it will be overwritten anyway.
660  // - if it does not have a "mute" config entry, the sound is unmuted currently and should be muted now.
661  bool mute = true;
662 
663  if (ConfMan.hasKey("mute")) {
664  mute = !ConfMan.getBool("mute");
665  }
666 
667  ConfMan.setBool("mute", mute);
668 
670 }
671 
673  // In case autosaves are on, do a save first before loading the new save
675 
677 
678  if (!saveFile)
679  return Common::kReadingFailed;
680 
682  if (result.getCode() == Common::kNoError) {
685  setTotalPlayTime(header.playtime);
686  }
687 
688  delete saveFile;
689  return result;
690 }
691 
693  // Default to returning an error when not implemented
694  return Common::kReadingFailed;
695 }
696 
698  // Do not allow loading by default
699  return false;
700 }
701 
702 Common::Error Engine::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
704 
705  if (!saveFile)
706  return Common::kWritingFailed;
707 
708  Common::Error result = saveGameStream(saveFile, isAutosave);
709  if (result.getCode() == Common::kNoError) {
711 
712  saveFile->finalize();
713  }
714 
715  delete saveFile;
716  return result;
717 }
718 
720  // Default to returning an error when not implemented
721  return Common::kWritingFailed;
722 }
723 
725  // Do not allow saving by default
726  return false;
727 }
728 
730  if (!canLoadGameStateCurrently()) {
731  g_system->displayMessageOnOSD(_("Loading game is currently unavailable"));
732  return false;
733  }
734 
735  GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
736  pauseEngine(true);
737  int slotNum = dialog->runModalWithCurrentTarget();
738  pauseEngine(false);
739  delete dialog;
740 
741  if (slotNum < 0)
742  return false;
743 
744  Common::Error loadError = loadGameState(slotNum);
745  if (loadError.getCode() != Common::kNoError) {
746  GUI::MessageDialog errorDialog(loadError.getDesc());
747  errorDialog.runModal();
748  return false;
749  }
750 
751  return true;
752 }
753 
755  if (!canSaveGameStateCurrently()) {
756  g_system->displayMessageOnOSD(_("Saving game is currently unavailable"));
757  return false;
758  }
759 
760  GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
761  pauseEngine(true);
762  int slotNum = dialog->runModalWithCurrentTarget();
763  pauseEngine(false);
764 
765  Common::String desc = dialog->getResultString();
766  if (desc.empty())
767  desc = dialog->createDefaultSaveDescription(slotNum);
768 
769  delete dialog;
770 
771  if (slotNum < 0)
772  return false;
773 
774  Common::Error saveError = saveGameState(slotNum, desc);
775  if (saveError.getCode() != Common::kNoError) {
776  GUI::MessageDialog errorDialog(saveError.getDesc());
777  errorDialog.runModal();
778  return false;
779  }
780 
781  return true;
782 }
783 
785  Common::Event event;
786 
787  event.type = Common::EVENT_QUIT;
789 }
790 
793  return (eventMan->shouldQuit() || eventMan->shouldRTL());
794 }
795 
797  if (!_debugger)
798  // Create a bare-bones debugger. This is useful for engines without their own
799  // debugger when an error occurs
800  _debugger = new GUI::Debugger();
801 
802  return _debugger;
803 }
804 
805 /*
806 EnginePlugin *Engine::getMetaEnginePlugin() const {
807  return EngineMan.findPlugin(ConfMan.get("engineid"));
808 }
809 
810 */
811 
813  const Plugin *plugin = EngineMan.findPlugin(ConfMan.get("engineid"));
814  assert(plugin);
815  return plugin->get<MetaEngine>();
816 }
Engine::_saveSlotToLoad
int _saveSlotToLoad
Save slot selected via global main menu.
Definition: engine.h:110
Graphics::Surface::w
uint16 w
The width of the surface.
Definition: surface.h:53
splashScreen
void splashScreen()
Definition: engine.cpp:227
OSystem::kTransactionFormatNotSupported
Failed setting the color format.
Definition: system.h:820
OSystem::updateScreen
virtual void updateScreen()=0
Flush the whole screen, that is render the current content of the screen framebuffer to the display.
Common::SeekableReadStream
Interface for a seekable & readable data stream.
Definition: stream.h:569
OSystem::kFeatureFilteringMode
If supported this flag can be used to switch between unfiltered and filtered graphics modes.
Definition: system.h:319
HDB::dialog
static int dialog(lua_State *L)
Definition: lua-script.cpp:929
Glk::Alan2::header
AcdHdr * header
Definition: main.cpp:49
gScummVMVersionDate
const char * gScummVMVersionDate
Definition: version.cpp:64
OSystem::hideOverlay
virtual void hideOverlay()=0
Deactivate the overlay mode.
Common::EventManager::shouldRTL
virtual int shouldRTL() const =0
Should we return to the launcher?
Common::Array
This class implements a dynamically sized container, which can be accessed similar to a regular C++ a...
Definition: array.h:45
scummsys.h
Engine
Definition: engine.h:60
Common::Event::type
EventType type
The type of the event.
Definition: events.h:173
MetaEngine::appendExtendedSave
static void appendExtendedSave(Common::OutSaveFile *saveFile, uint32 playtime, Common::String desc, bool isAutosave)
Definition: metaengine.cpp:144
Engine::getSaveStateName
virtual Common::String getSaveStateName(int slot) const
Generates the savegame filename.
Definition: engine.h:239
Common::MemoryReadStream
Simple memory based 'stream', which implements the ReadStream interface for a plain memory block.
Definition: memstream.h:36
defaultOutputFormatter
static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize)
Definition: engine.cpp:77
SaveStateDescriptor
Object describing a save state.
Definition: savestate.h:45
str.h
Engine::saveAutosaveIfEnabled
void saveAutosaveIfEnabled()
Does an autosave immediately if autosaves are turned on.
Definition: engine.cpp:496
Engine::setGameToLoadSlot
void setGameToLoadSlot(int slot)
Sets the game slot for a savegame to be loaded after global main menu execution.
Definition: engine.cpp:623
Common::EventManager::pushEvent
virtual void pushEvent(const Event &event)=0
Pushes a "fake" event into the event queue.
OSystem::kFeatureAspectRatioCorrection
Control aspect ratio correction.
Definition: system.h:313
gui-manager.h
Engine::saveGameStream
virtual Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false)
Save a game state.
Definition: engine.cpp:719
Graphics::Font
Instances of this class represent a distinct font, with a built-in renderer.
Definition: font.h:52
cursorman.h
Audio::Mixer::kSpeechSoundType
Definition: mixer.h:60
OSystem::kFeatureFullscreenMode
If supported, this feature flag can be used to switch between windowed and fullscreen mode.
Definition: system.h:298
x
x
Definition: soft_render_surface.inl:123
Engine::initializePath
virtual void initializePath(const Common::FSNode &gamePath)
Init SearchMan according to the game path.
Definition: engine.cpp:196
GUI::Dialog::runModal
virtual int runModal()
Definition: dialog.cpp:72
message.h
Engine::checkCD
void checkCD()
On some systems, check if the game appears to be run from CD.
Definition: engine.cpp:418
GUIErrorMessage
void GUIErrorMessage(const Common::String &msg)
Initializes graphics and shows error message.
Definition: engine.cpp:394
OSystem::kTransactionStretchModeSwitchFailed
Failed setting the stretch mode.
Definition: system.h:822
Engine::getTotalPlayTime
uint32 getTotalPlayTime() const
Get the total play time.
Definition: engine.cpp:597
Common::EventManager::shouldQuit
virtual int shouldQuit() const =0
Should the application terminate? Set to true if we received an EVENT_QUIT.
Common::EventManager
The EventManager provides user input events to the client code.
Definition: events.h:411
Engine::canSaveGameStateCurrently
virtual bool canSaveGameStateCurrently()
Indicates whether a game state can be saved.
Definition: engine.cpp:724
util.h
Engine::handleAutoSave
void handleAutoSave()
Checks for whether it's time to do an autosave, and if so, does it.
Definition: engine.cpp:487
Engine::shouldQuit
static bool shouldQuit()
Return whether the ENGINE should quit respectively should return to the launcher.
Definition: engine.cpp:791
Common::EventManager::pollEvent
virtual bool pollEvent(Event &event)=0
Get the next event in the event queue.
Audio::Mixer::stopAll
virtual void stopAll()=0
Stop all currently playing sounds.
Common::OutSaveFile
A class which allows game engines to save game state data.
Definition: savefile.h:47
Engine::_system
OSystem * _system
Definition: engine.h:62
pixelformat.h
textconsole.h
OSystem::setFeatureState
virtual void setFeatureState(Feature f, bool enable)
En-/disable the specified feature.
Definition: system.h:453
OSystem::kTransactionModeSwitchFailed
Failed switching the GFX graphics mode (setGraphicsMode)
Definition: system.h:818
memstream.h
Common::String
Simple string class for ScummVM.
Definition: str.h:49
Engine::saveGameDialog
bool saveGameDialog()
Shows the ScummVM save dialog, allowing users to save their game.
Definition: engine.cpp:754
Engine::~Engine
virtual ~Engine()
Definition: engine.cpp:184
height
uint16 height
Definition: thumbnail.cpp:41
ChainedGamesManager::Game::target
Common::String target
Definition: engine.h:428
Audio::Mixer::pauseAll
virtual void pauseAll(bool paused)=0
Pause/unpause all sounds, including all regular and permanent channels.
config-manager.h
file.h
Common::DECLARE_SINGLETON
DECLARE_SINGLETON(Cloud::CloudManager)
translation.h
OSystem::getTaskbarManager
virtual Common::TaskbarManager * getTaskbarManager()
Returns the TaskbarManager, used to handle progress bars, icon overlay, tasks and recent items list o...
Definition: system.h:1330
uint32
unsigned int uint32
Definition: cdtypes.h:26
ChainedGamesManager::Game::slot
int slot
Definition: engine.h:429
Common::Error
An Error instance pairs an error code with string description providing more details about the error.
Definition: error.h:77
keymapper.h
Common::kReadingFailed
Failed to read a file (permission denied?)
Definition: error.h:59
error
void NORETURN_PRE error(const char *s,...)
Definition: textconsole.cpp:67
Sword25::pause
int pause(lua_State *L)
Definition: movieplayer_script.cpp:70
error.h
Common::TaskbarManager::clearError
virtual void clearError()
Clears the error notification.
Definition: taskbar.h:136
Engine::loadGameState
virtual Common::Error loadGameState(int slot)
Load a game state.
Definition: engine.cpp:672
Common::Error::getDesc
const String & getDesc() const
Get the description of this error.
Definition: error.h:98
logo_data
byte logo_data[]
Definition: logo_data.h:27
Plugin::get
T & get() const
Definition: plugins.h:185
OSystem::endGFXTransaction
virtual TransactionError endGFXTransaction()
End (and thereby commit) the current GFX transaction.
Definition: system.h:831
singleton.h
Glk::AGT::buffer
static uchar * buffer
Definition: util.cpp:518
Engine::setTotalPlayTime
void setTotalPlayTime(uint32 time=0)
Set the game time counter to the specified time.
Definition: engine.cpp:604
Common::ListInternal::ConstIterator
Definition: list_intern.h:46
width
uint16 width
Definition: thumbnail.cpp:41
Common::EVENT_QUIT
Definition: events.h:66
Common::SaveFileManager::openForSaving
virtual OutSaveFile * openForSaving(const String &name, bool compress=true)=0
Open the savefile with the specified name in the given directory for saving.
splash
bool splash
Definition: engine.cpp:223
OSystem::getOverlayFormat
virtual Graphics::PixelFormat getOverlayFormat() const =0
Returns the pixel format description of the overlay.
ChainedGamesManager::clear
void clear()
Definition: engine.cpp:114
metaengine.h
Engine::syncSoundSettings
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:627
Cruise::getCode
static uint16 getCode(UnpackCtx *uc, byte numChunks)
Definition: delphine-unpack.cpp:56
ChainedGamesManager::pop
bool pop(Common::String &target, int &slot)
Definition: engine.cpp:125
list.h
ChainedGamesManager::push
void push(const Common::String target, const int slot=-1)
Definition: engine.cpp:118
Common::String::vformat
static String static String vformat(const char *fmt, va_list args)
Print formatted data into a String object.
Definition: str.cpp:653
ChainedGamesManager::_chainedGames
Common::Queue< Game > _chainedGames
Definition: engine.h:432
Graphics::Surface::free
void free()
Release the memory used by the pixels memory of this surface.
Definition: surface.cpp:79
OSystem::kTransactionFullscreenFailed
Failed switching fullscreen mode.
Definition: system.h:817
Common::setErrorOutputFormatter
void setErrorOutputFormatter(OutputFormatter f)
Set the output formatter used by error().
Definition: textconsole.cpp:33
GUI::Debugger::onFrame
virtual void onFrame()
The onFrame() method should be invoked by the engine at regular intervals (usually once per main loop...
Definition: debugger.cpp:172
warning
void warning(const char *s,...)
Print a warning message to the text console (stderr).
Definition: textconsole.cpp:49
ChainedGamesManager::Game
Definition: engine.h:427
Common::kWritingFailed
Failure to write data – disk full?
Definition: error.h:60
OSystem::kTransactionAspectRatioFailed
Failed switching aspect ratio correction mode.
Definition: system.h:816
Common
This is the namespace of the AGOS engine.
Definition: default-audiocd.h:29
savefile.h
ChainedGamesManager
Singleton class which manages chained games.
Definition: engine.h:425
fontman.h
GUI::Debugger
Definition: debugger.h:40
MetaEngine::querySaveMetaInfos
virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const
Returns meta infos from the specified save state.
Definition: metaengine.cpp:346
Engine::loadGameStream
virtual Common::Error loadGameStream(Common::SeekableReadStream *stream)
Load a game state.
Definition: engine.cpp:692
Engine::_lastAutosaveTime
int _lastAutosaveTime
The last time an autosave was done.
Definition: engine.h:103
Graphics::Surface
An arbitrary graphics surface, which can be the target (or source) of blit operations,...
Definition: surface.h:42
OSystem::setWindowCaption
virtual void setWindowCaption(const char *caption)
Set a window caption or any other comparable status display to the given value.
Definition: system.h:1278
Common::TextToSpeechManager::popState
bool popState()
Pops the TTS state.
Definition: text-to-speech.cpp:104
initGraphicsModes
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:284
GUI::kMessageOK
Definition: message.h:34
Graphics::Surface::getPixels
const void * getPixels() const
Return a pointer to the pixel data.
Definition: surface.h:90
GUI::Debugger::isActive
bool isActive() const
Return true if the debugger is currently active (i.e.
Definition: debugger.h:74
MainMenuDialog
Definition: dialogs.h:37
version.h
Engine::canLoadGameStateCurrently
virtual bool canLoadGameStateCurrently()
Indicates whether a game state can be loaded.
Definition: engine.cpp:697
Engine::quitGame
static void quitGame()
Request the engine to quit.
Definition: engine.cpp:784
OSystem::delayMillis
virtual void delayMillis(uint msecs)=0
Delay/sleep for the specified amount of milliseconds.
format
PixelFormat format
Definition: thumbnail.cpp:42
Common::FSNode::getPath
String getPath() const
Return a string representation of the file which is suitable for archiving (i.e.
Definition: fs.cpp:111
MetaEngine
A meta engine is essentially a factory for Engine instances with the added ability of listing and det...
Definition: metaengine.h:96
OSystem::getSupportedFormats
virtual Common::List< Graphics::PixelFormat > getSupportedFormats() const =0
Returns a list of all pixel formats supported by the backend.
Engine::_mixer
Audio::Mixer * _mixer
Definition: engine.h:63
Engine::Engine
Engine(OSystem *syst)
Definition: engine.cpp:139
Common::List::end
iterator end()
Definition: list.h:218
Common::setErrorHandler
void setErrorHandler(ErrorHandler handler)
Set a callback that is invoked by error() after the error message has been printed,...
Definition: textconsole.cpp:39
Graphics::Surface::h
uint16 h
The height of the surface.
Definition: surface.h:58
g_engine
Engine * g_engine
Definition: engine.cpp:73
OSystem::getMillis
virtual uint32 getMillis(bool skipRecord=false)=0
Get the number of milliseconds since the program was started.
Cruise::screen
char screen[320 *200]
Definition: gfxModule.cpp:39
Graphics::FontManager::kConsoleFont
Definition: fontman.h:42
MAX
T MAX(T a, T b)
Definition: util.h:50
Common::String::format
static String format(const char *fmt,...) GCC_PRINTF(1
Print formatted data into a String object.
Definition: str.cpp:641
HDB::message
static int message(lua_State *L)
Definition: lua-script.cpp:965
Engine::runDialog
virtual int runDialog(GUI::Dialog &dialog)
Definition: engine.cpp:615
Common::Rect
Simple class for handling a rectangular zone.
Definition: rect.h:95
GUI::SaveLoadChooser
Definition: saveload.h:33
Common::File::exists
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
Common::FSNode
FSNode, short for "File System Node", provides an abstraction for file paths, allowing for portable f...
Definition: fs.h:58
Engine::_autosaveInterval
const int _autosaveInterval
Autosave interval.
Definition: engine.h:98
Engine::_pauseStartTime
uint32 _pauseStartTime
The time when the pause was started.
Definition: engine.h:87
Audio::Mixer::setVolumeForSoundType
virtual void setVolumeForSoundType(SoundType type, int volume)=0
Set the volume for the given sound type.
findCompatibleFormat
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:371
fmt
char fmt[4]
Definition: cdaudio.cpp:43
dialog.h
Engine::_saveFileMan
Common::SaveFileManager * _saveFileMan
Definition: engine.h:68
LastExpress::time
uint32 time
Definition: kronos.cpp:48
uint
unsigned int uint
Definition: scummsys.h:440
Common::List< Graphics::PixelFormat >
Engine::_engineStartTime
int32 _engineStartTime
The time when the engine was started.
Definition: engine.h:93
GUI::MessageDialog
Simple message dialog ("alert box"): presents a text message in a dialog with up to two buttons.
Definition: message.h:42
Common::strlcpy
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:1106
OSystem::initSizeHint
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:770
Common::ConfigManager::Domain::contains
bool contains(const String &key) const
Definition: config-manager.h:62
OSystem::getTextToSpeechManager
virtual Common::TextToSpeechManager * getTextToSpeechManager()
Returns the TextToSpeechManager, used to handle text to speech features.
Definition: system.h:1353
GUIErrorMessageFormat
void GUIErrorMessageFormat(const char *fmt,...)
Definition: engine.cpp:407
Common::WriteStream
Generic interface for a writable data stream.
Definition: stream.h:65
OSystem::showOverlay
virtual void showOverlay()=0
Activate the overlay mode.
Common::Error::getCode
ErrorCode getCode() const
Get the error code of this error.
Definition: error.h:103
ExtendedSavegameHeader
Definition: metaengine.h:66
size
u32 size
Definition: cdaudio.cpp:39
Audio::Mixer::kSFXSoundType
Definition: mixer.h:59
initCommonGFX
void initCommonGFX()
Setup the backend's graphics mode.
Definition: engine.cpp:200
Engine::getMetaEngine
static MetaEngine & getMetaEngine()
Definition: engine.cpp:812
Plugin
Abstract base class for the plugin system.
Definition: plugins.h:161
GUI::Dialog
Definition: dialog.h:49
taskbar.h
text-to-speech.h
Common::Event
Data structure for an event.
Definition: events.h:170
Common::Singleton< GuiManager >::instance
static GuiManager & instance()
Definition: singleton.h:66
Glk::Level9::bitmap
Bitmap * bitmap
Definition: level9_main.cpp:120
Audio::Mixer::kPlainSoundType
Definition: mixer.h:56
OSystem::getOverlayWidth
virtual int16 getOverlayWidth()=0
Return the width of the overlay.
Graphics::desc
static const BdfFontData desc
Definition: consolefont.cpp:5852
OSystem::kTransactionFilteringFailed
Failed setting the filtering mode.
Definition: system.h:821
Audio::Mixer::isReady
virtual bool isReady() const =0
Is the mixer ready and setup? This may not be the case on systems which don't support digital sound o...
system.h
Engine::getAutosaveSlot
virtual int getAutosaveSlot() const
Returns the slot that should be used for autosaves.
Definition: engine.h:407
MetaEngine::readSavegameHeader
static WARN_UNUSED_RESULT bool readSavegameHeader(Common::InSaveFile *in, ExtendedSavegameHeader *header, bool skipThumbnail=true)
Definition: metaengine.cpp:206
y
y
Definition: soft_render_surface.inl:124
Common::List::begin
iterator begin()
Definition: list.h:210
OSystem::TransactionError
TransactionError
This type is able to save the different errors which can happen while changing GFX config values insi...
Definition: system.h:814
DS::getMillis
int getMillis(bool skipRecord)
Definition: dsmain.cpp:2279
dialogs.h
Engine::getOrCreateDebugger
GUI::Debugger * getOrCreateDebugger()
Return the engine's debugger instance, or create one if none is present.
Definition: engine.cpp:796
Engine::loadGameDialog
bool loadGameDialog()
Shows the ScummVM Restore dialog, allowing users to load a game.
Definition: engine.cpp:729
Engine::warnUserAboutUnsupportedGame
static bool warnUserAboutUnsupportedGame()
Display a warning to the user that the game is not fully supported.
Definition: engine.cpp:586
saveload.h
OSystem
Interface for ScummVM backends.
Definition: system.h:114
Common::kNoError
No error occurred.
Definition: error.h:45
OSystem::copyRectToOverlay
virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)=0
Blit a graphics buffer to the overlay.
defaultErrorHandler
static void defaultErrorHandler(const char *msg)
Definition: engine.cpp:85
Common::SaveFileManager::openForLoading
virtual InSaveFile * openForLoading(const String &name)=0
Open the file with the specified name in the given directory for loading.
Engine::flipMute
virtual void flipMute()
Flip mute all sound option.
Definition: engine.cpp:657
OSystem::getEventManager
Common::EventManager * getEventManager()
Return the event manager singleton.
Definition: system.h:1139
engine.h
Engine::_targetName
const Common::String _targetName
Definition: engine.h:73
Common::TextToSpeechManager
The TextToSpeechManager allows speech synthesis.
Definition: text-to-speech.h:137
events.h
logo_data.h
Common::ConfigManager::Domain
Definition: config-manager.h:49
OSystem::beginGFXTransaction
virtual void beginGFXTransaction()
Begin a new GFX transaction, which is a sequence of GFX mode changes.
Definition: system.h:803
OSystem::setStretchMode
virtual bool setStretchMode(int mode)
Switch to the specified stretch mode.
Definition: system.h:711
Common::TaskbarManager::notifyError
virtual void notifyError()
Notifies the user an error occurred through the taskbar icon.
Definition: taskbar.h:131
Engine::canSaveAutosaveCurrently
virtual bool canSaveAutosaveCurrently()
Indicates whether an autosave can currently be saved.
Definition: engine.h:399
Common::List::front
t_T & front()
Returns a reference to the first element of the list.
Definition: list.h:147
Engine::_pauseLevel
int _pauseLevel
The pause level, 0 means 'running', a positive value indicates how often the engine has been paused (...
Definition: engine.h:82
Engine::pauseEngineIntern
virtual void pauseEngineIntern(bool pause)
Actual implementation of pauseEngine by subclasses.
Definition: engine.cpp:547
LastExpress::saveFile
const char * saveFile
Definition: savegame.cpp:45
Engine::errorString
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:525
OSystem::displayMessageOnOSD
virtual void displayMessageOnOSD(const char *msg)=0
Display a message in an 'on screen display'.
Common::TextToSpeechManager::pushState
void pushState()
Pushes the current state of the TTS.
Definition: text-to-speech.cpp:91
Supernova::font
static const byte font[][5]
Definition: screenstatic.cpp:406
initGraphics
void initGraphics(int width, int height, const Graphics::PixelFormat *format)
Definition: engine.cpp:288
action.h
Engine::openMainMenuDialog
void openMainMenuDialog()
Run the Global Main Menu Dialog.
Definition: engine.cpp:552
OSystem::kTransactionSuccess
Everything fine (use EQUAL check for this one!)
Definition: system.h:815
Engine::pauseEngine
void pauseEngine(bool pause)
Pause or resume the engine.
Definition: engine.cpp:529
g_system
OSystem * g_system
The global OSystem instance.
Definition: system.cpp:40
GUI::Debugger::attach
virtual void attach(const char *entry=nullptr)
'Attach' the debugger.
Definition: debugger.cpp:157
Engine::saveGameState
virtual Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false)
Save a game state.
Definition: engine.cpp:702
Audio::Mixer::muteSoundType
virtual void muteSoundType(SoundType type, bool mute)=0
Set the mute state for a given sound type.
Audio::Mixer::kMaxMixerVolume
Definition: mixer.h:65
Graphics::PixelFormat
A pixel format description.
Definition: pixelformat.h:136
OSystem::initSize
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format=nullptr)=0
Set the size and color format of the virtual screen.
Audio::Mixer::kMusicSoundType
Definition: mixer.h:58
OSystem::getOverlayHeight
virtual int16 getOverlayHeight()=0
Return the height of the overlay.
OSystem::kTransactionSizeChangeFailed
Failed switching the screen dimensions (initSize)
Definition: system.h:819
ChainedGamesManager::ChainedGamesManager
ChainedGamesManager()
Definition: engine.cpp:110
Graphics::PixelFormat::createFormatCLUT8
static PixelFormat createFormatCLUT8()
Definition: pixelformat.h:162
mixer.h
Engine::_mainMenuDialog
GUI::Dialog * _mainMenuDialog
Definition: engine.h:70
Common::String::c_str
const char * c_str() const
Definition: str.h:206
Engine::_debugger
GUI::Debugger * _debugger
Optional debugger for the engine.
Definition: engine.h:115
Graphics::Surface::pitch
uint16 pitch
The number of bytes a pixel line has.
Definition: surface.h:65