GUI: Apply graphics mode change when closing global options dialog

This commit is contained in:
Thierry Crozat 2011-05-15 16:31:58 +01:00
parent 3c59e37035
commit 0b8d2c4d60

View file

@ -305,8 +305,14 @@ void OptionsDialog::close() {
if (getResult()) {
// Graphic options
bool graphicsModeChanged = false;
if (_fullscreenCheckbox) {
if (_enableGraphicSettings) {
if (ConfMan.getBool("fullscreen", _domain) != _fullscreenCheckbox->getState())
graphicsModeChanged = true;
if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
graphicsModeChanged = true;
ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
ConfMan.setBool("disable_dithering", _disableDitheringCheckbox->getState(), _domain);
@ -318,6 +324,8 @@ void OptionsDialog::close() {
while (gm->name) {
if (gm->id == (int)_gfxPopUp->getSelectedTag()) {
if (ConfMan.get("gfx_mode", _domain) != gm->name)
graphicsModeChanged = true;
ConfMan.set("gfx_mode", gm->name, _domain);
isSet = true;
break;
@ -338,6 +346,48 @@ void OptionsDialog::close() {
ConfMan.removeKey("render_mode", _domain);
}
}
// Setup graphics again if needed
if (_domain == Common::ConfigManager::kApplicationDomain && graphicsModeChanged) {
g_system->beginGFXTransaction();
g_system->setGraphicsMode(ConfMan.get("gfx_mode", _domain).c_str());
if (ConfMan.hasKey("aspect_ratio"))
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio", _domain));
if (ConfMan.hasKey("fullscreen"))
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain));
OSystem::TransactionError gfxError = g_system->endGFXTransaction();
if (gfxError != OSystem::kTransactionSuccess) {
// Revert ConfMan to what OSystem is using.
Common::String message = "Failed to apply some of the graphic options changes:";
if (gfxError & OSystem::kTransactionModeSwitchFailed) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
while (gm->name) {
if (gm->id == g_system->getGraphicsMode()) {
ConfMan.set("gfx_mode", gm->name, _domain);
break;
}
gm++;
}
message += "\nthe video mode could not be changed.";
}
if (gfxError & OSystem::kTransactionAspectRatioFailed) {
ConfMan.setBool("aspect_ratio", g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection), _domain);
message += "\nthe fullscreen setting could not be changed";
}
if (gfxError & OSystem::kTransactionFullscreenFailed) {
ConfMan.setBool("fullscreen", g_system->getFeatureState(OSystem::kFeatureFullscreenMode), _domain);
message += "\nthe aspect ratio setting could not be changed";
}
// And display the error
GUI::MessageDialog dialog(message);
dialog.runModal();
}
}
// Volume options
if (_musicVolumeSlider) {