mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-22 23:17:26 -04:00
fix mouse position scaling
This commit is contained in:
parent
8c726d4033
commit
7ab7255140
10 changed files with 40 additions and 18 deletions
|
@ -14,8 +14,8 @@
|
|||
[ext_resource type="Texture2D" uid="uid://btn6ytky782a2" path="res://textures/star.svg" id="8_b00p6"]
|
||||
[ext_resource type="Texture2D" uid="uid://lxx36xkotvh1" path="res://textures/star_filled.svg" id="9_2en0l"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/search/prompt_results.gd" id="14_0lofv"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/top_level.gd" id="14_5k27g"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/search/prompt_navigation.gd" id="14_h86vl"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/search/fix_promt_position.gd" id="15_35wcy"]
|
||||
[ext_resource type="Resource" uid="uid://cjcdum6fm4ta0" path="res://resources/api_settings.tres" id="15_uafyh"]
|
||||
[ext_resource type="PackedScene" uid="uid://b57n6cvtqn5b7" path="res://scenes/components/prompt.tscn" id="16_lbcsd"]
|
||||
|
||||
|
@ -432,7 +432,7 @@ offset_right = 500.0
|
|||
offset_bottom = 860.0
|
||||
grow_horizontal = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mh73y")
|
||||
script = ExtResource("14_5k27g")
|
||||
script = ExtResource("15_35wcy")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Prompt/Panel" node_paths=PackedStringArray("panel")]
|
||||
layout_mode = 1
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=18 format=3 uid="uid://5btb7nvgmfhl"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://5btb7nvgmfhl"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/ui/menu/menu_navigation.gd" id="1_7anvm"]
|
||||
[ext_resource type="Texture2D" uid="uid://8wvea7j0v0rx" path="res://textures/Reload.svg" id="1_d6dhb"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/menu/menu.gd" id="1_o6vga"]
|
||||
[ext_resource type="Texture2D" uid="uid://byvigfpu44dnu" path="res://textures/arrow.svg" id="1_wkgtd"]
|
||||
[ext_resource type="Texture2D" uid="uid://dystd8vvbqwo2" path="res://textures/exit.svg" id="3_1a6fk"]
|
||||
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="3_m632k"]
|
||||
|
@ -153,6 +154,8 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_o6vga")
|
||||
ui_events = ExtResource("8_8dnbq")
|
||||
|
||||
[node name="Background" type="Panel" parent="."]
|
||||
layout_mode = 0
|
||||
|
|
|
@ -305,6 +305,7 @@ custom_minimum_size = Vector2(1300, 0)
|
|||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
script = ExtResource("9_ncfxj")
|
||||
ui_events = ExtResource("9_ir58h")
|
||||
|
||||
[node name="RenderResult" type="TextureRect" parent="HBoxContainer/WorldCanvas"]
|
||||
layout_mode = 1
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
extends Resource
|
||||
class_name UiEvents
|
||||
|
||||
signal visibility_changed(visible: bool)
|
||||
signal ui_visibility_changed(visible: bool)
|
||||
signal ui_size_changed(size: Vector2)
|
||||
|
||||
var current_ui_size: Vector2
|
||||
|
||||
|
||||
func visibility_changed_emit(visible: bool) -> void:
|
||||
visibility_changed.emit(visible)
|
||||
func ui_visibility_changed_emit(visible: bool) -> void:
|
||||
ui_visibility_changed.emit(visible)
|
||||
|
||||
|
||||
func ui_size_changed_emit(size: Vector2) -> void:
|
||||
current_ui_size = size
|
||||
ui_size_changed.emit(size)
|
||||
|
|
|
@ -13,13 +13,10 @@ var should_send := false
|
|||
|
||||
func _ready() -> void:
|
||||
gate_events.gate_entered.connect(start_server)
|
||||
ui_events.visibility_changed.connect(on_ui_visibility_changed)
|
||||
ui_events.ui_visibility_changed.connect(on_ui_visibility_changed)
|
||||
|
||||
# Scale mouse position for resolutions other than 1920x1080
|
||||
var viewport_width = ProjectSettings.get_setting("display/window/size/viewport_width", 1152)
|
||||
var viewport_height = ProjectSettings.get_setting("display/window/size/viewport_height", 648)
|
||||
scale_width = float(render_result.width) / viewport_width
|
||||
scale_height = float(render_result.height) / viewport_height
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ var fullscreen := false
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
ui_events.visibility_changed.connect(on_visibility_changed)
|
||||
gate_events.open_gate.connect(func(_url): on_visibility_changed(true))
|
||||
ui_events.ui_visibility_changed.connect(on_ui_visibility_changed)
|
||||
gate_events.open_gate.connect(func(_url): on_ui_visibility_changed(true))
|
||||
|
||||
|
||||
func on_visibility_changed(visible: bool) -> void:
|
||||
func on_ui_visibility_changed(visible: bool) -> void:
|
||||
if visible and fullscreen:
|
||||
fullscreen = false
|
||||
play(INITIAL)
|
||||
|
|
12
project/scripts/ui/menu/menu.gd
Normal file
12
project/scripts/ui/menu/menu.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Control
|
||||
|
||||
@export var ui_events: UiEvents
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
resized.connect(on_resized)
|
||||
on_resized()
|
||||
|
||||
|
||||
func on_resized() -> void:
|
||||
ui_events.ui_size_changed_emit(size)
|
|
@ -1,5 +1,6 @@
|
|||
extends Control
|
||||
|
||||
@export var ui_events: UiEvents
|
||||
@export var interpolate: float:
|
||||
set(value):
|
||||
interpolate = value
|
||||
|
@ -13,7 +14,7 @@ func _ready() -> void:
|
|||
var viewport_width = ProjectSettings.get_setting("display/window/size/viewport_width", 1152)
|
||||
var scale_width = float(custom_minimum_size.x) / viewport_width
|
||||
|
||||
full_screen = int(get_parent_control().size.x)
|
||||
full_screen = int(ui_events.current_ui_size.x)
|
||||
initial = int(full_screen * scale_width)
|
||||
custom_minimum_size.x = initial
|
||||
Debug.logclr("WorldCanvas initial: %d full_screen: %d" % [initial, full_screen], Color.DIM_GRAY)
|
||||
|
|
|
@ -31,7 +31,7 @@ func show_ui() -> void:
|
|||
_visible = true
|
||||
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
ui_events.visibility_changed_emit(true)
|
||||
ui_events.ui_visibility_changed_emit(true)
|
||||
|
||||
|
||||
func hide_ui() -> void:
|
||||
|
@ -39,4 +39,4 @@ func hide_ui() -> void:
|
|||
_visible = false
|
||||
|
||||
Input.set_mouse_mode(mouse_mode)
|
||||
ui_events.visibility_changed_emit(false)
|
||||
ui_events.ui_visibility_changed_emit(false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue