From 3e08c33c352b3d28c75e818fe601904a26d03d0f Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Wed, 12 Oct 2016 22:32:36 +0100 Subject: [PATCH] GUI: Add checkbox and config option to enable/disable graphics filtering --- base/commandLine.cpp | 6 +++++ base/main.cpp | 2 ++ engines/engine.cpp | 11 +++++++- gui/options.cpp | 24 ++++++++++++++++++ gui/options.h | 1 + gui/themes/default.inc | 6 +++++ gui/themes/scummclassic.zip | Bin 126490 -> 126628 bytes gui/themes/scummclassic/classic_layout.stx | 3 +++ .../scummclassic/classic_layout_lowres.stx | 3 +++ gui/themes/scummmodern.zip | Bin 1646030 -> 1646168 bytes gui/themes/scummmodern/scummmodern_layout.stx | 3 +++ .../scummmodern/scummmodern_layout_lowres.stx | 3 +++ 12 files changed, 61 insertions(+), 1 deletion(-) diff --git a/base/commandLine.cpp b/base/commandLine.cpp index c2b4ea765f2..8be20573382 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -80,6 +80,8 @@ static const char HELP_STRING[] = " -g, --gfx-mode=MODE Select graphics scaler (1x,2x,3x,2xsai,super2xsai,\n" " supereagle,advmame2x,advmame3x,hq2x,hq3x,tv2x,\n" " dotmatrix)\n" + " --filtering Force filtered graphics mode\n" + " --no-filtering Force unfiltered graphics mode\n" " --gui-theme=THEME Select GUI theme\n" " --themepath=PATH Path to where GUI themes are stored\n" " --list-themes Display list of all usable GUI themes\n" @@ -178,6 +180,7 @@ void registerDefaults() { // Graphics ConfMan.registerDefault("fullscreen", false); + ConfMan.registerDefault("filtering", false); ConfMan.registerDefault("aspect_ratio", false); ConfMan.registerDefault("gfx_mode", "normal"); ConfMan.registerDefault("render_mode", "default"); @@ -441,6 +444,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha DO_OPTION_BOOL('f', "fullscreen") END_OPTION + + DO_LONG_OPTION_BOOL("filtering") + END_OPTION #ifdef ENABLE_EVENTRECORDER DO_LONG_OPTION_INT("disable-display") diff --git a/base/main.cpp b/base/main.cpp index 7807ddff7d6..ca3a764f3ad 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -290,6 +290,8 @@ static void setupGraphics(OSystem &system) { system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); if (ConfMan.hasKey("fullscreen")) system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); + if (ConfMan.hasKey("filtering")) + system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering")); system.endGFXTransaction(); // When starting up launcher for the first time, the user might have specified diff --git a/engines/engine.cpp b/engines/engine.cpp index 68d9e8fde61..aac9c8c7173 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -223,7 +223,7 @@ void initCommonGFX(bool defaultTo1XScaler) { g_system->setGraphicsMode(gfxMode.c_str()); // HACK: For OpenGL modes, we will still honor the graphics scale override - if (defaultTo1XScaler && (gfxMode.equalsIgnoreCase("opengl_linear") || gfxMode.equalsIgnoreCase("opengl_nearest"))) + if (defaultTo1XScaler && gfxMode.equalsIgnoreCase("opengl")) g_system->resetGraphicsScale(); } } @@ -242,6 +242,10 @@ void initCommonGFX(bool defaultTo1XScaler) { // (De)activate fullscreen mode as determined by the config settings if (gameDomain && gameDomain->contains("fullscreen")) g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); + + // (De)activate filtering mode as determined by the config settings + if (gameDomain && gameDomain->contains("filtering")) + g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering")); } // Please leave the splash screen in working order for your releases, even if they're commercial. @@ -364,6 +368,11 @@ void initGraphics(int width, int height, bool defaultTo1xScaler, const Graphics: GUI::MessageDialog dialog(_("Could not apply fullscreen setting.")); dialog.runModal(); } + + if (gfxError & OSystem::kTransactionFilteringFailed) { + GUI::MessageDialog dialog(_("Could not apply filtering setting.")); + dialog.runModal(); + } } diff --git a/gui/options.cpp b/gui/options.cpp index 1f6683d3886..4f8dbc20f96 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -135,6 +135,7 @@ void OptionsDialog::init() { _renderModePopUp = 0; _renderModePopUpDesc = 0; _fullscreenCheckbox = 0; + _filteringCheckbox = 0; _aspectCheckbox = 0; _enableAudioSettings = false; _midiTabId = 0; @@ -243,6 +244,12 @@ void OptionsDialog::open() { _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain)); #endif // GUI_ONLY_FULLSCREEN + // Filtering setting + if (g_system->hasFeature(OSystem::kFeatureFilteringMode)) + _filteringCheckbox->setState(ConfMan.getBool("filtering", _domain)); + else + _filteringCheckbox->setVisible(false); + // Aspect ratio setting if (_guioptions.contains(GUIO_NOASPECT)) { _aspectCheckbox->setState(false); @@ -353,11 +360,14 @@ void OptionsDialog::close() { bool graphicsModeChanged = false; if (_fullscreenCheckbox) { if (_enableGraphicSettings) { + if (ConfMan.getBool("filtering", _domain) != _filteringCheckbox->getState()) + graphicsModeChanged = true; if (ConfMan.getBool("fullscreen", _domain) != _fullscreenCheckbox->getState()) graphicsModeChanged = true; if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState()) graphicsModeChanged = true; + ConfMan.setBool("filtering", _filteringCheckbox->getState(), _domain); ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain); ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain); @@ -384,6 +394,7 @@ void OptionsDialog::close() { ConfMan.set("render_mode", Common::getRenderModeCode((Common::RenderMode)_renderModePopUp->getSelectedTag()), _domain); } else { ConfMan.removeKey("fullscreen", _domain); + ConfMan.removeKey("filtering", _domain); ConfMan.removeKey("aspect_ratio", _domain); ConfMan.removeKey("gfx_mode", _domain); ConfMan.removeKey("render_mode", _domain); @@ -399,6 +410,9 @@ void OptionsDialog::close() { g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio", _domain)); if (ConfMan.hasKey("fullscreen")) g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain)); + if (ConfMan.hasKey("filtering")) + g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering", _domain)); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); // Since this might change the screen resolution we need to give @@ -441,6 +455,12 @@ void OptionsDialog::close() { message += "\n"; message += _("the fullscreen setting could not be changed"); } + + if (gfxError & OSystem::kTransactionFilteringFailed) { + ConfMan.setBool("filtering", g_system->getFeatureState(OSystem::kFeatureFilteringMode), _domain); + message += "\n"; + message += _("the filtering setting could not be changed"); + } // And display the error GUI::MessageDialog dialog(message); @@ -633,6 +653,7 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) { _gfxPopUp->setEnabled(enabled); _renderModePopUpDesc->setEnabled(enabled); _renderModePopUp->setEnabled(enabled); + _filteringCheckbox->setEnabled(enabled); #ifndef GUI_ENABLE_KEYSDIALOG _fullscreenCheckbox->setEnabled(enabled); if (_guioptions.contains(GUIO_NOASPECT)) @@ -785,6 +806,9 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr // Fullscreen checkbox _fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", _("Fullscreen mode")); + + // Filtering checkbox + _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 320x200 games")); diff --git a/gui/options.h b/gui/options.h index 03dbdac4922..802a503fd35 100644 --- a/gui/options.h +++ b/gui/options.h @@ -114,6 +114,7 @@ private: StaticTextWidget *_gfxPopUpDesc; PopUpWidget *_gfxPopUp; CheckboxWidget *_fullscreenCheckbox; + CheckboxWidget *_filteringCheckbox; CheckboxWidget *_aspectCheckbox; StaticTextWidget *_renderModePopUpDesc; PopUpWidget *_renderModePopUp; diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 07e596163d8..8524a7728f5 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -834,6 +834,9 @@ const char *defaultXML1 = "" "" +"" "" "" "" @@ -2370,6 +2373,9 @@ const char *defaultXML1 = "" "" +"" "" "" "" diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index eb0ded51621984dfc95d7e9842becf9c67bdb44c..300e2ce0877a415fc7f422b3ae8f5e3e6b85cabb 100644 GIT binary patch delta 454 zcmbPrhkeOicHRJQW)=|!5b($@p2!=Gxt)t&Cg`>t$8IE z_;_|&_|`sJ$H4Gtb5i6x>FIy-7zMf0i`+7EN>Yn5^U^0jEYaK?PL7i76K5_)3+Hn@iTj57f)|^&1l2{GQ~>t(d6m>UNeeKzwnw- z4XkYXuh)zYARkS)eZy#l>Z9o`Zy1f`QQghJAPEi~2w2h>JN?=lMh!(2H*zyDh@&Vv zw}o+f;uc1U=?C62@_^Nr?`SxAn45tCgi+NB9{{Trp04?ZQ4r$9p0|ur%-m-fr_Vdh eC=NCQB7Wg5qZE_-o#}7hGHS5>e$B|hzyJW7?u;t{ delta 399 zcmZ2-mwnb9cHRJQW)=|!5co3b&qUrZ7DkK59vjp5@PQed)%o}EF{`F)Ylhe7ScqY|;#)?M&DD`trKkUPVl>@+s&wuozEwrKo_<}S(O*|HFnnFT zy_AFT1VnoBsnXrk6C4;dCa){o4`JLb=bF5rd^3boQ*nB`p$6mf9zd;%ELc>CbeoH;hJLvFQ$P7#$$2mN$$JAh%CH{)W+t7sc(< z`Q9=b%cHuJfk6@+4iK=UQDS<+TSg6tQ9W-Nr5IhNFMrFZ1`)XUmQjkib3fyBg9D5b z(|5dKYj*7(iGI#k9uL(~aISsz7u{y + diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 212ef7c4512..7f43c7b1e15 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -257,6 +257,9 @@ + diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index 0b8b771bf6559e702225b4e21ae9258350905b11..0968f06b406de9da563c3bb1d791a7cffef68ab0 100644 GIT binary patch delta 1220 zcmb7^UuYCZ9LFcwJ-u`9k~{a`{O*s5K8O|nU`#H_sh7lnMiSa+Y)nJYH0F}K<{C5? zh@uHb&_T_K@ed=UXezq?frM1(ZHw#K2NgvWd=ag!mfGgUhgPr%KD1?L&Oo3q9a#9x z%y+*t^PS)BqZ^%1txiv4y&x*cZgoAWQO~F1g#+uVhr14S<$c?gzr|o(Vj20wG6Z57 zBC!kyv5YyyGUgJ?a1zUK5zClIEJHFa!~OR(eer|ngb7O5>c-|0na*vqBGtJR7ew$-Xr zg(pM!te2TqM7j>t+0Gp*8x;W)F-v zY}(hoX=7#zp^WJ|saJ*Qf%m#k>h9Z+NcPA2620B@@j3hvmHyF})8m8KNpFqexwPW7 zK0tqo;Z@X|)yt@-9p5sGztM+BnPtt@q0FmEgkG7G>+#0m|F!&~9f!@rcHA>6J{&t- zWe&Z;tvu-GZ*lG(B6-lk$IgqeorRzAL6;!Z^`vM*ff80W^t=KQPCqLU=A^3-u`{Au zRVZP((W5GaIo(!aEz6#Y8dP(tV>A(u(h&_xb2<$oPP<+%rHw@;_5O%tzHrMT@WuH)A2sCiQUi(p no$-$T-v9F6Z+-kSEFfe*@+|K`A5gCk6#88VymNk203q}*3e|XV delta 1126 zcmZvbT}TvB6vyxGtfj51Yx8+rS4|MK)WCFItu#Nt#0W_=T`a|P&9Krm4EhisDyy}l z*ZCZdA-=)qbF^A}KFR9|3@_g^kml}x%KPFOPQK>rY%JmXTi(YRs@kFVylsrLdY85O zW}zjX(p;y|9uZZ#g%*wm2YZB8w*2XW(8)Or&oNKz6;3-sPBM-K&^j&&X?E5CVY?-9KbY^fAy6Is+*Z{!*la8IMC^)yON5l3%2q{T`q zeRo=liHu~fK;9i0$(JIzka=_Om6sYFnO#{m(^cOd_RS*Hr^N;3GB+7&RaVL81v#56 zwJCNoGAEa5tF!XY3CDwTxi!BQa^6kNAT*_|S18pf+EA-95@g$oT~mB)9-Tjw$hclv zpq<6CW8gTO(P$F*IW8RBAnO9;(^`@(LJ6ZT5j>1;iBMvAA&Vm9Q@ccvz{BXU1p8Rp zRS6C-`e2YT79z<|5XqBG;V~HssN72#JjSt+4HF6#Q|!C~1$6Dc0>u=*Dp1DccL9_$ z>IEpLQjfq?Ujx%hRZB2ZV!_Rh5W8iQiZx&i&fy*)inOk7fN0;8J9t_^pbKn05yBe z4X&#Bu!8yr&i1wsoXKlH-TQB0^Jw}h4~LNPCPnqiwSZYjk^rPqqmS2-Ve`ZzWW0{3 h^q>t;|6upPiIe~DM4YMMvaUNxZYpGM@d + diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 2ca89ce7344..13ec698b85f 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -255,6 +255,9 @@ +