mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added target to starting site map
This commit is contained in:
parent
9e76561ad6
commit
c28e61383d
BIN
assets/voxygen/element/ui/char_select/icons/target.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/ui/char_select/icons/target.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -24,6 +24,8 @@ use client::{Client, ServerInfo};
|
|||||||
use common::{
|
use common::{
|
||||||
character::{CharacterId, CharacterItem, MAX_CHARACTERS_PER_PLAYER, MAX_NAME_LENGTH},
|
character::{CharacterId, CharacterItem, MAX_CHARACTERS_PER_PLAYER, MAX_NAME_LENGTH},
|
||||||
comp::{self, humanoid, inventory::slot::EquipSlot, Inventory, Item},
|
comp::{self, humanoid, inventory::slot::EquipSlot, Inventory, Item},
|
||||||
|
terrain::TerrainChunkSize,
|
||||||
|
vol::RectVolSize,
|
||||||
LoadoutBuilder,
|
LoadoutBuilder,
|
||||||
};
|
};
|
||||||
use common_net::msg::world_msg::{SiteId, SiteInfo, SiteKind};
|
use common_net::msg::world_msg::{SiteId, SiteInfo, SiteKind};
|
||||||
@ -36,7 +38,7 @@ use iced::{
|
|||||||
button, scrollable, slider, text_input, Align, Button, Column, Container, HorizontalAlignment,
|
button, scrollable, slider, text_input, Align, Button, Column, Container, HorizontalAlignment,
|
||||||
Length, Row, Scrollable, Slider, Space, Text, TextInput,
|
Length, Row, Scrollable, Slider, Space, Text, TextInput,
|
||||||
};
|
};
|
||||||
use vek::Rgba;
|
use vek::{Rgba, Vec2};
|
||||||
|
|
||||||
pub const TEXT_COLOR: iced::Color = iced::Color::from_rgb(1.0, 1.0, 1.0);
|
pub const TEXT_COLOR: iced::Color = iced::Color::from_rgb(1.0, 1.0, 1.0);
|
||||||
pub const DISABLED_TEXT_COLOR: iced::Color = iced::Color::from_rgba(1.0, 1.0, 1.0, 0.2);
|
pub const DISABLED_TEXT_COLOR: iced::Color = iced::Color::from_rgba(1.0, 1.0, 1.0, 0.2);
|
||||||
@ -123,6 +125,9 @@ image_ids_ice! {
|
|||||||
// Tooltips
|
// Tooltips
|
||||||
tt_edge: "voxygen.element.ui.generic.frames.tooltip.edge",
|
tt_edge: "voxygen.element.ui.generic.frames.tooltip.edge",
|
||||||
tt_corner: "voxygen.element.ui.generic.frames.tooltip.corner",
|
tt_corner: "voxygen.element.ui.generic.frames.tooltip.corner",
|
||||||
|
|
||||||
|
// Map things
|
||||||
|
target: "voxygen.element.ui.char_select.icons.target",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,6 +298,7 @@ struct Controls {
|
|||||||
default_name: String,
|
default_name: String,
|
||||||
map_img: GraphicId,
|
map_img: GraphicId,
|
||||||
possible_starting_sites: Vec<SiteInfo>,
|
possible_starting_sites: Vec<SiteInfo>,
|
||||||
|
world_sz: Vec2<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -338,6 +344,7 @@ impl Controls {
|
|||||||
server_info: &ServerInfo,
|
server_info: &ServerInfo,
|
||||||
map_img: GraphicId,
|
map_img: GraphicId,
|
||||||
possible_starting_sites: Vec<SiteInfo>,
|
possible_starting_sites: Vec<SiteInfo>,
|
||||||
|
world_sz: Vec2<u32>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let version = common::util::DISPLAY_VERSION_LONG.clone();
|
let version = common::util::DISPLAY_VERSION_LONG.clone();
|
||||||
let alpha = format!("Veloren {}", common::util::DISPLAY_VERSION.as_str());
|
let alpha = format!("Veloren {}", common::util::DISPLAY_VERSION.as_str());
|
||||||
@ -358,6 +365,7 @@ impl Controls {
|
|||||||
default_name,
|
default_name,
|
||||||
map_img,
|
map_img,
|
||||||
possible_starting_sites,
|
possible_starting_sites,
|
||||||
|
world_sz,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,11 +1253,32 @@ impl Controls {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let right_column_content = if character_id.is_none() {
|
let right_column_content = if character_id.is_none() {
|
||||||
|
let map_sz = Vec2::new(300, 300);
|
||||||
|
let map_img = Image::new(self.map_img)
|
||||||
|
.height(Length::Units(map_sz.x))
|
||||||
|
.width(Length::Units(map_sz.y));
|
||||||
|
let map = if let Some(info) = self.possible_starting_sites.get(*start_site_idx)
|
||||||
|
{
|
||||||
|
let pos_frac = info
|
||||||
|
.wpos
|
||||||
|
.map2(self.world_sz * TerrainChunkSize::RECT_SIZE, |e, sz| {
|
||||||
|
e as f32 / sz as f32
|
||||||
|
});
|
||||||
|
let point = Vec2::new(pos_frac.x, 1.0 - pos_frac.y)
|
||||||
|
.map2(map_sz, |e, sz| e * sz as f32 - 12.0);
|
||||||
|
Overlay::new(
|
||||||
|
Image::new(imgs.target)
|
||||||
|
.height(Length::Units(24))
|
||||||
|
.width(Length::Units(24)),
|
||||||
|
map_img,
|
||||||
|
)
|
||||||
|
.over_position(iced::Point::new(point.x, point.y))
|
||||||
|
.into()
|
||||||
|
} else {
|
||||||
|
map_img.into()
|
||||||
|
};
|
||||||
vec![
|
vec![
|
||||||
Image::new(self.map_img)
|
map,
|
||||||
.height(Length::Units(300))
|
|
||||||
.width(Length::Units(300))
|
|
||||||
.into(),
|
|
||||||
Column::with_children(if self.possible_starting_sites.is_empty() {
|
Column::with_children(if self.possible_starting_sites.is_empty() {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
@ -1807,6 +1836,7 @@ impl CharSelectionUi {
|
|||||||
.filter(|info| matches!(&info.site.kind, SiteKind::Town | SiteKind::Castle | SiteKind::Bridge))
|
.filter(|info| matches!(&info.site.kind, SiteKind::Town | SiteKind::Castle | SiteKind::Bridge))
|
||||||
.map(|info| info.site.clone())
|
.map(|info| info.site.clone())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
client.world_data().chunk_size().as_(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -19,6 +19,7 @@ pub struct Overlay<'a, M, R: Renderer> {
|
|||||||
vertical_alignment: Align,
|
vertical_alignment: Align,
|
||||||
over: Element<'a, M, R>,
|
over: Element<'a, M, R>,
|
||||||
under: Element<'a, M, R>,
|
under: Element<'a, M, R>,
|
||||||
|
pos: Option<Point>,
|
||||||
// add style etc as needed
|
// add style etc as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +42,16 @@ where
|
|||||||
vertical_alignment: Align::Start,
|
vertical_alignment: Align::Start,
|
||||||
over: over.into(),
|
over: over.into(),
|
||||||
under: under.into(),
|
under: under.into(),
|
||||||
|
pos: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn over_position(mut self, pos: Point) -> Self {
|
||||||
|
self.pos = Some(pos);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
|
pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
|
||||||
self.padding = pad.into();
|
self.padding = pad.into();
|
||||||
@ -130,10 +138,10 @@ where
|
|||||||
.pad(self.padding),
|
.pad(self.padding),
|
||||||
);
|
);
|
||||||
|
|
||||||
over.move_to(Point::new(
|
over.move_to(
|
||||||
self.padding.left.into(),
|
self.pos
|
||||||
self.padding.top.into(),
|
.unwrap_or_else(|| Point::new(self.padding.left.into(), self.padding.top.into())),
|
||||||
));
|
);
|
||||||
over.align(self.horizontal_alignment, self.vertical_alignment, size);
|
over.align(self.horizontal_alignment, self.vertical_alignment, size);
|
||||||
|
|
||||||
layout::Node::with_children(size, vec![over, under])
|
layout::Node::with_children(size, vec![over, under])
|
||||||
|
Loading…
Reference in New Issue
Block a user