aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp5
-rw-r--r--engines/agos/agos.cpp5
-rw-r--r--engines/cine/cine.cpp5
-rw-r--r--engines/cruise/cruise.cpp5
-rw-r--r--engines/drascula/drascula.cpp5
-rw-r--r--engines/engine.cpp55
-rw-r--r--engines/engine.h13
-rw-r--r--engines/gob/video.cpp5
-rw-r--r--engines/groovie/groovie.cpp5
-rw-r--r--engines/igor/igor.cpp5
-rw-r--r--engines/kyra/screen.cpp30
-rw-r--r--engines/lure/lure.cpp5
-rw-r--r--engines/m4/m4.cpp7
-rw-r--r--engines/made/made.cpp5
-rw-r--r--engines/parallaction/graphics.cpp5
-rw-r--r--engines/queen/queen.cpp5
-rw-r--r--engines/saga/gfx.cpp5
-rw-r--r--engines/scumm/scumm.cpp32
-rw-r--r--engines/sky/sky.cpp5
-rw-r--r--engines/sword1/sword1.cpp5
-rw-r--r--engines/sword2/screen.cpp2
-rw-r--r--engines/sword2/sword2.cpp6
-rw-r--r--engines/tinsel/tinsel.cpp5
-rw-r--r--engines/touche/touche.cpp5
-rw-r--r--engines/tucker/tucker.cpp5
25 files changed, 112 insertions, 123 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 15af27b587..42a53424ae 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -782,10 +782,7 @@ AgiEngine::~AgiEngine() {
Common::Error AgiBase::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
initialize();
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index e7669941b3..b3690b3d59 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -540,10 +540,7 @@ Common::Error AGOSEngine::init() {
_screenHeight = 200;
}
- _system->beginGFXTransaction();
- initCommonGFX(getGameType() == GType_FF || getGameType() == GType_PP);
- _system->initSize(_screenWidth, _screenHeight);
- _system->endGFXTransaction();
+ initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP);
// Setup mixer
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 51f778610a..3a2954f7d6 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -76,10 +76,7 @@ CineEngine::~CineEngine() {
Common::Error CineEngine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
if (g_cine->getPlatform() == Common::kPlatformPC) {
g_sound = new PCSound(_mixer, this);
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index c84f4d7361..c664e6e0ad 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -72,10 +72,7 @@ CruiseEngine::~CruiseEngine() {
Common::Error CruiseEngine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
initialize();
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 8bd51123b5..32adfe7a11 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -106,10 +106,7 @@ DrasculaEngine::~DrasculaEngine() {
Common::Error DrasculaEngine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
switch (getLanguage()) {
case Common::EN_ANY:
diff --git a/engines/engine.cpp b/engines/engine.cpp
index fc13adf9c7..dcdcbd1d32 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -125,15 +125,62 @@ void initCommonGFX(bool defaultTo1XScaler) {
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
}
+void initGraphics(int width, int height, bool defaultTo1xScaler) {
+ g_system->beginGFXTransaction();
+
+ initCommonGFX(defaultTo1xScaler);
+ g_system->initSize(width, height);
+
+ OSystem::TransactionError gfxError = g_system->endGFXTransaction();
+
+ if (gfxError == OSystem::kTransactionSuccess)
+ return;
+
+ // Error out on size switch failure
+ if (gfxError & OSystem::kTransactionSizeChangeFailed) {
+ char buffer[16];
+ snprintf(buffer, 16, "%dx%d", width, height);
+
+ Common::String message = "Could not switch to resolution: '";
+ message += buffer;
+ message += "'.";
+
+ GUIErrorMessage(message);
+ error(message.c_str());
+ }
+
+ // Just show warnings then these occur:
+ if (gfxError & OSystem::kTransactionModeSwitchFailed) {
+ Common::String message = "Could not switch to video mode: '";
+ message += ConfMan.get("gfx_mode");
+ message += "'.";
+
+ GUI::MessageDialog dialog(message);
+ dialog.runModal();
+ }
+
+ if (gfxError & OSystem::kTransactionAspectRatioFailed) {
+ GUI::MessageDialog dialog("Could not apply aspect ratio setting.");
+ dialog.runModal();
+ }
+
+ if (gfxError & OSystem::kTransactionFullscreenFailed) {
+ GUI::MessageDialog dialog("Could not apply fullscreen setting.");
+ dialog.runModal();
+ }
+}
+
void GUIErrorMessage(const Common::String msg) {
g_system->setWindowCaption("Error");
g_system->beginGFXTransaction();
initCommonGFX(false);
g_system->initSize(320, 200);
- g_system->endGFXTransaction();
-
- GUI::MessageDialog dialog(msg);
- dialog.runModal();
+ if (g_system->endGFXTransaction() == OSystem::kTransactionSuccess) {
+ GUI::MessageDialog dialog(msg);
+ dialog.runModal();
+ } else {
+ error(msg.c_str());
+ }
}
void Engine::checkCD() {
diff --git a/engines/engine.h b/engines/engine.h
index 5444293a36..4e16f01335 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -51,7 +51,18 @@ namespace GUI {
void initCommonGFX(bool defaultTo1XScaler);
/**
- * Initialized graphics and shows error message.
+ * Setup the backend's screen size and graphics mode.
+ *
+ * Shows an various warnings on certain backend graphics
+ * transaction failures (aspect switch, fullscreen switch, etc.).
+ *
+ * Errors out when backend is not able to switch to the specified
+ * mode.
+ */
+void initGraphics(int width, int height, bool defaultTo1xScaler);
+
+/**
+ * Initializes graphics and shows error message.
*/
void GUIErrorMessage(const Common::String msg);
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index 30994cf4a7..361f8573d3 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -169,10 +169,7 @@ void Video::clearScreen() {
}
void Video::setSize(bool defaultTo1XScaler) {
- _vm->_system->beginGFXTransaction();
- _vm->_system->initSize(_vm->_width, _vm->_height);
- initCommonGFX(defaultTo1XScaler);
- _vm->_system->endGFXTransaction();
+ initGraphics(_vm->_width, _vm->_height, defaultTo1XScaler);
}
void Video::retrace(bool mouse) {
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index d49579c0a2..692748dac3 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -66,10 +66,7 @@ GroovieEngine::~GroovieEngine() {
Common::Error GroovieEngine::init() {
// Initialize the graphics
- _system->beginGFXTransaction();
- initCommonGFX(true);
- _system->initSize(640, 480);
- _system->endGFXTransaction();
+ initGraphics(640, 480, true);
// Create debugger. It requires GFX to be initialized
_debugger = new Debugger(this);
diff --git a/engines/igor/igor.cpp b/engines/igor/igor.cpp
index d68aeb7c3e..a3dbb57a52 100644
--- a/engines/igor/igor.cpp
+++ b/engines/igor/igor.cpp
@@ -89,10 +89,7 @@ IgorEngine::~IgorEngine() {
}
Common::Error IgorEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
return Common::kNoError;
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 0b859f5032..0076739abe 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -186,24 +186,26 @@ void Screen::setResolution() {
byte palette[4*256];
_system->grabPalette(palette, 0, 256);
+ int width = 320, height = 200;
+ bool defaultTo1xScaler = false;
+
if (_vm->gameFlags().useHiResOverlay) {
- _system->beginGFXTransaction();
- if (_debugEnabled)
- _system->initSize(960, 400);
- else
- _system->initSize(640, 400);
- initCommonGFX(true);
- _system->endGFXTransaction();
+ defaultTo1xScaler = true;
+ height = 400;
+
+ if (_debugEnabled)
+ width = 960;
+ else
+ width = 640;
} else {
- _system->beginGFXTransaction();
- if (_debugEnabled)
- _system->initSize(640, 200);
- else
- _system->initSize(320, 200);
- initCommonGFX(false);
- _system->endGFXTransaction();
+ if (_debugEnabled)
+ width = 640;
+ else
+ width = 320;
}
+ initGraphics(width, height, defaultTo1xScaler);
+
_system->setPalette(palette, 0, 256);
}
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index 282aa9801d..13173c8a96 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -52,10 +52,7 @@ Common::Error LureEngine::init() {
int_engine = this;
_initialised = false;
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
- _system->endGFXTransaction();
+ initGraphics(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT, false);
// Check the version of the lure.dat file
Common::File f;
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 45185b3b86..6cc81bf274 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -143,13 +143,10 @@ M4Engine::~M4Engine() {
Common::Error M4Engine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(isM4());
if (isM4())
- _system->initSize(640, 480);
+ initGraphics(640, 480, true);
else
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
_screen = new M4Surface(true); // Special form for creating screen reference
diff --git a/engines/made/made.cpp b/engines/made/made.cpp
index ae1b09b6e2..146115553d 100644
--- a/engines/made/made.cpp
+++ b/engines/made/made.cpp
@@ -130,10 +130,7 @@ MadeEngine::~MadeEngine() {
Common::Error MadeEngine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
return Common::kNoError;
}
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 9f1bd559b3..7de5e882cb 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -749,10 +749,7 @@ void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
Gfx::Gfx(Parallaction* vm) :
_vm(vm), _disk(vm->_disk) {
- _vm->_system->beginGFXTransaction();
- _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
- initCommonGFX(_vm->getGameType() == GType_BRA);
- _vm->_system->endGFXTransaction();
+ initGraphics(_vm->_screenWidth, _vm->_screenHeight, _vm->getGameType() == GType_BRA);
setPalette(_palette);
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index 995c2aff60..2de66c400e 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -473,10 +473,7 @@ Common::Error QueenEngine::go() {
}
Common::Error QueenEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
- _system->endGFXTransaction();
+ initGraphics(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, false);
_resource = new Resource();
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 2cc4e8c095..9585aac1b1 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -40,10 +40,7 @@ namespace Saga {
#define RID_IHNM_HOURGLASS_CURSOR 11 // not in demo
Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) {
- _system->beginGFXTransaction();
- initCommonGFX(width > 320);
- _system->initSize(width, height);
- _system->endGFXTransaction();
+ initGraphics(width, height, width > 320);
debug(5, "Init screen %dx%d", width, height);
// Convert surface data to R surface data
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 8ee880691b..0869a3dff6 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -822,10 +822,7 @@ ScummEngine_vCUPhe::~ScummEngine_vCUPhe() {
}
Common::Error ScummEngine_vCUPhe::init() {
- _system->beginGFXTransaction();
- _system->initSize(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight);
- initCommonGFX(true);
- _system->endGFXTransaction();
+ initGraphics(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight, true);
return Common::kNoError;
}
@@ -1069,23 +1066,16 @@ Common::Error ScummEngine::init() {
loadCJKFont();
// Initialize backend
- _system->beginGFXTransaction();
- bool defaultTo1XScaler = false;
- if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
- _system->initSize(Common::kHercW, Common::kHercH);
- defaultTo1XScaler = true;
- } else if (_useCJKMode) {
- _system->initSize(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier);
-
- // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
- // there is no text surface for them. This takes that into account
- defaultTo1XScaler = (_screenWidth * _textSurfaceMultiplier > 320);
- } else {
- _system->initSize(_screenWidth, _screenHeight);
- defaultTo1XScaler = (_screenWidth > 320);
- }
- initCommonGFX(defaultTo1XScaler);
- _system->endGFXTransaction();
+ if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
+ initGraphics(Common::kHercW, Common::kHercH, true);
+ } else if (_useCJKMode) {
+ initGraphics(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier,
+ // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
+ // there is no text surface for them. This takes that into account
+ (_screenWidth * _textSurfaceMultiplier > 320));
+ } else {
+ initGraphics(_screenWidth, _screenHeight, _screenWidth > 320);
+ }
setupScumm();
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index f6f926cae6..b1ea5ac3f9 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -238,10 +238,7 @@ Common::Error SkyEngine::go() {
}
Common::Error SkyEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
if (ConfMan.getBool("sfx_mute")) {
SkyEngine::_systemVars.systemFlags |= SF_FX_OFF;
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 504b2ce92d..5302e5102b 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -78,10 +78,7 @@ SwordEngine::~SwordEngine() {
Common::Error SwordEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(true);
- _system->initSize(640, 480);
- _system->endGFXTransaction();
+ initGraphics(640, 480, true);
if ( 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") ||
0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo") )
diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp
index d793e46192..d656674a98 100644
--- a/engines/sword2/screen.cpp
+++ b/engines/sword2/screen.cpp
@@ -52,8 +52,6 @@ Screen::Screen(Sword2Engine *vm, int16 width, int16 height) {
_dirtyGrid = _buffer = NULL;
- _vm->_system->initSize(width, height);
-
_screenWide = width;
_screenDeep = height;
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 7602368cac..39c04da592 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -371,10 +371,8 @@ Common::Error Sword2Engine::init() {
_resman = NULL;
_memory = NULL;
- _system->beginGFXTransaction();
- initCommonGFX(true);
- _screen = new Screen(this, 640, 480);
- _system->endGFXTransaction();
+ initGraphics(640, 480, true);
+ _screen = new Screen(this, 640, 480);
// Create the debugger as early as possible (but not before the
// screen object!) so that errors can be displayed in it. In
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index e876fbc40c..fdf38d9409 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -660,10 +660,7 @@ TinselEngine::~TinselEngine() {
Common::Error TinselEngine::init() {
// Initialize backend
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT);
- _system->endGFXTransaction();
+ initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false);
_screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, 1);
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index be211a34a1..0c9f16ef6a 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -82,10 +82,7 @@ ToucheEngine::~ToucheEngine() {
}
Common::Error ToucheEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(true);
- _system->initSize(kScreenWidth, kScreenHeight);
- _system->endGFXTransaction();
+ initGraphics(kScreenWidth, kScreenHeight, true);
Graphics::setupFont(_language);
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp
index 5b11574cfc..3e7a0be19b 100644
--- a/engines/tucker/tucker.cpp
+++ b/engines/tucker/tucker.cpp
@@ -42,10 +42,7 @@ TuckerEngine::~TuckerEngine() {
}
Common::Error TuckerEngine::init() {
- _system->beginGFXTransaction();
- initCommonGFX(false);
- _system->initSize(320, 200);
- _system->endGFXTransaction();
+ initGraphics(320, 200, false);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));