|
@@ -1,5 +1,11 @@
|
|
|
class_name IntegerScalingControl extends Control
|
|
|
|
|
|
+@export
|
|
|
+var auto_scaling_rate:bool = true
|
|
|
+
|
|
|
+@export_range(0, 65535)
|
|
|
+var fixed_scaling_rate:int = 1
|
|
|
+
|
|
|
var _origin_size: Vector2
|
|
|
|
|
|
func _ready() -> void:
|
|
@@ -11,8 +17,15 @@ func _ready() -> void:
|
|
|
func _on_screen_resized() -> void:
|
|
|
var window_size: Vector2i = get_viewport().size
|
|
|
var raw_size := Vector2(ProjectSettings["display/window/size/viewport_width"], ProjectSettings["display/window/size/viewport_height"])
|
|
|
- var possible_scale := window_size / Vector2i(raw_size)
|
|
|
- var final_scale: Vector2i = max(1, min(possible_scale.x, possible_scale.y)) * Vector2i.ONE
|
|
|
+
|
|
|
+ var final_scale: Vector2i
|
|
|
+
|
|
|
+ if auto_scaling_rate:
|
|
|
+ var possible_scale := window_size / Vector2i(raw_size)
|
|
|
+ final_scale = max(1, min(possible_scale.x, possible_scale.y)) * Vector2i.ONE
|
|
|
+ else:
|
|
|
+ final_scale = Vector2i.ONE * fixed_scaling_rate
|
|
|
+
|
|
|
scale = final_scale
|
|
|
|
|
|
var window_size_unscaled := Vector2(window_size.x / final_scale.x, window_size.y / final_scale.y)
|