mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
group member indicator visuals
functional group member indicators adjust visuals z-comparison
This commit is contained in:
parent
985156fca4
commit
b5a2104ca5
BIN
assets/voxygen/element/frames/settings_l.png
(Stored with Git LFS)
BIN
assets/voxygen/element/frames/settings_l.png
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/element/frames/settings_r.png
(Stored with Git LFS)
BIN
assets/voxygen/element/frames/settings_r.png
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/element/map/group_indicator.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/group_indicator.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/map/group_indicator_arrow_down.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/group_indicator_arrow_down.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/map/group_indicator_arrow_up.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/group_indicator_arrow_up.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/map/group_indicator_hover.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/map/group_indicator_hover.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -179,6 +179,10 @@ image_ids! {
|
||||
map_frame_art: "voxygen.element.misc_bg.map_frame_art",
|
||||
indicator_mmap: "voxygen.element.buttons.indicator_mmap",
|
||||
indicator_map_overlay: "voxygen.element.buttons.indicator_mmap_small",
|
||||
indicator_group: "voxygen.element.map.group_indicator",
|
||||
indicator_group_hover: "voxygen.element.map.group_indicator_hover",
|
||||
indicator_group_up: "voxygen.element.map.group_indicator_arrow_up",
|
||||
indicator_group_down: "voxygen.element.map.group_indicator_arrow_down",
|
||||
|
||||
// MiniMap
|
||||
mmap_frame: "voxygen.element.frames.mmap",
|
||||
|
@ -9,14 +9,15 @@ use crate::{
|
||||
GlobalState,
|
||||
};
|
||||
use client::{self, Client};
|
||||
use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize};
|
||||
use common_net::msg::world_msg::SiteKind;
|
||||
use common::{
|
||||
comp, comp::group::Role, msg::world_msg::SiteKind, terrain::TerrainChunkSize, vol::RectVolSize,
|
||||
};
|
||||
use conrod_core::{
|
||||
color, position,
|
||||
widget::{self, Button, Image, Rectangle, Text},
|
||||
widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||
};
|
||||
use specs::WorldExt;
|
||||
use specs::{saveload::MarkerAllocator, WorldExt};
|
||||
use vek::*;
|
||||
|
||||
widget_ids! {
|
||||
@ -37,6 +38,8 @@ widget_ids! {
|
||||
zoom_slider,
|
||||
mmap_site_icons[],
|
||||
site_difs[],
|
||||
member_indicators[],
|
||||
member_height_indicators[],
|
||||
map_settings_align,
|
||||
show_towns_img,
|
||||
show_towns_box,
|
||||
@ -641,15 +644,84 @@ impl<'a> Widget for Map<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Group member indicators
|
||||
let client_state = self.client.state();
|
||||
let stats = client_state.ecs().read_storage::<common::comp::Stats>();
|
||||
let member_pos = client_state.ecs().read_storage::<common::comp::Pos>();
|
||||
let group_members = self
|
||||
.client
|
||||
.group_members()
|
||||
.iter()
|
||||
.filter_map(|(u, r)| match r {
|
||||
Role::Member => Some(u),
|
||||
Role::Pet => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let group_size = group_members.len();
|
||||
//let in_group = !group_members.is_empty();
|
||||
let uid_allocator = client_state
|
||||
.ecs()
|
||||
.read_resource::<common::sync::UidAllocator>();
|
||||
if state.ids.member_indicators.len() < group_size {
|
||||
state.update(|s| {
|
||||
s.ids
|
||||
.member_indicators
|
||||
.resize(group_size, &mut ui.widget_id_generator())
|
||||
})
|
||||
};
|
||||
for (i, &uid) in group_members.iter().copied().enumerate() {
|
||||
let entity = uid_allocator.retrieve_entity_internal(uid.into());
|
||||
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
||||
let stats = entity.and_then(|entity| stats.get(entity));
|
||||
let name= if let Some(stats) = stats {stats.name.to_string()} else {"".to_string()};
|
||||
|
||||
if let Some(member_pos) = member_pos {
|
||||
// Site pos in world coordinates relative to the player
|
||||
let rwpos = member_pos.0.xy().map(|e| e as f32) - player_pos;
|
||||
// Convert to chunk coordinates
|
||||
let rcpos = rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32)
|
||||
// Add map dragging
|
||||
+ drag.map(|e| e as f32);
|
||||
// Convert to fractional coordinates relative to the worldsize
|
||||
let rfpos = rcpos / max_zoom as f32;
|
||||
// Convert to relative pixel coordinates from the center of the map
|
||||
// Accounting for zooming
|
||||
let rpos = rfpos.map2(map_size, |e, sz| e * sz as f32 * zoom as f32);
|
||||
|
||||
if rpos
|
||||
.map2(map_size, |e, sz| e.abs() > sz as f32 / 2.0)
|
||||
.reduce_or()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let factor = 1.2;
|
||||
let z_comparison = (member_pos.0.z - player_pos.z) as i32;
|
||||
|
||||
Button::image(match z_comparison {
|
||||
10..=i32::MAX => self.imgs.indicator_group_up,
|
||||
i32::MIN..=-10 => self.imgs.indicator_group_down,
|
||||
_ => self.imgs.indicator_group,
|
||||
})
|
||||
.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 * factor, 20.0 * factor)
|
||||
.floating(true)
|
||||
.with_tooltip(
|
||||
self.tooltip_manager,
|
||||
&name,
|
||||
"",
|
||||
&site_tooltip,
|
||||
TEXT_COLOR,
|
||||
)
|
||||
.set(state.ids.member_indicators[i], ui);
|
||||
}
|
||||
}
|
||||
// Cursor pos relative to playerpos and widget size
|
||||
// Cursor stops moving on an axis as soon as it's position exceeds the maximum
|
||||
// // size of the widget
|
||||
|
||||
/*let rel = Vec2::from(player_pos).map2(worldsize, |e: f32, sz: f64| {
|
||||
(e as f64 / sz).clamped(0.0, 1.0)
|
||||
});*/
|
||||
//let xy = rel * 760.0;
|
||||
// // size of the widget
|
||||
|
||||
// Offset from map center due to dragging
|
||||
let rcpos = drag.map(|e| e as f32);
|
||||
|
@ -5,15 +5,14 @@ use super::{
|
||||
};
|
||||
use crate::ui::{fonts::Fonts, img_ids};
|
||||
use client::{self, Client};
|
||||
use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize};
|
||||
use common_net::msg::world_msg::SiteKind;
|
||||
use common::{comp, comp::group::Role, 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 specs::WorldExt;
|
||||
use specs::{saveload::MarkerAllocator, WorldExt};
|
||||
use vek::*;
|
||||
|
||||
widget_ids! {
|
||||
@ -33,6 +32,7 @@ widget_ids! {
|
||||
mmap_west,
|
||||
mmap_site_icons_bgs[],
|
||||
mmap_site_icons[],
|
||||
member_indicators[],
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,12 +295,79 @@ impl<'a> Widget for MiniMap<'a> {
|
||||
.set(state.ids.mmap_site_icons[i], ui);
|
||||
}
|
||||
|
||||
// Group member indicators
|
||||
let client_state = self.client.state();
|
||||
let member_pos = client_state.ecs().read_storage::<common::comp::Pos>();
|
||||
let group_members = self
|
||||
.client
|
||||
.group_members()
|
||||
.iter()
|
||||
.filter_map(|(u, r)| match r {
|
||||
Role::Member => Some(u),
|
||||
Role::Pet => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let group_size = group_members.len();
|
||||
//let in_group = !group_members.is_empty();
|
||||
let uid_allocator = client_state
|
||||
.ecs()
|
||||
.read_resource::<common::sync::UidAllocator>();
|
||||
if state.ids.member_indicators.len() < group_size {
|
||||
state.update(|s| {
|
||||
s.ids
|
||||
.member_indicators
|
||||
.resize(group_size, &mut ui.widget_id_generator())
|
||||
})
|
||||
};
|
||||
for (i, &uid) in group_members.iter().copied().enumerate() {
|
||||
let entity = uid_allocator.retrieve_entity_internal(uid.into());
|
||||
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
||||
|
||||
if let Some(member_pos) = member_pos {
|
||||
// Site pos in world coordinates relative to the player
|
||||
let rwpos = member_pos.0.xy().map(|e| e as f32) - player_pos;
|
||||
// Convert to chunk coordinates
|
||||
let rcpos = rwpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e / sz as f32);
|
||||
// Convert to fractional coordinates relative to the worldsize
|
||||
let rfpos = rcpos / max_zoom as f32;
|
||||
// Convert to unrotated pixel coordinates from the player location on the map
|
||||
// (the center)
|
||||
// Accounting for zooming
|
||||
let rpixpos = rfpos.map2(map_size, |e, sz| e * sz as f32 * zoom as f32);
|
||||
let rpos = Vec2::unit_x().rotated_z(self.ori.x) * rpixpos.x
|
||||
+ Vec2::unit_y().rotated_z(self.ori.x) * rpixpos.y;
|
||||
|
||||
if rpos
|
||||
.map2(map_size, |e, sz| e.abs() > sz as f32 / 2.0)
|
||||
.reduce_or()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let factor = 1.2;
|
||||
let z_comparison = (member_pos.0.z - player_pos.z) as i32;
|
||||
Button::image(match z_comparison {
|
||||
10..=i32::MAX => self.imgs.indicator_group_up,
|
||||
i32::MIN..=-10 => self.imgs.indicator_group_down,
|
||||
_ => self.imgs.indicator_group,
|
||||
})
|
||||
.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 * factor, 16.0 * factor)
|
||||
.image_color(Color::Rgba(1.0, 1.0, 1.0, 1.0))
|
||||
.set(state.ids.member_indicators[i], ui);
|
||||
}
|
||||
}
|
||||
|
||||
// Indicator
|
||||
let ind_scale = 0.4;
|
||||
Image::new(self.rot_imgs.indicator_mmap_small.none)
|
||||
.middle_of(state.ids.grid)
|
||||
.w_h(32.0 * ind_scale, 37.0 * ind_scale)
|
||||
.color(Some(UI_HIGHLIGHT_0))
|
||||
.floating(true)
|
||||
.set(state.ids.indicator, ui);
|
||||
|
||||
// Compass directions
|
||||
|
Loading…
Reference in New Issue
Block a user