mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-18 12:16:33 -04:00
Apply screen scale (for hidpi)
This commit is contained in:
parent
b5d8a6da5a
commit
e9fcd708c3
3 changed files with 9 additions and 13 deletions
|
@ -222,7 +222,6 @@ text = "Loading..."
|
|||
label_settings = ExtResource("20_v1648")
|
||||
|
||||
[node name="WorldCanvas" type="Control" parent="."]
|
||||
custom_minimum_size = Vector2(1300, 0)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -258,7 +257,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
expand_mode = 5
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
script = ExtResource("5_nlg2s")
|
||||
gate_events = ExtResource("2_q7cvi")
|
||||
|
|
|
@ -4,8 +4,8 @@ extends Node
|
|||
@export var ui_events: UiEvents
|
||||
@export var render_result: RenderResult
|
||||
|
||||
var scale_width: float
|
||||
var scale_height: float
|
||||
var scale: float
|
||||
var offset: Vector2
|
||||
|
||||
var input_sync: InputSync
|
||||
var should_send := false
|
||||
|
@ -20,9 +20,9 @@ func start_server() -> void:
|
|||
input_sync = InputSync.new()
|
||||
input_sync.bind()
|
||||
|
||||
scale_width = float(render_result.width) / ui_events.current_ui_size.x
|
||||
scale_height = float(render_result.height) / ui_events.current_ui_size.y
|
||||
Debug.logclr("Mouse position scale: %.2fx%.2f" % [scale_width, scale_height], Color.DIM_GRAY)
|
||||
scale = DisplayServer.screen_get_scale()
|
||||
offset = render_result.global_position
|
||||
Debug.logclr("Mouse position scale: %.2f. Offset: %.2f" % [scale, offset.y], Color.DIM_GRAY)
|
||||
|
||||
|
||||
func on_ui_mode_changed(mode: UiEvents.UiMode) -> void:
|
||||
|
@ -42,10 +42,7 @@ func _input(_event: InputEvent) -> void:
|
|||
|
||||
|
||||
func get_scaled_mouse_pos(position : Vector2) -> Vector2:
|
||||
#position.x *= scale_width
|
||||
#position.y *= scale_height
|
||||
position.y -= 101
|
||||
return position
|
||||
return (position - offset) * scale
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
|
|
|
@ -5,8 +5,8 @@ class_name RenderResult
|
|||
@export var command_events: CommandEvents
|
||||
@export var ui_events: UiEvents
|
||||
|
||||
@onready var width: int = get_viewport().size.x
|
||||
@onready var height: int = get_viewport().size.y - 101
|
||||
@onready var width: int = int(size.x * DisplayServer.screen_get_scale())
|
||||
@onready var height: int = int(size.y * DisplayServer.screen_get_scale())
|
||||
|
||||
var ext_texure: ExternalTexture
|
||||
var texture_rid: RID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue