This commit is contained in:
Monty Marz 2021-11-27 01:03:10 +01:00 committed by Sam
parent 714e080535
commit 7515c26d68
6 changed files with 66 additions and 43 deletions

10
Cargo.lock generated
View File

@ -2651,6 +2651,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "inline_tweak"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7033e97b20277cc0d043226d1940fa7719ff08d2305d1fc7421e53066d00eb4b"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "inotify" name = "inotify"
version = "0.7.1" version = "0.7.1"
@ -6521,6 +6530,7 @@ dependencies = [
"iced_native", "iced_native",
"iced_winit", "iced_winit",
"image", "image",
"inline_tweak",
"itertools", "itertools",
"keyboard-keynames", "keyboard-keynames",
"lazy_static", "lazy_static",

BIN
assets/voxygen/element/ui/diary/diary_skills_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/ui/diary/spellbook_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -122,7 +122,7 @@ treeculler = "0.2"
tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] } tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] }
num_cpus = "1.0" num_cpus = "1.0"
# vec_map = { version = "0.8.2" } # vec_map = { version = "0.8.2" }
# inline_tweak = "1.0.2" inline_tweak = "1.0.2"
itertools = "0.10.0" itertools = "0.10.0"
# Tracy # Tracy

View File

@ -1,8 +1,8 @@
use super::{ use super::{
img_ids::{Imgs, ImgsRot}, img_ids::{Imgs, ImgsRot},
item_imgs::{animate_by_pulse, ItemImgs, ItemKey::Tool}, item_imgs::{animate_by_pulse, ItemImgs, ItemKey::Tool},
Position, PositionSpecifier, Show, CRITICAL_HP_COLOR, HP_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, Position, PositionSpecifier, Show, BLACK, CRITICAL_HP_COLOR, HP_COLOR, TEXT_COLOR,
UI_MAIN, XP_COLOR, UI_HIGHLIGHT_0, UI_MAIN, XP_COLOR,
}; };
use crate::{ use crate::{
hud::{self, util}, hud::{self, util},
@ -32,6 +32,7 @@ use common::{
consts::{ENERGY_PER_LEVEL, HP_PER_LEVEL}, consts::{ENERGY_PER_LEVEL, HP_PER_LEVEL},
}; };
use hashbrown::HashMap; use hashbrown::HashMap;
use inline_tweak::*;
use std::borrow::Cow; use std::borrow::Cow;
const ART_SIZE: [f64; 2] = [320.0, 320.0]; const ART_SIZE: [f64; 2] = [320.0, 320.0];
@ -193,10 +194,11 @@ widget_ids! {
skill_general_swim_0, skill_general_swim_0,
skill_general_swim_1, skill_general_swim_1,
// Ability selection // Ability selection
spellbook_art,
spellbook_skills_bg,
spellbook_btn, spellbook_btn,
spellbook_btn_bg, spellbook_btn_bg,
ability_select_title, ability_select_title,
ability_scroll_align,
ability_scroller, ability_scroller,
active_abilities[], active_abilities[],
active_abilities_bg[], active_abilities_bg[],
@ -302,7 +304,8 @@ const TREES: [&str; 8] = [
"Fire Staff", "Fire Staff",
"Mining", "Mining",
]; ];
// Possible future sections: Bestiary ("Pokedex" of fought enemies), Weapon and
// armour catalogue, Achievements...
const SECTIONS: [&str; 2] = ["Abilities", "Skill-Trees"]; const SECTIONS: [&str; 2] = ["Abilities", "Skill-Trees"];
pub enum Event { pub enum Event {
@ -789,13 +792,16 @@ impl<'a> Widget for Diary<'a> {
}, },
DiarySection::AbilitySelection => { DiarySection::AbilitySelection => {
use comp::ability::AbilityInput; use comp::ability::AbilityInput;
// Title for ability selection UI // Background Art
Text::new("Ability Selection") Image::new(self.imgs.book_bg)
.mid_top_with_margin_on(state.ids.content_align, 2.0) .w_h(299.0 * 4.0, 184.0 * 4.0)
.font_id(self.fonts.cyri.conrod_id) .mid_top_with_margin_on(state.ids.content_align, tweak!(4.0))
.font_size(self.fonts.cyri.scale(34)) //.graphics_for(state.ids.content_align)
.color(TEXT_COLOR) .set(state.ids.spellbook_art, ui);
.set(state.ids.ability_select_title, ui); Image::new(self.imgs.skills_bg)
.w_h(240.0 * 2.0, 40.0 * 2.0)
.mid_bottom_with_margin_on(state.ids.content_align, tweak!(8.0))
.set(state.ids.spellbook_skills_bg, ui);
// Display all active abilities on right of window // Display all active abilities on right of window
state.update(|s| { state.update(|s| {
@ -818,27 +824,28 @@ impl<'a> Widget for Diary<'a> {
) )
.ability_id(Some(self.inventory)); .ability_id(Some(self.inventory));
let image_size = 50.0; let image_size = tweak!(80.0);
let image_offsets = 60.0 * i as f64; let image_offsets = tweak!(92.0) * i as f64;
Image::new(self.imgs.inv_slot) let mut ability_slot =
.w_h(image_size, image_size) Image::new(self.imgs.inv_slot).w_h(image_size, image_size);
.top_right_with_margins_on( if i == 0 {
state.ids.content_align, ability_slot = ability_slot.top_left_with_margins_on(
150.0 + image_offsets, state.ids.spellbook_skills_bg,
30.0, tweak!(0.0),
) tweak!(32.0) + image_offsets,
.set(state.ids.active_abilities_bg[i], ui); );
} else {
ability_slot =
ability_slot.right_from(state.ids.active_abilities_bg[i - 1], tweak!(4.0))
}
ability_slot.set(state.ids.active_abilities_bg[i], ui);
let ability_image = ability_id let ability_image = ability_id
.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)); .map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id));
let (ability_title, ability_desc) = let (ability_title, ability_desc) =
util::ability_description(ability_id.unwrap_or("")); util::ability_description(ability_id.unwrap_or(""));
if Button::image(ability_image) if Button::image(ability_image)
.w_h(image_size, image_size) .w_h(image_size * tweak!(0.9), image_size * tweak!(0.9))
.top_right_with_margins_on( .middle_of(state.ids.active_abilities_bg[i])
state.ids.content_align,
150.0 + image_offsets,
30.0,
)
.with_tooltip( .with_tooltip(
self.tooltip_manager, self.tooltip_manager,
ability_title, ability_title,
@ -860,23 +867,19 @@ impl<'a> Widget for Diary<'a> {
} }
} }
// Scroller and alignment // Scrollbar
Rectangle::fill_with([1098.0, 838.0], color::TRANSPARENT) Scrollbar::y_axis(state.ids.spellbook_art)
.top_left_with_margins_on(state.ids.content_align, 0.0, 0.0)
.scroll_kids_vertically()
.set(state.ids.ability_scroll_align, ui);
Scrollbar::y_axis(state.ids.ability_scroll_align)
.thickness(5.0) .thickness(5.0)
.middle_of(state.ids.spellbook_art)
.rgba(0.33, 0.33, 0.33, 1.0) .rgba(0.33, 0.33, 0.33, 1.0)
.set(state.ids.ability_scroller, ui); .set(state.ids.ability_scroller, ui);
// Display list of abilities from main weapon // Display list of abilities from main weapon
Text::new("Main Weapon Abilities") Text::new("Main Weapon Abilities")
.top_left_with_margins_on(state.ids.ability_scroll_align, 75.0, 25.0) .top_left_with_margins_on(state.ids.spellbook_art, 75.0, 25.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(28)) .font_size(self.fonts.cyri.scale(28))
.color(TEXT_COLOR) .color(BLACK)
.set(state.ids.main_weap_title, ui); .set(state.ids.main_weap_title, ui);
// TODO: Maybe try to keep this as an iterator. Not sure how to get length // TODO: Maybe try to keep this as an iterator. Not sure how to get length
@ -919,7 +922,7 @@ impl<'a> Widget for Diary<'a> {
.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)); .map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id));
let ability_color = if self.show.diary_fields.selected_ability != Some(*ability) let ability_color = if self.show.diary_fields.selected_ability != Some(*ability)
{ {
TEXT_COLOR BLACK
} else { } else {
XP_COLOR XP_COLOR
}; };
@ -944,14 +947,16 @@ impl<'a> Widget for Diary<'a> {
Text::new(ability_title) Text::new(ability_title)
.top_left_with_margins_on(state.ids.main_weap_abilities[i], 5.0, 125.0) .top_left_with_margins_on(state.ids.main_weap_abilities[i], 5.0, 125.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(24)) .font_size(self.fonts.cyri.scale(tweak!(28)))
.color(ability_color) .color(ability_color)
.graphics_for(state.ids.main_weap_abilities[i])
.set(state.ids.main_weap_ability_titles[i], ui); .set(state.ids.main_weap_ability_titles[i], ui);
Text::new(ability_desc) Text::new(ability_desc)
.top_left_with_margins_on(state.ids.main_weap_abilities[i], 30.0, 125.0) .top_left_with_margins_on(state.ids.main_weap_abilities[i], 30.0, 125.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(16)) .font_size(self.fonts.cyri.scale(tweak!(18)))
.color(ability_color) .color(ability_color)
.graphics_for(state.ids.main_weap_abilities[i])
.set(state.ids.main_weap_ability_descs[i], ui); .set(state.ids.main_weap_ability_descs[i], ui);
} }
@ -965,7 +970,7 @@ impl<'a> Widget for Diary<'a> {
.bottom_left_with_margins_on(offset_state, -50.0, 0.0) .bottom_left_with_margins_on(offset_state, -50.0, 0.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(28)) .font_size(self.fonts.cyri.scale(28))
.color(TEXT_COLOR) .color(BLACK)
.set(state.ids.off_weap_title, ui); .set(state.ids.off_weap_title, ui);
// TODO: Maybe try to keep this as an iterator. Not sure how to get length // TODO: Maybe try to keep this as an iterator. Not sure how to get length
@ -1008,7 +1013,7 @@ impl<'a> Widget for Diary<'a> {
.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)); .map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id));
let ability_color = if self.show.diary_fields.selected_ability != Some(*ability) let ability_color = if self.show.diary_fields.selected_ability != Some(*ability)
{ {
TEXT_COLOR BLACK
} else { } else {
XP_COLOR XP_COLOR
}; };
@ -1050,7 +1055,7 @@ impl<'a> Widget for Diary<'a> {
let ability_id = Ability::from(ability).ability_id(Some(self.inventory)); let ability_id = Ability::from(ability).ability_id(Some(self.inventory));
if let Some(ability_id) = ability_id { if let Some(ability_id) = ability_id {
Image::new(util::ability_image(self.imgs, ability_id)) Image::new(util::ability_image(self.imgs, ability_id))
.w_h(50.0, 50.0) .w_h(80.0, 80.0)
.xy(mouse_pos) .xy(mouse_pos)
.set(state.ids.dragged_ability, ui); .set(state.ids.dragged_ability, ui);
} }

View File

@ -70,6 +70,8 @@ image_ids! {
pixel: "voxygen.element.ui.diary.pixel", pixel: "voxygen.element.ui.diary.pixel",
// Skill Trees // Skill Trees
book_bg: "voxygen.element.ui.diary.spellbook_bg",
skills_bg: "voxygen.element.ui.diary.diary_skills_bg",
slot_skills: "voxygen.element.ui.diary.buttons.slot_skilltree", slot_skills: "voxygen.element.ui.diary.buttons.slot_skilltree",
swords_crossed: "voxygen.element.weapons.swords_crossed", swords_crossed: "voxygen.element.weapons.swords_crossed",
sceptre: "voxygen.element.weapons.sceptre", sceptre: "voxygen.element.weapons.sceptre",