From f2ebbb7f7ffb524be63be024893cbe00c4c9e920 Mon Sep 17 00:00:00 2001
From: James Melkonian <jemelkonian@gmail.com>
Date: Mon, 5 Apr 2021 16:44:00 -0700
Subject: [PATCH] Map icon scaling

---
 client/src/lib.rs          |  2 +-
 voxygen/src/hud/map.rs     | 29 +++++++++++++++--------------
 voxygen/src/hud/minimap.rs | 18 +++++++++---------
 voxygen/src/settings.rs    |  2 ++
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/client/src/lib.rs b/client/src/lib.rs
index 161caab118..b0b30b8c8e 100644
--- a/client/src/lib.rs
+++ b/client/src/lib.rs
@@ -440,7 +440,7 @@ impl Client {
                                 Rgba::new(1.0, 0.9, 0.6, 1.0)
                             }
                         } else if is_contours && is_contour_line {
-                            Rgba::new(0.15, 0.15, 0.15, 0.9)
+                            Rgba::new(0.15, 0.15, 0.15, 0.8)
                         } else {
                             Rgba::new(rgba.r, rgba.g, rgba.b, 0.5)
                         }.map(|e| (e * 255.0) as u8);
diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs
index 2205df6b66..d3ee0b2f73 100644
--- a/voxygen/src/hud/map.rs
+++ b/voxygen/src/hud/map.rs
@@ -71,7 +71,7 @@ const SHOW_ECONOMY: bool = false; // turn this display off (for 0.9) until we ha
 #[derive(WidgetCommon)]
 pub struct Map<'a> {
     client: &'a Client,
-    world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
+    world_map: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
     imgs: &'a Imgs,
     fonts: &'a Fonts,
     #[conrod(common_builder)]
@@ -88,7 +88,7 @@ impl<'a> Map<'a> {
         client: &'a Client,
         imgs: &'a Imgs,
         rot_imgs: &'a ImgsRot,
-        world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
+        world_map: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
         fonts: &'a Fonts,
         pulse: f32,
         localized_strings: &'a Localization,
@@ -98,7 +98,7 @@ impl<'a> Map<'a> {
         Self {
             imgs,
             rot_imgs,
-            world_map_layers,
+            world_map,
             client,
             fonts,
             common: widget::CommonBuilder::default(),
@@ -267,12 +267,12 @@ impl<'a> Widget for Map<'a> {
         }*/
         // Map Layers
         // It is assumed that there is at least one layer
-        if state.ids.map_layers.len() < self.world_map_layers.0.len() {
+        if state.ids.map_layers.len() < self.world_map.0.len() {
             state.update(|state| {
                 state
                     .ids
                     .map_layers
-                    .resize(self.world_map_layers.0.len(), &mut ui.widget_id_generator())
+                    .resize(self.world_map.0.len(), &mut ui.widget_id_generator())
             });
         }
 
@@ -283,7 +283,7 @@ impl<'a> Widget for Map<'a> {
             .set(state.ids.map_layers[0], ui);
 
         // Map Size
-        let worldsize = self.world_map_layers.1;
+        let worldsize = self.world_map.1;
 
         // Coordinates
         let player_pos = self
@@ -334,7 +334,7 @@ impl<'a> Widget for Map<'a> {
         }
 
         // Map Layer Images
-        for (index, layer) in self.world_map_layers.0.iter().enumerate() {
+        for (index, layer) in self.world_map.0.iter().enumerate() {
             if index == 0 {
                 Image::new(layer.none)
                     .mid_top_with_margin_on(state.ids.map_align, 10.0)
@@ -603,6 +603,7 @@ impl<'a> Widget for Map<'a> {
             // Convert to relative pixel coordinates from the center of the map
             // Accounting for zooming
             let rpos = rfpos.map2(map_size, |e, sz| e * sz as f32 * zoom as f32);
+            let rside = zoom * 6.0;
 
             if rpos
                 .map2(map_size, |e, sz| e.abs() > sz as f32 / 2.0)
@@ -641,7 +642,7 @@ impl<'a> Widget for Map<'a> {
                 position::Relative::Scalar(rpos.x as f64),
                 position::Relative::Scalar(rpos.y as f64),
             )
-            .w_h(20.0 * 1.2, 20.0 * 1.2)
+            .w_h(rside * 1.2, rside * 1.2)
             .hover_image(match &site.kind {
                 SiteKind::Town => self.imgs.mmap_site_town_hover,
                 SiteKind::Dungeon { .. } => self.imgs.mmap_site_dungeon_hover,
@@ -700,16 +701,16 @@ impl<'a> Widget for Map<'a> {
                     _ => self.imgs.nothing,
                 })
                 .mid_top_with_margin_on(state.ids.mmap_site_icons[i], match difficulty {
-                    5 => -12.0 * size,
-                    _ => -4.0 * size,
+                    5 => -2.0 * zoom * size,
+                    _ => -1.0 * zoom * size,
                 })
                 .w(match difficulty {
-                    5 => 12.0 * size,
-                    _ => 4.0 * size * difficulty as f64,
+                    5 => 2.0 * zoom * size,
+                    _ => 1.0 * zoom * size * difficulty as f64,
                 })
                 .h(match difficulty {
-                    5 => 12.0 * size,
-                    _ => 4.0 * size,
+                    5 => 2.0 * size * zoom,
+                    _ => 1.0 * zoom * size,
                 })
                 .color(Some(match difficulty {
                     0 => QUALITY_LOW,
diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs
index e8c9dc8a70..b9e481c50a 100644
--- a/voxygen/src/hud/minimap.rs
+++ b/voxygen/src/hud/minimap.rs
@@ -47,7 +47,7 @@ pub struct MiniMap<'a> {
 
     imgs: &'a Imgs,
     rot_imgs: &'a ImgsRot,
-    world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
+    world_map: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
     fonts: &'a Fonts,
     #[conrod(common_builder)]
     common: widget::CommonBuilder,
@@ -60,7 +60,7 @@ impl<'a> MiniMap<'a> {
         client: &'a Client,
         imgs: &'a Imgs,
         rot_imgs: &'a ImgsRot,
-        world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
+        world_map: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
         fonts: &'a Fonts,
         ori: Vec3<f32>,
         global_state: &'a GlobalState,
@@ -69,7 +69,7 @@ impl<'a> MiniMap<'a> {
             client,
             imgs,
             rot_imgs,
-            world_map_layers,
+            world_map,
             fonts,
             common: widget::CommonBuilder::default(),
             ori,
@@ -99,7 +99,7 @@ impl<'a> Widget for MiniMap<'a> {
             ids: Ids::new(id_gen),
 
             zoom: {
-                let min_world_dim = self.world_map_layers.1.reduce_partial_min() as f64;
+                let min_world_dim = self.world_map.1.reduce_partial_min() as f64;
                 min_world_dim.min(
                     min_world_dim
                         * (TerrainChunkSize::RECT_SIZE.reduce_partial_max() as f64 / 32.0)
@@ -140,15 +140,15 @@ impl<'a> Widget for MiniMap<'a> {
                 .set(state.ids.mmap_frame_bg, ui);
 
             // Map size in chunk coords
-            let worldsize = self.world_map_layers.1;
+            let worldsize = self.world_map.1;
             // Map Layers
             // It is assumed that there is at least one layer
-            if state.ids.map_layers.len() < self.world_map_layers.0.len() {
+            if state.ids.map_layers.len() < self.world_map.0.len() {
                 state.update(|state| {
                     state
                         .ids
                         .map_layers
-                        .resize(self.world_map_layers.0.len(), &mut ui.widget_id_generator())
+                        .resize(self.world_map.0.len(), &mut ui.widget_id_generator())
                 });
             }
 
@@ -259,7 +259,7 @@ impl<'a> Widget for MiniMap<'a> {
 
             // Map Image
             // Map Layer Images
-            for (index, layer) in self.world_map_layers.0.iter().enumerate() {
+            for (index, layer) in self.world_map.0.iter().enumerate() {
                 let world_map_rotation = if is_facing_north {
                     layer.none
                 } else {
@@ -350,7 +350,7 @@ impl<'a> Widget for MiniMap<'a> {
                     SiteKind::Cave => Color::Rgba(1.0, 1.0, 1.0, 0.0),
                     SiteKind::Tree => Color::Rgba(1.0, 1.0, 1.0, 0.0),
                 }))
-                .parent(state.ids.map_layers[0])
+                .parent(state.ids.map_layers[2])
                 .set(state.ids.mmap_site_icons_bgs[i], ui);
                 Image::new(match &site.kind {
                     SiteKind::Town => self.imgs.mmap_site_town,
diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs
index 55dcd9851a..11c3a826ea 100644
--- a/voxygen/src/settings.rs
+++ b/voxygen/src/settings.rs
@@ -451,6 +451,7 @@ pub struct InterfaceSettings {
     pub loading_tips: bool,
     pub map_show_caves: bool,
     pub map_show_trees: bool,
+    pub map_show_topo: bool,
     pub minimap_show: bool,
     pub minimap_face_north: bool,
 }
@@ -483,6 +484,7 @@ impl Default for InterfaceSettings {
             loading_tips: true,
             map_show_caves: true,
             map_show_trees: true,
+            map_show_topo: false,
             minimap_show: true,
             minimap_face_north: false,
         }