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::time_attack_plugin::TimeAttackEndedEvent;
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;
@@ -533,19 +534,19 @@ fn spawn_queued_toast(commands: &mut Commands, message: String) -> Entity {
left: Val::Percent(15.0),
top: Val::Percent(8.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,
align_items: AlignItems::Center,
..default()
},
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.60)),
ZIndex(400),
ZIndex(Z_TOAST),
))
.with_children(|b| {
b.spawn((
Text::new(message),
TextFont { font_size: 22.0, ..default() },
TextColor(Color::srgb(1.0, 1.0, 1.0)),
TextColor(TEXT_PRIMARY),
));
})
.id()
@@ -589,7 +590,7 @@ fn spawn_toast(commands: &mut Commands, message: String, duration_secs: f32) {
left: Val::Percent(25.0),
top: Val::Percent(42.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,
align_items: AlignItems::Center,
..default()
@@ -603,7 +604,7 @@ fn spawn_toast(commands: &mut Commands, message: String, duration_secs: f32) {
font_size: 32.0,
..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::ui_theme::{
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,
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((
Node {
position_type: PositionType::Absolute,
right: Val::Px(12.0),
top: Val::Px(8.0),
right: VAL_SPACE_3,
top: VAL_SPACE_2,
flex_direction: FlexDirection::Row,
column_gap: Val::Px(8.0),
column_gap: VAL_SPACE_2,
align_items: AlignItems::Center,
..default()
},
@@ -560,12 +560,12 @@ fn spawn_modes_popover(
ModesPopover,
Node {
position_type: PositionType::Absolute,
right: Val::Px(12.0),
right: VAL_SPACE_3,
top: Val::Px(50.0),
flex_direction: FlexDirection::Column,
row_gap: Val::Px(4.0),
padding: UiRect::all(Val::Px(8.0)),
border_radius: BorderRadius::all(Val::Px(6.0)),
row_gap: VAL_SPACE_1,
padding: UiRect::all(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default()
},
BackgroundColor(BG_ELEVATED),
@@ -579,11 +579,11 @@ fn spawn_modes_popover(
ActionButton,
Button,
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,
align_items: AlignItems::Center,
min_width: Val::Px(150.0),
border_radius: BorderRadius::all(Val::Px(4.0)),
border_radius: BorderRadius::all(Val::Px(RADIUS_SM)),
..default()
},
BackgroundColor(ACTION_BTN_IDLE),
@@ -689,12 +689,12 @@ fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&FontResource>)
MenuPopover,
Node {
position_type: PositionType::Absolute,
right: Val::Px(12.0),
right: VAL_SPACE_3,
top: Val::Px(50.0),
flex_direction: FlexDirection::Column,
row_gap: Val::Px(4.0),
padding: UiRect::all(Val::Px(8.0)),
border_radius: BorderRadius::all(Val::Px(6.0)),
row_gap: VAL_SPACE_1,
padding: UiRect::all(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default()
},
BackgroundColor(BG_ELEVATED),
@@ -708,11 +708,11 @@ fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&FontResource>)
ActionButton,
Button,
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,
align_items: AlignItems::Center,
min_width: Val::Px(150.0),
border_radius: BorderRadius::all(Val::Px(4.0)),
border_radius: BorderRadius::all(Val::Px(RADIUS_SM)),
..default()
},
BackgroundColor(ACTION_BTN_IDLE),
+33 -28
View File
@@ -22,7 +22,12 @@ use crate::progress_plugin::ProgressResource;
use crate::resources::GameStateResource;
use crate::settings_plugin::SettingsResource;
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
@@ -454,8 +459,8 @@ fn spawn_overlay(
align_items: AlignItems::Center,
..default()
},
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 0.70)),
ZIndex(300),
BackgroundColor(SCRIM),
ZIndex(Z_WIN_CASCADE),
))
.with_children(|root| {
root.spawn((
@@ -465,25 +470,25 @@ fn spawn_overlay(
row_gap: Val::Px(18.0),
min_width: Val::Px(320.0),
align_items: AlignItems::Center,
border_radius: BorderRadius::all(Val::Px(12.0)),
border_radius: BorderRadius::all(Val::Px(RADIUS_LG)),
..default()
},
BackgroundColor(Color::srgb(0.10, 0.12, 0.10)),
BackgroundColor(BG_ELEVATED),
))
.with_children(|card| {
// Heading
card.spawn((
Text::new("You Won!"),
TextFont { font_size: 42.0, ..default() },
TextColor(Color::srgb(1.0, 0.87, 0.0)),
TextFont { font_size: TYPE_DISPLAY, ..default() },
TextColor(ACCENT_PRIMARY),
));
// Challenge-mode annotation — shown only for Challenge wins.
if let Some(level) = challenge_level {
card.spawn((
Text::new(format!("Challenge {level} complete!")),
TextFont { font_size: 28.0, ..default() },
TextColor(Color::srgb(0.4, 0.85, 1.0)),
TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(STATE_INFO),
));
}
@@ -492,30 +497,30 @@ fn spawn_overlay(
if pending.new_record {
card.spawn((
Text::new("New Record!"),
TextFont { font_size: 26.0, ..default() },
TextColor(Color::srgb(1.0, 0.55, 0.0)),
TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(STATE_WARNING),
));
}
// Score
card.spawn((
Text::new(format!("Score: {}", pending.score)),
TextFont { font_size: 26.0, ..default() },
TextColor(Color::WHITE),
TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(TEXT_PRIMARY),
));
// Time
card.spawn((
Text::new(format!("Time: {}", format_win_time(pending.time_seconds))),
TextFont { font_size: 26.0, ..default() },
TextColor(Color::WHITE),
TextFont { font_size: TYPE_HEADLINE, ..default() },
TextColor(TEXT_PRIMARY),
));
// XP total
card.spawn((
Text::new(format!("XP earned: +{}", pending.xp)),
TextFont { font_size: 22.0, ..default() },
TextColor(Color::srgb(0.4, 1.0, 0.4)),
TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(STATE_SUCCESS),
));
// XP breakdown (smaller, dimmer text)
@@ -523,7 +528,7 @@ fn spawn_overlay(
card.spawn((
Text::new(pending.xp_detail.clone()),
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,
Button,
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,
margin: UiRect::top(Val::Px(8.0)),
border_radius: BorderRadius::all(Val::Px(6.0)),
margin: UiRect::top(VAL_SPACE_2),
border_radius: BorderRadius::all(Val::Px(RADIUS_MD)),
..default()
},
BackgroundColor(Color::srgb(0.22, 0.45, 0.22)),
BackgroundColor(ACCENT_PRIMARY),
))
.with_children(|b| {
b.spawn((
Text::new("Play Again"),
TextFont { font_size: 22.0, ..default() },
TextColor(Color::WHITE),
TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(BG_BASE),
));
});
});
@@ -569,8 +574,8 @@ const MAX_ACHIEVEMENTS_SHOWN: usize = 3;
fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String]) {
card.spawn((
Text::new("Achievements Unlocked"),
TextFont { font_size: 18.0, ..default() },
TextColor(Color::srgb(1.0, 0.87, 0.0)),
TextFont { font_size: TYPE_BODY_LG, ..default() },
TextColor(ACCENT_PRIMARY),
));
let shown = names.len().min(MAX_ACHIEVEMENTS_SHOWN);
@@ -578,7 +583,7 @@ fn spawn_achievements_section(card: &mut ChildSpawnerCommands, names: &[String])
card.spawn((
Text::new(format!(" {name}")),
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((
Text::new(format!(" ...and {overflow} more")),
TextFont { font_size: 15.0, ..default() },
TextColor(Color::srgb(0.6, 0.6, 0.65)),
TextColor(TEXT_SECONDARY),
));
}
}