mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add layers to minimap
This commit is contained in:
parent
bacda06dba
commit
8ee1fc4a0f
@ -352,8 +352,9 @@ impl Client {
|
|||||||
let MapConfig {
|
let MapConfig {
|
||||||
gain,
|
gain,
|
||||||
is_contours,
|
is_contours,
|
||||||
is_hill_shaded,
|
is_height_map,
|
||||||
is_political,
|
is_political,
|
||||||
|
is_roads,
|
||||||
..
|
..
|
||||||
} = *map_config;
|
} = *map_config;
|
||||||
let mut is_contour_line = false;
|
let mut is_contour_line = false;
|
||||||
@ -365,7 +366,8 @@ impl Client {
|
|||||||
let alti = alt[pos];
|
let alti = alt[pos];
|
||||||
// Compute contours (chunks are assigned in the river code below)
|
// Compute contours (chunks are assigned in the river code below)
|
||||||
let altj = rescale_height(scale_height_big(alti));
|
let altj = rescale_height(scale_height_big(alti));
|
||||||
let chunk_contour = (altj * gain / 150.0) as u32;
|
let contour_interval = 150.0;
|
||||||
|
let chunk_contour = (altj * gain / contour_interval) as u32;
|
||||||
|
|
||||||
// Compute downhill.
|
// Compute downhill.
|
||||||
let downhill = {
|
let downhill = {
|
||||||
@ -374,7 +376,7 @@ impl Client {
|
|||||||
for nposi in neighbors(*map_size_lg, posi) {
|
for nposi in neighbors(*map_size_lg, posi) {
|
||||||
let nbh = alt.raw()[nposi];
|
let nbh = alt.raw()[nposi];
|
||||||
let nalt = rescale_height(scale_height_big(nbh));
|
let nalt = rescale_height(scale_height_big(nbh));
|
||||||
let nchunk_contour = (nalt * gain / 150.0) as u32;
|
let nchunk_contour = (nalt * gain / contour_interval) as u32;
|
||||||
if !is_contour_line && chunk_contour > nchunk_contour {
|
if !is_contour_line && chunk_contour > nchunk_contour {
|
||||||
is_contour_line = true;
|
is_contour_line = true;
|
||||||
}
|
}
|
||||||
@ -412,7 +414,7 @@ impl Client {
|
|||||||
.unwrap_or(wpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32));
|
.unwrap_or(wpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32));
|
||||||
let is_path = rgba.r == 0x37 && rgba.g == 0x29 && rgba.b == 0x23;
|
let is_path = rgba.r == 0x37 && rgba.g == 0x29 && rgba.b == 0x23;
|
||||||
let rgba = rgba.map(|e: u8| e as f64 / 255.0);
|
let rgba = rgba.map(|e: u8| e as f64 / 255.0);
|
||||||
let rgba = if is_hill_shaded {
|
let rgba = if is_height_map {
|
||||||
if is_path {
|
if is_path {
|
||||||
// Path color is Rgb::new(0x37, 0x29, 0x23)
|
// Path color is Rgb::new(0x37, 0x29, 0x23)
|
||||||
Rgba::new(0.9, 0.9, 0.63, 1.0)
|
Rgba::new(0.9, 0.9, 0.63, 1.0)
|
||||||
@ -427,9 +429,8 @@ impl Client {
|
|||||||
let lightness = (alt + 0.2).min(1.0) as f64;
|
let lightness = (alt + 0.2).min(1.0) as f64;
|
||||||
Rgba::new(lightness, 0.9 * lightness, 0.5 * lightness, 0.5)
|
Rgba::new(lightness, 0.9 * lightness, 0.5 * lightness, 0.5)
|
||||||
}
|
}
|
||||||
} else if is_contours && is_contour_line {
|
} else if is_roads && is_path {
|
||||||
// Color contour lines
|
Rgba::new(0.9, 0.9, 0.63, 1.0)
|
||||||
Rgba::new(0.15, 0.15, 0.15, 0.9)
|
|
||||||
} else if is_political {
|
} else if is_political {
|
||||||
if is_path {
|
if is_path {
|
||||||
Rgba::new(0.3, 0.3, 0.3, 1.0)
|
Rgba::new(0.3, 0.3, 0.3, 1.0)
|
||||||
@ -438,6 +439,8 @@ impl Client {
|
|||||||
} else {
|
} else {
|
||||||
Rgba::new(1.0, 0.9, 0.6, 1.0)
|
Rgba::new(1.0, 0.9, 0.6, 1.0)
|
||||||
}
|
}
|
||||||
|
} else if is_contours && is_contour_line {
|
||||||
|
Rgba::new(0.15, 0.15, 0.15, 0.9)
|
||||||
} else {
|
} else {
|
||||||
Rgba::new(rgba.r, rgba.g, rgba.b, 0.5)
|
Rgba::new(rgba.r, rgba.g, rgba.b, 0.5)
|
||||||
}.map(|e| (e * 255.0) as u8);
|
}.map(|e| (e * 255.0) as u8);
|
||||||
@ -485,8 +488,8 @@ impl Client {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
// Generate topographic map
|
// Generate topographic map
|
||||||
//map_config.is_hill_shaded = true;
|
|
||||||
map_config.is_contours = true;
|
map_config.is_contours = true;
|
||||||
|
map_config.is_roads = true;
|
||||||
map_config.generate(
|
map_config.generate(
|
||||||
|pos| sample_pos(&map_config, pos, &alt, &rgba, &map_size, &map_size_lg, max_height),
|
|pos| sample_pos(&map_config, pos, &alt, &rgba, &map_size, &map_size_lg, max_height),
|
||||||
|wpos| {
|
|wpos| {
|
||||||
|
@ -321,16 +321,19 @@ pub struct MapConfig<'a> {
|
|||||||
///
|
///
|
||||||
/// Defaults to false.
|
/// Defaults to false.
|
||||||
pub is_contours: bool,
|
pub is_contours: bool,
|
||||||
/// If true, hill shading is applied to the terrain and all the
|
/// If true, a yellow/terracotta heightmap shading is applied to the
|
||||||
/// colors are different. Is incompatible with humidity/temperature/shaded
|
/// terrain and water is a faded blue.
|
||||||
/// maps.
|
|
||||||
///
|
///
|
||||||
/// Defaults to false
|
/// Defaults to false
|
||||||
pub is_hill_shaded: bool,
|
pub is_height_map: bool,
|
||||||
/// If true, terrain is white, rivers, borders, and roads are black.
|
/// If true, terrain is white, rivers, borders, and roads are black.
|
||||||
///
|
///
|
||||||
/// Defaults to false
|
/// Defaults to false
|
||||||
pub is_political: bool,
|
pub is_political: bool,
|
||||||
|
/// If true, roads are colored on top of everything else
|
||||||
|
///
|
||||||
|
/// Defaults to false
|
||||||
|
pub is_roads: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const QUADRANTS: usize = 4;
|
pub const QUADRANTS: usize = 4;
|
||||||
@ -412,8 +415,9 @@ impl<'a> MapConfig<'a> {
|
|||||||
is_humidity: false,
|
is_humidity: false,
|
||||||
is_debug: false,
|
is_debug: false,
|
||||||
is_contours: false,
|
is_contours: false,
|
||||||
is_hill_shaded: false,
|
is_height_map: false,
|
||||||
is_political: false,
|
is_political: false,
|
||||||
|
is_roads: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +515,7 @@ impl<'a> MapConfig<'a> {
|
|||||||
let alt = alt as f32;
|
let alt = alt as f32;
|
||||||
let wposi = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
let wposi = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
||||||
let rgb = Rgb::new(rgba.r, rgba.g, rgba.b).map(|e| e as f64 / 255.0);
|
let rgb = Rgb::new(rgba.r, rgba.g, rgba.b).map(|e| e as f64 / 255.0);
|
||||||
let rgba = rgba.map(|e| e as f64 / 255.0);
|
let mut rgba = rgba.map(|e| e as f64 / 255.0);
|
||||||
|
|
||||||
// Material properties:
|
// Material properties:
|
||||||
//
|
//
|
||||||
@ -587,7 +591,7 @@ impl<'a> MapConfig<'a> {
|
|||||||
if has_river {
|
if has_river {
|
||||||
let water_rgb = Rgb::new(0, ((g_water) * 1.0) as u8, ((b_water) * 1.0) as u8)
|
let water_rgb = Rgb::new(0, ((g_water) * 1.0) as u8, ((b_water) * 1.0) as u8)
|
||||||
.map(|e| e as f64 / 255.0);
|
.map(|e| e as f64 / 255.0);
|
||||||
//rgba = Rgba::new(water_rgb.r, water_rgb.g, water_rgb.b, 1.0);
|
rgba = Rgba::new(water_rgb.r, water_rgb.g, water_rgb.b, rgba.a);
|
||||||
k_s = Rgb::new(1.0, 1.0, 1.0);
|
k_s = Rgb::new(1.0, 1.0, 1.0);
|
||||||
k_d = water_rgb;
|
k_d = water_rgb;
|
||||||
k_a = water_rgb;
|
k_a = water_rgb;
|
||||||
|
@ -31,9 +31,7 @@ widget_ids! {
|
|||||||
location_name,
|
location_name,
|
||||||
indicator,
|
indicator,
|
||||||
indicator_overlay,
|
indicator_overlay,
|
||||||
grid_layer_0,
|
map_layers[],
|
||||||
grid_layer_1,
|
|
||||||
grid_layer_2,
|
|
||||||
map_title,
|
map_title,
|
||||||
qlog_title,
|
qlog_title,
|
||||||
zoom_slider,
|
zoom_slider,
|
||||||
@ -125,7 +123,6 @@ pub enum Event {
|
|||||||
ShowDungeons(bool),
|
ShowDungeons(bool),
|
||||||
ShowCaves(bool),
|
ShowCaves(bool),
|
||||||
ShowTrees(bool),
|
ShowTrees(bool),
|
||||||
ShowTopoMap(bool),
|
|
||||||
Close,
|
Close,
|
||||||
RequestSiteInfo(SiteId),
|
RequestSiteInfo(SiteId),
|
||||||
}
|
}
|
||||||
@ -187,7 +184,6 @@ impl<'a> Widget for Map<'a> {
|
|||||||
let show_castles = self.global_state.settings.interface.map_show_castles;
|
let show_castles = self.global_state.settings.interface.map_show_castles;
|
||||||
let show_caves = self.global_state.settings.interface.map_show_caves;
|
let show_caves = self.global_state.settings.interface.map_show_caves;
|
||||||
let show_trees = self.global_state.settings.interface.map_show_trees;
|
let show_trees = self.global_state.settings.interface.map_show_trees;
|
||||||
let show_topo_map = self.global_state.settings.interface.map_show_topo_map;
|
|
||||||
let mut events = Vec::new();
|
let mut events = Vec::new();
|
||||||
let i18n = &self.localized_strings;
|
let i18n = &self.localized_strings;
|
||||||
// Tooltips
|
// Tooltips
|
||||||
@ -269,16 +265,24 @@ impl<'a> Widget for Map<'a> {
|
|||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.location_name, ui),
|
.set(state.ids.location_name, ui),
|
||||||
}*/
|
}*/
|
||||||
|
// Map Layers
|
||||||
|
// It is assumed that there is at least one layer
|
||||||
|
if state.ids.map_layers.len() < self.world_map_layers.0.len() {
|
||||||
|
state.update(|state| {
|
||||||
|
state
|
||||||
|
.ids
|
||||||
|
.map_layers
|
||||||
|
.resize(self.world_map_layers.0.len(), &mut ui.widget_id_generator())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Image::new(self.imgs.map_frame_art)
|
Image::new(self.imgs.map_frame_art)
|
||||||
.mid_top_with_margin_on(state.ids.map_align, 5.0)
|
.mid_top_with_margin_on(state.ids.map_align, 5.0)
|
||||||
.w_h(765.0, 765.0)
|
.w_h(765.0, 765.0)
|
||||||
.parent(state.ids.bg)
|
.parent(state.ids.bg)
|
||||||
.set(state.ids.grid_layer_0, ui);
|
.set(state.ids.map_layers[0], ui);
|
||||||
// Map Image
|
|
||||||
//let (world_map, worldsize) = if !show_topo_map { self.world_map } else { self.world_map_topo };
|
// Map Size
|
||||||
let world_map_layer_0 = &self.world_map_layers.0[0];
|
|
||||||
let world_map_layer_1 = &self.world_map_layers.0[1];
|
|
||||||
let world_map_layer_2 = &self.world_map_layers.0[2];
|
|
||||||
let worldsize = self.world_map_layers.1;
|
let worldsize = self.world_map_layers.1;
|
||||||
|
|
||||||
// Coordinates
|
// Coordinates
|
||||||
@ -300,7 +304,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
// Handle dragging
|
// Handle dragging
|
||||||
let drag = self.global_state.settings.interface.map_drag;
|
let drag = self.global_state.settings.interface.map_drag;
|
||||||
let dragged: Vec2<f64> = ui
|
let dragged: Vec2<f64> = ui
|
||||||
.widget_input(state.ids.grid_layer_0)
|
.widget_input(state.ids.map_layers[0])
|
||||||
.drags()
|
.drags()
|
||||||
.left()
|
.left()
|
||||||
.map(|drag| Vec2::<f64>::from(drag.delta_xy))
|
.map(|drag| Vec2::<f64>::from(drag.delta_xy))
|
||||||
@ -328,32 +332,30 @@ impl<'a> Widget for Map<'a> {
|
|||||||
{
|
{
|
||||||
events.push(Event::Close);
|
events.push(Event::Close);
|
||||||
}
|
}
|
||||||
// Map layer 0
|
|
||||||
Image::new(world_map_layer_0.none)
|
// Map Layer Images
|
||||||
.mid_top_with_margin_on(state.ids.map_align, 10.0)
|
for (index, layer) in self.world_map_layers.0.iter().enumerate() {
|
||||||
.w_h(map_size.x, map_size.y)
|
if index == 0 {
|
||||||
.parent(state.ids.bg)
|
Image::new(layer.none)
|
||||||
.source_rectangle(rect_src)
|
.mid_top_with_margin_on(state.ids.map_align, 10.0)
|
||||||
.set(state.ids.grid_layer_0, ui);
|
.w_h(map_size.x, map_size.y)
|
||||||
// Map layer 1
|
.parent(state.ids.bg)
|
||||||
Image::new(world_map_layer_1.none)
|
.source_rectangle(rect_src)
|
||||||
.mid_top_with_margin_on(state.ids.map_align, 10.0)
|
.set(state.ids.map_layers[index], ui);
|
||||||
.w_h(map_size.x, map_size.y)
|
} else {
|
||||||
.parent(state.ids.bg)
|
Image::new(layer.none)
|
||||||
.source_rectangle(rect_src)
|
.mid_top_with_margin_on(state.ids.map_align, 10.0)
|
||||||
.graphics_for(state.ids.grid_layer_0)
|
.w_h(map_size.x, map_size.y)
|
||||||
.set(state.ids.grid_layer_1, ui);
|
.parent(state.ids.bg)
|
||||||
// Map layer 2
|
.source_rectangle(rect_src)
|
||||||
Image::new(world_map_layer_2.none)
|
.graphics_for(state.ids.map_layers[0])
|
||||||
.mid_top_with_margin_on(state.ids.map_align, 10.0)
|
.set(state.ids.map_layers[index], ui);
|
||||||
.w_h(map_size.x, map_size.y)
|
}
|
||||||
.parent(state.ids.bg)
|
}
|
||||||
.source_rectangle(rect_src)
|
|
||||||
.graphics_for(state.ids.grid_layer_0)
|
|
||||||
.set(state.ids.grid_layer_2, ui);
|
|
||||||
// Handle zooming with the mousewheel
|
// Handle zooming with the mousewheel
|
||||||
let scrolled: f64 = ui
|
let scrolled: f64 = ui
|
||||||
.widget_input(state.ids.grid_layer_0)
|
.widget_input(state.ids.map_layers[0])
|
||||||
.scrolls()
|
.scrolls()
|
||||||
.map(|scroll| scroll.y)
|
.map(|scroll| scroll.y)
|
||||||
.sum();
|
.sum();
|
||||||
@ -635,7 +637,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
SiteKind::Tree => self.imgs.mmap_site_tree,
|
SiteKind::Tree => self.imgs.mmap_site_tree,
|
||||||
})
|
})
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid_layer_0,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
position::Relative::Scalar(rpos.y as f64),
|
position::Relative::Scalar(rpos.y as f64),
|
||||||
)
|
)
|
||||||
@ -810,7 +812,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
_ => self.imgs.indicator_group,
|
_ => self.imgs.indicator_group,
|
||||||
})
|
})
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid_layer_0,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
position::Relative::Scalar(rpos.y as f64),
|
position::Relative::Scalar(rpos.y as f64),
|
||||||
)
|
)
|
||||||
@ -844,7 +846,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
{
|
{
|
||||||
Image::new(self.rot_imgs.indicator_mmap_small.target_north)
|
Image::new(self.rot_imgs.indicator_mmap_small.target_north)
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid_layer_0,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
position::Relative::Scalar(rpos.y as f64),
|
position::Relative::Scalar(rpos.y as f64),
|
||||||
)
|
)
|
||||||
@ -863,7 +865,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
};
|
};
|
||||||
if Button::image(self.imgs.button)
|
if Button::image(self.imgs.button)
|
||||||
.w_h(92.0, icon_size.y)
|
.w_h(92.0, icon_size.y)
|
||||||
.mid_bottom_with_margin_on(state.ids.grid_layer_0, -36.0)
|
.mid_bottom_with_margin_on(state.ids.map_layers[0], -36.0)
|
||||||
.hover_image(if recenter {
|
.hover_image(if recenter {
|
||||||
self.imgs.button_hover
|
self.imgs.button_hover
|
||||||
} else {
|
} else {
|
||||||
@ -895,7 +897,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Image::new(self.imgs.m_move_ico)
|
Image::new(self.imgs.m_move_ico)
|
||||||
.bottom_left_with_margins_on(state.ids.grid_layer_0, -36.0, 0.0)
|
.bottom_left_with_margins_on(state.ids.map_layers[0], -36.0, 0.0)
|
||||||
.w_h(icon_size.x, icon_size.y)
|
.w_h(icon_size.x, icon_size.y)
|
||||||
.color(Some(UI_HIGHLIGHT_0))
|
.color(Some(UI_HIGHLIGHT_0))
|
||||||
.set(state.ids.drag_ico, ui);
|
.set(state.ids.drag_ico, ui);
|
||||||
@ -903,7 +905,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
.right_from(state.ids.drag_ico, 5.0)
|
.right_from(state.ids.drag_ico, 5.0)
|
||||||
.font_size(self.fonts.cyri.scale(14))
|
.font_size(self.fonts.cyri.scale(14))
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.graphics_for(state.ids.grid_layer_0)
|
.graphics_for(state.ids.map_layers[0])
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.drag_txt, ui);
|
.set(state.ids.drag_txt, ui);
|
||||||
Image::new(self.imgs.m_scroll_ico)
|
Image::new(self.imgs.m_scroll_ico)
|
||||||
@ -915,7 +917,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
.right_from(state.ids.zoom_ico, 5.0)
|
.right_from(state.ids.zoom_ico, 5.0)
|
||||||
.font_size(self.fonts.cyri.scale(14))
|
.font_size(self.fonts.cyri.scale(14))
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.graphics_for(state.ids.grid_layer_0)
|
.graphics_for(state.ids.map_layers[0])
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.zoom_txt, ui);
|
.set(state.ids.zoom_txt, ui);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ widget_ids! {
|
|||||||
mmap_plus,
|
mmap_plus,
|
||||||
mmap_minus,
|
mmap_minus,
|
||||||
mmap_north_button,
|
mmap_north_button,
|
||||||
grid,
|
map_layers[],
|
||||||
indicator,
|
indicator,
|
||||||
mmap_north,
|
mmap_north,
|
||||||
mmap_east,
|
mmap_east,
|
||||||
@ -47,7 +47,7 @@ pub struct MiniMap<'a> {
|
|||||||
|
|
||||||
imgs: &'a Imgs,
|
imgs: &'a Imgs,
|
||||||
rot_imgs: &'a ImgsRot,
|
rot_imgs: &'a ImgsRot,
|
||||||
world_map: &'a (&'a img_ids::Rotations, Vec2<u32>),
|
world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
|
||||||
fonts: &'a Fonts,
|
fonts: &'a Fonts,
|
||||||
#[conrod(common_builder)]
|
#[conrod(common_builder)]
|
||||||
common: widget::CommonBuilder,
|
common: widget::CommonBuilder,
|
||||||
@ -60,7 +60,7 @@ impl<'a> MiniMap<'a> {
|
|||||||
client: &'a Client,
|
client: &'a Client,
|
||||||
imgs: &'a Imgs,
|
imgs: &'a Imgs,
|
||||||
rot_imgs: &'a ImgsRot,
|
rot_imgs: &'a ImgsRot,
|
||||||
world_map: &'a (&'a img_ids::Rotations, Vec2<u32>),
|
world_map_layers: &'a (Vec<img_ids::Rotations>, Vec2<u32>),
|
||||||
fonts: &'a Fonts,
|
fonts: &'a Fonts,
|
||||||
ori: Vec3<f32>,
|
ori: Vec3<f32>,
|
||||||
global_state: &'a GlobalState,
|
global_state: &'a GlobalState,
|
||||||
@ -69,7 +69,7 @@ impl<'a> MiniMap<'a> {
|
|||||||
client,
|
client,
|
||||||
imgs,
|
imgs,
|
||||||
rot_imgs,
|
rot_imgs,
|
||||||
world_map,
|
world_map_layers,
|
||||||
fonts,
|
fonts,
|
||||||
common: widget::CommonBuilder::default(),
|
common: widget::CommonBuilder::default(),
|
||||||
ori,
|
ori,
|
||||||
@ -99,7 +99,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
ids: Ids::new(id_gen),
|
ids: Ids::new(id_gen),
|
||||||
|
|
||||||
zoom: {
|
zoom: {
|
||||||
let min_world_dim = self.world_map.1.reduce_partial_min() as f64;
|
let min_world_dim = self.world_map_layers.1.reduce_partial_min() as f64;
|
||||||
min_world_dim.min(
|
min_world_dim.min(
|
||||||
min_world_dim
|
min_world_dim
|
||||||
* (TerrainChunkSize::RECT_SIZE.reduce_partial_max() as f64 / 32.0)
|
* (TerrainChunkSize::RECT_SIZE.reduce_partial_max() as f64 / 32.0)
|
||||||
@ -140,9 +140,17 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
.set(state.ids.mmap_frame_bg, ui);
|
.set(state.ids.mmap_frame_bg, ui);
|
||||||
|
|
||||||
// Map size in chunk coords
|
// Map size in chunk coords
|
||||||
//let show_topo_map = self.global_state.settings.interface.map_show_topo_map;
|
let worldsize = self.world_map_layers.1;
|
||||||
//let (world_map, worldsize) = if !show_topo_map { self.world_map } else { self.world_map_topo };
|
// Map Layers
|
||||||
let (world_map, worldsize) = self.world_map;
|
// It is assumed that there is at least one layer
|
||||||
|
if state.ids.map_layers.len() < self.world_map_layers.0.len() {
|
||||||
|
state.update(|state| {
|
||||||
|
state
|
||||||
|
.ids
|
||||||
|
.map_layers
|
||||||
|
.resize(self.world_map_layers.0.len(), &mut ui.widget_id_generator())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Zoom Buttons
|
// Zoom Buttons
|
||||||
|
|
||||||
@ -250,17 +258,30 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
let map_size = Vec2::new(170.0 * SCALE, 170.0 * SCALE);
|
let map_size = Vec2::new(170.0 * SCALE, 170.0 * SCALE);
|
||||||
|
|
||||||
// Map Image
|
// Map Image
|
||||||
let world_map_rotation = if is_facing_north {
|
// Map Layer Images
|
||||||
world_map.none
|
for (index, layer) in self.world_map_layers.0.iter().enumerate() {
|
||||||
} else {
|
let world_map_rotation = if is_facing_north {
|
||||||
world_map.source_north
|
layer.none
|
||||||
};
|
} else {
|
||||||
Image::new(world_map_rotation)
|
layer.source_north
|
||||||
.middle_of(state.ids.mmap_frame_bg)
|
};
|
||||||
.w_h(map_size.x, map_size.y)
|
if index == 0 {
|
||||||
.parent(state.ids.mmap_frame_bg)
|
Image::new(world_map_rotation)
|
||||||
.source_rectangle(rect_src)
|
.middle_of(state.ids.mmap_frame_bg)
|
||||||
.set(state.ids.grid, ui);
|
.w_h(map_size.x, map_size.y)
|
||||||
|
.parent(state.ids.mmap_frame_bg)
|
||||||
|
.source_rectangle(rect_src)
|
||||||
|
.set(state.ids.map_layers[index], ui);
|
||||||
|
} else {
|
||||||
|
Image::new(world_map_rotation)
|
||||||
|
.middle_of(state.ids.mmap_frame_bg)
|
||||||
|
.w_h(map_size.x, map_size.y)
|
||||||
|
.parent(state.ids.mmap_frame_bg)
|
||||||
|
.source_rectangle(rect_src)
|
||||||
|
.graphics_for(state.ids.map_layers[0])
|
||||||
|
.set(state.ids.map_layers[index], ui);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Map icons
|
// Map icons
|
||||||
if state.ids.mmap_site_icons.len() < self.client.sites().len() {
|
if state.ids.mmap_site_icons.len() < self.client.sites().len() {
|
||||||
@ -309,7 +330,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
SiteKind::Tree => self.imgs.mmap_site_tree,
|
SiteKind::Tree => self.imgs.mmap_site_tree,
|
||||||
})
|
})
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
position::Relative::Scalar(rpos.y as f64),
|
position::Relative::Scalar(rpos.y as f64),
|
||||||
)
|
)
|
||||||
@ -329,7 +350,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
SiteKind::Cave => Color::Rgba(1.0, 1.0, 1.0, 0.0),
|
SiteKind::Cave => Color::Rgba(1.0, 1.0, 1.0, 0.0),
|
||||||
SiteKind::Tree => Color::Rgba(1.0, 1.0, 1.0, 0.0),
|
SiteKind::Tree => Color::Rgba(1.0, 1.0, 1.0, 0.0),
|
||||||
}))
|
}))
|
||||||
.parent(state.ids.grid)
|
.parent(state.ids.map_layers[0])
|
||||||
.set(state.ids.mmap_site_icons_bgs[i], ui);
|
.set(state.ids.mmap_site_icons_bgs[i], ui);
|
||||||
Image::new(match &site.kind {
|
Image::new(match &site.kind {
|
||||||
SiteKind::Town => self.imgs.mmap_site_town,
|
SiteKind::Town => self.imgs.mmap_site_town,
|
||||||
@ -400,7 +421,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
_ => self.imgs.indicator_group,
|
_ => self.imgs.indicator_group,
|
||||||
})
|
})
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(rpos.x as f64),
|
position::Relative::Scalar(rpos.x as f64),
|
||||||
position::Relative::Scalar(rpos.y as f64),
|
position::Relative::Scalar(rpos.y as f64),
|
||||||
)
|
)
|
||||||
@ -418,7 +439,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
self.rot_imgs.indicator_mmap_small.none
|
self.rot_imgs.indicator_mmap_small.none
|
||||||
};
|
};
|
||||||
Image::new(ind_rotation)
|
Image::new(ind_rotation)
|
||||||
.middle_of(state.ids.grid)
|
.middle_of(state.ids.map_layers[0])
|
||||||
.w_h(32.0 * ind_scale, 37.0 * ind_scale)
|
.w_h(32.0 * ind_scale, 37.0 * ind_scale)
|
||||||
.color(Some(UI_HIGHLIGHT_0))
|
.color(Some(UI_HIGHLIGHT_0))
|
||||||
.floating(true)
|
.floating(true)
|
||||||
@ -438,7 +459,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
let pos = clamped * (map_size / 2.0 - 10.0);
|
let pos = clamped * (map_size / 2.0 - 10.0);
|
||||||
Text::new(name)
|
Text::new(name)
|
||||||
.x_y_position_relative_to(
|
.x_y_position_relative_to(
|
||||||
state.ids.grid,
|
state.ids.map_layers[0],
|
||||||
position::Relative::Scalar(pos.x),
|
position::Relative::Scalar(pos.x),
|
||||||
position::Relative::Scalar(pos.y),
|
position::Relative::Scalar(pos.y),
|
||||||
)
|
)
|
||||||
|
@ -250,7 +250,6 @@ widget_ids! {
|
|||||||
chat,
|
chat,
|
||||||
map,
|
map,
|
||||||
world_map,
|
world_map,
|
||||||
world_map_topo,
|
|
||||||
character_window,
|
character_window,
|
||||||
popup,
|
popup,
|
||||||
minimap,
|
minimap,
|
||||||
@ -381,7 +380,6 @@ pub enum Event {
|
|||||||
MapShowCastles(bool),
|
MapShowCastles(bool),
|
||||||
MapShowCaves(bool),
|
MapShowCaves(bool),
|
||||||
MapShowTrees(bool),
|
MapShowTrees(bool),
|
||||||
MapShowTopo(bool),
|
|
||||||
AdjustWindowSize([u16; 2]),
|
AdjustWindowSize([u16; 2]),
|
||||||
ChangeFullscreenMode(FullScreenSettings),
|
ChangeFullscreenMode(FullScreenSettings),
|
||||||
ToggleParticlesEnabled(bool),
|
ToggleParticlesEnabled(bool),
|
||||||
@ -2235,7 +2233,7 @@ impl Hud {
|
|||||||
client,
|
client,
|
||||||
&self.imgs,
|
&self.imgs,
|
||||||
&self.rot_imgs,
|
&self.rot_imgs,
|
||||||
&(&self.world_map_layers.0[1], self.world_map_layers.1),
|
&self.world_map_layers,
|
||||||
&self.fonts,
|
&self.fonts,
|
||||||
camera.get_orientation(),
|
camera.get_orientation(),
|
||||||
&global_state,
|
&global_state,
|
||||||
@ -2827,9 +2825,6 @@ impl Hud {
|
|||||||
map::Event::ShowTrees(map_show_trees) => {
|
map::Event::ShowTrees(map_show_trees) => {
|
||||||
events.push(Event::MapShowTrees(map_show_trees));
|
events.push(Event::MapShowTrees(map_show_trees));
|
||||||
},
|
},
|
||||||
map::Event::ShowTopoMap(map_show_topo_map) => {
|
|
||||||
events.push(Event::MapShowTopo(map_show_topo_map));
|
|
||||||
},
|
|
||||||
map::Event::RequestSiteInfo(id) => {
|
map::Event::RequestSiteInfo(id) => {
|
||||||
events.push(Event::RequestSiteInfo(id));
|
events.push(Event::RequestSiteInfo(id));
|
||||||
},
|
},
|
||||||
|
@ -1356,10 +1356,6 @@ impl PlayState for SessionState {
|
|||||||
global_state.settings.interface.map_show_trees = map_show_trees;
|
global_state.settings.interface.map_show_trees = map_show_trees;
|
||||||
global_state.settings.save_to_file_warn();
|
global_state.settings.save_to_file_warn();
|
||||||
},
|
},
|
||||||
HudEvent::MapShowTopo(map_show_topo) => {
|
|
||||||
global_state.settings.interface.map_show_topo_map = map_show_topo;
|
|
||||||
global_state.settings.save_to_file_warn();
|
|
||||||
},
|
|
||||||
HudEvent::RequestSiteInfo(id) => {
|
HudEvent::RequestSiteInfo(id) => {
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
client.request_site_economy(id);
|
client.request_site_economy(id);
|
||||||
|
@ -451,7 +451,6 @@ pub struct InterfaceSettings {
|
|||||||
pub loading_tips: bool,
|
pub loading_tips: bool,
|
||||||
pub map_show_caves: bool,
|
pub map_show_caves: bool,
|
||||||
pub map_show_trees: bool,
|
pub map_show_trees: bool,
|
||||||
pub map_show_topo_map: bool,
|
|
||||||
pub minimap_show: bool,
|
pub minimap_show: bool,
|
||||||
pub minimap_face_north: bool,
|
pub minimap_face_north: bool,
|
||||||
}
|
}
|
||||||
@ -484,7 +483,6 @@ impl Default for InterfaceSettings {
|
|||||||
loading_tips: true,
|
loading_tips: true,
|
||||||
map_show_caves: true,
|
map_show_caves: true,
|
||||||
map_show_trees: true,
|
map_show_trees: true,
|
||||||
map_show_topo_map: false,
|
|
||||||
minimap_show: true,
|
minimap_show: true,
|
||||||
minimap_face_north: false,
|
minimap_face_north: false,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user