mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 11:04:44 +00:00
GUI: Handle the GUI Scale option as a scaling rather than base resolution
Now that we can get an accurate HiDPI screen scaling from OSystem, defaulting to using that seems to make sense. But we may still want to use a slightly different scaling. The GUI scale option allows that by providing a scaling (in percentage) with which to multiply the HiDPI scaling. I think it works better than a base resolution as it avoids having the GUI getting bigger or smaller when we resize the window. This commit keeps a popup widget, but this could be changed with a slider if we want more fine grain control.
This commit is contained in:
parent
abf782c670
commit
ad31dfc8d5
@ -109,33 +109,12 @@ GuiManager::~GuiManager() {
|
||||
void GuiManager::computeScaleFactor() {
|
||||
uint16 w = g_system->getOverlayWidth();
|
||||
uint16 h = g_system->getOverlayHeight();
|
||||
float scale = g_system->getHiDPIScreenFactor();
|
||||
|
||||
_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;
|
||||
_scaleFactor = g_system->getHiDPIScreenFactor();
|
||||
if (ConfMan.hasKey("gui_scale"))
|
||||
_scaleFactor *= ConfMan.getInt("gui_scale") / 100.f;
|
||||
|
||||
_baseHeight = (int16)((float)h / _scaleFactor);
|
||||
_baseWidth = (int16)((float)w / _scaleFactor);
|
||||
|
||||
if (_theme)
|
||||
|
@ -134,8 +134,8 @@ static const char *savePeriodLabels[] = { _s("Never"), _s("Every 5 mins"), _s("E
|
||||
static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 };
|
||||
|
||||
static const char *guiBaseLabels[] = {
|
||||
// I18N: Automatic GUI scaling
|
||||
_s("Auto"),
|
||||
// I18N: Very large GUI scale
|
||||
_s("Very large"),
|
||||
// I18N: Large GUI scale
|
||||
_s("Large"),
|
||||
// I18N: Medium GUI scale
|
||||
@ -144,7 +144,7 @@ static const char *guiBaseLabels[] = {
|
||||
_s("Small"),
|
||||
nullptr
|
||||
};
|
||||
static const int guiBaseValues[] = { 0, 240, 480, 720, -1 };
|
||||
static const int guiBaseValues[] = { 150, 125, 100, 75, -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
|
||||
@ -2134,8 +2134,8 @@ void GlobalOptionsDialog::build() {
|
||||
#endif
|
||||
|
||||
// Misc Tab
|
||||
_guiBasePopUp->setSelected(1);
|
||||
int value = ConfMan.getInt("gui_base");
|
||||
_guiBasePopUp->setSelected(2);
|
||||
int value = ConfMan.getInt("gui_scale");
|
||||
for (int i = 0; guiBaseLabels[i]; i++) {
|
||||
if (value == guiBaseValues[i])
|
||||
_guiBasePopUp->setSelected(i);
|
||||
@ -2517,9 +2517,9 @@ 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 != (int)_guiBasePopUp->getSelectedTag())
|
||||
int oldGuiScale = ConfMan.getInt("gui_scale");
|
||||
ConfMan.setInt("gui_scale", _guiBasePopUp->getSelectedTag(), _domain);
|
||||
if (oldGuiScale != (int)_guiBasePopUp->getSelectedTag())
|
||||
g_gui.computeScaleFactor();
|
||||
|
||||
ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
|
||||
|
Loading…
x
Reference in New Issue
Block a user