Make bubble menu feedback immediate
This commit is contained in:
parent
8f8398cbcd
commit
3dbfd74b6c
6 changed files with 214 additions and 238 deletions
|
|
@ -4,6 +4,9 @@ extends Control
|
|||
const ControllerFocusNavigationType = preload(
|
||||
"res://ui/controller_focus_navigation.gd"
|
||||
)
|
||||
const QUICK_ENTER_DURATION: float = 0.14
|
||||
const QUICK_EXIT_DURATION: float = 0.10
|
||||
const QUICK_ENTER_SCALE: float = 0.97
|
||||
|
||||
@export var page_id: StringName
|
||||
@export var cluster_path: NodePath = ^"BubbleCluster"
|
||||
|
|
@ -13,8 +16,6 @@ const ControllerFocusNavigationType = preload(
|
|||
@export var back_focus_path: NodePath
|
||||
@export var back_entry_path: NodePath
|
||||
@export var maximum_layout_size: Vector2 = Vector2(720.0, 520.0)
|
||||
@export_range(0.0, 128.0, 1.0) var transition_safe_margin: float = 24.0
|
||||
|
||||
var _cluster: BubbleCluster
|
||||
var _bubbles: Array[BubbleButton] = []
|
||||
var _focus_controls: Array[Control] = []
|
||||
|
|
@ -35,6 +36,7 @@ func _ready() -> void:
|
|||
if focus_control != null:
|
||||
_focus_controls.append(focus_control)
|
||||
_cluster.configure(_bubbles)
|
||||
_cluster.motion_scale = 0.0
|
||||
_configure_focus_order()
|
||||
resized.connect(_update_layout)
|
||||
call_deferred("_update_layout")
|
||||
|
|
@ -47,6 +49,7 @@ func show_page(should_focus: bool = true) -> void:
|
|||
show()
|
||||
_is_transitioning = false
|
||||
_cluster.position = _resting_cluster_position
|
||||
_reset_cluster_presentation()
|
||||
set_process(true)
|
||||
_set_interactive(true)
|
||||
var paper := get_node_or_null("Paper") as Control
|
||||
|
|
@ -68,18 +71,22 @@ func transition_out(
|
|||
if paper != null:
|
||||
UtilityPageStyle.animate_out(paper, Callable())
|
||||
set_process(true)
|
||||
var target_y: float = -_cluster.size.y - transition_safe_margin
|
||||
var duration := UIMotion.bubble_duration(
|
||||
target_y - _cluster.position.y
|
||||
)
|
||||
var generation: int = _transition_generation
|
||||
_transition = create_tween()
|
||||
_cluster.position = _resting_cluster_position
|
||||
_cluster.pivot_offset = _cluster.size * 0.5
|
||||
_transition = create_tween().set_parallel(true)
|
||||
_transition.tween_property(
|
||||
_cluster,
|
||||
"position:y",
|
||||
target_y,
|
||||
duration
|
||||
).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
"scale",
|
||||
Vector2.ONE * QUICK_ENTER_SCALE,
|
||||
QUICK_EXIT_DURATION
|
||||
).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
_transition.tween_property(
|
||||
_cluster,
|
||||
"modulate:a",
|
||||
0.0,
|
||||
QUICK_EXIT_DURATION
|
||||
)
|
||||
_transition.finished.connect(
|
||||
_finish_transition_out.bind(generation, completed),
|
||||
CONNECT_ONE_SHOT
|
||||
|
|
@ -97,24 +104,27 @@ func transition_in(
|
|||
_is_transitioning = true
|
||||
_set_interactive(false)
|
||||
set_process(true)
|
||||
_cluster.position = Vector2(
|
||||
_resting_cluster_position.x,
|
||||
size.y + transition_safe_margin
|
||||
)
|
||||
_cluster.position = _resting_cluster_position
|
||||
_cluster.pivot_offset = _cluster.size * 0.5
|
||||
_cluster.scale = Vector2.ONE * QUICK_ENTER_SCALE
|
||||
_cluster.modulate.a = 0.0
|
||||
var paper := get_node_or_null("Paper") as Control
|
||||
if paper != null:
|
||||
UtilityPageStyle.animate_in(paper)
|
||||
var duration := UIMotion.bubble_duration(
|
||||
_cluster.position.y - _resting_cluster_position.y
|
||||
)
|
||||
var generation: int = _transition_generation
|
||||
_transition = create_tween()
|
||||
_transition = create_tween().set_parallel(true)
|
||||
_transition.tween_property(
|
||||
_cluster,
|
||||
"position",
|
||||
_resting_cluster_position,
|
||||
duration
|
||||
).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
"scale",
|
||||
Vector2.ONE,
|
||||
QUICK_ENTER_DURATION
|
||||
).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
|
||||
_transition.tween_property(
|
||||
_cluster,
|
||||
"modulate:a",
|
||||
1.0,
|
||||
QUICK_ENTER_DURATION
|
||||
)
|
||||
_transition.finished.connect(
|
||||
_finish_transition_in.bind(generation, should_focus, completed),
|
||||
CONNECT_ONE_SHOT
|
||||
|
|
@ -130,6 +140,7 @@ func hide_page() -> void:
|
|||
hide()
|
||||
if _cluster != null:
|
||||
_cluster.position = _resting_cluster_position
|
||||
_reset_cluster_presentation()
|
||||
|
||||
|
||||
func focus_initial() -> void:
|
||||
|
|
@ -183,6 +194,7 @@ func _update_layout() -> void:
|
|||
if not _is_transitioning:
|
||||
_cluster.position = _resting_cluster_position
|
||||
_cluster.size = field_size
|
||||
_cluster.pivot_offset = _cluster.size * 0.5
|
||||
_cluster.apply_layout(field_size, false)
|
||||
_configure_focus_navigation()
|
||||
|
||||
|
|
@ -243,6 +255,7 @@ func _finish_transition_out(generation: int, completed: Callable) -> void:
|
|||
_is_transitioning = false
|
||||
hide()
|
||||
_cluster.position = _resting_cluster_position
|
||||
_reset_cluster_presentation()
|
||||
if completed.is_valid():
|
||||
completed.call()
|
||||
|
||||
|
|
@ -257,6 +270,7 @@ func _finish_transition_in(
|
|||
_transition = null
|
||||
_is_transitioning = false
|
||||
_cluster.position = _resting_cluster_position
|
||||
_reset_cluster_presentation()
|
||||
set_process(true)
|
||||
_set_interactive(true)
|
||||
if should_focus:
|
||||
|
|
@ -268,3 +282,10 @@ func _cancel_transition() -> void:
|
|||
if _transition != null:
|
||||
_transition.kill()
|
||||
_transition = null
|
||||
|
||||
|
||||
func _reset_cluster_presentation() -> void:
|
||||
if _cluster == null:
|
||||
return
|
||||
_cluster.scale = Vector2.ONE
|
||||
_cluster.modulate.a = 1.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue