Browse Source

Always show correct game resolution in settings, unaffected by scaling

Ivan Savenko 2 years ago
parent
commit
8dc009e2c9

+ 3 - 0
client/render/IScreenHandler.h

@@ -37,4 +37,7 @@ public:
 
 	/// Converts provided rect from logical coordinates into coordinates within window, accounting for scaling and viewport
 	virtual Rect convertLogicalPointsToWindow(const Rect & input) const = 0;
+
+	/// Dimensions of render output
+	virtual Point getRenderResolution() const = 0;
 };

+ 3 - 3
client/renderSDL/ScreenHandler.cpp

@@ -46,7 +46,7 @@ std::tuple<int, int> ScreenHandler::getSupportedScalingRange() const
 	// arbitrary limit on *downscaling*. Allow some downscaling, if requested by user. Should be generally limited to 100+ for all but few devices
 	static const double minimalScaling = 50;
 
-	Point renderResolution = getActualRenderResolution();
+	Point renderResolution = getRenderResolution();
 	double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
 	Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
 
@@ -85,7 +85,7 @@ Rect ScreenHandler::convertLogicalPointsToWindow(const Rect & input) const
 
 Point ScreenHandler::getPreferredLogicalResolution() const
 {
-	Point renderResolution = getActualRenderResolution();
+	Point renderResolution = getRenderResolution();
 	double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
 	Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
 
@@ -99,7 +99,7 @@ Point ScreenHandler::getPreferredLogicalResolution() const
 	return logicalResolution;
 }
 
-Point ScreenHandler::getActualRenderResolution() const
+Point ScreenHandler::getRenderResolution() const
 {
 	assert(mainRenderer != nullptr);
 

+ 3 - 3
client/renderSDL/ScreenHandler.h

@@ -39,9 +39,6 @@ class ScreenHandler final : public IScreenHandler
 	/// This value is what player views as window size
 	Point getPreferredWindowResolution() const;
 
-	/// Dimensions of render output, usually same as window size except for high-DPI screens on macOS / iOS
-	Point getActualRenderResolution() const;
-
 	EWindowMode getPreferredWindowMode() const;
 
 	/// Returns index of display on which window should be created
@@ -86,6 +83,9 @@ public:
 	/// Fills screen with black color, erasing any existing content
 	void clearScreen() final;
 
+	/// Dimensions of render output, usually same as window size except for high-DPI screens on macOS / iOS
+	Point getRenderResolution() const final;
+
 	std::vector<Point> getSupportedResolutions() const final;
 	std::vector<Point> getSupportedResolutions(int displayIndex) const;
 	std::tuple<int, int> getSupportedScalingRange() const final;

+ 8 - 14
client/windows/settings/GeneralOptionsTab.cpp

@@ -224,25 +224,19 @@ void GeneralOptionsTab::updateResolutionSelector()
 	std::shared_ptr<CButton> resolutionButton = widget<CButton>("resolutionButton");
 	std::shared_ptr<CLabel> resolutionLabel = widget<CLabel>("resolutionLabel");
 
-	if (settings["video"]["fullscreen"].Bool() && !settings["video"]["realFullscreen"].Bool())
+	if (resolutionButton)
 	{
-		if (resolutionButton)
+		if (settings["video"]["fullscreen"].Bool() && !settings["video"]["realFullscreen"].Bool())
 			resolutionButton->disable();
-
-		if (resolutionLabel)
-			resolutionLabel->setText(resolutionToLabelString(GH.screenDimensions().x, GH.screenDimensions().y));
-	}
-	else
-	{
-		const auto & currentResolution = settings["video"]["resolution"];
-
-		if (resolutionButton)
+		else
 			resolutionButton->enable();
-
-		if (resolutionLabel)
-			resolutionLabel->setText(resolutionToLabelString(currentResolution["width"].Integer(), currentResolution["height"].Integer()));
 	}
 
+	if (resolutionLabel)
+	{
+		Point resolution = GH.screenHandler().getRenderResolution();
+		resolutionLabel->setText(resolutionToLabelString(resolution.x, resolution.y));
+	}
 }
 
 void GeneralOptionsTab::selectGameResolution()