mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 17:17:31 -04:00
ui events
This commit is contained in:
parent
00e6c3070a
commit
1d31e6e0a9
5 changed files with 32 additions and 2 deletions
6
project/the_gates/resources/ui_events.tres
Normal file
6
project/the_gates/resources/ui_events.tres
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_resource type="Resource" script_class="UiEvents" load_steps=2 format=3 uid="uid://h1gdyodd66gv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://the_gates/scripts/resources/ui_events.gd" id="1_kqets"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_kqets")
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=32 format=3 uid="uid://dagj0celx6tjq"]
|
[gd_scene load_steps=33 format=3 uid="uid://dagj0celx6tjq"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://the_gates/scripts/loading/pack_loader.gd" id="1_5swiq"]
|
[ext_resource type="Script" path="res://the_gates/scripts/loading/pack_loader.gd" id="1_5swiq"]
|
||||||
[ext_resource type="Script" path="res://the_gates/scripts/loading/gate_loader.gd" id="1_coscx"]
|
[ext_resource type="Script" path="res://the_gates/scripts/loading/gate_loader.gd" id="1_coscx"]
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/loading_ui.gd" id="5_vcmvs"]
|
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/loading_ui.gd" id="5_vcmvs"]
|
||||||
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/gate_info.gd" id="6_iwanm"]
|
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/gate_info.gd" id="6_iwanm"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bvvgx8ij2mdna" path="res://the_gates/textures/star.png" id="6_mtwek"]
|
[ext_resource type="Texture2D" uid="uid://bvvgx8ij2mdna" path="res://the_gates/textures/star.png" id="6_mtwek"]
|
||||||
|
[ext_resource type="Resource" uid="uid://h1gdyodd66gv" path="res://the_gates/resources/ui_events.tres" id="7_bmkgi"]
|
||||||
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/home.gd" id="8_bo3qr"]
|
[ext_resource type="Script" path="res://the_gates/scripts/ui/world/home.gd" id="8_bo3qr"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c5hu6cmvuipg7" path="res://the_gates/textures/star_filled.png" id="8_gho7k"]
|
[ext_resource type="Texture2D" uid="uid://c5hu6cmvuipg7" path="res://the_gates/textures/star_filled.png" id="8_gho7k"]
|
||||||
[ext_resource type="Resource" uid="uid://bewhdj6jugt6q" path="res://the_gates/resources/bookmarks.tres" id="8_wox3p"]
|
[ext_resource type="Resource" uid="uid://bewhdj6jugt6q" path="res://the_gates/resources/bookmarks.tres" id="8_wox3p"]
|
||||||
|
@ -167,6 +168,7 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("4_xatjs")
|
script = ExtResource("4_xatjs")
|
||||||
|
ui_events = ExtResource("7_bmkgi")
|
||||||
|
|
||||||
[node name="Blur" type="Panel" parent="UICanvas/UI"]
|
[node name="Blur" type="Panel" parent="UICanvas/UI"]
|
||||||
material = SubResource("ShaderMaterial_kc7rv")
|
material = SubResource("ShaderMaterial_kc7rv")
|
||||||
|
@ -721,6 +723,7 @@ grow_vertical = 2
|
||||||
[node name="InputSync" type="Node" parent="WorldCanvas"]
|
[node name="InputSync" type="Node" parent="WorldCanvas"]
|
||||||
script = ExtResource("18_rsdyb")
|
script = ExtResource("18_rsdyb")
|
||||||
gate_events = ExtResource("2_ot8b0")
|
gate_events = ExtResource("2_ot8b0")
|
||||||
|
ui_events = ExtResource("7_bmkgi")
|
||||||
|
|
||||||
[connection signal="pressed" from="UICanvas/UI/Blur/HideOnPress" to="UICanvas/UI" method="hide_ui"]
|
[connection signal="pressed" from="UICanvas/UI/Blur/HideOnPress" to="UICanvas/UI" method="hide_ui"]
|
||||||
[connection signal="pressed" from="UICanvas/UI/GateInfo/Bookmark/Star" to="UICanvas/UI/GateInfo" method="_on_star_pressed"]
|
[connection signal="pressed" from="UICanvas/UI/GateInfo/Bookmark/Star" to="UICanvas/UI/GateInfo" method="_on_star_pressed"]
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
|
@export var ui_events: UiEvents
|
||||||
|
|
||||||
var input_sync: InputSync
|
var input_sync: InputSync
|
||||||
|
var should_send := true
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
gate_events.gate_entered.connect(start_server)
|
gate_events.gate_entered.connect(start_server)
|
||||||
|
ui_events.visibility_changed.connect(on_ui_visibility_changed)
|
||||||
|
|
||||||
|
|
||||||
func start_server() -> void:
|
func start_server() -> void:
|
||||||
|
@ -13,6 +16,10 @@ func start_server() -> void:
|
||||||
input_sync.bind()
|
input_sync.bind()
|
||||||
|
|
||||||
|
|
||||||
|
func on_ui_visibility_changed(visible: bool) -> void:
|
||||||
|
should_send = not visible
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if input_sync == null: return
|
if input_sync == null or not should_send: return
|
||||||
input_sync.send_input_event(event)
|
input_sync.send_input_event(event)
|
||||||
|
|
8
project/the_gates/scripts/resources/ui_events.gd
Normal file
8
project/the_gates/scripts/resources/ui_events.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Resource
|
||||||
|
class_name UiEvents
|
||||||
|
|
||||||
|
signal visibility_changed(visible: bool)
|
||||||
|
|
||||||
|
|
||||||
|
func visibility_changed_emit(visible: bool) -> void:
|
||||||
|
visibility_changed.emit(visible)
|
|
@ -1,5 +1,7 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
@export var ui_events: UiEvents
|
||||||
|
|
||||||
var mouse_mode: int = Input.MOUSE_MODE_VISIBLE
|
var mouse_mode: int = Input.MOUSE_MODE_VISIBLE
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,9 +25,13 @@ func show_ui() -> void:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
else:
|
else:
|
||||||
mouse_mode = Input.MOUSE_MODE_VISIBLE
|
mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
|
|
||||||
|
ui_events.visibility_changed_emit(true)
|
||||||
|
|
||||||
|
|
||||||
func hide_ui() -> void:
|
func hide_ui() -> void:
|
||||||
visible = false
|
visible = false
|
||||||
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
ui_events.visibility_changed_emit(false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue