Add animations to popups, points, songs, the winner and the tabs (#48)
Popups fade in while growing and close the reverse way, with the backdrop fading along. The winner gets confetti, bouncing pictures and a score graph that draws itself from the left. Filtered statistics cards and search rows fade in, the tabs slide in from their side, and every button bounces on hover and click (ButtonBounce, now added to all buttons). In the player list the score pops on every point, the first point flashes the row, and a player on match point glows with a "Match point!" tag. A song starting fades in the title, flashes its row (kept across list rebuilds) and pops the play button. Common/anim.gd holds the helpers. A saved "Reduce animations" switch in Settings turns all movement off; the tests use it. The flash colours are theme colours (Palette first_point, match_point, flash) in every theme. Closes #48 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae231975bd
commit
0fc3be79e1
31 files changed
+1510
-639
No files matched your search
+43
-3
@@ -15,6 +15,13 @@ const MARGIN_BOTTOM: float = 44.0
|
||||
## About how many song numbers fit along the bottom.
|
||||
const MAX_SONG_LABELS: int = 20
|
||||
|
||||
## How much of the lines is drawn, from 0 (none) to 1 (all), so they can be drawn from
|
||||
## left to right.
|
||||
var progress: float = 1.0:
|
||||
set(value):
|
||||
progress = value
|
||||
queue_redraw()
|
||||
|
||||
var _history: ScoreHistory
|
||||
var _winning_score: int = 0
|
||||
|
||||
@@ -33,6 +40,32 @@ func show_history(history: ScoreHistory, winning_score: int) -> void:
|
||||
queue_redraw()
|
||||
|
||||
|
||||
## Draws the lines from left to right over [param duration] seconds.
|
||||
func draw_lines_in(duration: float = 1.2) -> void:
|
||||
var draw_tween: Tween = Anim.tween(self, &"draw")
|
||||
progress = 1.0
|
||||
if draw_tween == null:
|
||||
return
|
||||
progress = 0.0
|
||||
draw_tween.tween_property(self, "progress", 1.0, duration) \
|
||||
.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
|
||||
|
||||
## The part of [param points] left of [param limit_x], cut where the line crosses it.
|
||||
static func clip_line(points: PackedVector2Array, limit_x: float) -> PackedVector2Array:
|
||||
var clipped: PackedVector2Array = []
|
||||
for i: int in points.size():
|
||||
if points[i].x <= limit_x:
|
||||
clipped.append(points[i])
|
||||
continue
|
||||
if i > 0 && points[i - 1].x < limit_x:
|
||||
var before: Vector2 = points[i - 1]
|
||||
var weight: float = (limit_x - before.x) / (points[i].x - before.x)
|
||||
clipped.append(before.lerp(points[i], weight))
|
||||
break
|
||||
return clipped
|
||||
|
||||
|
||||
## The colour of the player at [param index] in the player list.
|
||||
func player_color(index: int) -> Color:
|
||||
return get_theme_color(StringName("player_%d" % (index % 7 + 1)), THEME_TYPE)
|
||||
@@ -63,13 +96,20 @@ func _draw() -> void:
|
||||
|
||||
var line_width: int = get_theme_constant(&"line_width", THEME_TYPE)
|
||||
var dot_radius: int = get_theme_constant(&"dot_radius", THEME_TYPE)
|
||||
var limit_x: float = lerpf(MARGIN_LEFT, size.x - MARGIN_RIGHT, progress)
|
||||
for index: int in _history.players.size():
|
||||
var color: Color = player_color(index)
|
||||
var scores: Array[int] = _history.scores_after_songs(_history.players[index].id)
|
||||
draw_polyline(line_points(index), color, line_width, true)
|
||||
var points: PackedVector2Array = clip_line(line_points(index), limit_x)
|
||||
if points.size() >= 2:
|
||||
draw_polyline(points, color, line_width, true)
|
||||
for song: int in range(1, scores.size()):
|
||||
if scores[song] > scores[song - 1]:
|
||||
draw_circle(_point(song, scores[song], index), dot_radius, color)
|
||||
var dot: Vector2 = _point(song, scores[song], index)
|
||||
if scores[song] > scores[song - 1] && dot.x <= limit_x:
|
||||
draw_circle(dot, dot_radius, color)
|
||||
# The final scores are written once the lines have reached them
|
||||
if progress < 1.0:
|
||||
return
|
||||
var label_positions: Array[Vector2] = score_label_positions()
|
||||
for index: int in _history.players.size():
|
||||
draw_string(font, label_positions[index],
|
||||
|
||||
Reference in new issue
Block a user