Merge pull request #1173 from ludovic111/fix/launcher-says-no-sounds
🤖 Agent: merged after integration wave 2 on the desktop (integ/w2 @ 38307d15 = main c16b41ab + this wave): fmt, clippy -D warnings, workspace + launcher + telemetry-server tests, release build and every affected parity harness pass; the 3 harness failures and the panel test passed on rerun (known flakes).
This commit is contained in:
@@ -592,6 +592,32 @@ pub fn is_prepared(tag: &str) -> bool {
|
||||
resources(tag).join(RESOURCES_MANIFEST).exists()
|
||||
}
|
||||
|
||||
/// Whether a version's resources hold Minecraft's sounds, which `sounds` copies from the player's own
|
||||
/// install beside the preparation. A version prepared while that copy failed (Mojang's republished 26.3
|
||||
/// asset index, #1076), or one that reused such a version's resources, plays no sound at all (#1035).
|
||||
pub fn has_sounds(tag: &str) -> bool {
|
||||
sounds_in(&resources(tag))
|
||||
}
|
||||
|
||||
fn sounds_in(resources: &Path) -> bool {
|
||||
// What the game's sound registry reads (horizon-client sound_events.rs).
|
||||
resources.join("assets/minecraft/sounds.json").is_file()
|
||||
}
|
||||
|
||||
/// What the Play page says of a version's resources.
|
||||
pub fn resources_summary(prepared: bool, sounds: bool, version: &str) -> String {
|
||||
match (prepared, sounds) {
|
||||
(false, _) => {
|
||||
format!("Not prepared. Horizon needs the files of your own Minecraft {version}.")
|
||||
}
|
||||
(true, true) => format!("Prepared for Minecraft {version}"),
|
||||
(true, false) => format!(
|
||||
"Prepared for Minecraft {version}, without its sounds: the game will be silent. \
|
||||
Prepare again to copy them from your Minecraft install."
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the resources `from` prepared are the ones preparing `to` would make. The output
|
||||
/// depends on the Horizon version, not only on Minecraft's: the manifest records the hashes of
|
||||
/// the vanilla exporters it was made with (mods/horizon/src/test/java/.../parity), and the
|
||||
@@ -2165,6 +2191,30 @@ mod tests {
|
||||
use super::*;
|
||||
use std::cmp::Ordering::*;
|
||||
|
||||
#[test]
|
||||
fn resources_without_sounds_are_reported() {
|
||||
let dir = std::env::temp_dir().join(format!("horizon-no-sounds-{}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&dir);
|
||||
fs::create_dir_all(dir.join("assets/minecraft/textures")).unwrap();
|
||||
fs::write(dir.join(RESOURCES_MANIFEST), "{}").unwrap();
|
||||
assert!(!sounds_in(&dir));
|
||||
fs::write(dir.join("assets/minecraft/sounds.json"), "{}").unwrap();
|
||||
assert!(sounds_in(&dir));
|
||||
fs::remove_dir_all(&dir).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
resources_summary(true, true, "26.3"),
|
||||
"Prepared for Minecraft 26.3"
|
||||
);
|
||||
let silent = resources_summary(true, false, "26.3");
|
||||
assert!(silent.contains("without its sounds") && silent.contains("Prepare again"));
|
||||
// Not prepared says only that, sounds or not.
|
||||
assert_eq!(
|
||||
resources_summary(false, false, "26.3"),
|
||||
resources_summary(false, true, "26.3")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_game_plays_under_its_own_audio_stream_name() {
|
||||
if std::env::var_os("PIPEWIRE_PROPS").is_some() {
|
||||
|
||||
+4
-2
@@ -422,10 +422,12 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> {
|
||||
} else {
|
||||
" "
|
||||
};
|
||||
let state = if backend::is_prepared(tag) {
|
||||
let state = if !backend::is_prepared(tag) {
|
||||
"not prepared"
|
||||
} else if backend::has_sounds(tag) {
|
||||
"prepared"
|
||||
} else {
|
||||
"not prepared"
|
||||
"prepared, no sounds (prepare again)"
|
||||
};
|
||||
println!("{mark} {tag} {state}");
|
||||
}
|
||||
|
||||
@@ -1388,6 +1388,8 @@ impl Launcher {
|
||||
));
|
||||
};
|
||||
let prepared = backend::is_prepared(&tag);
|
||||
// Prepared without sounds (#1035): Prepare again is the fix, so it stands out.
|
||||
let silent = prepared && !backend::has_sounds(&tag);
|
||||
let version = backend::game_version(&tag);
|
||||
let hero = self.hero(&tag, &version, prepared, cx);
|
||||
let running = self.client.is_some() || self.starting_client.is_some();
|
||||
@@ -1429,15 +1431,13 @@ impl Launcher {
|
||||
|
||||
let resources_value = if self.preparing {
|
||||
"Preparing…".to_string()
|
||||
} else if prepared {
|
||||
format!("Prepared for Minecraft {version}")
|
||||
} else {
|
||||
format!("Not prepared. Horizon needs the files of your own Minecraft {version}.")
|
||||
backend::resources_summary(prepared, !silent, &version)
|
||||
};
|
||||
let mut prepare = button(
|
||||
"prepare",
|
||||
if prepared { "Prepare again" } else { "Prepare" },
|
||||
if prepared {
|
||||
if prepared && !silent {
|
||||
Kind::Ghost
|
||||
} else {
|
||||
Kind::Secondary
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ impl Session {
|
||||
"list_versions" => {
|
||||
let installed = backend::installed();
|
||||
let mut out = json!({
|
||||
"installed": installed.iter().map(|t| json!({ "tag": t, "prepared": backend::is_prepared(t) })).collect::<Vec<_>>(),
|
||||
"installed": installed.iter().map(|t| json!({ "tag": t, "prepared": backend::is_prepared(t), "sounds": backend::has_sounds(t) })).collect::<Vec<_>>(),
|
||||
"selected": backend::resolve_version(None).ok(),
|
||||
});
|
||||
if !args
|
||||
|
||||
Reference in New Issue
Block a user