adjusted foot step sounds, inventory space above bag

This commit is contained in:
Pfauenauge90
2020-03-25 21:06:01 +01:00
parent 8b05dda1d9
commit 5f10cdf0c6
3 changed files with 40 additions and 5 deletions

View File

@ -9,7 +9,7 @@
"voxygen.audio.sfx.footsteps.stepgrass_5", "voxygen.audio.sfx.footsteps.stepgrass_5",
"voxygen.audio.sfx.footsteps.stepgrass_6", "voxygen.audio.sfx.footsteps.stepgrass_6",
], ],
threshold: 0.4, threshold: 0.25,
), ),
GliderOpen: ( GliderOpen: (
files: [ files: [

View File

@ -1,15 +1,17 @@
use super::{img_ids::Imgs, Windows, BLACK, CRITICAL_HP_COLOR, LOW_HP_COLOR, TEXT_COLOR};
use crate::ui::{fonts::ConrodVoxygenFonts, ToggleButton};
use client::Client;
use conrod_core::{ use conrod_core::{
widget::{self, Button, Image, Text}, widget::{self, Button, Image, Text},
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
}; };
use super::{img_ids::Imgs, Windows, TEXT_COLOR};
use crate::ui::{fonts::ConrodVoxygenFonts, ToggleButton};
widget_ids! { widget_ids! {
struct Ids { struct Ids {
bag, bag,
bag_text, bag_text,
bag_space_bg,
bag_space,
bag_show_map, bag_show_map,
map_button, map_button,
settings_button, settings_button,
@ -22,6 +24,7 @@ widget_ids! {
#[derive(WidgetCommon)] #[derive(WidgetCommon)]
pub struct Buttons<'a> { pub struct Buttons<'a> {
client: &'a Client,
open_windows: &'a Windows, open_windows: &'a Windows,
show_map: bool, show_map: bool,
show_bag: bool, show_bag: bool,
@ -34,6 +37,7 @@ pub struct Buttons<'a> {
impl<'a> Buttons<'a> { impl<'a> Buttons<'a> {
pub fn new( pub fn new(
client: &'a Client,
open_windows: &'a Windows, open_windows: &'a Windows,
show_map: bool, show_map: bool,
show_bag: bool, show_bag: bool,
@ -41,6 +45,7 @@ impl<'a> Buttons<'a> {
fonts: &'a ConrodVoxygenFonts, fonts: &'a ConrodVoxygenFonts,
) -> Self { ) -> Self {
Self { Self {
client,
open_windows, open_windows,
show_map, show_map,
show_bag, show_bag,
@ -78,6 +83,11 @@ impl<'a> Widget for Buttons<'a> {
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event { fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs { state, ui, .. } = args; let widget::UpdateArgs { state, ui, .. } = args;
let invs = self.client.inventories();
let inventory = match invs.get(self.client.entity()) {
Some(inv) => inv,
None => return None,
};
// Bag // Bag
if !self.show_map { if !self.show_map {
@ -110,6 +120,30 @@ impl<'a> Widget for Buttons<'a> {
.color(TEXT_COLOR) .color(TEXT_COLOR)
.set(state.ids.bag_text, ui); .set(state.ids.bag_text, ui);
} }
if !self.show_bag {
let space_used = inventory.amount;
let space_max = inventory.slots.len();
let bag_space = format!("{}/{}", space_used, space_max);
let bag_space_percentage = space_used as f32 / space_max as f32;
Text::new(&bag_space)
.mid_top_with_margin_on(state.ids.bag, -15.0)
.font_size(12)
.font_id(self.fonts.cyri.conrod_id)
.color(BLACK)
.set(state.ids.bag_space_bg, ui);
Text::new(&bag_space)
.top_left_with_margins_on(state.ids.bag_space_bg, -1.0, -1.0)
.font_size(12)
.font_id(self.fonts.cyri.conrod_id)
.color(if bag_space_percentage < 0.8 {
TEXT_COLOR
} else if bag_space_percentage < 1.0 {
LOW_HP_COLOR
} else {
CRITICAL_HP_COLOR
})
.set(state.ids.bag_space, ui);
}
// 0 Settings // 0 Settings
if Button::image(self.imgs.settings) if Button::image(self.imgs.settings)

View File

@ -1573,6 +1573,7 @@ impl Hud {
// Bag button and nearby icons // Bag button and nearby icons
match Buttons::new( match Buttons::new(
client,
&self.show.open_windows, &self.show.open_windows,
self.show.map, self.show.map,
self.show.bag, self.show.bag,