mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-11 10:31:38 -10:00
Music page: its headings are lang keys again
775981f9a8 made the biome headings at run time and brought back raw English
labels shown with Text::literal. The built-in and biome group labels are now
keys under horizon.pages.music, and Row::Heading shows tr(key).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
775981f9a8
commit
90acfe8039
3 files changed
+36
-22
No files matched your search
@@ -1475,7 +1475,7 @@ pub struct MusicTrack {
|
||||
/// One group of rows on the Music page: a situation, or a dimension's biomes.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct MusicGroup {
|
||||
/// The heading the page shows ("Overworld", "Nether biomes").
|
||||
/// The lang key of the heading the page shows (`horizon.pages.music.overworld`).
|
||||
pub label: String,
|
||||
/// The rows, in `sounds.json` order.
|
||||
pub tracks: Vec<MusicTrack>,
|
||||
@@ -1820,7 +1820,7 @@ enum Row {
|
||||
Big(Opt),
|
||||
Pair(Opt, Option<Opt>),
|
||||
Header(&'static str),
|
||||
/// A heading the page makes at run time (the Music page's groups).
|
||||
/// A heading the page makes at run time, by lang key (the Music page's groups).
|
||||
Heading(String),
|
||||
/// A line of grey text (a path).
|
||||
Note(String),
|
||||
@@ -3260,8 +3260,8 @@ impl OptionsUi {
|
||||
let label = tr(key);
|
||||
self.heading_row(&mut out, label, &mut y, w, top);
|
||||
}
|
||||
Row::Heading(text) => {
|
||||
let label = Text::literal(text);
|
||||
Row::Heading(key) => {
|
||||
let label = tr(key);
|
||||
self.heading_row(&mut out, label, &mut y, w, top);
|
||||
}
|
||||
Row::Note(text) => {
|
||||
@@ -7648,7 +7648,7 @@ mod tests {
|
||||
let mut s = Settings::default();
|
||||
let mut ui = OptionsUi {
|
||||
music_groups: vec![MusicGroup {
|
||||
label: "Overworld".into(),
|
||||
label: "horizon.pages.music.overworld".into(),
|
||||
tracks: vec![
|
||||
MusicTrack {
|
||||
event: "minecraft:music.game".into(),
|
||||
|
||||
@@ -39,6 +39,17 @@
|
||||
"horizon.pages.split_profiles": "Who's playing?",
|
||||
"horizon.pages.split_setup": "Splitscreen Setup",
|
||||
"horizon.pages.music": "Music",
|
||||
"horizon.pages.music.menu": "Menu",
|
||||
"horizon.pages.music.overworld": "Overworld",
|
||||
"horizon.pages.music.creative": "Creative",
|
||||
"horizon.pages.music.underwater": "Underwater",
|
||||
"horizon.pages.music.end": "The End",
|
||||
"horizon.pages.music.boss": "Boss",
|
||||
"horizon.pages.music.credits": "Credits",
|
||||
"horizon.pages.music.overworld_biomes": "Overworld biomes",
|
||||
"horizon.pages.music.nether_biomes": "Nether biomes",
|
||||
"horizon.pages.music.end_biomes": "End biomes",
|
||||
"horizon.pages.music.other": "Other music",
|
||||
"horizon.pages.music.empty": "No music tracks: the game's sounds are not loaded.",
|
||||
"horizon.pages.music.tooltip": "The built-in tracks, by situation: play one now, or turn any off so the game stops picking it.",
|
||||
"horizon.pages.settings.tooltip": "Horizon's own settings: graphics, controllers, extras and mods.",
|
||||
|
||||
@@ -58,17 +58,17 @@ impl Music {
|
||||
pub fn game() -> Self {
|
||||
Self::new("minecraft:music.game", 12000, 24000, false)
|
||||
}
|
||||
/// The built-in situations the Music page lists, in its order: the label
|
||||
/// the page's group shows and the music that situation plays.
|
||||
/// The built-in situations the Music page lists, in its order: the lang key
|
||||
/// of the heading the page's group shows and the music that situation plays.
|
||||
pub fn builtin() -> [(&'static str, Music); 7] {
|
||||
[
|
||||
("Menu", Self::menu()),
|
||||
("Overworld", Self::game()),
|
||||
("Creative", Self::creative()),
|
||||
("Underwater", Self::under_water()),
|
||||
("The End", Self::end()),
|
||||
("Boss", Self::end_boss()),
|
||||
("Credits", Self::credits()),
|
||||
("horizon.pages.music.menu", Self::menu()),
|
||||
("horizon.pages.music.overworld", Self::game()),
|
||||
("horizon.pages.music.creative", Self::creative()),
|
||||
("horizon.pages.music.underwater", Self::under_water()),
|
||||
("horizon.pages.music.end", Self::end()),
|
||||
("horizon.pages.music.boss", Self::end_boss()),
|
||||
("horizon.pages.music.credits", Self::credits()),
|
||||
]
|
||||
}
|
||||
/// `Music.CODEC`.
|
||||
@@ -152,13 +152,13 @@ pub fn track_groups(registry: &SoundRegistry) -> Vec<MusicGroup> {
|
||||
fn biome_group(event: &str) -> (u8, &'static str) {
|
||||
let path = event.strip_prefix("minecraft:").unwrap_or(event);
|
||||
if path.starts_with("music.overworld.") {
|
||||
(1, "Overworld biomes")
|
||||
(1, "horizon.pages.music.overworld_biomes")
|
||||
} else if path.starts_with("music.nether.") {
|
||||
(2, "Nether biomes")
|
||||
(2, "horizon.pages.music.nether_biomes")
|
||||
} else if path.starts_with("music.end.") {
|
||||
(3, "End biomes")
|
||||
(3, "horizon.pages.music.end_biomes")
|
||||
} else {
|
||||
(4, "Other music")
|
||||
(4, "horizon.pages.music.other")
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
@@ -915,11 +915,14 @@ mod tests {
|
||||
assert_eq!(
|
||||
summary,
|
||||
[
|
||||
("Menu", vec!["one"]),
|
||||
("Overworld", vec!["shared", "second"]),
|
||||
("horizon.pages.music.menu", vec!["one"]),
|
||||
("horizon.pages.music.overworld", vec!["shared", "second"]),
|
||||
// A biome pool's own track, from the pool that plays it.
|
||||
("Overworld biomes", vec!["bromeliad", "aerie"]),
|
||||
("Nether biomes", vec!["rubedo"]),
|
||||
(
|
||||
"horizon.pages.music.overworld_biomes",
|
||||
vec!["bromeliad", "aerie"]
|
||||
),
|
||||
("horizon.pages.music.nether_biomes", vec!["rubedo"]),
|
||||
]
|
||||
);
|
||||
// Each row plays from a pool that has the track; no track repeats.
|
||||
|
||||
Reference in new issue
Block a user