diff --git a/src/engine_constants/mod.rs b/src/engine_constants/mod.rs index 119c61a..5847627 100644 --- a/src/engine_constants/mod.rs +++ b/src/engine_constants/mod.rs @@ -92,7 +92,6 @@ pub struct CaretConsts { #[derive(serde::Serialize, serde::Deserialize)] pub struct TextureSizeTable { - r#override: bool, sizes: HashMap, } @@ -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... diff --git a/src/shared_game_state.rs b/src/shared_game_state.rs index b67feac..b0c8db3 100644 --- a/src/shared_game_state.rs +++ b/src/shared_game_state.rs @@ -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;