diff --git a/assets/voxygen/element/map/cave.png b/assets/voxygen/element/map/cave.png new file mode 100644 index 0000000000..e6837435ba --- /dev/null +++ b/assets/voxygen/element/map/cave.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3d514d0d812da55df4ab4a1084f08ca7d6374150450b19ba0b5a975f9befdcd +size 156 diff --git a/assets/voxygen/element/map/cave_bg.png b/assets/voxygen/element/map/cave_bg.png new file mode 100644 index 0000000000..626f6b8d38 --- /dev/null +++ b/assets/voxygen/element/map/cave_bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c96e7cee0ef68c2bd50407c016c8af2dded071020e053cccc610b9e1bda615f7 +size 155 diff --git a/assets/voxygen/element/map/cave_hover.png b/assets/voxygen/element/map/cave_hover.png new file mode 100644 index 0000000000..e7197a9a61 --- /dev/null +++ b/assets/voxygen/element/map/cave_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b6f9c60863d94567050fc9fe4e22152ec5fc43ccca6694b9c1ac8a09a037e43 +size 212 diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index 5b58e3ec5e..2c57b849ef 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -418,6 +418,8 @@ magically infused items?"#, "hud.map.towns": "Towns", "hud.map.castles": "Castles", "hud.map.dungeons": "Dungeons", + "hud.map.caves": "Caves", + "hud.map.cave": "Cave", "hud.map.town": "Town", "hud.map.castle": "Castle", "hud.map.dungeon": "Dungeon", diff --git a/common/src/msg/world_msg.rs b/common/src/msg/world_msg.rs index be2d16292d..5290871b81 100644 --- a/common/src/msg/world_msg.rs +++ b/common/src/msg/world_msg.rs @@ -136,4 +136,5 @@ pub enum SiteKind { Town, Dungeon { difficulty: u32 }, Castle, + Cave, } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index fe9f525e2e..c68a98253a 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -210,6 +210,9 @@ image_ids! { mmap_site_castle: "voxygen.element.map.castle", mmap_site_castle_hover: "voxygen.element.map.castle_hover", mmap_site_castle_bg: "voxygen.element.map.castle_bg", + mmap_site_cave_bg: "voxygen.element.map.cave_bg", + mmap_site_cave_hover: "voxygen.element.map.cave_hover", + mmap_site_cave: "voxygen.element.map.cave", // Window Parts window_3: "voxygen.element.frames.window_3", diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 8ea0fd4944..498babea7d 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -55,7 +55,9 @@ widget_ids! { drag_ico, zoom_txt, zoom_ico, - + show_caves_img, + show_caves_box, + show_caves_text, } } @@ -117,6 +119,7 @@ pub enum Event { ShowTowns(bool), ShowCastles(bool), ShowDungeons(bool), + ShowCaves(bool), Close, } @@ -142,6 +145,7 @@ impl<'a> Widget for Map<'a> { let show_towns = self.global_state.settings.gameplay.map_show_towns; let show_dungeons = self.global_state.settings.gameplay.map_show_dungeons; let show_castles = self.global_state.settings.gameplay.map_show_castles; + let show_caves = self.global_state.settings.gameplay.map_show_caves; let mut events = Vec::new(); let i18n = &self.localized_strings; // Tooltips @@ -453,6 +457,40 @@ impl<'a> Widget for Map<'a> { .graphics_for(state.ids.show_dungeons_box) .color(TEXT_COLOR) .set(state.ids.show_dungeons_text, ui); + // Caves + Image::new(self.imgs.mmap_site_cave) + .down_from(state.ids.show_dungeons_img, 10.0) + .w_h(20.0, 20.0) + .set(state.ids.show_caves_img, ui); + if Button::image(if show_caves { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox + }) + .w_h(18.0, 18.0) + .hover_image(if show_caves { + self.imgs.checkbox_checked_mo + } else { + self.imgs.checkbox_mo + }) + .press_image(if show_caves { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox_press + }) + .right_from(state.ids.show_caves_img, 10.0) + .set(state.ids.show_caves_box, ui) + .was_clicked() + { + events.push(Event::ShowCaves(!show_caves)); + } + Text::new(i18n.get("hud.map.caves")) + .right_from(state.ids.show_caves_box, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .graphics_for(state.ids.show_caves_box) + .color(TEXT_COLOR) + .set(state.ids.show_caves_text, ui); // Map icons if state.ids.mmap_site_icons.len() < self.client.sites().len() { state.update(|state| { @@ -493,6 +531,7 @@ impl<'a> Widget for Map<'a> { SiteKind::Town => i18n.get("hud.map.town"), SiteKind::Dungeon { .. } => i18n.get("hud.map.dungeon"), SiteKind::Castle => i18n.get("hud.map.castle"), + SiteKind::Cave => i18n.get("hud.map.cave"), }); let (difficulty, desc) = match &site.kind { SiteKind::Town => (0, i18n.get("hud.map.town").to_string()), @@ -502,6 +541,7 @@ impl<'a> Widget for Map<'a> { .replace("{difficulty}", difficulty.to_string().as_str()), ), SiteKind::Castle => (0, i18n.get("hud.map.castle").to_string()), + SiteKind::Cave => (0, i18n.get("hud.map.cave").to_string()), }; let site_btn = Button::image(match &site.kind { SiteKind::Town => { @@ -525,6 +565,13 @@ impl<'a> Widget for Map<'a> { self.imgs.nothing } }, + SiteKind::Cave => { + if show_caves { + self.imgs.mmap_site_cave + } else { + self.imgs.nothing + } + }, }) .x_y_position_relative_to( state.ids.grid, @@ -536,6 +583,7 @@ impl<'a> Widget for Map<'a> { SiteKind::Town => self.imgs.mmap_site_town_hover, SiteKind::Dungeon { .. } => self.imgs.mmap_site_dungeon_hover, SiteKind::Castle => self.imgs.mmap_site_castle_hover, + SiteKind::Cave => self.imgs.mmap_site_cave_hover, }) .image_color(UI_HIGHLIGHT_0) .with_tooltip( @@ -555,6 +603,7 @@ impl<'a> Widget for Map<'a> { 5 => QUALITY_DEBUG, _ => TEXT_COLOR, }, + SiteKind::Cave => TEXT_COLOR, }, ); // Only display sites that are toggled on @@ -574,6 +623,11 @@ impl<'a> Widget for Map<'a> { site_btn.set(state.ids.mmap_site_icons[i], ui); } }, + SiteKind::Cave => { + if show_caves { + site_btn.set(state.ids.mmap_site_icons[i], ui); + } + }, } // Difficulty from 0-6 @@ -626,6 +680,11 @@ impl<'a> Widget for Map<'a> { dif_img.set(state.ids.site_difs[i], ui) } }, + SiteKind::Cave => { + if show_caves { + dif_img.set(state.ids.site_difs[i], ui) + } + }, } } } diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 9d53a08e6b..e4264dbbed 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -258,6 +258,7 @@ impl<'a> Widget for MiniMap<'a> { SiteKind::Town => self.imgs.mmap_site_town_bg, SiteKind::Dungeon { .. } => self.imgs.mmap_site_dungeon_bg, SiteKind::Castle => self.imgs.mmap_site_castle_bg, + SiteKind::Cave => self.imgs.mmap_site_cave_bg, }) .x_y_position_relative_to( state.ids.grid, @@ -277,6 +278,7 @@ impl<'a> Widget for MiniMap<'a> { 5 => QUALITY_DEBUG, _ => Color::Rgba(1.0, 1.0, 1.0, 0.0), }, + SiteKind::Cave => Color::Rgba(1.0, 1.0, 1.0, 0.0), })) .parent(state.ids.grid) .set(state.ids.mmap_site_icons_bgs[i], ui); @@ -284,6 +286,7 @@ impl<'a> Widget for MiniMap<'a> { SiteKind::Town => self.imgs.mmap_site_town, SiteKind::Dungeon { .. } => self.imgs.mmap_site_dungeon, SiteKind::Castle => self.imgs.mmap_site_castle, + SiteKind::Cave => self.imgs.mmap_site_cave, }) .middle_of(state.ids.mmap_site_icons_bgs[i]) .w_h(20.0, 20.0) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index c513fa3ccf..4ee016ee6e 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -330,6 +330,7 @@ pub enum Event { MapShowTowns(bool), MapShowDungeons(bool), MapShowCastles(bool), + MapShowCaves(bool), AdjustWindowSize([u16; 2]), ChangeFullscreenMode(FullScreenSettings), ToggleParticlesEnabled(bool), @@ -2285,6 +2286,9 @@ impl Hud { map::Event::MapDrag(map_drag) => { events.push(Event::MapDrag(map_drag)); }, + map::Event::ShowCaves(map_show_caves) => { + events.push(Event::MapShowCaves(map_show_caves)); + }, } } } else { diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index a22d6ec32c..3c7002c475 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -984,6 +984,10 @@ impl PlayState for SessionState { global_state.settings.gameplay.map_show_castles = map_show_castles; global_state.settings.save_to_file_warn(); }, + HudEvent::MapShowCaves(map_show_caves) => { + global_state.settings.gameplay.map_show_caves = map_show_caves; + global_state.settings.save_to_file_warn(); + }, HudEvent::ChangeGamma(new_gamma) => { global_state.settings.graphics.gamma = new_gamma; global_state.settings.save_to_file_warn(); diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 1ad981073a..cf4cd44a5e 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -522,6 +522,7 @@ pub struct GameplaySettings { pub map_show_dungeons: bool, pub map_show_castles: bool, pub loading_tips: bool, + pub map_show_caves: bool, } impl Default for GameplaySettings { @@ -558,6 +559,7 @@ impl Default for GameplaySettings { map_show_dungeons: true, map_show_castles: true, loading_tips: true, + map_show_caves: true, } } } diff --git a/world/examples/water.rs b/world/examples/water.rs index cba3bc7250..61e031bd90 100644 --- a/world/examples/water.rs +++ b/world/examples/water.rs @@ -72,7 +72,6 @@ fn main() { sample_pos( config, sampler, - index, samples, uniform_idx_as_vec2(map_size_lg, posi), ) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 4ef8c81ca9..fb990d9d95 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -6,7 +6,7 @@ use self::{Occupation::*, Stock::*}; use crate::{ config::CONFIG, sim::WorldSim, - site::{Castle, Dungeon, Settlement, Site as WorldSite}, + site::{namegen::NameGen, Castle, Dungeon, Settlement, Site as WorldSite}, util::{attempt, seed_expan, MapVec, CARDINALS, NEIGHBORS}, Index, }; @@ -38,6 +38,11 @@ const fn initial_civ_count(map_size_lg: MapSizeLg) -> u32 { (3 << (map_size_lg.vec().x + map_size_lg.vec().y)) >> 16 } +pub struct CaveInfo { + pub location: (Vec2, Vec2), + pub name: String, +} + #[allow(clippy::type_complexity)] // TODO: Pending review in #587 #[derive(Default)] pub struct Civs { @@ -56,6 +61,7 @@ pub struct Civs { >, pub sites: Store, + pub caves: Store, } // Change this to get rid of particularly horrid seeds @@ -231,7 +237,7 @@ impl Civs { } // TODO: Move this - fn generate_cave(&self, ctx: &mut GenCtx) { + fn generate_cave(&mut self, ctx: &mut GenCtx) { let mut pos = ctx .sim .get_size() @@ -292,6 +298,24 @@ impl Civs { chunk.spawn_rate = 0.0; } } + self.caves.insert(CaveInfo { + location: ( + path.first().unwrap().0 * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32), + path.last().unwrap().0 * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32), + ), + name: { + let name = NameGen::location(&mut ctx.rng).generate(); + match ctx.rng.gen_range(0, 7) { + 0 => format!("{} Hole", name), + 1 => format!("{} Cavern", name), + 2 => format!("{} Hollow", name), + 3 => format!("{} Tunnel", name), + 4 => format!("{} Mouth", name), + 5 => format!("{} Grotto", name), + _ => format!("{} Den", name), + } + }, + }); } pub fn place(&self, id: Id) -> &Place { self.places.get(id) } diff --git a/world/src/lib.rs b/world/src/lib.rs index a3c4cf7ca1..cc7bcfaf1f 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -114,6 +114,22 @@ impl World { wpos: site.center * TerrainChunkSize::RECT_SIZE.map(|e| e as i32), } }) + .chain( + self.civs() + .caves + .iter() + .map(|(_, info)| { + // separate the two locations, combine with name + std::iter::once((info.name.clone(), info.location.0)) + .chain(std::iter::once((info.name.clone(), info.location.1))) + }) + .flatten() // unwrap inner iteration + .map(|(name, pos)| world_msg::SiteInfo { + name: Some(name), + kind: world_msg::SiteKind::Cave, + wpos: pos, + }), + ) .collect(), ..self.sim.get_map(index) } diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index b7be863e60..63384a1de3 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -1,7 +1,7 @@ use crate::{ column::ColumnSample, sim::{RiverKind, WorldSim}, - IndexRef, CONFIG, + CONFIG, }; use common::{ terrain::{ @@ -71,7 +71,6 @@ pub fn sample_wpos(config: &MapConfig, sampler: &WorldSim, wpos: Vec2) -> f pub fn sample_pos( config: &MapConfig, sampler: &WorldSim, - index: IndexRef, samples: Option<&[Option]>, pos: Vec2, ) -> MapSample { @@ -102,8 +101,6 @@ pub fn sample_pos( river_kind, spline_derivative, is_path, - is_cave, - _near_site, ) = sampler .get(pos) .map(|sample| { @@ -118,13 +115,6 @@ pub fn sample_pos( sample.river.river_kind, sample.river.spline_derivative, sample.path.0.is_way(), - sample.cave.0.is_way(), - sample.sites.iter().any(|site| { - index.sites[*site] - .get_origin() - .distance_squared(pos * TerrainChunkSize::RECT_SIZE.x as i32) - < 64i32.pow(2) - }), ) }) .unwrap_or(( @@ -138,8 +128,6 @@ pub fn sample_pos( None, Vec2::zero(), false, - false, - false, )); let humidity = humidity.min(1.0).max(0.0); @@ -247,12 +235,8 @@ pub fn sample_pos( ), }; // TODO: Make principled. - let rgb = /*if near_site { - Rgb::new(0x57, 0x39, 0x33) - } else*/ if is_path { + let rgb = if is_path { Rgb::new(0x37, 0x29, 0x23) - } else if is_cave { - Rgb::new(0x37, 0x37, 0x37) } else { rgb }; diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index a6b9f1f93b..d0beeefa2f 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -1476,7 +1476,7 @@ impl WorldSim { map_config.is_shaded = false; map_config.generate( - |pos| sample_pos(&map_config, self, index, Some(&samples_data), pos), + |pos| sample_pos(&map_config, self, Some(&samples_data), pos), |pos| sample_wpos(&map_config, self, pos), |pos, (r, g, b, _a)| { // We currently ignore alpha and replace it with the height at pos, scaled to diff --git a/world/src/site/mod.rs b/world/src/site/mod.rs index cbe82647c3..da168c28f5 100644 --- a/world/src/site/mod.rs +++ b/world/src/site/mod.rs @@ -2,7 +2,7 @@ mod block_mask; mod castle; mod dungeon; pub mod economy; -mod namegen; +pub mod namegen; mod settlement; // Reexports