chore(engine): final literal-to-token sweep

Migrates the last remaining colour, spacing, font-size, and z-index
literals in animation_plugin (toasts), hud_plugin (action bar +
Modes/Menu popovers), and win_summary_plugin (full win modal restyle)
onto the ui_theme token system established in step 1. Win summary now
uses SCRIM/BG_ELEVATED/ACCENT_PRIMARY/STATE_* with a yellow Play Again
button. Sprite-tinted gameplay art (cards, felt, drop-zone hints,
pile markers) and sub-rung pixel sizes (1px borders, fixed cell
widths) are intentionally left untouched.

cargo build / clippy --workspace -- -D warnings / test --workspace
all green (819 passed, 0 failed, 8 ignored).
This commit is contained in:
funman300
2026-04-30 04:47:20 +00:00
parent 3a01318fbd
commit 54e024c1b0
3 changed files with 56 additions and 50 deletions
+7 -6
View File
@@ -30,7 +30,8 @@ use crate::progress_plugin::LevelUpEvent;
use crate::settings_plugin::{SettingsChangedEvent, SettingsResource}; use crate::settings_plugin::{SettingsChangedEvent, SettingsResource};
use crate::time_attack_plugin::TimeAttackEndedEvent; use crate::time_attack_plugin::TimeAttackEndedEvent;
use crate::ui_theme::{ use crate::ui_theme::{
scaled_duration, MOTION_CASCADE_SLIDE_SECS, MOTION_CASCADE_STAGGER_SECS, MOTION_SLIDE_SECS, scaled_duration, ACCENT_PRIMARY, MOTION_CASCADE_SLIDE_SECS, MOTION_CASCADE_STAGGER_SECS,
MOTION_SLIDE_SECS, TEXT_PRIMARY, VAL_SPACE_2, VAL_SPACE_3, VAL_SPACE_4, Z_TOAST,
}; };
use crate::weekly_goals_plugin::WeeklyGoalCompletedEvent; use crate::weekly_goals_plugin::WeeklyGoalCompletedEvent;
@@ -533,19 +534,19 @@ fn spawn_queued_toast(commands: &mut Commands, message: String) -> Entity {
left: Val::Percent(15.0), left: Val::Percent(15.0),
top: Val::Percent(8.0), top: Val::Percent(8.0),
width: Val::Percent(70.0), width: Val::Percent(70.0),
padding: UiRect::axes(Val::Px(16.0), Val::Px(8.0)), padding: UiRect::axes(VAL_SPACE_4, VAL_SPACE_2),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
}, },
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.60)), BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.60)),
ZIndex(400), ZIndex(Z_TOAST),
)) ))
.with_children(|b| { .with_children(|b| {
b.spawn(( b.spawn((
Text::new(message), Text::new(message),
TextFont { font_size: 22.0, ..default() }, TextFont { font_size: 22.0, ..default() },
TextColor(Color::srgb(1.0, 1.0, 1.0)), TextColor(TEXT_PRIMARY),
)); ));
}) })
.id() .id()
@@ -589,7 +590,7 @@ fn spawn_toast(commands: &mut Commands, message: String, duration_secs: f32) {
left: Val::Percent(25.0), left: Val::Percent(25.0),
top: Val::Percent(42.0), top: Val::Percent(42.0),
width: Val::Percent(50.0), width: Val::Percent(50.0),
padding: UiRect::axes(Val::Px(16.0), Val::Px(10.0)), padding: UiRect::axes(VAL_SPACE_4, VAL_SPACE_3),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@@ -603,7 +604,7 @@ fn spawn_toast(commands: &mut Commands, message: String, duration_secs: f32) {
font_size: 32.0, font_size: 32.0,
..default() ..default()
}, },
TextColor(Color::srgb(1.0, 0.87, 0.0)), TextColor(ACCENT_PRIMARY),
)); ));
}); });
} }
+16 -16
View File
@@ -17,7 +17,7 @@ use crate::daily_challenge_plugin::DailyChallengeResource;
use crate::progress_plugin::ProgressResource; use crate::progress_plugin::ProgressResource;
use crate::ui_theme::{ use crate::ui_theme::{
ACCENT_PRIMARY, ACCENT_SECONDARY, BG_ELEVATED, BG_ELEVATED_HI, BG_ELEVATED_PRESSED, ACCENT_PRIMARY, ACCENT_SECONDARY, BG_ELEVATED, BG_ELEVATED_HI, BG_ELEVATED_PRESSED,
BORDER_SUBTLE, RADIUS_MD, STATE_DANGER, STATE_INFO, STATE_SUCCESS, STATE_WARNING, BORDER_SUBTLE, RADIUS_MD, RADIUS_SM, STATE_DANGER, STATE_INFO, STATE_SUCCESS, STATE_WARNING,
TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY, TYPE_BODY_LG, TYPE_CAPTION, TYPE_HEADLINE, TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY, TYPE_BODY_LG, TYPE_CAPTION, TYPE_HEADLINE,
VAL_SPACE_1, VAL_SPACE_2, VAL_SPACE_3, VAL_SPACE_1, VAL_SPACE_2, VAL_SPACE_3,
}; };
@@ -387,10 +387,10 @@ fn spawn_action_buttons(font_res: Option<Res<FontResource>>, mut commands: Comma
.spawn(( .spawn((
Node { Node {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
right: Val::Px(12.0), right: VAL_SPACE_3,
top: Val::Px(8.0), top: VAL_SPACE_2,
flex_direction: FlexDirection::Row, flex_direction: FlexDirection::Row,
column_gap: Val::Px(8.0), column_gap: VAL_SPACE_2,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
}, },
@@ -560,12 +560,12 @@ fn spawn_modes_popover(
ModesPopover, ModesPopover,
Node { Node {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
right: Val::Px(12.0), right: VAL_SPACE_3,
top: Val::Px(50.0), top: Val::Px(50.0),
flex_direction: FlexDirection::Column, flex_direction: FlexDirection::Column,
row_gap: Val::Px(4.0), row_gap: VAL_SPACE_1,
padding: UiRect::all(Val::Px(8.0)), padding: UiRect::all(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(6.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default() ..default()
}, },
BackgroundColor(BG_ELEVATED), BackgroundColor(BG_ELEVATED),
@@ -579,11 +579,11 @@ fn spawn_modes_popover(
ActionButton, ActionButton,
Button, Button,
Node { Node {
padding: UiRect::axes(Val::Px(12.0), Val::Px(6.0)), padding: UiRect::axes(VAL_SPACE_3, Val::Px(6.0)),
justify_content: JustifyContent::FlexStart, justify_content: JustifyContent::FlexStart,
align_items: AlignItems::Center, align_items: AlignItems::Center,
min_width: Val::Px(150.0), min_width: Val::Px(150.0),
border_radius: BorderRadius::all(Val::Px(4.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_SM)),
..default() ..default()
}, },
BackgroundColor(ACTION_BTN_IDLE), BackgroundColor(ACTION_BTN_IDLE),
@@ -689,12 +689,12 @@ fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&FontResource>)
MenuPopover, MenuPopover,
Node { Node {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
right: Val::Px(12.0), right: VAL_SPACE_3,
top: Val::Px(50.0), top: Val::Px(50.0),
flex_direction: FlexDirection::Column, flex_direction: FlexDirection::Column,
row_gap: Val::Px(4.0), row_gap: VAL_SPACE_1,
padding: UiRect::all(Val::Px(8.0)), padding: UiRect::all(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(6.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default() ..default()
}, },
BackgroundColor(BG_ELEVATED), BackgroundColor(BG_ELEVATED),
@@ -708,11 +708,11 @@ fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&FontResource>)
ActionButton, ActionButton,
Button, Button,
Node { Node {
padding: UiRect::axes(Val::Px(12.0), Val::Px(6.0)), padding: UiRect::axes(VAL_SPACE_3, Val::Px(6.0)),
justify_content: JustifyContent::FlexStart, justify_content: JustifyContent::FlexStart,
align_items: AlignItems::Center, align_items: AlignItems::Center,
min_width: Val::Px(150.0), min_width: Val::Px(150.0),
border_radius: BorderRadius::all(Val::Px(4.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_SM)),
..default() ..default()
}, },
BackgroundColor(ACTION_BTN_IDLE), BackgroundColor(ACTION_BTN_IDLE),
+33 -28
View File
@@ -22,7 +22,12 @@ use crate::progress_plugin::ProgressResource;
use crate::resources::GameStateResource; use crate::resources::GameStateResource;
use crate::settings_plugin::SettingsResource; use crate::settings_plugin::SettingsResource;
use crate::stats_plugin::{StatsResource, StatsUpdate}; use crate::stats_plugin::{StatsResource, StatsUpdate};
use crate::ui_theme::{scaled_duration, MOTION_WIN_SHAKE_AMPLITUDE, MOTION_WIN_SHAKE_SECS}; use crate::ui_theme::{
scaled_duration, ACCENT_PRIMARY, BG_BASE, BG_ELEVATED, MOTION_WIN_SHAKE_AMPLITUDE,
MOTION_WIN_SHAKE_SECS, RADIUS_LG, RADIUS_MD, SCRIM, STATE_INFO, STATE_SUCCESS, STATE_WARNING,
TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY_LG, TYPE_DISPLAY, TYPE_HEADLINE, VAL_SPACE_2,
VAL_SPACE_3, Z_WIN_CASCADE,
};
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Constants // Constants
@@ -454,8 +459,8 @@ fn spawn_overlay(
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
}, },
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.70)), BackgroundColor(SCRIM),
ZIndex(300), ZIndex(Z_WIN_CASCADE),
)) ))
.with_children(|root| { .with_children(|root| {
root.spawn(( root.spawn((
@@ -465,25 +470,25 @@ fn spawn_overlay(
row_gap: Val::Px(18.0), row_gap: Val::Px(18.0),
min_width: Val::Px(320.0), min_width: Val::Px(320.0),
align_items: AlignItems::Center, align_items: AlignItems::Center,
border_radius: BorderRadius::all(Val::Px(12.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_LG)),
..default() ..default()
}, },
BackgroundColor(Color::srgb(0.10, 0.12, 0.10)), BackgroundColor(BG_ELEVATED),
)) ))
.with_children(|card| { .with_children(|card| {
// Heading // Heading
card.spawn(( card.spawn((
Text::new("You Won!"), Text::new("You Won!"),
TextFont { font_size: 42.0, ..default() }, TextFont { font_size: TYPE_DISPLAY, ..default() },
TextColor(Color::srgb(1.0, 0.87, 0.0)), TextColor(ACCENT_PRIMARY),
)); ));
// Challenge-mode annotation — shown only for Challenge wins. // Challenge-mode annotation — shown only for Challenge wins.
if let Some(level) = challenge_level { if let Some(level) = challenge_level {
card.spawn(( card.spawn((
Text::new(format!("Challenge {level} complete!")), Text::new(format!("Challenge {level} complete!")),
TextFont { font_size: 28.0, ..default() }, TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(Color::srgb(0.4, 0.85, 1.0)), TextColor(STATE_INFO),
)); ));
} }
@@ -492,30 +497,30 @@ fn spawn_overlay(
if pending.new_record { if pending.new_record {
card.spawn(( card.spawn((
Text::new("New Record!"), Text::new("New Record!"),
TextFont { font_size: 26.0, ..default() }, TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(Color::srgb(1.0, 0.55, 0.0)), TextColor(STATE_WARNING),
)); ));
} }
// Score // Score
card.spawn(( card.spawn((
Text::new(format!("Score: {}", pending.score)), Text::new(format!("Score: {}", pending.score)),
TextFont { font_size: 26.0, ..default() }, TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(Color::WHITE), TextColor(TEXT_PRIMARY),
)); ));
// Time // Time
card.spawn(( card.spawn((
Text::new(format!("Time: {}", format_win_time(pending.time_seconds))), Text::new(format!("Time: {}", format_win_time(pending.time_seconds))),
TextFont { font_size: 26.0, ..default() }, TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(Color::WHITE), TextColor(TEXT_PRIMARY),
)); ));
// XP total // XP total
card.spawn(( card.spawn((
Text::new(format!("XP earned: +{}", pending.xp)), Text::new(format!("XP earned: +{}", pending.xp)),
TextFont { font_size: 22.0, ..default() }, TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(Color::srgb(0.4, 1.0, 0.4)), TextColor(STATE_SUCCESS),
)); ));
// XP breakdown (smaller, dimmer text) // XP breakdown (smaller, dimmer text)
@@ -523,7 +528,7 @@ fn spawn_overlay(
card.spawn(( card.spawn((
Text::new(pending.xp_detail.clone()), Text::new(pending.xp_detail.clone()),
TextFont { font_size: 15.0, ..default() }, TextFont { font_size: 15.0, ..default() },
TextColor(Color::srgb(0.55, 0.80, 0.55)), TextColor(TEXT_SECONDARY),
)); ));
} }
@@ -538,19 +543,19 @@ fn spawn_overlay(
WinSummaryButton::PlayAgain, WinSummaryButton::PlayAgain,
Button, Button,
Node { Node {
padding: UiRect::axes(Val::Px(28.0), Val::Px(12.0)), padding: UiRect::axes(Val::Px(28.0), VAL_SPACE_3),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
margin: UiRect::top(Val::Px(8.0)), margin: UiRect::top(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(6.0)), border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default() ..default()
}, },
BackgroundColor(Color::srgb(0.22, 0.45, 0.22)), BackgroundColor(ACCENT_PRIMARY),
)) ))
.with_children(|b| { .with_children(|b| {
b.spawn(( b.spawn((
Text::new("Play Again"), Text::new("Play Again"),
TextFont { font_size: 22.0, ..default() }, TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(Color::WHITE), TextColor(BG_BASE),
)); ));
}); });
}); });
@@ -569,8 +574,8 @@ const MAX_ACHIEVEMENTS_SHOWN: usize = 3;
fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String]) { fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String]) {
card.spawn(( card.spawn((
Text::new("Achievements Unlocked"), Text::new("Achievements Unlocked"),
TextFont { font_size: 18.0, ..default() }, TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(Color::srgb(1.0, 0.87, 0.0)), TextColor(ACCENT_PRIMARY),
)); ));
let shown = names.len().min(MAX_ACHIEVEMENTS_SHOWN); let shown = names.len().min(MAX_ACHIEVEMENTS_SHOWN);
@@ -578,7 +583,7 @@ fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String])
card.spawn(( card.spawn((
Text::new(format!(" {name}")), Text::new(format!(" {name}")),
TextFont { font_size: 16.0, ..default() }, TextFont { font_size: 16.0, ..default() },
TextColor(Color::srgb(0.9, 0.9, 0.9)), TextColor(TEXT_PRIMARY),
)); ));
} }
@@ -587,7 +592,7 @@ fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String])
card.spawn(( card.spawn((
Text::new(format!(" ...and {overflow} more")), Text::new(format!(" ...and {overflow} more")),
TextFont { font_size: 15.0, ..default() }, TextFont { font_size: 15.0, ..default() },
TextColor(Color::srgb(0.6, 0.6, 0.65)), TextColor(TEXT_SECONDARY),
)); ));
} }
} }