feat(engine): group HUD menu popover into Play/You/Community/System sections
Phase C of docs/ui-redesign-2026-07.md. The Modes row is gone — Home owns mode selection, so the popover's Play section carries a Home row firing the new ToggleHomeRequestEvent (read by toggle_home_screen alongside the existing M accelerator). Section headers are quiet caption-size labels inside the existing panel widget, not a new widget. The action-bar Modes button and its popover are untouched (their removal is Phase B territory when Home gains hierarchy). - MenuOption: Modes variant replaced by Home; rows grouped Play (Home) · You (Profile, Stats, Achievements) · Community (Leaderboard) · System (Settings, Help) - handle_menu_option_click no longer chains into spawn_modes_popover - Tests: tooltip sweep updated (7 rows still), new toggle_home_event_opens_home_screen covers the popover's open path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -311,44 +311,65 @@ pub(super) fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&Font
|
||||
..default()
|
||||
};
|
||||
|
||||
// Each row carries a tooltip alongside its label so hover reveals
|
||||
// a one-line description of what each overlay shows — mirroring
|
||||
// the tooltips on the action-bar buttons that opened this popover.
|
||||
let rows: [(MenuOption, &'static str, &'static str); 7] = [
|
||||
// One popover row: destination, label, hover tooltip.
|
||||
type MenuRow = (MenuOption, &'static str, &'static str);
|
||||
// Destinations grouped into labelled sections (Phase C of the menu
|
||||
// redesign): Play · You · Community · System. Each row carries a
|
||||
// tooltip alongside its label so hover reveals a one-line
|
||||
// description of what each overlay shows — mirroring the tooltips
|
||||
// on the action-bar buttons that opened this popover. Mode
|
||||
// selection lives on Home now, so there is no Modes row.
|
||||
let sections: [(&'static str, &'static [MenuRow]); 4] = [
|
||||
(
|
||||
MenuOption::Help,
|
||||
"Help",
|
||||
"Show controls, rules, and keyboard shortcuts.",
|
||||
"Play",
|
||||
&[(
|
||||
MenuOption::Home,
|
||||
"Home",
|
||||
"Pick a mode, continue, or start a new game.",
|
||||
)],
|
||||
),
|
||||
(
|
||||
MenuOption::Modes,
|
||||
"Game Modes",
|
||||
"Switch modes: Classic, Daily, Zen, Challenge, Time Attack.",
|
||||
"You",
|
||||
&[
|
||||
(
|
||||
MenuOption::Profile,
|
||||
"Profile",
|
||||
"Your level, XP progress, and sync status.",
|
||||
),
|
||||
(
|
||||
MenuOption::Stats,
|
||||
"Stats",
|
||||
"Lifetime totals: wins, streaks, fastest time, best score.",
|
||||
),
|
||||
(
|
||||
MenuOption::Achievements,
|
||||
"Achievements",
|
||||
"Browse unlocked achievements and the rewards still ahead.",
|
||||
),
|
||||
],
|
||||
),
|
||||
(
|
||||
MenuOption::Stats,
|
||||
"Stats",
|
||||
"Lifetime totals: wins, streaks, fastest time, best score.",
|
||||
"Community",
|
||||
&[(
|
||||
MenuOption::Leaderboard,
|
||||
"Leaderboard",
|
||||
"Top players from your sync server. Opt in from Profile.",
|
||||
)],
|
||||
),
|
||||
(
|
||||
MenuOption::Achievements,
|
||||
"Achievements",
|
||||
"Browse unlocked achievements and the rewards still ahead.",
|
||||
),
|
||||
(
|
||||
MenuOption::Profile,
|
||||
"Profile",
|
||||
"Your level, XP progress, and sync status.",
|
||||
),
|
||||
(
|
||||
MenuOption::Settings,
|
||||
"Settings",
|
||||
"Audio, animations, theme, draw mode, and sync.",
|
||||
),
|
||||
(
|
||||
MenuOption::Leaderboard,
|
||||
"Leaderboard",
|
||||
"Top players from your sync server. Opt in from Profile.",
|
||||
"System",
|
||||
&[
|
||||
(
|
||||
MenuOption::Settings,
|
||||
"Settings",
|
||||
"Audio, animations, theme, draw mode, and sync.",
|
||||
),
|
||||
(
|
||||
MenuOption::Help,
|
||||
"Help",
|
||||
"Show controls, rules, and keyboard shortcuts.",
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
@@ -373,27 +394,48 @@ pub(super) fn spawn_menu_popover(commands: &mut Commands, font_res: Option<&Font
|
||||
ZIndex(Z_HUD_POPOVER),
|
||||
))
|
||||
.with_children(|panel| {
|
||||
for (option, label, tooltip) in rows {
|
||||
let section_font = TextFont {
|
||||
font: font_res.map(|f| f.0.clone()).unwrap_or_default(),
|
||||
font_size: TYPE_CAPTION,
|
||||
..default()
|
||||
};
|
||||
for (section, rows) in sections {
|
||||
// Non-interactive section header — a quiet divider
|
||||
// inside the existing panel, not a new widget.
|
||||
panel
|
||||
.spawn((
|
||||
option,
|
||||
ActionButton,
|
||||
PopoverRow,
|
||||
Button,
|
||||
Tooltip::new(tooltip),
|
||||
Node {
|
||||
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(RADIUS_SM)),
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(ACTION_BTN_IDLE),
|
||||
))
|
||||
.spawn(Node {
|
||||
padding: UiRect::axes(VAL_SPACE_3, Val::Px(2.0)),
|
||||
..default()
|
||||
})
|
||||
.with_children(|b| {
|
||||
b.spawn((Text::new(label), font.clone(), TextColor(TEXT_PRIMARY)));
|
||||
b.spawn((
|
||||
Text::new(section),
|
||||
section_font.clone(),
|
||||
TextColor(TEXT_SECONDARY),
|
||||
));
|
||||
});
|
||||
for &(option, label, tooltip) in rows {
|
||||
panel
|
||||
.spawn((
|
||||
option,
|
||||
ActionButton,
|
||||
PopoverRow,
|
||||
Button,
|
||||
Tooltip::new(tooltip),
|
||||
Node {
|
||||
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(RADIUS_SM)),
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(ACTION_BTN_IDLE),
|
||||
))
|
||||
.with_children(|b| {
|
||||
b.spawn((Text::new(label), font.clone(), TextColor(TEXT_PRIMARY)));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -422,31 +464,28 @@ pub(super) fn handle_menu_option_click(
|
||||
interaction_query: Query<(&Interaction, &MenuOption), Changed<Interaction>>,
|
||||
popovers: Query<Entity, With<MenuPopover>>,
|
||||
backdrops: Query<Entity, With<MenuPopoverBackdrop>>,
|
||||
mut home: MessageWriter<ToggleHomeRequestEvent>,
|
||||
mut stats: MessageWriter<ToggleStatsRequestEvent>,
|
||||
mut achievements: MessageWriter<ToggleAchievementsRequestEvent>,
|
||||
mut profile: MessageWriter<ToggleProfileRequestEvent>,
|
||||
mut settings: MessageWriter<ToggleSettingsRequestEvent>,
|
||||
mut leaderboard: MessageWriter<ToggleLeaderboardRequestEvent>,
|
||||
mut help: MessageWriter<HelpRequestEvent>,
|
||||
progress: Option<Res<ProgressResource>>,
|
||||
daily: Option<Res<DailyChallengeResource>>,
|
||||
font_res: Option<Res<FontResource>>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
let mut clicked_any = false;
|
||||
let mut open_modes = false;
|
||||
for (interaction, option) in &interaction_query {
|
||||
if *interaction != Interaction::Pressed {
|
||||
continue;
|
||||
}
|
||||
clicked_any = true;
|
||||
match option {
|
||||
MenuOption::Home => {
|
||||
home.write(ToggleHomeRequestEvent);
|
||||
}
|
||||
MenuOption::Help => {
|
||||
help.write(HelpRequestEvent);
|
||||
}
|
||||
MenuOption::Modes => {
|
||||
open_modes = true;
|
||||
}
|
||||
MenuOption::Stats => {
|
||||
stats.write(ToggleStatsRequestEvent);
|
||||
}
|
||||
@@ -470,14 +509,6 @@ pub(super) fn handle_menu_option_click(
|
||||
commands.entity(e).despawn();
|
||||
}
|
||||
}
|
||||
if open_modes {
|
||||
spawn_modes_popover(
|
||||
&mut commands,
|
||||
progress.as_deref(),
|
||||
daily.as_deref(),
|
||||
font_res.as_deref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Despawns the [`ModesPopover`] and its backdrop when Escape / Android back
|
||||
|
||||
Reference in New Issue
Block a user