mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
68 lines
1.3 KiB
GDScript
68 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
@export var gate_events: GateEvents
|
|
@export var bookmarks: Bookmarks
|
|
|
|
@export var star: Control
|
|
@export var unstar: Control
|
|
|
|
var gate: Gate
|
|
var url: String
|
|
|
|
|
|
func _ready() -> void:
|
|
star.visible = false
|
|
unstar.visible = false
|
|
|
|
gate_events.open_gate.connect(show_buttons)
|
|
gate_events.open_gate.connect(update_gate_order)
|
|
gate_events.search.connect(func(_query): hide_buttons())
|
|
gate_events.exit_gate.connect(hide_buttons)
|
|
gate_events.gate_info_loaded.connect(update_info)
|
|
gate_events.gate_icon_loaded.connect(update_info)
|
|
gate_events.gate_image_loaded.connect(update_info)
|
|
|
|
|
|
func show_buttons(_url: String) -> void:
|
|
url = _url
|
|
if bookmarks.gates.has(url):
|
|
star.visible = false
|
|
unstar.visible = true
|
|
else:
|
|
star.visible = true
|
|
unstar.visible = false
|
|
|
|
|
|
func hide_buttons() -> void:
|
|
star.visible = false
|
|
unstar.visible = false
|
|
gate = null
|
|
|
|
|
|
func update_gate_order(_url: String) -> void:
|
|
bookmarks.make_first(_url)
|
|
|
|
|
|
func update_info(_gate: Gate) -> void:
|
|
gate = _gate
|
|
bookmarks.update(gate)
|
|
|
|
|
|
func _on_star_pressed() -> void:
|
|
if gate == null:
|
|
gate = Gate.new()
|
|
gate.url = url
|
|
|
|
bookmarks.star(gate)
|
|
star.visible = false
|
|
unstar.visible = true
|
|
|
|
|
|
func _on_unstar_pressed() -> void:
|
|
if gate == null:
|
|
gate = Gate.new()
|
|
gate.url = url
|
|
|
|
bookmarks.unstar(gate)
|
|
star.visible = true
|
|
unstar.visible = false
|