mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Enable auto-detection of UI scaling
This commit is contained in:
@@ -93,6 +93,22 @@ Point ScreenHandler::getPreferredLogicalResolution() const
|
||||
auto [minimalScaling, maximalScaling] = getSupportedScalingRange();
|
||||
|
||||
int userScaling = settings["video"]["resolution"]["scaling"].Integer();
|
||||
|
||||
if (userScaling == 0) // autodetection
|
||||
{
|
||||
#ifdef VCMI_MOBILE
|
||||
// for mobiles - stay at maximum scaling unless we have large screen
|
||||
// might be better to check screen DPI / physical dimensions, but way more complex, and may result in different edge cases, e.g. chromebooks / tv's
|
||||
int preferredMinimalScaling = 200;
|
||||
#else
|
||||
// for PC - avoid downscaling if possible
|
||||
int preferredMinimalScaling = 100;
|
||||
#endif
|
||||
// prefer a little below maximum - to give space for extended UI
|
||||
int preferredMaximalScaling = maximalScaling * 10 / 12;
|
||||
userScaling = std::max(std::min(maximalScaling, preferredMinimalScaling), preferredMaximalScaling);
|
||||
}
|
||||
|
||||
int scaling = std::clamp(userScaling, minimalScaling, maximalScaling);
|
||||
|
||||
Point logicalResolution = availableResolution * 100.0 / scaling;
|
||||
|
||||
@@ -195,17 +195,14 @@
|
||||
"additionalProperties" : false,
|
||||
"required" : [ "width", "height", "scaling" ],
|
||||
"properties" : {
|
||||
"width" : { "type" : "number" },
|
||||
"height" : { "type" : "number" },
|
||||
"scaling" : { "type" : "number" }
|
||||
},
|
||||
"defaultIOS" : {"width" : 800, "height" : 600, "scaling" : 200 },
|
||||
"defaultAndroid" : {"width" : 800, "height" : 600, "scaling" : 200 },
|
||||
"default" : {"width" : 800, "height" : 600, "scaling" : 100 }
|
||||
"width" : { "type" : "number", "default" : 800 },
|
||||
"height" : { "type" : "number", "default" : 600 },
|
||||
"scaling" : { "type" : "number", "default" : 0 }
|
||||
}
|
||||
},
|
||||
"reservedWidth" : {
|
||||
"type" : "number",
|
||||
"defaultIOS" : 0.1, // iOS camera cutout / notch is excluded from available area by SDL
|
||||
"defaultIOS" : 0.1, // iOS camera cutout / notch is not excluded from available area by SDL, handle it this way
|
||||
"default" : 0
|
||||
},
|
||||
"fullscreen" : {
|
||||
|
||||
Reference in New Issue
Block a user