reenabled inventory slots

This commit is contained in:
Pfauenauge90 2020-03-15 17:27:56 +01:00 committed by timokoesters
parent 1f78344d6f
commit db6099a62f
13 changed files with 75 additions and 87 deletions

BIN
assets/voxygen/element/buttons/inv_slot.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/buttons/inv_slot_sel.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/icons/character.png (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/element/slider/scrollbar.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -190,6 +190,10 @@ Want to free your cursor to close this window? Press TAB!
Enjoy your stay in the World of Veloren."#,
// Inventory
"hud.bag.inventory": "'s Inventory",
// Settings
"hud.settings.general": "General",
"hud.settings.none": "None",
"hud.settings.help_window": "Help Window",

View File

@ -3,11 +3,15 @@ use super::{
item_imgs::{ItemImgs, ItemKey},
Event as HudEvent, TEXT_COLOR,
};
use crate::ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable};
use crate::{
i18n::VoxygenLocalization,
ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
};
use client::Client;
use common::comp::Stats;
use conrod_core::{
color, image,
widget::{self, Button, Image, Rectangle},
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
@ -28,6 +32,8 @@ widget_ids! {
tooltip[],
bg,
bg_frame,
char_art,
inventory_title,
}
}
@ -43,6 +49,8 @@ pub struct Bag<'a> {
rot_imgs: &'a ImgsRot,
tooltip_manager: &'a mut TooltipManager,
pulse: f32,
localized_strings: &'a std::sync::Arc<VoxygenLocalization>,
stats: &'a Stats,
}
impl<'a> Bag<'a> {
@ -54,6 +62,8 @@ impl<'a> Bag<'a> {
rot_imgs: &'a ImgsRot,
tooltip_manager: &'a mut TooltipManager,
pulse: f32,
localized_strings: &'a std::sync::Arc<VoxygenLocalization>,
stats: &'a Stats,
) -> Self {
Self {
client,
@ -64,6 +74,8 @@ impl<'a> Bag<'a> {
rot_imgs,
tooltip_manager,
pulse,
localized_strings,
stats,
}
}
}
@ -106,7 +118,9 @@ impl<'a> Widget for Bag<'a> {
Some(inv) => inv,
None => return None,
};
let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64);
let exp_treshold = format!("{}/{}", self.stats.exp.current(), self.stats.exp.maximum());
let level = (self.stats.level.level()).to_string();
// Tooltips
let item_tooltip = Tooltip::new({
// Edge images [t, b, r, l]
@ -128,7 +142,6 @@ impl<'a> Widget for Bag<'a> {
.desc_text_color(TEXT_COLOR);
// BG
Image::new(self.imgs.inv_bg)
.w_h(424.0, 708.0)
.bottom_right_with_margins_on(ui.window, 60.0, 5.0)
@ -138,6 +151,17 @@ impl<'a> Widget for Bag<'a> {
.w_h(424.0, 708.0)
.middle_of(state.ids.bg)
.set(state.ids.bg_frame, ui);
// Title
Text::new(&format!(
"{}{}",
&self.stats.name,
&self.localized_strings.get("hud.bag.inventory")
))
.mid_top_with_margin_on(state.ids.bg_frame, 9.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(24))
.color(TEXT_COLOR)
.set(state.ids.inventory_title, ui);
// Close button
if Button::image(self.imgs.close_btn)
@ -151,6 +175,17 @@ impl<'a> Widget for Bag<'a> {
event = Some(Event::Close);
}
// Char Pixel Art
Image::new(self.imgs.char_art)
.w_h(40.0, 37.0)
.top_left_with_margins_on(state.ids.bg, 4.0, 2.0)
.set(state.ids.char_art, ui);
// Alignment for Grid
Rectangle::fill_with([360.0, 200.0], color::TRANSPARENT)
.bottom_left_with_margins_on(state.ids.bg_frame, 29.0, 44.0)
.scroll_kids_vertically()
.set(state.ids.inv_alignment, ui);
/*
// Bag parts
Image::new(self.imgs.bag_bot)
@ -165,13 +200,7 @@ impl<'a> Widget for Bag<'a> {
Image::new(self.imgs.bag_top)
.w_h(58.0 * BAG_SCALE, 9.0 * BAG_SCALE)
.up_from(state.ids.bag_mid, 0.0)
.set(state.ids.bag_top, ui);
// Alignment for Grid
Rectangle::fill_with([56.0 * BAG_SCALE, mid_height], color::TRANSPARENT)
.top_left_with_margins_on(state.ids.bag_mid, 0.0, 3.0 * BAG_SCALE)
.scroll_kids_vertically()
.set(state.ids.inv_alignment, ui);
.set(state.ids.bag_top, ui);*/
// Create available inventory slot widgets
if state.ids.inv_slots.len() < inventory.len() {
@ -197,8 +226,8 @@ impl<'a> Widget for Bag<'a> {
// Display inventory contents
for (i, item) in inventory.slots().iter().enumerate() {
let x = i % 5;
let y = i / 5;
let x = i % 9;
let y = i / 9;
let is_selected = Some(i) == state.selected_slot;
@ -211,15 +240,15 @@ impl<'a> Widget for Bag<'a> {
})
.top_left_with_margins_on(
state.ids.inv_alignment,
0.0 + y as f64 * (40.0 + 2.0),
0.0 + x as f64 * (40.0 + 2.0),
0.0 + y as f64 * (40.0),
0.0 + x as f64 * (40.0),
)
.wh(if is_selected { [40.0; 2] } else { [40.0; 2] })
.image_color(if is_selected {
/*.image_color(if is_selected {
color::WHITE
} else {
color::DARK_YELLOW
});
})*/;
let slot_widget_clicked = if let Some(item) = item {
slot_widget
@ -289,8 +318,6 @@ impl<'a> Widget for Bag<'a> {
}
}
*/
event
}
}

View File

@ -11,8 +11,6 @@ widget_ids! {
bag,
bag_text,
bag_show_map,
character_button,
character_button_bg,
map_button,
qlog_button,
qlog_button_bg,
@ -169,15 +167,6 @@ impl<'a> Widget for Buttons<'a> {
.w_h(28.0, 25.0)
.left_from(state.ids.map_button, 10.0)
.set(state.ids.spellbook_button_bg, ui);
Image::new(self.imgs.character_button)
.w_h(27.0, 25.0)
.left_from(state.ids.spellbook_button_bg, 10.0)
.set(state.ids.character_button_bg, ui);
Image::new(self.imgs.qlog_button)
.w_h(23.0, 25.0)
.left_from(state.ids.character_button_bg, 10.0)
.set(state.ids.qlog_button_bg, ui);
// Other Windows can only be accessed when `Settings` is closed.
// Opening `Settings` will close all other Windows, including the `Bag`.
// Opening the `Map` won't close the previously displayed windows.
@ -217,42 +206,6 @@ impl<'a> Widget for Buttons<'a> {
{
return Some(Event::ToggleSpell);
}
// 4 Char-Window
if Button::image(self.imgs.character_button)
.w_h(27.0, 25.0)
.left_from(state.ids.spellbook_button, 10.0)
.hover_image(self.imgs.character_hover)
.press_image(self.imgs.character_press)
.label("C")
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(10)
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(-7.0))
.label_x(conrod_core::position::Relative::Scalar(10.0))
.set(state.ids.character_button, ui)
.was_clicked()
{
return Some(Event::ToggleCharacter);
}
// 5 Quest-Log
if Button::image(self.imgs.qlog_button)
.w_h(23.0, 25.0)
.left_from(state.ids.character_button, 10.0)
.hover_image(self.imgs.qlog_hover)
.press_image(self.imgs.qlog_press)
.label("L")
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(10)
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(-7.0))
.label_x(conrod_core::position::Relative::Scalar(10.0))
.set(state.ids.qlog_button, ui)
.was_clicked()
{
return Some(Event::ToggleQuest);
}
}
None

View File

@ -98,10 +98,6 @@ impl<'a> CharacterWindow<'a> {
}
}
/*pub struct State {
ids: Ids,
}*/
pub enum Event {
Close,
}

View File

@ -22,16 +22,6 @@ image_ids! {
pub struct Imgs {
<VoxelGraphic>
// Bag
bag_contents: "voxygen.element.frames.bag",
inv_grid: "voxygen.element.frames.inv_grid",
inv_slot: "voxygen.element.buttons.inv_slot",
inv_slot_sel: "voxygen.element.buttons.inv_slot_sel",
grid_inv: "voxygen.element.buttons.grid_inv",
bag_top: "voxygen.element.bag.top",
bag_mid: "voxygen.element.bag.mid",
bag_bot: "voxygen.element.bag.bot",
// Skillbar
xp_bar_mid: "voxygen.element.skillbar.xp_bar_mid",
xp_bar_left: "voxygen.element.skillbar.xp_bar_left",
@ -142,7 +132,6 @@ image_ids! {
indicator_mmap_3: "voxygen.element.buttons.indicator_mmap_3",
// Crosshair
crosshair_outer_round: "voxygen.element.misc_bg.crosshair_outer_1",
crosshair_outer_round_edges: "voxygen.element.misc_bg.crosshair_outer_2",
crosshair_outer_edges: "voxygen.element.misc_bg.crosshair_outer_3",
@ -153,7 +142,6 @@ image_ids! {
crosshair_bg_pressed: "voxygen.element.misc_bg.crosshair_bg_pressed",
// Checkboxes and Radio buttons
check: "voxygen.element.buttons.radio.inactive",
check_mo: "voxygen.element.buttons.radio.inactive_hover",
check_press: "voxygen.element.buttons.radio.press",
@ -257,6 +245,9 @@ image_ids! {
// Inventory
inv_bg: "voxygen.element.misc_bg.inv_bg",
inv_frame: "voxygen.element.misc_bg.inv_frame",
char_art: "voxygen.element.icons.character",
inv_slot: "voxygen.element.buttons.inv_slot",
inv_slot_sel: "voxygen.element.buttons.inv_slot_sel",
not_found:"voxygen.element.not_found",

View File

@ -213,7 +213,7 @@ impl<'a> Widget for MiniMap<'a> {
} else {
Image::new(self.imgs.mmap_frame_closed)
.w_h(174.0 * SCALE, 18.0 * SCALE)
.top_right_with_margins_on(ui.window, 0.0, 0.0)
.top_right_with_margins_on(ui.window, 0.0, 5.0)
.set(state.ids.mmap_frame, ui);
}

View File

@ -1636,6 +1636,9 @@ impl Hud {
// Bag contents
if self.show.bag {
let ecs = client.state().ecs();
let stats = ecs.read_storage::<comp::Stats>();
let player_stats = stats.get(client.entity()).unwrap();
match Bag::new(
client,
&self.imgs,
@ -1644,6 +1647,8 @@ impl Hud {
&self.rot_imgs,
tooltip_manager,
self.pulse,
&self.voxygen_i18n,
&player_stats,
)
.set(self.ids.bag, ui_widgets)
{