From cc73fd7f5f9984ce30ddb0cb5ab6b30b179e29da Mon Sep 17 00:00:00 2001 From: antoniou79 Date: Sat, 17 Jun 2023 20:40:27 +0300 Subject: [PATCH] GUI: Ommit aspect ratio checkbox if this feature is missing Also fix compilation when building for --disable-aspect (buggy end bracket in backends/graphics/surfacesdl/surfacesdl-graphics.cpp) --- backends/graphics/opengl/opengl-graphics.cpp | 2 + .../surfacesdl/surfacesdl-graphics.cpp | 2 +- gui/options.cpp | 41 ++++++++++++------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 9141416572a..62b1be501f2 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -108,7 +108,9 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() { bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) const { switch (f) { +#ifdef USE_ASPECT case OSystem::kFeatureAspectRatioCorrection: +#endif case OSystem::kFeatureCursorPalette: case OSystem::kFeatureFilteringMode: case OSystem::kFeatureStretchMode: diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 0256b2d8436..4a536b1f0a5 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -1381,8 +1381,8 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() { #ifdef USE_ASPECT if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayInGUI) r->h = stretch200To240((uint8 *) _hwScreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1, _videoMode.filtering, convertSDLPixelFormat(_hwScreen->format)); - } #endif + } } SDL_UnlockSurface(srcSurf); SDL_UnlockSurface(_hwScreen); diff --git a/gui/options.cpp b/gui/options.cpp index 5b0e45fa6fc..c86f701e0b8 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -366,12 +366,14 @@ void OptionsDialog::build() { } // Aspect ratio setting - if (_guioptions.contains(GUIO_NOASPECT)) { - _aspectCheckbox->setState(false); - _aspectCheckbox->setEnabled(false); - } else { - _aspectCheckbox->setEnabled(true); - _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain)); + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) { + if (_guioptions.contains(GUIO_NOASPECT)) { + _aspectCheckbox->setState(false); + _aspectCheckbox->setEnabled(false); + } else { + _aspectCheckbox->setEnabled(true); + _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain)); + } } if (g_system->hasFeature(OSystem::kFeatureVSync)) { @@ -612,8 +614,10 @@ void OptionsDialog::apply() { ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain); _fullscreenCheckbox->setOverride(false); } - if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState()) - graphicsModeChanged = true; + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) { + if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState()) + graphicsModeChanged = true; + } if (g_system->hasFeature(OSystem::kFeatureVSync)) { if (ConfMan.getBool("vsync", _domain) != _vsyncCheckbox->getState()) { graphicsModeChanged = true; @@ -622,7 +626,9 @@ void OptionsDialog::apply() { } } - ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain); + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) { + ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain); + } bool isSet = false; @@ -1291,10 +1297,12 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) { else _fullscreenCheckbox->setEnabled(false); - if (_guioptions.contains(GUIO_NOASPECT)) - _aspectCheckbox->setEnabled(false); - else - _aspectCheckbox->setEnabled(enabled); + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) { + if (_guioptions.contains(GUIO_NOASPECT)) + _aspectCheckbox->setEnabled(false); + else + _aspectCheckbox->setEnabled(enabled); + } if (g_system->hasFeature(OSystem::kFeatureVSync)) _vsyncCheckbox->setEnabled(enabled); @@ -1699,7 +1707,8 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr _filteringCheckbox = new CheckboxWidget(boss, prefix + "grFilteringCheckbox", _("Filter graphics"), _("Use linear filtering when scaling graphics")); // Aspect ratio checkbox - _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for games")); + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) + _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for games")); _enableGraphicSettings = true; } @@ -2047,7 +2056,9 @@ void OptionsDialog::setupGraphicsTab() { if (g_system->hasFeature(OSystem::kFeatureFilteringMode)) _filteringCheckbox->setVisible(true); - _aspectCheckbox->setVisible(true); + if (g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) + _aspectCheckbox->setVisible(true); + _renderModePopUpDesc->setVisible(true); _renderModePopUp->setVisible(true);