GUI: Add improved scaler selection to the Options dialog

This commit is contained in:
Cameron Cawley 2021-01-06 23:24:00 +00:00 committed by Eugene Sandulenko
parent da5d773924
commit b2d41daabc
24 changed files with 248 additions and 8 deletions

View file

@ -103,10 +103,11 @@ static const char HELP_STRING[] =
" -x, --save-slot[=NUM] Save game slot to load (default: autosave)\n"
" -f, --fullscreen Force full-screen mode\n"
" -F, --no-fullscreen Force windowed mode\n"
" -g, --gfx-mode=MODE Select graphics scaler (1x,2x,3x,2xsai,super2xsai,\n"
" supereagle,advmame2x,advmame3x,hq2x,hq3x,tv2x,\n"
" dotmatrix)\n"
" -g, --gfx-mode=MODE Select graphics mode\n"
" --stretch-mode=MODE Select stretch mode (center, integral, fit, stretch)\n"
" --scaler=MODE Select graphics scaler (normal,hq,edge,advmame,sai,\n"
" supersai,supereagle,pm,dotmatrix,tv2x)\n"
" --scale-factor=FACTOR Factor to scale the graphics by\n"
" --filtering Force filtered graphics mode\n"
" --no-filtering Force unfiltered graphics mode\n"
#ifdef USE_OPENGL
@ -248,6 +249,8 @@ void registerDefaults() {
ConfMan.registerDefault("render_mode", "default");
ConfMan.registerDefault("desired_screen_aspect_ratio", "auto");
ConfMan.registerDefault("stretch_mode", "default");
ConfMan.registerDefault("scaler", "default");
ConfMan.registerDefault("scale_factor", -1);
ConfMan.registerDefault("shader", "default");
ConfMan.registerDefault("show_fps", false);
ConfMan.registerDefault("dirtyrects", true);
@ -663,6 +666,12 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION("stretch-mode")
END_OPTION
DO_LONG_OPTION("scaler")
END_OPTION
DO_LONG_OPTION_INT("scale-factor")
END_OPTION
DO_LONG_OPTION("shader")
END_OPTION

View file

@ -343,6 +343,7 @@ static void setupGraphics(OSystem &system) {
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
system.setStretchMode(ConfMan.get("stretch_mode").c_str());
system.setShader(ConfMan.get("shader").c_str());
system.setScaler(ConfMan.get("scaler").c_str(), ConfMan.getInt("scale_factor"));
system.initSize(320, 200);

View file

@ -215,6 +215,9 @@ void initCommonGFX() {
if (gameDomain->contains("stretch_mode"))
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
if (gameDomain->contains("scaler") || gameDomain->contains("scale_factor"))
g_system->setScaler(ConfMan.get("scaler").c_str(), ConfMan.getInt("scale_factor"));
if (gameDomain->contains("shader"))
g_system->setShader(ConfMan.get("shader").c_str());
}

View file

@ -37,7 +37,7 @@
#include "graphics/pixelformat.h"
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.46"
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.47"
class OSystem;

View file

@ -411,6 +411,8 @@ void EditGameDialog::open() {
e = ConfMan.hasKey("gfx_mode", _domain) ||
ConfMan.hasKey("render_mode", _domain) ||
ConfMan.hasKey("stretch_mode", _domain) ||
ConfMan.hasKey("scaler", _domain) ||
ConfMan.hasKey("scale_factor", _domain) ||
ConfMan.hasKey("aspect_ratio", _domain) ||
ConfMan.hasKey("fullscreen", _domain) ||
ConfMan.hasKey("vsync", _domain) ||

View file

@ -64,6 +64,7 @@
#endif
#include "graphics/renderer.h"
#include "graphics/scalerplugin.h"
namespace GUI {
@ -90,6 +91,7 @@ enum {
kKbdMouseSpeedChanged = 'kmsc',
kJoystickDeadzoneChanged= 'jodc',
kGraphicsTabContainerReflowCmd = 'gtcr',
kScalerPopUpCmd = 'scPU',
kFullscreenToggled = 'oful'
};
@ -185,6 +187,9 @@ void OptionsDialog::init() {
_renderModePopUpDesc = nullptr;
_stretchPopUp = nullptr;
_stretchPopUpDesc = nullptr;
_scalerPopUp = nullptr;
_scalerPopUpDesc = nullptr;
_scaleFactorPopUp = nullptr;
_fullscreenCheckbox = nullptr;
_filteringCheckbox = nullptr;
_aspectCheckbox = nullptr;
@ -350,6 +355,37 @@ void OptionsDialog::build() {
_stretchPopUp->setVisible(false);
}
_scalerPopUp->setSelected(0);
_scaleFactorPopUp->setSelected(0);
if (g_system->hasFeature(OSystem::kFeatureScalers)) {
if (ConfMan.hasKey("scaler", _domain)) {
const PluginList &scalerPlugins = ScalerMan.getPlugins();
Common::String scaler(ConfMan.get("scaler", _domain));
for (uint scalerIndex = 0; scalerIndex < scalerPlugins.size(); scalerIndex++) {
if (scumm_stricmp(scalerPlugins[scalerIndex]->get<ScalerPluginObject>().getName(), scaler.c_str()) != 0)
continue;
_scalerPopUp->setSelectedTag(scalerIndex);
updateScaleFactors(scalerIndex);
if (ConfMan.hasKey("scale_factor", _domain)) {
int scaleFactor = ConfMan.getInt("scale_factor", _domain);
if (scalerPlugins[scalerIndex]->get<ScalerPluginObject>().hasFactor(scaleFactor))
_scaleFactorPopUp->setSelectedTag(scaleFactor);
}
break;
}
}
} else {
_scalerPopUpDesc->setVisible(false);
_scalerPopUp->setVisible(false);
_scaleFactorPopUp->setVisible(false);
}
// Fullscreen setting
if (g_system->hasFeature(OSystem::kFeatureFullscreenMode)) {
_fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
@ -587,6 +623,31 @@ void OptionsDialog::apply() {
graphicsModeChanged = true;
}
isSet = false;
const PluginList &scalerPlugins = ScalerMan.getPlugins();
if ((int32)_scalerPopUp->getSelectedTag() >= 0) {
const char *name = scalerPlugins[_scalerPopUp->getSelectedTag()]->get<ScalerPluginObject>().getName();
if (ConfMan.get("scaler", _domain) != name)
graphicsModeChanged = true;
ConfMan.set("scaler", name, _domain);
int factor = _scaleFactorPopUp->getSelectedTag();
if (ConfMan.getInt("scale_factor", _domain) != factor)
graphicsModeChanged = true;
ConfMan.setInt("scale_factor", factor, _domain);
isSet = true;
}
if (!isSet) {
ConfMan.removeKey("scaler", _domain);
ConfMan.removeKey("scale_factor", _domain);
uint defaultScaler = g_system->getDefaultScaler();
if (g_system->getScaler() != defaultScaler)
graphicsModeChanged = true;
else if (scalerPlugins[defaultScaler]->get<ScalerPluginObject>().getFactor() != g_system->getDefaultScaleFactor())
graphicsModeChanged = true;
}
if (_rendererTypePopUp->getSelectedTag() > 0) {
Graphics::RendererType selected = (Graphics::RendererType) _rendererTypePopUp->getSelectedTag();
ConfMan.set("renderer", Graphics::getRendererTypeCode(selected), _domain);
@ -607,6 +668,8 @@ void OptionsDialog::apply() {
ConfMan.removeKey("aspect_ratio", _domain);
ConfMan.removeKey("gfx_mode", _domain);
ConfMan.removeKey("stretch_mode", _domain);
ConfMan.removeKey("scaler", _domain);
ConfMan.removeKey("scale_factor", _domain);
ConfMan.removeKey("render_mode", _domain);
ConfMan.removeKey("renderer", _domain);
ConfMan.removeKey("antialiasing", _domain);
@ -647,6 +710,7 @@ void OptionsDialog::apply() {
g_system->beginGFXTransaction();
g_system->setGraphicsMode(ConfMan.get("gfx_mode", _domain).c_str());
g_system->setStretchMode(ConfMan.get("stretch_mode", _domain).c_str());
g_system->setScaler(ConfMan.get("scaler", _domain).c_str(), ConfMan.getInt("scale_factor", _domain));
if (ConfMan.hasKey("aspect_ratio"))
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio", _domain));
@ -967,6 +1031,10 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
case kGraphicsTabContainerReflowCmd:
setupGraphicsTab();
break;
case kScalerPopUpCmd:
updateScaleFactors(data);
g_gui.scheduleTopDialogRedraw();
break;
case kApplyCmd:
apply();
break;
@ -1007,6 +1075,9 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_renderModePopUp->setEnabled(enabled);
_stretchPopUpDesc->setEnabled(enabled);
_stretchPopUp->setEnabled(enabled);
_scalerPopUpDesc->setEnabled(enabled);
_scalerPopUp->setEnabled(enabled);
_scaleFactorPopUp->setEnabled(enabled);
_vsyncCheckbox->setEnabled(enabled);
_filteringCheckbox->setEnabled(enabled);
_rendererTypePopUpDesc->setEnabled(enabled);
@ -1353,6 +1424,20 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
sm++;
}
// The Scaler popup
const PluginList &scalerPlugins = ScalerMan.getPlugins();
_scalerPopUpDesc = new StaticTextWidget(boss, prefix + "grScalerPopupDesc", _("Scaler:"));
_scalerPopUp = new PopUpWidget(boss, prefix + "grScalerPopup", Common::U32String(), kScalerPopUpCmd);
_scalerPopUp->appendEntry(_("<default>"));
_scalerPopUp->appendEntry(Common::U32String());
for (uint scalerIndex = 0; scalerIndex < scalerPlugins.size(); scalerIndex++) {
_scalerPopUp->appendEntry(_c(scalerPlugins[scalerIndex]->get<ScalerPluginObject>().getPrettyName(), context), scalerIndex);
}
_scaleFactorPopUp = new PopUpWidget(boss, prefix + "grScaleFactorPopup");
updateScaleFactors(_scalerPopUp->getSelectedTag());
// Fullscreen checkbox
_fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", _("Fullscreen mode"), Common::U32String(), kFullscreenToggled);
@ -1722,6 +1807,33 @@ void OptionsDialog::setupGraphicsTab() {
_aspectCheckbox->setVisible(true);
_renderModePopUpDesc->setVisible(true);
_renderModePopUp->setVisible(true);
if (g_system->hasFeature(OSystem::kFeatureScalers)) {
_scalerPopUpDesc->setVisible(true);
_scalerPopUp->setVisible(true);
_scaleFactorPopUp->setVisible(true);
} else {
_scalerPopUpDesc->setVisible(false);
_scalerPopUp->setVisible(false);
_scaleFactorPopUp->setVisible(false);
}
}
void OptionsDialog::updateScaleFactors(uint32 tag) {
if ((int32)tag >= 0) {
const PluginList &scalerPlugins = ScalerMan.getPlugins();
const Common::Array<uint> &factors = scalerPlugins[tag]->get<ScalerPluginObject>().getFactors();
_scaleFactorPopUp->clearEntries();
for (Common::Array<uint>::const_iterator it = factors.begin(); it != factors.end(); it++) {
_scaleFactorPopUp->appendEntry(Common::U32String::format("%dx", (*it)), (*it));
}
_scaleFactorPopUp->setSelectedTag(scalerPlugins[tag]->get<ScalerPluginObject>().getFactor());
} else {
_scaleFactorPopUp->clearEntries();
_scaleFactorPopUp->appendEntry(_("<default>"));
_scaleFactorPopUp->setSelected(0);
}
}
#pragma mark -

View file

@ -112,6 +112,7 @@ protected:
void setSubtitleSettingsState(bool enabled);
virtual void setupGraphicsTab();
void updateScaleFactors(uint32 tag);
bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType = MT_AUTO);
void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting);
@ -152,6 +153,8 @@ private:
PopUpWidget *_gfxPopUp;
StaticTextWidget *_stretchPopUpDesc;
PopUpWidget *_stretchPopUp;
StaticTextWidget *_scalerPopUpDesc;
PopUpWidget *_scalerPopUp, *_scaleFactorPopUp;
CheckboxWidget *_fullscreenCheckbox;
CheckboxWidget *_filteringCheckbox;
CheckboxWidget *_aspectCheckbox;

View file

@ -1703,6 +1703,17 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"type='PopUp' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='10' align='center'>"
"<widget name='grScalerPopupDesc' "
"type='OptionsLabel' "
"/>"
"<widget name='grScalerPopup' "
"type='PopUp' "
"/>"
"<widget name='grScaleFactorPopup' "
"type='PopUp' "
"/>"
"</layout>"
"<widget name='grAspectCheckbox' "
"type='Checkbox' "
"/>"
@ -3532,6 +3543,17 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"type='PopUp' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
"<widget name='grScalerPopupDesc' "
"type='OptionsLabel' "
"/>"
"<widget name='grScalerPopup' "
"type='PopUp' "
"/>"
"<widget name='grScaleFactorPopup' "
"type='PopUp' "
"/>"
"</layout>"
"<widget name='grAspectCheckbox' "
"type='Checkbox' "
"/>"

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.46:ResidualVM Modern Theme:No Author]
[SCUMMVM_STX0.8.47:ResidualVM Modern Theme:No Author]

View file

@ -347,6 +347,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

View file

@ -329,6 +329,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.46:ScummVM Classic Theme:No Author]
[SCUMMVM_STX0.8.47:ScummVM Classic Theme:No Author]

View file

@ -333,6 +333,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

View file

@ -329,6 +329,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.46:ScummVM Modern Theme:No Author]
[SCUMMVM_STX0.8.47:ScummVM Modern Theme:No Author]

View file

@ -347,6 +347,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

View file

@ -329,6 +329,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.46:ScummVM Modern Theme Remastered:No Author]
[SCUMMVM_STX0.8.47:ScummVM Modern Theme Remastered:No Author]

View file

@ -349,6 +349,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>

View file

@ -331,6 +331,17 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'grScalerPopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'grScalerPopup'
type = 'PopUp'
/>
<widget name = 'grScaleFactorPopup'
type = 'PopUp'
/>
</layout>
<widget name = 'grAspectCheckbox'
type = 'Checkbox'
/>