mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Fix handling of autoselected interface scaling by client
This commit is contained in:
@@ -44,6 +44,8 @@ public:
|
||||
/// Dimensions of logical output. Can be different if scaling is used
|
||||
virtual Point getLogicalResolution() const = 0;
|
||||
|
||||
virtual int getInterfaceScalingPercentage() const = 0;
|
||||
|
||||
virtual int getScalingFactor() const = 0;
|
||||
|
||||
/// Window has focus
|
||||
|
||||
@@ -48,7 +48,7 @@ void CursorHardware::setVisible(bool on)
|
||||
|
||||
void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
|
||||
{
|
||||
int videoScalingSettings = settings["video"]["resolution"]["scaling"].Integer();
|
||||
int videoScalingSettings = GH.screenHandler().getInterfaceScalingPercentage();
|
||||
float cursorScalingSettings = settings["video"]["cursorScalingFactor"].Float();
|
||||
int cursorScalingPercent = videoScalingSettings * cursorScalingSettings;
|
||||
Point cursorDimensions = image->dimensions() * GH.screenHandler().getScalingFactor();
|
||||
|
||||
@@ -84,12 +84,8 @@ Rect ScreenHandler::convertLogicalPointsToWindow(const Rect & input) const
|
||||
return result;
|
||||
}
|
||||
|
||||
Point ScreenHandler::getPreferredLogicalResolution() const
|
||||
int ScreenHandler::getInterfaceScalingPercentage() const
|
||||
{
|
||||
Point renderResolution = getRenderResolution();
|
||||
double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
|
||||
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
||||
|
||||
auto [minimalScaling, maximalScaling] = getSupportedScalingRange();
|
||||
|
||||
int userScaling = settings["video"]["resolution"]["scaling"].Integer();
|
||||
@@ -110,9 +106,17 @@ Point ScreenHandler::getPreferredLogicalResolution() const
|
||||
}
|
||||
|
||||
int scaling = std::clamp(userScaling, minimalScaling, maximalScaling);
|
||||
return scaling;
|
||||
}
|
||||
|
||||
Point ScreenHandler::getPreferredLogicalResolution() const
|
||||
{
|
||||
Point renderResolution = getRenderResolution();
|
||||
double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
|
||||
|
||||
int scaling = getInterfaceScalingPercentage();
|
||||
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
||||
Point logicalResolution = availableResolution * 100.0 / scaling;
|
||||
|
||||
return logicalResolution;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,8 @@ public:
|
||||
|
||||
int getScalingFactor() const final;
|
||||
|
||||
int getInterfaceScalingPercentage() const final;
|
||||
|
||||
std::vector<Point> getSupportedResolutions() const final;
|
||||
std::vector<Point> getSupportedResolutions(int displayIndex) const;
|
||||
std::tuple<int, int> getSupportedScalingRange() const final;
|
||||
|
||||
@@ -194,10 +194,8 @@ GeneralOptionsTab::GeneralOptionsTab()
|
||||
|
||||
build(config);
|
||||
|
||||
const auto & currentResolution = settings["video"]["resolution"];
|
||||
|
||||
std::shared_ptr<CLabel> scalingLabel = widget<CLabel>("scalingLabel");
|
||||
scalingLabel->setText(scalingToLabelString(currentResolution["scaling"].Integer()));
|
||||
scalingLabel->setText(scalingToLabelString(GH.screenHandler().getInterfaceScalingPercentage()));
|
||||
|
||||
std::shared_ptr<CLabel> longTouchLabel = widget<CLabel>("longTouchLabel");
|
||||
if (longTouchLabel)
|
||||
|
||||
Reference in New Issue
Block a user