aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/map/icon_texture_manager.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/client/map/icon_texture_manager.rs b/src/client/map/icon_texture_manager.rs
index c6b7fea..b64638c 100644
--- a/src/client/map/icon_texture_manager.rs
+++ b/src/client/map/icon_texture_manager.rs
@@ -10,6 +10,9 @@ use std::fs::{self, File};
/// The directory containing all files related to icons.
pub const ICON_DIR: &str = "assets/icons";
+/// Default amount of pixels per meter, which is used, when an icon does not have
+/// an associated ron-file, which sets them explicitly.
+pub const ICON_DEFAULT_PPM: f64 = 256.;
#[derive(Deserialize)]
pub(super) struct IconFileInfo {
@@ -65,9 +68,18 @@ impl IconTextureManager {
let mut file = file.path();
file.set_extension("ron");
- let ron = File::open(file).expect("Could not read ron file for icon information.");
- let icon_info: IconFileInfo =
- from_reader(ron).expect("Could not parse icon info from reader.");
+
+ /* Try to read the ron file containing information about this icon.
+ * If no ron-file is found, the anchor is set to the middle of the
+ * texture, and the default pixels per meter value is used. */
+ let icon_info = if let Ok(ron) = File::open(file) {
+ from_reader(ron).expect("Could not parse icon info from reader.")
+ } else {
+ IconFileInfo {
+ anchor: Vec2::new(texture.width as f64, texture.height as f64),
+ pixels_per_m: ICON_DEFAULT_PPM,
+ }
+ };
texture_data.push((texture, icon_info));
}