GUI: Don't create a popup for the stretch mode if it's not supported

This commit is contained in:
Cameron Cawley 2023-02-05 18:54:04 +00:00 committed by Eugene Sandulenko
parent 380643315e
commit 5f06b599c8

View file

@ -346,26 +346,6 @@ void OptionsDialog::build() {
_renderModePopUp->setSelectedTag(sel); _renderModePopUp->setSelectedTag(sel);
} }
_stretchPopUp->setSelected(0);
if (g_system->hasFeature(OSystem::kFeatureStretchMode)) {
if (ConfMan.hasKey("stretch_mode", _domain)) {
const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes();
Common::String stretchMode(ConfMan.get("stretch_mode", _domain));
int stretchCount = 1;
while (sm->name) {
stretchCount++;
if (scumm_stricmp(sm->name, stretchMode.c_str()) == 0)
_stretchPopUp->setSelected(stretchCount);
sm++;
}
}
} else {
_stretchPopUpDesc->setVisible(false);
_stretchPopUp->setVisible(false);
_stretchPopUp->setEnabled(false);
}
_scalerPopUp->setSelected(0); _scalerPopUp->setSelected(0);
_scaleFactorPopUp->setSelected(0); _scaleFactorPopUp->setSelected(0);
@ -442,6 +422,27 @@ void OptionsDialog::build() {
} }
} }
if (_stretchPopUp) {
if (g_system->hasFeature(OSystem::kFeatureStretchMode)) {
_stretchPopUp->setSelected(0);
if (ConfMan.hasKey("stretch_mode", _domain)) {
const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes();
Common::String stretchMode(ConfMan.get("stretch_mode", _domain));
int stretchCount = 1;
while (sm->name) {
stretchCount++;
if (scumm_stricmp(sm->name, stretchMode.c_str()) == 0)
_stretchPopUp->setSelected(stretchCount);
sm++;
}
}
} else {
_stretchPopUpDesc->setVisible(false);
_stretchPopUp->setVisible(false);
}
}
// Shader options // Shader options
if (_shader) { if (_shader) {
if (g_system->hasFeature(OSystem::kFeatureShaders)) { if (g_system->hasFeature(OSystem::kFeatureShaders)) {
@ -650,6 +651,7 @@ void OptionsDialog::apply() {
} }
} }
if (g_system->hasFeature(OSystem::kFeatureStretchMode)) {
isSet = false; isSet = false;
if ((int32)_stretchPopUp->getSelectedTag() >= 0) { if ((int32)_stretchPopUp->getSelectedTag() >= 0) {
const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes(); const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes();
@ -673,6 +675,7 @@ void OptionsDialog::apply() {
if (g_system->getStretchMode() != g_system->getDefaultStretchMode()) if (g_system->getStretchMode() != g_system->getDefaultStretchMode())
graphicsModeChanged = true; graphicsModeChanged = true;
} }
}
isSet = false; isSet = false;
const PluginList &scalerPlugins = ScalerMan.getPlugins(); const PluginList &scalerPlugins = ScalerMan.getPlugins();
@ -1229,9 +1232,12 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_stretchPopUpDesc->setEnabled(enabled); _stretchPopUpDesc->setEnabled(enabled);
_stretchPopUp->setEnabled(enabled); _stretchPopUp->setEnabled(enabled);
} else { } else {
// Happens when we switch to backend that doesn't support stretch modes
if (_stretchPopUp) {
_stretchPopUpDesc->setEnabled(false); _stretchPopUpDesc->setEnabled(false);
_stretchPopUp->setEnabled(false); _stretchPopUp->setEnabled(false);
} }
}
if (g_system->hasFeature(OSystem::kFeatureScalers)) { if (g_system->hasFeature(OSystem::kFeatureScalers)) {
_scalerPopUpDesc->setEnabled(enabled); _scalerPopUpDesc->setEnabled(enabled);
@ -1582,6 +1588,7 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
} }
// The Stretch mode popup // The Stretch mode popup
if (g_system->hasFeature(OSystem::kFeatureStretchMode)) {
const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes(); const OSystem::GraphicsMode *sm = g_system->getSupportedStretchModes();
_stretchPopUpDesc = new StaticTextWidget(boss, prefix + "grStretchModePopupDesc", _("Stretch mode:")); _stretchPopUpDesc = new StaticTextWidget(boss, prefix + "grStretchModePopupDesc", _("Stretch mode:"));
if (ConfMan.isKeyTemporary("stretch_mode")) if (ConfMan.isKeyTemporary("stretch_mode"))
@ -1594,6 +1601,7 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
_stretchPopUp->appendEntry(_c(sm->description, context), sm->id); _stretchPopUp->appendEntry(_c(sm->description, context), sm->id);
sm++; sm++;
} }
}
// The Scaler popup // The Scaler popup
const PluginList &scalerPlugins = ScalerMan.getPlugins(); const PluginList &scalerPlugins = ScalerMan.getPlugins();
@ -1998,6 +2006,8 @@ void OptionsDialog::setupGraphicsTab() {
// Fixes crash when switching from SDL Surface to OpenGL // Fixes crash when switching from SDL Surface to OpenGL
if (!_shader && g_system->hasFeature(OSystem::kFeatureShaders)) { if (!_shader && g_system->hasFeature(OSystem::kFeatureShaders)) {
rebuild(); rebuild();
} else if (!_stretchPopUp && g_system->hasFeature(OSystem::kFeatureStretchMode)) {
rebuild();
} }
setGraphicSettingsState(_enableGraphicSettings); setGraphicSettingsState(_enableGraphicSettings);
} }
@ -2008,9 +2018,6 @@ void OptionsDialog::setupGraphicsTab() {
if (g_system->hasFeature(OSystem::kFeatureStretchMode)) { if (g_system->hasFeature(OSystem::kFeatureStretchMode)) {
_stretchPopUpDesc->setVisible(true); _stretchPopUpDesc->setVisible(true);
_stretchPopUp->setVisible(true); _stretchPopUp->setVisible(true);
} else {
_stretchPopUpDesc->setVisible(false);
_stretchPopUp->setVisible(false);
} }
_fullscreenCheckbox->setVisible(true); _fullscreenCheckbox->setVisible(true);
if (g_system->hasFeature(OSystem::kFeatureFilteringMode)) if (g_system->hasFeature(OSystem::kFeatureFilteringMode))