mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Show item amounts in item tooltips.
This commit is contained in:
parent
769f341795
commit
4669b4ab52
@ -1397,6 +1397,7 @@ pub trait ItemDesc {
|
||||
fn description(&self) -> &str;
|
||||
fn name(&self) -> Cow<str>;
|
||||
fn kind(&self) -> Cow<ItemKind>;
|
||||
fn amount(&self) -> NonZeroU32;
|
||||
fn quality(&self) -> Quality;
|
||||
fn num_slots(&self) -> u16;
|
||||
fn item_definition_id(&self) -> ItemDefinitionId<'_>;
|
||||
@ -1423,6 +1424,8 @@ impl ItemDesc for Item {
|
||||
|
||||
fn kind(&self) -> Cow<ItemKind> { self.kind() }
|
||||
|
||||
fn amount(&self) -> NonZeroU32 { self.amount }
|
||||
|
||||
fn quality(&self) -> Quality { self.quality() }
|
||||
|
||||
fn num_slots(&self) -> u16 { self.num_slots() }
|
||||
@ -1451,6 +1454,8 @@ impl ItemDesc for ItemDef {
|
||||
|
||||
fn kind(&self) -> Cow<ItemKind> { Cow::Borrowed(&self.kind) }
|
||||
|
||||
fn amount(&self) -> NonZeroU32 { NonZeroU32::new(1).unwrap() }
|
||||
|
||||
fn quality(&self) -> Quality { self.quality }
|
||||
|
||||
fn num_slots(&self) -> u16 { self.slots }
|
||||
@ -1495,6 +1500,8 @@ impl<'a, T: ItemDesc + ?Sized> ItemDesc for &'a T {
|
||||
|
||||
fn kind(&self) -> Cow<ItemKind> { (*self).kind() }
|
||||
|
||||
fn amount(&self) -> NonZeroU32 { (*self).amount() }
|
||||
|
||||
fn quality(&self) -> Quality { (*self).quality() }
|
||||
|
||||
fn num_slots(&self) -> u16 { (*self).num_slots() }
|
||||
|
@ -310,6 +310,7 @@ pub struct Style {
|
||||
widget_ids! {
|
||||
struct Ids {
|
||||
title,
|
||||
quantity,
|
||||
subtitle,
|
||||
desc,
|
||||
prices_buy,
|
||||
@ -570,6 +571,20 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
.color(quality)
|
||||
.set(state.ids.title, ui);
|
||||
|
||||
// Amount
|
||||
let mut subtitle_relative_id = state.ids.title;
|
||||
if self.item.amount().get() > 1 {
|
||||
subtitle_relative_id = state.ids.quantity;
|
||||
widget::Text::new(&format!("Amount: {}", self.item.amount().get()))
|
||||
.w(title_w)
|
||||
.graphics_for(id)
|
||||
.parent(id)
|
||||
.with_style(self.style.desc)
|
||||
.color(conrod_core::color::GREY)
|
||||
.down_from(state.ids.title, V_PAD)
|
||||
.set(state.ids.quantity, ui);
|
||||
}
|
||||
|
||||
// Subtitle
|
||||
widget::Text::new(&subtitle)
|
||||
.w(title_w)
|
||||
@ -577,7 +592,7 @@ impl<'a> Widget for ItemTooltip<'a> {
|
||||
.parent(id)
|
||||
.with_style(self.style.desc)
|
||||
.color(conrod_core::color::GREY)
|
||||
.down_from(state.ids.title, V_PAD)
|
||||
.down_from(subtitle_relative_id, V_PAD)
|
||||
.set(state.ids.subtitle, ui);
|
||||
|
||||
// Stats
|
||||
|
Loading…
Reference in New Issue
Block a user