Show caves in map

This commit is contained in:
Christof Petig 2020-11-22 00:05:48 +01:00
parent d52b595240
commit a3db20c9d6
13 changed files with 104 additions and 2 deletions

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

Binary file not shown.

BIN
assets/voxygen/element/map/cave_hover.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -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",

View File

@ -136,4 +136,5 @@ pub enum SiteKind {
Town,
Dungeon { difficulty: u32 },
Castle,
Cave,
}

View File

@ -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",

View File

@ -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)
}
},
}
}
}

View File

@ -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)

View File

@ -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 {

View File

@ -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();

View File

@ -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,
}
}
}

View File

@ -56,6 +56,7 @@ pub struct Civs {
>,
pub sites: Store<Site>,
pub caves: Store<Vec2<i32>>,
}
// Change this to get rid of particularly horrid seeds
@ -231,7 +232,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 +293,10 @@ impl Civs {
chunk.spawn_rate = 0.0;
}
}
self.caves
.insert(path.first().unwrap().0 * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32));
self.caves
.insert(path.last().unwrap().0 * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32));
}
pub fn place(&self, id: Id<Place>) -> &Place { self.places.get(id) }

View File

@ -114,6 +114,16 @@ impl World {
wpos: site.center * TerrainChunkSize::RECT_SIZE.map(|e| e as i32),
}
})
.chain(
self.civs()
.caves
.iter()
.map(|(_, pos)| world_msg::SiteInfo {
name: None,
kind: world_msg::SiteKind::Cave,
wpos: *pos,
}),
)
.collect(),
..self.sim.get_map(index)
}