mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -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
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=10 format=3 uid="uid://82ca8so31njy"]
|
[gd_scene load_steps=11 format=3 uid="uid://82ca8so31njy"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ui/menu/bookmark_ui.gd" id="1_bpkqj"]
|
[ext_resource type="Script" path="res://scripts/ui/menu/bookmark_ui.gd" id="1_bpkqj"]
|
||||||
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_7i5yr"]
|
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_7i5yr"]
|
||||||
|
[ext_resource type="Resource" uid="uid://crjhix0osmtnf" path="res://resources/ui_events.res" id="3_sp6jv"]
|
||||||
[ext_resource type="StyleBox" uid="uid://bllkg32sc4iam" path="res://assets/styles/panel.stylebox" id="3_tb1mf"]
|
[ext_resource type="StyleBox" uid="uid://bllkg32sc4iam" path="res://assets/styles/panel.stylebox" id="3_tb1mf"]
|
||||||
[ext_resource type="StyleBox" uid="uid://bmxiecm3vkddl" path="res://assets/styles/panel_hover.stylebox" id="4_figib"]
|
[ext_resource type="StyleBox" uid="uid://bmxiecm3vkddl" path="res://assets/styles/panel_hover.stylebox" id="4_figib"]
|
||||||
[ext_resource type="LabelSettings" uid="uid://85ms8ndcmbn0" path="res://assets/styles/text_small.tres" id="4_xqjm8"]
|
[ext_resource type="LabelSettings" uid="uid://85ms8ndcmbn0" path="res://assets/styles/text_small.tres" id="4_xqjm8"]
|
||||||
|
@ -40,6 +41,7 @@ offset_right = 180.0
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
script = ExtResource("1_bpkqj")
|
script = ExtResource("1_bpkqj")
|
||||||
gate_events = ExtResource("2_7i5yr")
|
gate_events = ExtResource("2_7i5yr")
|
||||||
|
ui_events = ExtResource("3_sp6jv")
|
||||||
icon = NodePath("Mask/Icon")
|
icon = NodePath("Mask/Icon")
|
||||||
title = NodePath("Title")
|
title = NodePath("Title")
|
||||||
button = NodePath("Button")
|
button = NodePath("Button")
|
||||||
|
|
|
@ -46,6 +46,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
script = ExtResource("1_2xh2a")
|
script = ExtResource("1_2xh2a")
|
||||||
|
ui_events = ExtResource("3_jta5g")
|
||||||
root = NodePath("Root")
|
root = NodePath("Root")
|
||||||
close = NodePath("Root/Carousel/Line/Close")
|
close = NodePath("Root/Carousel/Line/Close")
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ class_name UiEvents
|
||||||
signal ui_mode_changed(mode: UiMode)
|
signal ui_mode_changed(mode: UiMode)
|
||||||
signal ui_size_changed(size: Vector2)
|
signal ui_size_changed(size: Vector2)
|
||||||
|
|
||||||
|
signal onboarding_started()
|
||||||
|
signal onboarding_finished()
|
||||||
|
|
||||||
enum UiMode
|
enum UiMode
|
||||||
{
|
{
|
||||||
INITIAL,
|
INITIAL,
|
||||||
|
@ -11,6 +14,7 @@ enum UiMode
|
||||||
}
|
}
|
||||||
|
|
||||||
var current_ui_size: Vector2
|
var current_ui_size: Vector2
|
||||||
|
var is_onboarding_started: bool = false
|
||||||
|
|
||||||
|
|
||||||
func ui_mode_changed_emit(mode: UiMode) -> void:
|
func ui_mode_changed_emit(mode: UiMode) -> void:
|
||||||
|
@ -20,3 +24,13 @@ func ui_mode_changed_emit(mode: UiMode) -> void:
|
||||||
func ui_size_changed_emit(size: Vector2) -> void:
|
func ui_size_changed_emit(size: Vector2) -> void:
|
||||||
current_ui_size = size
|
current_ui_size = size
|
||||||
ui_size_changed.emit(size)
|
ui_size_changed.emit(size)
|
||||||
|
|
||||||
|
|
||||||
|
func onboarding_started_emit() -> void:
|
||||||
|
is_onboarding_started = true
|
||||||
|
onboarding_started.emit()
|
||||||
|
|
||||||
|
|
||||||
|
func onboarding_finished_emit() -> void:
|
||||||
|
is_onboarding_started = false
|
||||||
|
onboarding_finished.emit()
|
||||||
|
|
|
@ -2,27 +2,30 @@ extends Control
|
||||||
class_name BookmarkUI
|
class_name BookmarkUI
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
|
@export var ui_events: UiEvents
|
||||||
@export var icon: TextureRect
|
@export var icon: TextureRect
|
||||||
@export var title: Label
|
@export var title: Label
|
||||||
@export var button: Button
|
@export var button: Button
|
||||||
@export var button_special: Button
|
@export var button_special: Button
|
||||||
|
|
||||||
var url: String
|
var url: String
|
||||||
|
var is_special: bool
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
button.pressed.connect(on_pressed)
|
button.pressed.connect(on_pressed)
|
||||||
button_special.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:
|
func fill(gate: Gate) -> void:
|
||||||
if gate == null: return
|
if gate == null: return
|
||||||
|
|
||||||
button.visible = not gate.is_special
|
|
||||||
button_special.visible = gate.is_special
|
|
||||||
|
|
||||||
url = gate.url
|
url = gate.url
|
||||||
|
is_special = gate.is_special
|
||||||
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
||||||
|
update_button_type()
|
||||||
|
|
||||||
var icon_path = gate.icon
|
var icon_path = gate.icon
|
||||||
if icon_path.is_empty(): icon_path = await FileDownloader.download(gate.icon_url)
|
if icon_path.is_empty(): icon_path = await FileDownloader.download(gate.icon_url)
|
||||||
|
@ -30,6 +33,16 @@ func fill(gate: Gate) -> void:
|
||||||
icon.texture = FileTools.load_external_tex(icon_path)
|
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:
|
func on_pressed() -> void:
|
||||||
if url.is_empty(): return
|
if url.is_empty(): return
|
||||||
gate_events.open_gate_emit(url)
|
gate_events.open_gate_emit(url)
|
||||||
|
|
|
@ -7,6 +7,7 @@ const INITIAL_DELAY = 1.0
|
||||||
const SHOWN = Color(1, 1, 1, 1)
|
const SHOWN = Color(1, 1, 1, 1)
|
||||||
const HIDDEN = Color(1, 1, 1, 0)
|
const HIDDEN = Color(1, 1, 1, 0)
|
||||||
|
|
||||||
|
@export var ui_events: UiEvents
|
||||||
@export var root: Control
|
@export var root: Control
|
||||||
@export var close: Button
|
@export var close: Button
|
||||||
@export var fade_in: float = 0.2
|
@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)
|
var is_shown = DataSaver.get_value(SECTION, KEY, false)
|
||||||
if is_shown and not show_always: return
|
if is_shown and not show_always: return
|
||||||
|
|
||||||
|
ui_events.onboarding_started_emit()
|
||||||
|
|
||||||
await get_tree().create_timer(INITIAL_DELAY).timeout
|
await get_tree().create_timer(INITIAL_DELAY).timeout
|
||||||
show_onboarding()
|
show_onboarding()
|
||||||
|
|
||||||
|
@ -58,3 +61,5 @@ func hide_onboarding() -> void:
|
||||||
|
|
||||||
DataSaver.set_value(SECTION, KEY, true)
|
DataSaver.set_value(SECTION, KEY, true)
|
||||||
DataSaver.save_data()
|
DataSaver.save_data()
|
||||||
|
|
||||||
|
ui_events.onboarding_finished_emit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue