From 80d2fe2873bbc8df59b1770bc9158f694902b9f8 Mon Sep 17 00:00:00 2001 From: the-beper <193650145+the-beper@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:46:26 +0100 Subject: [PATCH] gui: tuning parts read their +hifr texture dictionary Tuning parts in a vehicle's _mods.rpf keep their textures in +hifr.ytd (for example gauntlet5_blower_a+hifr.ytd next to gauntlet5_blower_a.yft). The 3D preview looked only for .ytd and +hi.ytd, so such parts showed without their own textures. It now reads +hifr.ytd too, as one of the model's own dictionaries. Co-Authored-By: Claude Opus 5.5 --- crates/gui/src/preview.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/gui/src/preview.rs b/crates/gui/src/preview.rs index 34b7caa..4554349 100644 --- a/crates/gui/src/preview.rs +++ b/crates/gui/src/preview.rs @@ -562,11 +562,10 @@ pub(crate) fn load_preview(req: PreviewRequest) -> Loaded { Loaded { source, name: req.name.clone(), info, content, error, select: req.select.clone() } } -/// Texture dictionaries next to a model, named after it (`name.ytd`, and -/// `name+hi.ytd` as vehicles have). /// The texture dictionaries a model draws from: those of its name next to /// it, then the ones its dictionary inherits from (up to vehshare.ytd). -/// Tuning parts (in "_mods.rpf") use their vehicle's. +/// Tuning parts (in "_mods.rpf") use their vehicle's. A dictionary +/// is `name.ytd`, `name+hi.ytd` (vehicles) or `name+hifr.ytd` (tuning parts). fn sibling_textures(req: &PreviewRequest) -> Vec { let model = req.name.as_str(); let stem = model.rsplit_once('.').map_or(model, |(s, _)| s).to_ascii_lowercase(); @@ -575,7 +574,7 @@ fn sibling_textures(req: &PreviewRequest) -> Vec { Location::Archive(a) => a.join(name).read(req.keys.as_deref()).ok(), }; let here = |name: &str| req.rows.iter().find(|r| r.eq_ignore_ascii_case(&format!("{name}.ytd"))).cloned(); - let mut names = vec![stem.clone(), format!("{stem}+hi")]; + let mut names = vec![stem.clone(), format!("{stem}+hi"), format!("{stem}+hifr")]; if let Location::Archive(a) = &req.location { let archive = a.inner.iter().rev().chain(a.disk.file_name().map(|n| n.to_str().unwrap_or_default().to_string()).iter()).find(|p| p.to_ascii_lowercase().ends_with("_mods.rpf")).cloned(); if let Some(vehicle) = archive.map(|n| n.to_ascii_lowercase().trim_end_matches("_mods.rpf").to_string()) { @@ -662,3 +661,25 @@ pub(crate) fn load_icon(ctx: &egui::Context, png: &[u8]) -> Option String { name.rsplit_once('.').map(|(_, e)| e.to_ascii_uppercase()).unwrap_or_default() } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_tuning_part_reads_its_hifr_dictionary() { + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("car_blower_a+hifr.ytd"), include_bytes!("../tests/data/probe.ytd")).unwrap(); + let req = PreviewRequest { + name: "car_blower_a.yft".into(), + location: Location::Folder(dir.path().to_path_buf()), + rows: vec!["car_blower_a.yft".into(), "car_blower_a+hifr.ytd".into()], + keys: None, + shared: Arc::default(), + select: None, + delay: std::time::Duration::ZERO, + }; + let found = sibling_textures(&req); + assert!(found.iter().flat_map(|d| &d.textures).any(|t| t.name == "red_probe")); + } +}