map icons

This commit is contained in:
Monty Marz 2020-11-15 02:40:23 +01:00 committed by Joshua Barretto
parent de685b00b2
commit 1864f4626c
21 changed files with 172 additions and 86 deletions

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

Binary file not shown.

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

Binary file not shown.

BIN
assets/voxygen/element/map/dungeon.png (Stored with Git LFS)

Binary file not shown.

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

Binary file not shown.

BIN
assets/voxygen/element/map/town.png (Stored with Git LFS)

Binary file not shown.

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

Binary file not shown.

BIN
assets/world/tree/willow/1.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/willow/2.vox (Stored with Git LFS)

Binary file not shown.

BIN
assets/world/tree/willow/3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/tree/willow/4.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,11 +1,11 @@
use super::*;
use common::{
event::{EventBus, ServerEvent},
terrain::TerrainGrid,
state::DeltaTime,
comp,
event::{EventBus, ServerEvent},
state::DeltaTime,
terrain::TerrainGrid,
};
use specs::{Join, Read, ReadStorage, WriteStorage, System, WriteExpect, ReadExpect};
use specs::{Join, Read, ReadExpect, ReadStorage, System, WriteExpect, WriteStorage};
use std::sync::Arc;
const ENTITY_TICK_PERIOD: u64 = 30;
@ -47,21 +47,30 @@ impl<'a> System<'a> for Sys {
for (id, entity) in rtsim.entities.iter_mut() {
if entity.is_loaded {
// No load-specific behaviour yet
} else if rtsim.chunks.chunk_at(entity.pos.xy()).map(|c| c.is_loaded).unwrap_or(false) {
} else if rtsim
.chunks
.chunk_at(entity.pos.xy())
.map(|c| c.is_loaded)
.unwrap_or(false)
{
to_reify.push(id);
} else {
// Simulate behaviour
if let Some(travel_to) = entity.controller.travel_to {
// Move towards target at approximate character speed
entity.pos += Vec3::from((travel_to.xy() - entity.pos.xy())
.try_normalized()
.unwrap_or_else(Vec2::zero)
* entity.get_body().max_speed_approx()
* entity.controller.speed_factor)
* dt.0;
entity.pos += Vec3::from(
(travel_to.xy() - entity.pos.xy())
.try_normalized()
.unwrap_or_else(Vec2::zero)
* entity.get_body().max_speed_approx()
* entity.controller.speed_factor,
) * dt.0;
}
if let Some(alt) = world.sim().get_alt_approx(entity.pos.xy().map(|e| e.floor() as i32)) {
if let Some(alt) = world
.sim()
.get_alt_approx(entity.pos.xy().map(|e| e.floor() as i32))
{
entity.pos.z = alt;
}
}
@ -77,7 +86,10 @@ impl<'a> System<'a> for Sys {
for id in to_reify {
rtsim.reify_entity(id);
let entity = &rtsim.entities[id];
let spawn_pos = terrain.find_space(entity.pos.map(|e| e.floor() as i32)).map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0);
let spawn_pos = terrain
.find_space(entity.pos.map(|e| e.floor() as i32))
.map(|e| e as f32)
+ Vec3::new(0.5, 0.5, 0.0);
let body = entity.get_body();
server_emitter.emit(ServerEvent::CreateNpc {
pos: comp::Pos(spawn_pos),

View File

@ -1,10 +1,10 @@
use super::*;
use common::{
comp::Pos,
event::{EventBus, ServerEvent},
terrain::TerrainGrid,
comp::Pos,
};
use specs::{Join, Read, ReadStorage, System, Write, ReadExpect, WriteExpect, Entities};
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, Write, WriteExpect};
pub struct Sys;
impl<'a> System<'a> for Sys {

View File

@ -1,10 +1,6 @@
use super::SysTimer;
use crate::{
chunk_generator::ChunkGenerator,
client::Client,
presence::Presence,
rtsim::RtSim,
Tick,
chunk_generator::ChunkGenerator, client::Client, presence::Presence, rtsim::RtSim, Tick,
};
use common::{
comp::{self, bird_medium, item::tool::AbilityMap, Alignment, Pos},

View File

@ -194,7 +194,11 @@ image_ids! {
mmap_minus_hover: "voxygen.element.buttons.min_plus.mmap_button-min_hover",
mmap_minus_press: "voxygen.element.buttons.min_plus.mmap_button-min_press",
mmap_site_town: "voxygen.element.map.town",
mmap_site_town_hover: "voxygen.element.map.town_hover",
mmap_site_dungeon: "voxygen.element.map.dungeon",
mmap_site_dungeon_hover: "voxygen.element.map.dungeon_hover",
mmap_site_castle: "voxygen.element.map.castle",
mmap_site_castle_hover: "voxygen.element.map.castle_hover",
// Window Parts
window_3: "voxygen.element.frames.window_3",

View File

@ -1,21 +1,22 @@
use super::{
img_ids::{Imgs, ImgsRot},
Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN,
Show, TEXT_COLOR, UI_GOLD, UI_HIGHLIGHT_0, UI_MAIN,
};
use crate::{
i18n::Localization,
ui::{fonts::Fonts, img_ids, ImageSlider},
ui::{fonts::Fonts, img_ids, ImageFrame, ImageSlider, Tooltip, TooltipManager, Tooltipable},
GlobalState,
};
use client::{self, Client};
use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize, msg::world_msg::SiteKind};
use common::{comp, msg::world_msg::SiteKind, terrain::TerrainChunkSize, vol::RectVolSize};
use conrod_core::{
color, position,
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use specs::WorldExt;
use vek::*;
widget_ids! {
struct Ids {
frame,
@ -41,13 +42,14 @@ pub struct Map<'a> {
client: &'a Client,
world_map: &'a (img_ids::Rotations, Vec2<u32>),
imgs: &'a Imgs,
rot_imgs: &'a ImgsRot,
fonts: &'a Fonts,
#[conrod(common_builder)]
common: widget::CommonBuilder,
_pulse: f32,
localized_strings: &'a Localization,
global_state: &'a GlobalState,
rot_imgs: &'a ImgsRot,
tooltip_manager: &'a mut TooltipManager,
}
impl<'a> Map<'a> {
#[allow(clippy::too_many_arguments)] // TODO: Pending review in #587
@ -61,6 +63,7 @@ impl<'a> Map<'a> {
pulse: f32,
localized_strings: &'a Localization,
global_state: &'a GlobalState,
tooltip_manager: &'a mut TooltipManager,
) -> Self {
Self {
_show: show,
@ -73,6 +76,7 @@ impl<'a> Map<'a> {
_pulse: pulse,
localized_strings,
global_state,
tooltip_manager,
}
}
}
@ -105,6 +109,24 @@ impl<'a> Widget for Map<'a> {
let widget::UpdateArgs { state, ui, .. } = args;
let zoom = self.global_state.settings.gameplay.map_zoom * 0.8;
let mut events = Vec::new();
// Tooltips
let site_tooltip = Tooltip::new({
// Edge images [t, b, r, l]
// Corner images [tr, tl, br, bl]
let edge = &self.rot_imgs.tt_side;
let corner = &self.rot_imgs.tt_corner;
ImageFrame::new(
[edge.cw180, edge.none, edge.cw270, edge.cw90],
[corner.none, corner.cw270, corner.cw90, corner.cw180],
Color::Rgba(0.08, 0.07, 0.04, 1.0),
5.0,
)
})
.title_font_size(self.fonts.cyri.scale(15))
.parent(ui.window)
.desc_font_size(self.fonts.cyri.scale(12))
.font_id(self.fonts.cyri.conrod_id)
.desc_text_color(TEXT_COLOR);
// Frame
Image::new(self.imgs.map_bg)
.w_h(1052.0, 886.0)
@ -237,37 +259,52 @@ impl<'a> Widget for Map<'a> {
// Map icons
if state.ids.mmap_site_icons.len() < self.client.sites().len() {
state.update(|state| {
state.ids.mmap_site_icons.resize(
self.client.sites().len(),
&mut ui.widget_id_generator(),
)
state
.ids
.mmap_site_icons
.resize(self.client.sites().len(), &mut ui.widget_id_generator())
});
}
for (i, site) in self.client.sites().iter().enumerate() {
let rwpos = site.wpos.map(|e| e as f32) - player_pos;
let rcpos = rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32) * zoom as f32 * 3.0 / 4.0;
let rpos = Vec2::unit_x().rotated_z(0.0) * rcpos.x
+ Vec2::unit_y().rotated_z(0.0) * rcpos.y;
let rcpos =
rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32) * zoom as f32 * 3.0
/ 4.0;
let rpos =
Vec2::unit_x().rotated_z(0.0) * rcpos.x + Vec2::unit_y().rotated_z(0.0) * rcpos.y;
// TODO: Why does this require the magic constant 0.73? This this related to scaling issues?
if rpos.map2(map_size, |e, sz| e.abs() > sz as f32 / 2.0).reduce_or() {
if rpos
.map2(map_size, |e, sz| e.abs() > sz as f32 / 2.0)
.reduce_or()
{
continue;
}
Image::new(match &site.kind {
let title = match &site.kind {
SiteKind::Town => "Town",
SiteKind::Dungeon => "Dungeon",
SiteKind::Castle => "Castle",
};
let desc = "";
Button::image(match &site.kind {
SiteKind::Town => self.imgs.mmap_site_town,
SiteKind::Dungeon => self.imgs.mmap_site_dungeon,
SiteKind::Castle => continue,
SiteKind::Castle => self.imgs.mmap_site_castle,
})
.x_y_position_relative_to(
state.ids.grid,
position::Relative::Scalar(rpos.x as f64),
position::Relative::Scalar(rpos.y as f64),
)
.w_h(16.0 / 0.73, 16.0 / 0.73)
.floating(true)
.parent(ui.window)
.set(state.ids.mmap_site_icons[i], ui);
.x_y_position_relative_to(
state.ids.grid,
position::Relative::Scalar(rpos.x as f64),
position::Relative::Scalar(rpos.y as f64),
)
.w_h(20.0 * 1.2, 20.0 * 1.2)
.hover_image(match &site.kind {
SiteKind::Town => self.imgs.mmap_site_town_hover,
SiteKind::Dungeon => self.imgs.mmap_site_dungeon_hover,
SiteKind::Castle => self.imgs.mmap_site_castle_hover,
})
.image_color(UI_HIGHLIGHT_0)
.parent(ui.window)
.with_tooltip(self.tooltip_manager, title, desc, &site_tooltip, TEXT_COLOR)
.set(state.ids.mmap_site_icons[i], ui);
}
// Cursor pos relative to playerpos and widget size

View File

@ -4,12 +4,13 @@ use super::{
};
use crate::ui::{fonts::Fonts, img_ids};
use client::{self, Client};
use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize, msg::world_msg::SiteKind};
use common::{comp, msg::world_msg::SiteKind, terrain::TerrainChunkSize, vol::RectVolSize};
use conrod_core::{
color, position,
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use inline_tweak::*;
use specs::WorldExt;
use vek::*;
@ -226,37 +227,44 @@ impl<'a> Widget for MiniMap<'a> {
// Map icons
if state.ids.mmap_site_icons.len() < self.client.sites().len() {
state.update(|state| {
state.ids.mmap_site_icons.resize(
self.client.sites().len(),
&mut ui.widget_id_generator(),
)
state
.ids
.mmap_site_icons
.resize(self.client.sites().len(), &mut ui.widget_id_generator())
});
}
for (i, site) in self.client.sites().iter().enumerate() {
let rwpos = site.wpos.map(|e| e as f32) - player_pos;
let rcpos = rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32) * state.zoom as f32 / 4.0;
let rcpos = rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32)
* state.zoom as f32
/ 4.0;
let rpos = Vec2::unit_x().rotated_z(self.ori.x) * rcpos.x
+ Vec2::unit_y().rotated_z(self.ori.x) * rcpos.y;
// TODO: Why does this require the magic constant 0.73? This this related to scaling issues?
if rpos.map2(map_size, |e, sz| e.abs() > sz as f32 / 0.73 / 2.0).reduce_or() {
// TODO: Why does this require the magic constant 0.73? This this related to
// scaling issues?
if rpos
.map2(map_size, |e, sz| e.abs() > sz as f32 / 0.73 / 2.0)
.reduce_or()
{
continue;
}
Image::new(match &site.kind {
SiteKind::Town => self.imgs.mmap_site_town,
SiteKind::Dungeon => self.imgs.mmap_site_dungeon,
SiteKind::Castle => continue,
SiteKind::Castle => self.imgs.mmap_site_castle,
})
.x_y_position_relative_to(
state.ids.grid,
position::Relative::Scalar(rpos.x as f64),
position::Relative::Scalar(rpos.y as f64),
)
.w_h(16.0 / 0.73, 16.0 / 0.73)
.floating(true)
.parent(ui.window)
.set(state.ids.mmap_site_icons[i], ui);
.x_y_position_relative_to(
state.ids.grid,
position::Relative::Scalar(rpos.x as f64),
position::Relative::Scalar(rpos.y as f64),
)
.w_h(20.0 * tweak!(1.0), 20.0 * tweak!(1.0))
.color(Some(UI_HIGHLIGHT_0))
.floating(true)
.parent(ui.window)
.set(state.ids.mmap_site_icons[i], ui);
}
// Compass directions

View File

@ -148,6 +148,7 @@ const DEFAULT_NPC: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
const UI_MAIN: Color = Color::Rgba(0.61, 0.70, 0.70, 1.0); // Greenish Blue
//const UI_MAIN: Color = Color::Rgba(0.1, 0.1, 0.1, 0.97); // Dark
const UI_HIGHLIGHT_0: Color = Color::Rgba(0.79, 1.09, 1.09, 1.0);
const UI_GOLD: Color = Color::Rgba(0.75, 0.58, 0.0, 1.0);
// Pull-Down menu BG color
const MENU_BG: Color = Color::Rgba(0.1, 0.12, 0.12, 1.0);
//const UI_DARK_0: Color = Color::Rgba(0.25, 0.37, 0.37, 1.0);
@ -2251,6 +2252,7 @@ impl Hud {
self.pulse,
&self.i18n,
&global_state,
tooltip_manager,
)
.set(self.ids.map, ui_widgets)
{

View File

@ -45,11 +45,13 @@ struct Visibility {
impl Visibility {
/// Should the chunk actually get rendered?
fn is_visible(&self) -> bool {
// Currently, we don't take into account in_range to allow all chunks to do pop-in.
// This isn't really a problem because we no longer have VD mist or anything like that.
// Also, we don't load chunks outside of the VD anyway so this literally just controls
// which chunks get actually rendered.
/*self.in_range &&*/ self.in_frustum
// Currently, we don't take into account in_range to allow all chunks to do
// pop-in. This isn't really a problem because we no longer have VD mist
// or anything like that. Also, we don't load chunks outside of the VD
// anyway so this literally just controls which chunks get actually
// rendered.
/* self.in_range && */
self.in_frustum
}
}
@ -246,9 +248,7 @@ pub struct Terrain<V: RectRasterableVol> {
}
impl TerrainChunkData {
pub fn can_shadow_sun(&self) -> bool {
self.visible.is_visible() || self.can_shadow_sun
}
pub fn can_shadow_sun(&self) -> bool { self.visible.is_visible() || self.can_shadow_sun }
}
impl<V: RectRasterableVol> Terrain<V> {

View File

@ -57,7 +57,9 @@ pub fn apply_trees_to(canvas: &mut Canvas) {
|| col.path.map(|(d, _, _, _)| d < 12.0).unwrap_or(false)
{
return None;
} else if !is_quirky && ((seed.wrapping_mul(13)) & 0xFF) as f32 / 256.0 > col.tree_density {
} else if !is_quirky
&& ((seed.wrapping_mul(13)) & 0xFF) as f32 / 256.0 > col.tree_density
{
return None;
}
@ -72,8 +74,12 @@ pub fn apply_trees_to(canvas: &mut Canvas) {
}
} else {
match col.forest_kind {
ForestKind::Oak if QUIRKY_RAND.chance(seed + 1, 1.0 / 16.0) => &OAK_STUMPS,
ForestKind::Oak if QUIRKY_RAND.chance(seed + 2, 1.0 / 20.0) => &FRUIT_TREES,
ForestKind::Oak if QUIRKY_RAND.chance(seed + 1, 1.0 / 16.0) => {
&OAK_STUMPS
},
ForestKind::Oak if QUIRKY_RAND.chance(seed + 2, 1.0 / 20.0) => {
&FRUIT_TREES
},
ForestKind::Palm => &PALMS,
ForestKind::Savannah => &ACACIAS,
ForestKind::Oak => &OAKS,

View File

@ -42,7 +42,7 @@ use crate::{
};
use common::{
generation::{ChunkSupplement, EntityInfo},
msg::{WorldMapMsg, world_msg},
msg::{world_msg, WorldMapMsg},
terrain::{Block, BlockKind, SpriteKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize},
vol::{ReadVol, RectVolSize, WriteVol},
};
@ -93,7 +93,9 @@ impl World {
pub fn get_map_data(&self, index: IndexRef) -> WorldMapMsg {
WorldMapMsg {
sites: self.civs().sites
sites: self
.civs()
.sites
.iter()
.map(|(_, site)| {
world_msg::SiteInfo {

View File

@ -75,7 +75,8 @@ impl RngCore for RandomPerm {
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
dest.iter_mut().for_each(|b| *b = (self.next_u32() & 0xFF) as u8);
dest.iter_mut()
.for_each(|b| *b = (self.next_u32() & 0xFF) as u8);
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {