Переглянути джерело

feat: add option auto_scaling_rate

LanzaSchneider 1 рік тому
батько
коміт
7e2f5d3e4d
1 змінених файлів з 15 додано та 2 видалено
  1. 15 2
      components/ui/integer_scaling_control.gd

+ 15 - 2
components/ui/integer_scaling_control.gd

@@ -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)