Add texture size lookup file

This commit is contained in:
dawnDus 2022-02-26 14:07:35 -05:00
parent 9b3e2837b7
commit ccd4030dc1
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
2 changed files with 15 additions and 1 deletions

View File

@ -92,7 +92,6 @@ pub struct CaretConsts {
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TextureSizeTable {
r#override: bool,
sizes: HashMap<String, (u16, u16)>,
}
@ -1767,6 +1766,20 @@ impl EngineConstants {
pub fn apply_constant_json_files(&mut self) {}
pub fn load_texture_size_hints(&mut self, ctx: &mut Context) -> GameResult {
if let Ok(file) = filesystem::open_find(ctx, &self.base_paths, "/texture_sizes.json") {
match serde_json::from_reader::<_, TextureSizeTable>(file) {
Ok(tex_overrides) => {
for (key, (x, y)) in tex_overrides.sizes {
self.tex_sizes.insert(key, (x, y));
}
}
Err(err) => log::warn!("Failed to deserialize texture sizes: {}", err),
}
}
Ok(())
}
/// Loads bullet.tbl and arms_level.tbl from CS+ files,
/// even though they match vanilla 1:1, we should load them for completeness
/// or if any crazy person uses it for a CS+ mod...

View File

@ -316,6 +316,7 @@ impl SharedGameState {
self.constants.special_treatment_for_csplus_mods(self.mod_path.as_ref());
self.constants.load_csplus_tables(ctx)?;
self.constants.load_animated_faces(ctx)?;
self.constants.load_texture_size_hints(ctx)?;
let stages = StageData::load_stage_table(ctx, &self.constants.base_paths)?;
self.stages = stages;