From cbe752125994e02270ab33060bc23e5b83cafa47 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Thu, 13 May 2021 20:46:17 -0400 Subject: [PATCH] Add toggle for minimap, fix scaling formula, reduce minimap VD for better performance, and add changelog entry. --- CHANGELOG.md | 1 + assets/voxygen/i18n/en/hud/map.ron | 1 + voxygen/src/hud/map.rs | 38 ++++++++++++++++++++++++++ voxygen/src/hud/minimap.rs | 7 ++--- voxygen/src/session/settings_change.rs | 4 +++ voxygen/src/settings/interface.rs | 2 ++ 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e80e286d45..542c1b35d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - /skill_preset command which allows you to apply skill presets - Added timed bans and ban history. - Added non-admin moderators with limit privileges and updated the security model to reflect this. +- Added a minimap mode that visualizes terrain within a chunk. - Chat tabs - NPC's now hear certain sounds - Renamed Animal Trainers to Beastmasters and gave them their own set of armor to wear diff --git a/assets/voxygen/i18n/en/hud/map.ron b/assets/voxygen/i18n/en/hud/map.ron index 2b75841070..61f3e1ccc1 100644 --- a/assets/voxygen/i18n/en/hud/map.ron +++ b/assets/voxygen/i18n/en/hud/map.ron @@ -14,6 +14,7 @@ "hud.map.caves": "Caves", "hud.map.cave": "Cave", "hud.map.peaks": "Mountains", + "hud.map.voxel_map": "Voxel map", "hud.map.trees": "Giant Trees", "hud.map.tree": "Giant Tree", "hud.map.town": "Town", diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index fea6aa9a98..8c9c06d2fd 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -65,6 +65,9 @@ widget_ids! { show_peaks_img, show_peaks_box, show_peaks_text, + show_voxel_map_img, + show_voxel_map_box, + show_voxel_map_text, show_difficulty_img, show_difficulty_box, show_difficulty_text, @@ -200,6 +203,7 @@ impl<'a> Widget for Map<'a> { let show_caves = self.global_state.settings.interface.map_show_caves; let show_trees = self.global_state.settings.interface.map_show_trees; let show_peaks = self.global_state.settings.interface.map_show_peaks; + let show_voxel_map = self.global_state.settings.interface.map_show_voxel_map; let show_topo_map = self.global_state.settings.interface.map_show_topo_map; let mut events = Vec::new(); let i18n = &self.localized_strings; @@ -636,6 +640,40 @@ impl<'a> Widget for Map<'a> { .graphics_for(state.ids.show_peaks_box) .color(TEXT_COLOR) .set(state.ids.show_peaks_text, ui); + // Voxel map + Image::new(self.imgs.mmap_poi_peak) + .down_from(state.ids.show_peaks_img, 10.0) + .w_h(20.0, 20.0) + .set(state.ids.show_voxel_map_img, ui); + if Button::image(if show_voxel_map { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox + }) + .w_h(18.0, 18.0) + .hover_image(if show_voxel_map { + self.imgs.checkbox_checked_mo + } else { + self.imgs.checkbox_mo + }) + .press_image(if show_voxel_map { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox_press + }) + .right_from(state.ids.show_voxel_map_img, 10.0) + .set(state.ids.show_voxel_map_box, ui) + .was_clicked() + { + events.push(Event::SettingsChange(MapShowVoxelMap(!show_voxel_map))); + } + Text::new(i18n.get("hud.map.voxel_map")) + .right_from(state.ids.show_voxel_map_box, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .graphics_for(state.ids.show_voxel_map_box) + .color(TEXT_COLOR) + .set(state.ids.show_voxel_map_text, ui); // Map icons if state.ids.mmap_poi_icons.len() < self.client.pois().len() { state.update(|state| { diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 1d7cd743da..9e86e98ece 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -52,7 +52,7 @@ pub struct VoxelMinimap { keyed_jobs: KeyedJobs, MinimapColumn>, } -const VOXEL_MINIMAP_SIDELENGTH: u32 = 512; +const VOXEL_MINIMAP_SIDELENGTH: u32 = 256; impl VoxelMinimap { pub fn new(ui: &mut Ui) -> Self { let mut composited = RgbaImage::new(VOXEL_MINIMAP_SIDELENGTH, VOXEL_MINIMAP_SIDELENGTH); @@ -394,8 +394,7 @@ impl<'a> Widget for MiniMap<'a> { let show_minimap = self.global_state.settings.interface.minimap_show; let is_facing_north = self.global_state.settings.interface.minimap_face_north; let show_topo_map = self.global_state.settings.interface.map_show_topo_map; - //let show_voxel_map = self.global_state.settings.interface.map_show_voxel_map; - let show_voxel_map = true; + let show_voxel_map = self.global_state.settings.interface.map_show_voxel_map; let orientation = if is_facing_north { Vec3::new(0.0, 1.0, 0.0) } else { @@ -563,7 +562,7 @@ impl<'a> Widget for MiniMap<'a> { } else { self.voxel_minimap.image_id.source_north }; - let scaling = (VOXEL_MINIMAP_SIDELENGTH as f64 / 32.0) * max_zoom / zoom; + let scaling = 32.0 * max_zoom / zoom; let cmod: Vec2 = (player_pos.xy() % 32.0).as_(); let rect_src = position::Rect::from_xy_dim( [ diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index db4cc70b0e..a6d2f4c7c8 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -122,6 +122,7 @@ pub enum Interface { MapShowCaves(bool), MapShowTrees(bool), MapShowPeaks(bool), + MapShowVoxelMap(bool), ResetInterfaceSettings, } @@ -511,6 +512,9 @@ impl SettingsChange { Interface::MapShowPeaks(map_show_peaks) => { settings.interface.map_show_peaks = map_show_peaks; }, + Interface::MapShowVoxelMap(map_show_voxel_map) => { + settings.interface.map_show_voxel_map = map_show_voxel_map; + }, Interface::ResetInterfaceSettings => { // Reset Interface Settings let tmp = settings.interface.intro_show; diff --git a/voxygen/src/settings/interface.rs b/voxygen/src/settings/interface.rs index 4e898a9977..b3101b7245 100644 --- a/voxygen/src/settings/interface.rs +++ b/voxygen/src/settings/interface.rs @@ -34,6 +34,7 @@ pub struct InterfaceSettings { pub map_show_caves: bool, pub map_show_trees: bool, pub map_show_peaks: bool, + pub map_show_voxel_map: bool, pub minimap_show: bool, pub minimap_face_north: bool, pub minimap_zoom: f64, @@ -67,6 +68,7 @@ impl Default for InterfaceSettings { map_show_caves: true, map_show_trees: false, map_show_peaks: false, + map_show_voxel_map: false, minimap_show: true, minimap_face_north: false, minimap_zoom: 10.0,