mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-09-06 23:27:51 -04:00
40 lines
1.1 KiB
GDScript
40 lines
1.1 KiB
GDScript
extends Control
|
|
|
|
@export var gate_events: GateEvents
|
|
@export var search_line_edit: LineEdit
|
|
|
|
@export var search: Control
|
|
@export var downloading: Control
|
|
@export var success: Control
|
|
@export var error: Control
|
|
|
|
@export var white: Color
|
|
@export var gray: Color
|
|
|
|
|
|
func _ready() -> void:
|
|
search_line_edit.text_changed.connect(func(_text): switch_to(search))
|
|
gate_events.search.connect(func(_url): switch_to(search))
|
|
gate_events.exit_gate.connect(func(): switch_to(search))
|
|
gate_events.open_gate.connect(func(_url): switch_to(downloading))
|
|
gate_events.gate_entered.connect(func(): switch_to(success))
|
|
gate_events.gate_error.connect(func(_code): switch_to(error))
|
|
|
|
switch_to(search)
|
|
|
|
|
|
func switch_to(_state: Control) -> void:
|
|
disable([search, downloading, success, error])
|
|
_state.visible = true
|
|
_state.process_mode = Node.PROCESS_MODE_INHERIT
|
|
change_color.call_deferred()
|
|
|
|
|
|
func change_color() -> void:
|
|
modulate = gray if search_line_edit.text.is_empty() else white
|
|
|
|
|
|
func disable(states: Array[Control]) -> void:
|
|
for state in states:
|
|
state.visible = false
|
|
state.process_mode = Node.PROCESS_MODE_DISABLED
|