2019-12-21 20:42:19 +10:30
|
|
|
extends Viewport
|
|
|
|
|
2024-03-23 19:41:34 +10:30
|
|
|
onready var square := $'%square'
|
2024-03-22 21:27:13 +10:30
|
|
|
onready var root := $'/root'
|
2021-01-29 22:11:14 +10:30
|
|
|
onready var base_height = 1080.0
|
2020-12-23 00:02:30 +10:30
|
|
|
|
2021-01-29 22:11:14 +10:30
|
|
|
var container_size := Vector2(1080, 1080)
|
|
|
|
var scale := Vector2(1, 1)
|
2019-12-21 20:42:19 +10:30
|
|
|
func set_render_scale(scale: Vector2):
|
2021-01-29 22:11:14 +10:30
|
|
|
self.scale = scale
|
|
|
|
size = container_size * scale
|
2019-12-21 20:42:19 +10:30
|
|
|
$Center.position = size * 0.5
|
2021-01-01 23:51:41 +10:30
|
|
|
$Center.scale = size/base_height
|
2019-12-21 20:42:19 +10:30
|
|
|
|
2021-09-19 19:07:13 +09:30
|
|
|
func update_size() -> void:
|
2024-03-22 21:27:13 +10:30
|
|
|
var winscale = min(root.size.x, root.size.y)/base_height
|
|
|
|
container_size = square.rect_size * winscale
|
2021-01-29 22:11:14 +10:30
|
|
|
set_render_scale(scale)
|
2021-09-19 19:07:13 +09:30
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
Settings.connect('subsampling_changed', self, 'set_render_scale')
|
2024-03-22 21:27:13 +10:30
|
|
|
square.connect('item_rect_changed', self, 'update_size')
|
|
|
|
root.connect('size_changed', self, 'update_size')
|
2021-09-19 19:07:13 +09:30
|
|
|
scale = Settings.subsampling
|
|
|
|
update_size()
|