onboarding close button

This commit is contained in:
Nordup 2025-08-12 23:22:51 +07:00
parent 9e46290c36
commit 3131b731e0
7 changed files with 126 additions and 9 deletions

View file

@ -2,6 +2,7 @@ extends Control
@export var ui_events: UiEvents
@export var line: Control
@export var close: Button
@export var tween_duration: float
var boards: Array[OnboardingBoard] = []
@ -19,7 +20,8 @@ func _ready() -> void:
func setup_boards() -> void:
for child in line.get_children():
boards.append(child as OnboardingBoard)
if child is not OnboardingBoard: continue
boards.append(child)
for i in range(boards.size()):
boards[i].request_focus.connect(move_line.bind(i))
@ -48,3 +50,12 @@ func move_line(board_index: int) -> void:
if i == board_index:
boards[i].focus(tween_duration)
else: boards[i].unfocus(tween_duration)
await tween.finished
refresh_mouse_position()
func refresh_mouse_position() -> void:
var event = InputEventMouseMotion.new()
event.position = get_viewport().get_mouse_position()
Input.parse_input_event(event)

View file

@ -0,0 +1,34 @@
extends Button
@export var content: Control
@export var tween_duration: float
@export var base_modulate: Color
@export var hover_scale: float
var tween: Tween
func _ready() -> void:
mouse_entered.connect(on_mouse_entered)
mouse_exited.connect(on_mouse_exited)
on_mouse_exited()
func on_mouse_entered() -> void:
if is_instance_valid(tween): tween.stop()
tween = create_tween()
tween.set_parallel(true)
tween.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
tween.tween_property(content, "scale", Vector2.ONE * hover_scale, tween_duration)
tween.tween_property(content, "modulate", Color.WHITE, tween_duration)
func on_mouse_exited() -> void:
if is_instance_valid(tween): tween.stop()
tween = create_tween()
tween.set_parallel(true)
tween.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
tween.tween_property(content, "scale", Vector2.ONE, tween_duration)
tween.tween_property(content, "modulate", base_modulate, tween_duration)

View file

@ -5,7 +5,7 @@ const SHOWN = Color(1, 1, 1, 1)
const HIDDEN = Color(1, 1, 1, 0)
@export var root: Control
@export var skip: Button
@export var close: Button
@export var fade_in: float = 0.2
@export var fade_out: float = 0.2
@ -13,7 +13,7 @@ var tween: Tween
func _ready() -> void:
skip.pressed.connect(hide_onboarding)
close.pressed.connect(hide_onboarding)
visible = true
root.visible = false