mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'christof/cave_in_maps' into 'master'
Show cave entries in the map See merge request veloren/veloren!1540
This commit is contained in:
commit
c1fc9e08f1
BIN
assets/voxygen/element/map/cave.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/cave.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/map/cave_bg.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/cave_bg.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/map/cave_hover.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/cave_hover.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -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",
|
||||
|
@ -136,4 +136,5 @@ pub enum SiteKind {
|
||||
Town,
|
||||
Dungeon { difficulty: u32 },
|
||||
Castle,
|
||||
Cave,
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ fn main() {
|
||||
sample_pos(
|
||||
config,
|
||||
sampler,
|
||||
index,
|
||||
samples,
|
||||
uniform_idx_as_vec2(map_size_lg, posi),
|
||||
)
|
||||
|
@ -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<i32>, Vec2<i32>),
|
||||
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<Site>,
|
||||
pub caves: Store<CaveInfo>,
|
||||
}
|
||||
|
||||
// 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<impl Rng>) {
|
||||
fn generate_cave(&mut self, ctx: &mut GenCtx<impl Rng>) {
|
||||
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>) -> &Place { self.places.get(id) }
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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<i32>) -> f
|
||||
pub fn sample_pos(
|
||||
config: &MapConfig,
|
||||
sampler: &WorldSim,
|
||||
index: IndexRef,
|
||||
samples: Option<&[Option<ColumnSample>]>,
|
||||
pos: Vec2<i32>,
|
||||
) -> 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
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -2,7 +2,7 @@ mod block_mask;
|
||||
mod castle;
|
||||
mod dungeon;
|
||||
pub mod economy;
|
||||
mod namegen;
|
||||
pub mod namegen;
|
||||
mod settlement;
|
||||
|
||||
// Reexports
|
||||
|
Loading…
Reference in New Issue
Block a user