map icon options WIP

This commit is contained in:
Monty Marz 2020-11-16 20:30:04 +01:00 committed by Joshua Barretto
parent 34987c1654
commit c825e33f1a
12 changed files with 252 additions and 20 deletions

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
assets/voxygen/element/misc_bg/map_bg.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

@ -193,6 +193,12 @@ image_ids! {
mmap_minus: "voxygen.element.buttons.min_plus.mmap_button-min",
mmap_minus_hover: "voxygen.element.buttons.min_plus.mmap_button-min_hover",
mmap_minus_press: "voxygen.element.buttons.min_plus.mmap_button-min_press",
map_dif_0: "voxygen.element.map.dif_0",
map_dif_1: "voxygen.element.map.dif_1",
map_dif_2: "voxygen.element.map.dif_2",
map_dif_3: "voxygen.element.map.dif_3",
map_dif_4: "voxygen.element.map.dif_4",
map_dif_5: "voxygen.element.map.dif_5",
mmap_site_town: "voxygen.element.map.town",
mmap_site_town_hover: "voxygen.element.map.town_hover",
mmap_site_dungeon: "voxygen.element.map.dungeon",

@ -1,6 +1,6 @@
use super::{
img_ids::{Imgs, ImgsRot},
Show, TEXT_COLOR, UI_GOLD, UI_HIGHLIGHT_0, UI_MAIN,
Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, QUALITY_LOW, QUALITY_COMMON, QUALITY_MODERATE, QUALITY_HIGH, QUALITY_EPIC, QUALITY_DEBUG,
};
use crate::{
i18n::Localization,
@ -17,6 +17,8 @@ use conrod_core::{
use specs::WorldExt;
use vek::*;
use inline_tweak::*;
widget_ids! {
struct Ids {
frame,
@ -33,12 +35,26 @@ widget_ids! {
qlog_title,
zoom_slider,
mmap_site_icons[],
site_difs[],
map_settings_align,
show_towns_img,
show_towns_box,
show_towns_text,
show_castles_img,
show_castles_box,
show_castles_text,
show_dungeons_img,
show_dungeons_box,
show_dungeons_text,
show_difficulty_img,
show_difficulty_box,
show_difficulty_text,
}
}
#[derive(WidgetCommon)]
pub struct Map<'a> {
_show: &'a Show,
show: &'a Show,
client: &'a Client,
world_map: &'a (img_ids::Rotations, Vec2<u32>),
imgs: &'a Imgs,
@ -66,7 +82,7 @@ impl<'a> Map<'a> {
tooltip_manager: &'a mut TooltipManager,
) -> Self {
Self {
_show: show,
show: show,
imgs,
rot_imgs,
world_map,
@ -87,6 +103,10 @@ pub struct State {
pub enum Event {
MapZoom(f64),
ShowDifficulties,
ShowTowns,
ShowCastles,
ShowDungeons,
Close,
}
@ -129,20 +149,20 @@ impl<'a> Widget for Map<'a> {
.desc_text_color(TEXT_COLOR);
// Frame
Image::new(self.imgs.map_bg)
.w_h(1052.0, 886.0)
.w_h(1202.0, 886.0)
.mid_top_with_margin_on(ui.window, 5.0)
.color(Some(UI_MAIN))
.set(state.ids.bg, ui);
Image::new(self.imgs.map_frame)
.w_h(1052.0, 886.0)
.w_h(1202.0, 886.0)
.middle_of(state.ids.bg)
.color(Some(UI_HIGHLIGHT_0))
.set(state.ids.frame, ui);
// Map Content Alignment
Rectangle::fill_with([814.0, 834.0], color::TRANSPARENT)
.top_right_with_margins_on(state.ids.frame, 46.0, 2.0)
.top_left_with_margins_on(state.ids.frame, 46.0, tweak!(240.0))
.set(state.ids.map_align, ui);
// Questlog Content Alignment
@ -255,7 +275,113 @@ impl<'a> Widget for Map<'a> {
{
events.push(Event::MapZoom(new_val as f64));
}
// Icon settings
// Alignment
Rectangle::fill_with([tweak!(150.0), tweak!(200.0)], color::TRANSPARENT)
.top_right_with_margins_on(state.ids.frame, tweak!(55.0), tweak!(10.0))
.set(state.ids.map_settings_align, ui);
// Checkboxes
// Show difficulties
Image::new(self.imgs.map_dif_5)
.top_left_with_margins_on(state.ids.map_settings_align, 5.0, 5.0)
.w_h(20.0, 20.0)
.set(state.ids.show_difficulty_img, ui);
if Button::image(if self.show.map_difficulty {
self.imgs.checkbox_checked} else {self.imgs.checkbox})
.w_h(18.0, 18.0)
.hover_image(if self.show.map_difficulty {
self.imgs.checkbox_checked_mo} else {self.imgs.checkbox_mo})
.press_image(if self.show.map_difficulty {
self.imgs.checkbox_checked} else {self.imgs.checkbox_press})
.right_from(state.ids.show_difficulty_img, 10.0)
.set(state.ids.show_difficulty_box, ui)
.was_clicked()
{
events.push(Event::ShowDifficulties);
}
Text::new("Difficulty")
.right_from(state.ids.show_difficulty_box, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.show_difficulty_box)
.color(TEXT_COLOR)
.set(state.ids.show_difficulty_text, ui);
// Towns
Image::new(self.imgs.mmap_site_town)
.down_from(state.ids.show_difficulty_img, 10.0)
.w_h(20.0, 20.0)
.set(state.ids.show_towns_img, ui);
if Button::image(if self.show.map_towns {
self.imgs.checkbox_checked} else {self.imgs.checkbox})
.w_h(18.0, 18.0)
.hover_image(if self.show.map_towns {
self.imgs.checkbox_checked_mo} else {self.imgs.checkbox_mo})
.press_image(if self.show.map_towns {
self.imgs.checkbox_checked} else {self.imgs.checkbox_press})
.right_from(state.ids.show_towns_img, 10.0)
.set(state.ids.show_towns_box, ui)
.was_clicked()
{
events.push(Event::ShowTowns);
}
Text::new("Towns")
.right_from(state.ids.show_towns_box, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.show_towns_box)
.color(TEXT_COLOR)
.set(state.ids.show_towns_text, ui);
// Castles
Image::new(self.imgs.mmap_site_castle)
.down_from(state.ids.show_towns_img, 10.0)
.w_h(20.0, 20.0)
.set(state.ids.show_castles_img, ui);
if Button::image(if self.show.map_castles {
self.imgs.checkbox_checked} else {self.imgs.checkbox})
.w_h(18.0, 18.0)
.hover_image(if self.show.map_castles {
self.imgs.checkbox_checked_mo} else {self.imgs.checkbox_mo})
.press_image(if self.show.map_castles {
self.imgs.checkbox_checked} else {self.imgs.checkbox_press})
.right_from(state.ids.show_castles_img, 10.0)
.set(state.ids.show_castles_box, ui)
.was_clicked()
{
events.push(Event::ShowCastles);
}
Text::new("Castles")
.right_from(state.ids.show_castles_box, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.show_castles_box)
.color(TEXT_COLOR)
.set(state.ids.show_castles_text, ui);
// Dungeons
Image::new(self.imgs.mmap_site_dungeon)
.down_from(state.ids.show_castles_img, 10.0)
.w_h(20.0, 20.0)
.set(state.ids.show_dungeons_img, ui);
if Button::image(if self.show.map_dungeons {
self.imgs.checkbox_checked} else {self.imgs.checkbox})
.w_h(18.0, 18.0)
.hover_image(if self.show.map_dungeons {
self.imgs.checkbox_checked_mo} else {self.imgs.checkbox_mo})
.press_image(if self.show.map_dungeons {
self.imgs.checkbox_checked} else {self.imgs.checkbox_press})
.right_from(state.ids.show_dungeons_img, 10.0)
.set(state.ids.show_dungeons_box, ui)
.was_clicked()
{
events.push(Event::ShowDungeons);
}
Text::new("Dungeons")
.right_from(state.ids.show_dungeons_box, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.show_dungeons_box)
.color(TEXT_COLOR)
.set(state.ids.show_dungeons_text, ui);
// Map icons
if state.ids.mmap_site_icons.len() < self.client.sites().len() {
state.update(|state| {
@ -265,6 +391,14 @@ impl<'a> Widget for Map<'a> {
.resize(self.client.sites().len(), &mut ui.widget_id_generator())
});
}
if state.ids.site_difs.len() < self.client.sites().len() {
state.update(|state| {
state
.ids
.site_difs
.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 =
@ -279,16 +413,17 @@ impl<'a> Widget for Map<'a> {
{
continue;
}
let dif = (i as f64 / 100.0 * 6.0) as u8;
let title = match &site.kind {
SiteKind::Town => "Town",
SiteKind::Dungeon => "Dungeon",
SiteKind::Castle => "Castle",
};
let desc = "";
let desc = format!("Difficulty: {}", dif);
Button::image(match &site.kind {
SiteKind::Town => self.imgs.mmap_site_town,
SiteKind::Dungeon => self.imgs.mmap_site_dungeon,
SiteKind::Castle => self.imgs.mmap_site_castle,
SiteKind::Town => if self.show.map_towns {self.imgs.mmap_site_town } else {self.imgs.nothing},
SiteKind::Dungeon => if self.show.map_dungeons {self.imgs.mmap_site_dungeon} else {self.imgs.nothing},
SiteKind::Castle => if self.show.map_castles {self.imgs.mmap_site_castle} else {self.imgs.nothing},
})
.x_y_position_relative_to(
state.ids.grid,
@ -303,8 +438,62 @@ impl<'a> Widget for Map<'a> {
})
.image_color(UI_HIGHLIGHT_0)
.parent(ui.window)
.with_tooltip(self.tooltip_manager, title, desc, &site_tooltip, TEXT_COLOR)
.with_tooltip(self.tooltip_manager, title, &desc, &site_tooltip, match dif {
1 => QUALITY_LOW,
2 => QUALITY_COMMON,
3 => QUALITY_MODERATE,
4 => QUALITY_HIGH,
5 => QUALITY_EPIC,
6 => QUALITY_DEBUG,
_ => TEXT_COLOR,
})
.set(state.ids.mmap_site_icons[i], ui);
// Difficulty from 0-6
// 0 = towns and places without a difficulty level
// TODO: Pass actual difficulty in here
if self.show.map_difficulty {
let size = 1.8; // Size factor for difficulty indicators
let dif_img = Image::new(match dif {
1 => self.imgs.map_dif_0,
2 => self.imgs.map_dif_1,
3 => self.imgs.map_dif_2,
4 => self.imgs.map_dif_3,
5 => self.imgs.map_dif_4,
6 => self.imgs.map_dif_5,
_ => self.imgs.nothing,
})
.mid_top_with_margin_on(state.ids.mmap_site_icons[i], match dif {
6 => -12.0 * size,
_ => -4.0 * size,
})
.w(match dif {
6 => 12.0 * size,
_ => 4.0 * size * dif as f64,
})
.h(match dif {
6 => 12.0 * size,
_ => 4.0 * size,
})
.color(Some(match dif {
1 => QUALITY_LOW,
2 => QUALITY_COMMON,
3 => QUALITY_MODERATE,
4 => QUALITY_HIGH,
5 => QUALITY_EPIC,
6 => TEXT_COLOR,
_ => TEXT_COLOR,
}
)
);
match &site.kind {
SiteKind::Town => if self.show.map_towns {dif_img.set(state.ids.site_difs[i], ui) },
SiteKind::Dungeon => if self.show.map_dungeons {dif_img.set(state.ids.site_difs[i], ui)},
SiteKind::Castle => if self.show.map_castles {dif_img.set(state.ids.site_difs[i], ui)},
}
}
}
// Cursor pos relative to playerpos and widget size

@ -292,8 +292,7 @@ impl<'a> Widget for MiniMap<'a> {
Color::Rgba(0.75, 0.0, 0.0, 1.0)
} else {
TEXT_COLOR
})
.floating(true)
})
.parent(ui.window)
.set(*id, ui);
}

@ -148,7 +148,6 @@ 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);
@ -450,6 +449,10 @@ pub struct Show {
stats: bool,
free_look: bool,
auto_walk: bool,
map_difficulty: bool,
map_towns: bool,
map_castles: bool,
map_dungeons: bool,
}
impl Show {
fn bag(&mut self, open: bool) {
@ -463,7 +466,7 @@ impl Show {
fn toggle_bag(&mut self) { self.bag(!self.bag); }
fn map(&mut self, open: bool) {
if !self.esc_menu {
if !self.esc_menu {
self.map = open;
self.bag = false;
self.crafting = false;
@ -499,7 +502,8 @@ impl Show {
}
}
fn toggle_map(&mut self) { self.map(!self.map) }
fn toggle_map(&mut self) {
self.map(!self.map) }
fn toggle_mini_map(&mut self) { self.mini_map = !self.mini_map; }
@ -713,6 +717,10 @@ impl Hud {
stats: false,
free_look: false,
auto_walk: false,
map_difficulty: true,
map_towns: true,
map_castles: true,
map_dungeons: true,
},
to_focus: None,
//never_show: false,
@ -2262,6 +2270,18 @@ impl Hud {
self.show.want_grab = true;
self.force_ungrab = false;
},
map::Event::ShowDifficulties => {
self.show.map_difficulty = !self.show.map_difficulty
},
map::Event::ShowTowns => {
self.show.map_towns = !self.show.map_towns
},
map::Event::ShowCastles => {
self.show.map_castles = !self.show.map_castles
},
map::Event::ShowDungeons => {
self.show.map_dungeons = !self.show.map_dungeons
},
map::Event::MapZoom(map_zoom) => {
events.push(Event::MapZoom(map_zoom));
},