GUI: Expose base GUI scaling to GUI. This bumps theme version.

This commit is contained in:
Eugene Sandulenko 2021-04-17 19:35:08 +02:00
parent 9bcffc97ee
commit bba558770d
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
21 changed files with 137 additions and 81 deletions

View File

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

View File

@ -112,17 +112,27 @@ void GuiManager::computeScaleFactor() {
uint16 h = g_system->getOverlayHeight();
uint scale = g_system->getFeatureState(OSystem::kFeatureHiDPI) ? 2 : 1;
// Hardcoding for now
if (h < 240 * scale) { // 320 x 200
_baseHeight = MIN<int16>(200, h);
} else if (h < 400 * scale) { // 320 x 240
_baseHeight = 240;
} else if (h < 480 * scale) { // 640 x 400
_baseHeight = 400;
} else if (h < 720 * scale) { // 640 x 480
_baseHeight = 480;
} else { // 960 x 720
_baseHeight = 720;
_baseHeight = 0; // Clean up from previous iteration
if (ConfMan.hasKey("gui_base")) {
_baseHeight = ConfMan.getInt("gui_base");
if (h < _baseHeight)
_baseHeight = 0; // Switch to auto for lower resolutions
}
if (_baseHeight == 0) { // auto
if (h < 240 * scale) { // 320 x 200
_baseHeight = MIN<int16>(200, h);
} else if (h < 400 * scale) { // 320 x 240
_baseHeight = 240;
} else if (h < 480 * scale) { // 640 x 400
_baseHeight = 400;
} else if (h < 720 * scale) { // 640 x 480
_baseHeight = 480;
} else { // 960 x 720
_baseHeight = 720;
}
}
_scaleFactor = (float)h / (float)_baseHeight;

View File

@ -94,6 +94,7 @@ public:
int16 getGUIWidth() const { return _baseWidth; }
int16 getGUIHeight() const { return _baseHeight; }
float getScaleFactor() const { return _scaleFactor; }
void computeScaleFactor();
bool useRTL() const { return _useRTL; }
void setLanguageRTL();
@ -177,8 +178,6 @@ protected:
};
Common::List<GuiObjectTrashItem> _guiObjectTrash;
void computeScaleFactor();
void initKeymap();
void enableKeymap(bool enabled);

View File

@ -129,6 +129,10 @@ enum {
static const char *savePeriodLabels[] = { _s("Never"), _s("Every 5 mins"), _s("Every 10 mins"), _s("Every 15 mins"), _s("Every 30 mins"), nullptr };
static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 };
static const char *guiBaseLabels[] = { _s("Auto"), _s("Large"), _s("Medium"), _s("Small"), nullptr };
static const int guiBaseValues[] = { 0, 240, 480, 720, -1 };
// The keyboard mouse speed values range from 0 to 7 and correspond to speeds shown in the label
// "10" (value 3) is the default speed corresponding to the speed before introduction of this control
static const char *kbdMouseSpeedLabels[] = { "3", "5", "8", "10", "13", "15", "18", "20", nullptr };
@ -1704,6 +1708,8 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
_pluginsPathClearButton = nullptr;
#endif
_curTheme = nullptr;
_guiBasePopUpDesc = nullptr;
_guiBasePopUp = nullptr;
_rendererPopUpDesc = nullptr;
_rendererPopUp = nullptr;
_autosavePeriodPopUpDesc = nullptr;
@ -1982,8 +1988,15 @@ void GlobalOptionsDialog::build() {
#endif
// Misc Tab
_guiBasePopUp->setSelected(1);
int value = ConfMan.getInt("gui_base");
for (int i = 0; guiBaseLabels[i]; i++) {
if (value == guiBaseValues[i])
_guiBasePopUp->setSelected(i);
}
_autosavePeriodPopUp->setSelected(1);
int value = ConfMan.getInt("autosave_period");
value = ConfMan.getInt("autosave_period");
for (int i = 0; savePeriodLabels[i]; i++) {
if (value == savePeriodValues[i])
_autosavePeriodPopUp->setSelected(i);
@ -2075,6 +2088,13 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String
_curTheme = new StaticTextWidget(boss, prefix + "CurTheme", g_gui.theme()->getThemeName());
_guiBasePopUpDesc = new StaticTextWidget(boss, prefix + "GUIBasePopupDesc", _("GUI scale:"));
_guiBasePopUp = new PopUpWidget(boss, prefix + "GUIBasePopup");
for (int i = 0; guiBaseLabels[i]; i++) {
_guiBasePopUp->appendEntry(_(guiBaseLabels[i]), guiBaseValues[i]);
}
_rendererPopUpDesc = new StaticTextWidget(boss, prefix + "RendererPopupDesc", _("GUI renderer:"));
_rendererPopUp = new PopUpWidget(boss, prefix + "RendererPopup");
@ -2343,6 +2363,11 @@ void GlobalOptionsDialog::apply() {
#endif // USE_SDL_NET
#endif // USE_CLOUD
int oldGuiBase = ConfMan.getInt("gui_base");
ConfMan.setInt("gui_base", _guiBasePopUp->getSelectedTag(), _domain);
if (oldGuiBase != _guiBasePopUp->getSelectedTag())
g_gui.computeScaleFactor();
ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
#ifdef USE_UPDATES

View File

@ -292,6 +292,8 @@ protected:
// Misc controls
//
StaticTextWidget *_curTheme;
StaticTextWidget *_guiBasePopUpDesc;
PopUpWidget *_guiBasePopUp;
StaticTextWidget *_rendererPopUpDesc;
PopUpWidget *_rendererPopUp;
StaticTextWidget *_autosavePeriodPopUpDesc;

View File

@ -1969,6 +1969,14 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='10' align='center'>"
"<widget name='GUIBasePopupDesc' "
"type='OptionsLabel' "
"/>"
"<widget name='GUIBasePopup' "
"type='PopUp' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='10' align='center'>"
"<widget name='RendererPopupDesc' "
"type='OptionsLabel' "
"/>"
@ -2023,9 +2031,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"type='Button' "
"/>"
"</layout>"
"<widget name='KeysButton' "
"type='Button' "
"/>"
"</layout>"
"</dialog>"
"<dialog name='GlobalOptions_Cloud' overlays='Dialog.GlobalOptions.TabWidget'>"
@ -2343,30 +2348,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"</dialog>"
"<dialog name='KeysDialog' overlays='Dialog.GlobalOptions' shading='dim'>"
"<layout type='vertical' padding='8,8,8,8' align='center'>"
"<widget name='Action' "
"height='Globals.Line.Height' "
"/>"
"<widget name='List'/>"
"<widget name='Mapping' "
"height='Globals.Line.Height' "
"/>"
"<space size='Globals.Line.Height'/>"
"<layout type='horizontal'>"
"<widget name='Map' "
"type='Button' "
"/>"
"<space/>"
"<widget name='Cancel' "
"type='Button' "
"/>"
"<widget name='Ok' "
"type='Button' "
"/>"
"</layout>"
"</layout>"
"</dialog>"
"<dialog name='GameOptions' overlays='Dialog.Launcher.GameList' shading='dim'>"
"<layout type='vertical' padding='0,0,0,0'>"
"<widget name='TabWidget' type='TabWidget'/>"
@ -2582,10 +2563,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"<layout type='horizontal' padding='16,16,16,16'>"
"<space />"
"<widget name='Keys' "
"type='Button' "
"/>"
"<space />"
"<widget name='Cancel' "
"type='Button' "
"/>"
@ -3820,6 +3797,16 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
"<widget name='GUIBasePopupDesc' "
"width='80' "
"height='Globals.Line.Height' "
"textalign='end' "
"/>"
"<widget name='GUIBasePopup' "
"type='PopUp' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
"<widget name='RendererPopupDesc' "
"width='80' "
"height='Globals.Line.Height' "
@ -3882,9 +3869,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"type='Button' "
"/>"
"</layout>"
"<widget name='KeysButton' "
"type='Button' "
"/>"
"</layout>"
"</dialog>"
"<dialog name='GlobalOptions_Cloud' overlays='Dialog.GlobalOptions.TabWidget'>"
@ -4200,30 +4184,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"</dialog>"
"<dialog name='KeysDialog' overlays='Dialog.GlobalOptions' shading='dim'>"
"<layout type='vertical' padding='8,8,8,8' align='center'>"
"<widget name='Action' "
"height='Globals.Line.Height' "
"/>"
"<widget name='List'/>"
"<widget name='Mapping' "
"height='Globals.Line.Height' "
"/>"
"<space size='Globals.Line.Height'/>"
"<layout type='horizontal'>"
"<widget name='Map' "
"type='Button' "
"/>"
"<space/>"
"<widget name='Cancel' "
"type='Button' "
"/>"
"<widget name='Ok' "
"type='Button' "
"/>"
"</layout>"
"</layout>"
"</dialog>"
"<dialog name='GameOptions' overlays='screen' inset='16' shading='dim'>"
"<layout type='vertical' padding='0,0,0,0' spacing='16'>"
"<widget name='TabWidget' type='TabWidget'/>"
@ -4449,10 +4409,6 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"<layout type='horizontal' padding='8,8,0,8'>"
"<space />"
"<widget name='Keys' "
"type='Button' "
"/>"
"<space />"
"<widget name='Cancel' "
"type='Button' "
"/>"

Binary file not shown.

View File

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

View File

@ -620,6 +620,14 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'GUIBasePopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'RendererPopupDesc'
type = 'OptionsLabel'

View File

@ -601,6 +601,16 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'GUIBasePopupDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'end'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'RendererPopupDesc'
width = '80'

Binary file not shown.

View File

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

View File

@ -606,6 +606,14 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'GUIBasePopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'RendererPopupDesc'
type = 'OptionsLabel'

View File

@ -601,6 +601,16 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'GUIBasePopupDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'end'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'RendererPopupDesc'
width = '80'

Binary file not shown.

View File

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

View File

@ -601,6 +601,16 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'GUIBasePopupDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'end'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'RendererPopupDesc'
width = '80'

Binary file not shown.

View File

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

View File

@ -620,6 +620,14 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'GUIBasePopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'RendererPopupDesc'
type = 'OptionsLabel'

View File

@ -601,6 +601,16 @@
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'GUIBasePopupDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'end'
/>
<widget name = 'GUIBasePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
<widget name = 'RendererPopupDesc'
width = '80'