mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 08:17:34 -04:00
bookmark jump animation
This commit is contained in:
parent
25890062df
commit
e428bbb018
3 changed files with 69 additions and 17 deletions
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=13 format=3 uid="uid://82ca8so31njy"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://82ca8so31njy"]
|
||||
|
||||
[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://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://bmxiecm3vkddl" path="res://assets/styles/panel_hover.stylebox" id="4_figib"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/menu/bookmark_jump_animation.gd" id="4_xly7e"]
|
||||
[ext_resource type="LabelSettings" uid="uid://85ms8ndcmbn0" path="res://assets/styles/text_small.tres" id="4_xqjm8"]
|
||||
[ext_resource type="Texture2D" uid="uid://6k1ia4pidwrq" path="res://assets/textures/empty_icon.svg" id="5_vwpfy"]
|
||||
[ext_resource type="Shader" path="res://shaders/spinning_border.gdshader" id="6_16gpr"]
|
||||
|
@ -31,7 +32,7 @@ corner_radius_top_right = 20
|
|||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[node name="Bookmark" type="Control" node_paths=PackedStringArray("icon", "title", "button", "special_effect")]
|
||||
[node name="Bookmark" type="Control" node_paths=PackedStringArray("icon", "title", "button", "special_effect", "jump_animation")]
|
||||
custom_minimum_size = Vector2(180, 100)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
|
@ -40,12 +41,22 @@ offset_bottom = 100.0
|
|||
script = ExtResource("1_bpkqj")
|
||||
gate_events = ExtResource("2_7i5yr")
|
||||
ui_events = ExtResource("3_sp6jv")
|
||||
icon = NodePath("Mask/Icon")
|
||||
title = NodePath("Title")
|
||||
button = NodePath("Button")
|
||||
special_effect = NodePath("SpecialEffect")
|
||||
icon = NodePath("JumpAnimation/Mask/Icon")
|
||||
title = NodePath("JumpAnimation/Title")
|
||||
button = NodePath("JumpAnimation/Button")
|
||||
special_effect = NodePath("JumpAnimation/SpecialEffect")
|
||||
jump_animation = NodePath("JumpAnimation")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
[node name="JumpAnimation" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("4_xly7e")
|
||||
|
||||
[node name="Button" type="Button" parent="JumpAnimation"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -58,7 +69,7 @@ theme_override_styles/hover = ExtResource("4_figib")
|
|||
theme_override_styles/pressed = ExtResource("4_figib")
|
||||
theme_override_styles/normal = ExtResource("3_tb1mf")
|
||||
|
||||
[node name="SpecialEffect" type="Panel" parent="."]
|
||||
[node name="SpecialEffect" type="Panel" parent="JumpAnimation"]
|
||||
material = SubResource("ShaderMaterial_i1368")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
|
@ -69,7 +80,7 @@ grow_vertical = 2
|
|||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="Mask" type="Panel" parent="."]
|
||||
[node name="Mask" type="Panel" parent="JumpAnimation"]
|
||||
clip_children = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
|
@ -83,7 +94,7 @@ grow_horizontal = 2
|
|||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_od0ga")
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="Mask"]
|
||||
[node name="Icon" type="TextureRect" parent="JumpAnimation/Mask"]
|
||||
custom_minimum_size = Vector2(87, 87)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
|
@ -98,7 +109,7 @@ texture = ExtResource("5_vwpfy")
|
|||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
[node name="Title" type="Label" parent="JumpAnimation"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
|
|
34
app/scripts/ui/menu/bookmark_jump_animation.gd
Normal file
34
app/scripts/ui/menu/bookmark_jump_animation.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends Control
|
||||
class_name BookmarkJumpAnimation
|
||||
|
||||
var base_position: Vector2
|
||||
var base_z_index: int
|
||||
var tween: Tween
|
||||
|
||||
|
||||
func start_jump_animation() -> void:
|
||||
base_position = position
|
||||
base_z_index = z_index
|
||||
z_index = 1
|
||||
|
||||
var up_position: Vector2 = base_position + Vector2(0, -6)
|
||||
var down_position: Vector2 = base_position + Vector2(0, 6)
|
||||
|
||||
if is_instance_valid(tween): tween.stop()
|
||||
tween = create_tween()
|
||||
tween.set_loops()
|
||||
|
||||
tween.tween_interval(1.0)
|
||||
tween.tween_property(self, "position", down_position, 0.15).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(self, "position", up_position, 0.2).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(self, "position", base_position, 0.15).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
|
||||
|
||||
func stop_jump_animation() -> void:
|
||||
if is_instance_valid(tween): tween.stop()
|
||||
position = base_position
|
||||
z_index = base_z_index
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
stop_jump_animation()
|
|
@ -7,6 +7,7 @@ class_name BookmarkUI
|
|||
@export var title: Label
|
||||
@export var button: Button
|
||||
@export var special_effect: Panel
|
||||
@export var jump_animation: BookmarkJumpAnimation
|
||||
|
||||
var url: String
|
||||
var is_special: bool
|
||||
|
@ -14,8 +15,8 @@ var is_special: bool
|
|||
|
||||
func _ready() -> void:
|
||||
button.pressed.connect(on_pressed)
|
||||
ui_events.onboarding_started.connect(update_button_type)
|
||||
ui_events.onboarding_finished.connect(update_button_type)
|
||||
ui_events.onboarding_started.connect(update_special_effects)
|
||||
ui_events.onboarding_finished.connect(update_special_effects)
|
||||
|
||||
|
||||
func fill(gate: Gate) -> void:
|
||||
|
@ -24,20 +25,26 @@ func fill(gate: Gate) -> void:
|
|||
url = gate.url
|
||||
is_special = gate.is_special
|
||||
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
||||
update_button_type()
|
||||
update_special_effects()
|
||||
|
||||
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:
|
||||
func update_special_effects() -> void:
|
||||
if ui_events.is_onboarding_started:
|
||||
special_effect.visible = false
|
||||
jump_animation.stop_jump_animation()
|
||||
return
|
||||
|
||||
if is_special:
|
||||
special_effect.visible = true
|
||||
jump_animation.start_jump_animation()
|
||||
else:
|
||||
special_effect.visible = is_special
|
||||
special_effect.visible = false
|
||||
jump_animation.stop_jump_animation()
|
||||
|
||||
|
||||
func on_pressed() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue