mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 17:17:31 -04:00
hide special button during onboarding
This commit is contained in:
parent
ca10a8482d
commit
cd7168527f
5 changed files with 39 additions and 4 deletions
|
@ -2,32 +2,45 @@ extends Control
|
|||
class_name BookmarkUI
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
@export var ui_events: UiEvents
|
||||
@export var icon: TextureRect
|
||||
@export var title: Label
|
||||
@export var button: Button
|
||||
@export var button_special: Button
|
||||
|
||||
var url: String
|
||||
var is_special: bool
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
button.pressed.connect(on_pressed)
|
||||
button_special.pressed.connect(on_pressed)
|
||||
ui_events.onboarding_started.connect(update_button_type)
|
||||
ui_events.onboarding_finished.connect(update_button_type)
|
||||
|
||||
|
||||
func fill(gate: Gate) -> void:
|
||||
if gate == null: return
|
||||
|
||||
button.visible = not gate.is_special
|
||||
button_special.visible = gate.is_special
|
||||
|
||||
url = gate.url
|
||||
is_special = gate.is_special
|
||||
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
||||
update_button_type()
|
||||
|
||||
var icon_path = gate.icon
|
||||
if icon_path.is_empty(): icon_path = await FileDownloader.download(gate.icon_url)
|
||||
|
||||
icon.texture = FileTools.load_external_tex(icon_path)
|
||||
|
||||
|
||||
|
||||
func update_button_type() -> void:
|
||||
if ui_events.is_onboarding_started:
|
||||
button.visible = true
|
||||
button_special.visible = false
|
||||
else:
|
||||
button.visible = not is_special
|
||||
button_special.visible = is_special
|
||||
|
||||
|
||||
func on_pressed() -> void:
|
||||
|
|
|
@ -7,6 +7,7 @@ const INITIAL_DELAY = 1.0
|
|||
const SHOWN = Color(1, 1, 1, 1)
|
||||
const HIDDEN = Color(1, 1, 1, 0)
|
||||
|
||||
@export var ui_events: UiEvents
|
||||
@export var root: Control
|
||||
@export var close: Button
|
||||
@export var fade_in: float = 0.2
|
||||
|
@ -32,6 +33,8 @@ func try_show_onboarding() -> void:
|
|||
var is_shown = DataSaver.get_value(SECTION, KEY, false)
|
||||
if is_shown and not show_always: return
|
||||
|
||||
ui_events.onboarding_started_emit()
|
||||
|
||||
await get_tree().create_timer(INITIAL_DELAY).timeout
|
||||
show_onboarding()
|
||||
|
||||
|
@ -58,3 +61,5 @@ func hide_onboarding() -> void:
|
|||
|
||||
DataSaver.set_value(SECTION, KEY, true)
|
||||
DataSaver.save_data()
|
||||
|
||||
ui_events.onboarding_finished_emit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue