(voxygen) Better support for multibuff items

+ change `effect` field in ItemKind::Consumable to `effects`, as it's
set of effects and not single effect.
This commit is contained in:
juliancoffee 2021-06-30 23:48:30 +03:00
parent eb61b23d04
commit d4c61ae2f3
43 changed files with 119 additions and 119 deletions

View File

@ -2,8 +2,8 @@ ItemDef(
name: "Potent Potion", name: "Potent Potion",
description: "A potent healing potion.", description: "A potent healing potion.",
kind: Consumable( kind: Consumable(
kind: Potion, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Potion, kind: Potion,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "", description: "",
kind: Consumable( kind: Consumable(
kind: Drink, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Potion, kind: Potion,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "", description: "",
kind: Consumable( kind: Consumable(
kind: Drink, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Potion, kind: Potion,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "", description: "",
kind: Consumable( kind: Consumable(
kind: Drink, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Potion, kind: Potion,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Red and juicy", description: "Red and juicy",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Who could say no to that?", description: "Who could say no to that?",
kind: Consumable( kind: Consumable(
kind: ComplexFood, kind: ComplexFood,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "The stick makes it easier to carry!", description: "The stick makes it easier to carry!",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Giving you that special prickle.", description: "Giving you that special prickle.",
kind: Consumable( kind: Consumable(
kind: Drink, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "An orange root vegetable. They say it'll improve your vision!", description: "An orange root vegetable. They say it'll improve your vision!",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Aromatic and nutritious", description: "Aromatic and nutritious",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Reliable source of water and fat.\n\nNaturally growing at the top of palm trees.", description: "Reliable source of water and fat.\n\nNaturally growing at the top of palm trees.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A daisy-like flower often used in herbal teas.", description: "A daisy-like flower often used in herbal teas.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A small, yellow flower. Uses the wind to spread its seeds.", description: "A small, yellow flower. Uses the wind to spread its seeds.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Make sure to brush your teeth after eating.", description: "Make sure to brush your teeth after eating.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A vibrant green leafy vegetable. Lettuce make some salads!", description: "A vibrant green leafy vegetable. Lettuce make some salads!",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Meat. The lifeblood of mankind.", description: "Meat. The lifeblood of mankind.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Medium Rare.", description: "Medium Rare.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Chunk of beastly animal meat, best after cooking.", description: "Chunk of beastly animal meat, best after cooking.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Medium Rare.", description: "Medium Rare.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Small hunk of beastly animal meat, best after cooking.", description: "Small hunk of beastly animal meat, best after cooking.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Best enjoyed with one in each hand.", description: "Best enjoyed with one in each hand.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Makes for a legendary meal.", description: "Makes for a legendary meal.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "It's magificent.", description: "It's magificent.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A hefty drumstick.", description: "A hefty drumstick.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A fresh cooked seafood steak.", description: "A fresh cooked seafood steak.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A steak chopped from a fish, best after cooking.", description: "A steak chopped from a fish, best after cooking.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Tastes exotic.", description: "Tastes exotic.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Peculiar bit of meat, best after cooking.", description: "Peculiar bit of meat, best after cooking.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Hopefully this one is not poisonous", description: "Hopefully this one is not poisonous",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Roasted mushrooms on a stick for easy carrying", description: "Roasted mushrooms on a stick for easy carrying",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A vegetable that's made the toughest men cry.", description: "A vegetable that's made the toughest men cry.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Literally just chopped lettuce. Does this even count as a salad?", description: "Literally just chopped lettuce. Does this even count as a salad?",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A herb commonly used in tea.", description: "A herb commonly used in tea.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "You feel an evil force pulsating within.\n\nIt may be unwise to hold on to it for too long...", description: "You feel an evil force pulsating within.\n\nIt may be unwise to hold on to it for too long...",
kind: Consumable( kind: Consumable(
kind: ComplexFood, kind: ComplexFood,
effect: [ effects: [
Buff(( Buff((
kind: Frenzied, kind: Frenzied,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Brewed from freshly shelled sunflower seeds", description: "Brewed from freshly shelled sunflower seeds",
kind: Consumable( kind: Consumable(
kind: Drink, kind: Drink,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "A red fruit. Not actually a vegetable.", description: "A red fruit. Not actually a vegetable.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -3,7 +3,7 @@ ItemDef(
description: "Leafy salad with some chopped, juicy tomatoes mixed in.", description: "Leafy salad with some chopped, juicy tomatoes mixed in.",
kind: Consumable( kind: Consumable(
kind: Food, kind: Food,
effect: [ effects: [
Buff(( Buff((
kind: Saturation, kind: Saturation,
data: ( data: (

View File

@ -251,7 +251,7 @@ pub enum ItemKind {
Glider(Glider), Glider(Glider),
Consumable { Consumable {
kind: ConsumableKind, kind: ConsumableKind,
effect: Vec<Effect>, effects: Vec<Effect>,
}, },
Throwable { Throwable {
kind: Throwable, kind: Throwable,

View File

@ -526,8 +526,8 @@ impl TradePricing {
} }
}); });
printvec("Potions", &self.potions.entries, |i, p| { printvec("Potions", &self.potions.entries, |i, p| {
if let ItemKind::Consumable { kind: _, effect } = &i.kind { if let ItemKind::Consumable { kind: _, effects } = &i.kind {
effect effects
.iter() .iter()
.map(|e| { .map(|e| {
if let crate::effect::Effect::Buff(b) = e { if let crate::effect::Effect::Buff(b) = e {
@ -543,8 +543,8 @@ impl TradePricing {
} }
}); });
printvec("Food", &self.food.entries, |i, p| { printvec("Food", &self.food.entries, |i, p| {
if let ItemKind::Consumable { kind: _, effect } = &i.kind { if let ItemKind::Consumable { kind: _, effects } = &i.kind {
effect effects
.iter() .iter()
.map(|e| { .map(|e| {
if let crate::effect::Effect::Buff(b) = e { if let crate::effect::Effect::Buff(b) = e {

View File

@ -285,8 +285,8 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
&state.ecs().read_resource::<item::MaterialStatManifest>(), &state.ecs().read_resource::<item::MaterialStatManifest>(),
) { ) {
match item.kind() { match item.kind() {
ItemKind::Consumable { effect, .. } => { ItemKind::Consumable { effects, .. } => {
maybe_effect = Some(effect.clone()); maybe_effect = Some(effects.clone());
Some(comp::InventoryUpdateEvent::Consumed(item.name().to_owned())) Some(comp::InventoryUpdateEvent::Consumed(item.name().to_owned()))
}, },
ItemKind::Throwable { kind, .. } => { ItemKind::Throwable { kind, .. } => {

View File

@ -1452,10 +1452,10 @@ impl<'a> AgentData<'a> {
let mut value = 0; let mut value = 0;
#[allow(clippy::single_match)] #[allow(clippy::single_match)]
match item.kind() { match item.kind() {
ItemKind::Consumable { effect, .. } => { ItemKind::Consumable { effects, .. } => {
for e in effect.iter() { for effect in effects.iter() {
use BuffKind::*; use BuffKind::*;
match e { match effect {
Effect::Health(HealthChange { amount, .. }) => { Effect::Health(HealthChange { amount, .. }) => {
value += *amount; value += *amount;
}, },

View File

@ -4,7 +4,7 @@ use common::{
item::{ item::{
armor::{Armor, ArmorKind, Protection}, armor::{Armor, ArmorKind, Protection},
tool::{Hands, StatKind, Stats, Tool, ToolKind}, tool::{Hands, StatKind, Stats, Tool, ToolKind},
Item, ItemKind, MaterialKind, MaterialStatManifest, ModularComponent, Item, ItemDesc, ItemKind, MaterialKind, MaterialStatManifest, ModularComponent,
}, },
BuffKind, BuffKind,
}, },
@ -104,10 +104,41 @@ pub fn modular_component_desc(
result result
} }
pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { pub fn stats_count(item: &dyn ItemDesc) -> usize {
let mut description = String::new(); let mut count = match item.kind() {
ItemKind::Armor(armor) => {
if matches!(armor.kind, ArmorKind::Bag(_)) {
0
} else {
5
}
},
ItemKind::Tool(_) => 4,
ItemKind::Consumable { effects, .. } => effects.len(),
ItemKind::ModularComponent { .. } => 1,
_ => 0,
};
let is_bag = match item.kind() {
ItemKind::Armor(armor) => matches!(armor.kind, ArmorKind::Bag(_)),
_ => false,
};
if item.num_slots() != 0 && !is_bag {
count += 1
}
count as usize
}
/// Takes N `effects` and returns N effect descriptions
/// If effect isn't intended to have description, returns empty string
///
/// FIXME: handle which effects should have description in `stats_count`
/// to not waste space in item box
pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> Vec<String> {
let mut descriptions = Vec::new();
for effect in effects { for effect in effects {
let mut description = String::new();
if let Effect::Buff(buff) = effect { if let Effect::Buff(buff) = effect {
let strength = buff.data.strength * 0.1; let strength = buff.data.strength * 0.1;
let dur_secs = buff.data.duration.map(|d| d.as_secs_f32()); let dur_secs = buff.data.duration.map(|d| d.as_secs_f32());
@ -116,13 +147,13 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String {
let buff_desc = match buff.kind { let buff_desc = match buff.kind {
BuffKind::Saturation | BuffKind::Regeneration | BuffKind::Potion => i18n BuffKind::Saturation | BuffKind::Regeneration | BuffKind::Potion => i18n
.get("buff.stat.health") .get("buff.stat.health")
.replace("{str_total}", &*format!("{:.1}", &str_total)), .replace("{str_total}", &str_total.to_string()),
BuffKind::IncreaseMaxEnergy => i18n BuffKind::IncreaseMaxEnergy => i18n
.get("buff.stat.increase_max_stamina") .get("buff.stat.increase_max_stamina")
.replace("{strength}", &*format!("{:.1}", &strength)), .replace("{strength}", &strength.to_string()),
BuffKind::IncreaseMaxHealth => i18n BuffKind::IncreaseMaxHealth => i18n
.get("buff.stat.increase_max_health") .get("buff.stat.increase_max_health")
.replace("{strength}", &*format!("{:.1}", &strength)), .replace("{strength}", &strength.to_string()),
BuffKind::Invulnerability => i18n.get("buff.stat.invulnerability").to_string(), BuffKind::Invulnerability => i18n.get("buff.stat.invulnerability").to_string(),
BuffKind::Bleeding BuffKind::Bleeding
| BuffKind::Burning | BuffKind::Burning
@ -133,7 +164,7 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String {
| BuffKind::Frenzied | BuffKind::Frenzied
| BuffKind::Frozen | BuffKind::Frozen
| BuffKind::Wet | BuffKind::Wet
| BuffKind::Ensnared => continue, | BuffKind::Ensnared => "".to_owned(),
}; };
write!(&mut description, "{}", buff_desc).unwrap(); write!(&mut description, "{}", buff_desc).unwrap();
@ -158,19 +189,20 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String {
| BuffKind::Frenzied | BuffKind::Frenzied
| BuffKind::Frozen | BuffKind::Frozen
| BuffKind::Wet | BuffKind::Wet
| BuffKind::Ensnared => continue, | BuffKind::Ensnared => "".to_owned(),
} }
} else if let BuffKind::Saturation | BuffKind::Regeneration = buff.kind { } else if let BuffKind::Saturation | BuffKind::Regeneration = buff.kind {
i18n.get("buff.text.every_second").to_string() i18n.get("buff.text.every_second").to_string()
} else { } else {
continue; "".to_owned()
}; };
write!(&mut description, " {}", dur_desc).unwrap(); write!(&mut description, " {}", dur_desc).unwrap();
} }
descriptions.push(description);
} }
description descriptions
} }
// Armor // Armor

View File

@ -427,26 +427,6 @@ impl<'a> Widget for ItemTooltip<'a> {
.. ..
} = args; } = args;
fn stats_count(item: &dyn ItemDesc) -> usize {
let is_bag = matches!(item.kind(), ItemKind::Armor(armor) if matches!(armor.kind, ArmorKind::Bag(_)));
let mut count = match item.kind() {
ItemKind::Armor(armor) => {
if matches!(armor.kind, ArmorKind::Bag(_)) {
0
} else {
5
}
},
ItemKind::Tool(_) => 4,
ItemKind::Consumable { .. } => 1,
_ => 0,
};
if item.num_slots() != 0 && !is_bag {
count += 1
}
count as usize
}
let i18n = &self.localized_strings; let i18n = &self.localized_strings;
let inventories = self.client.inventories(); let inventories = self.client.inventories();
@ -503,13 +483,13 @@ impl<'a> Widget for ItemTooltip<'a> {
state.update(|s| { state.update(|s| {
s.ids s.ids
.stats .stats
.resize(stats_count(item), &mut ui.widget_id_generator()) .resize(util::stats_count(item), &mut ui.widget_id_generator())
}); });
state.update(|s| { state.update(|s| {
s.ids s.ids
.diffs .diffs
.resize(stats_count(item), &mut ui.widget_id_generator()) .resize(util::stats_count(item), &mut ui.widget_id_generator())
}); });
// Background image frame // Background image frame
@ -936,15 +916,28 @@ impl<'a> Widget for ItemTooltip<'a> {
} }
} }
}, },
ItemKind::Consumable { effect, .. } => { ItemKind::Consumable { effects, .. } => {
widget::Text::new(&util::consumable_desc(effect, i18n)) for (i, desc) in util::consumable_desc(effects, i18n).iter().enumerate() {
.x_align_to(state.ids.item_frame, conrod_core::position::Align::Start) if i == 0 {
.graphics_for(id) widget::Text::new(desc)
.parent(id) .x_align_to(state.ids.item_frame, conrod_core::position::Align::Start)
.with_style(self.style.desc) .graphics_for(id)
.color(text_color) .parent(id)
.down_from(state.ids.item_frame, V_PAD) .with_style(self.style.desc)
.set(state.ids.stats[0], ui); .color(text_color)
.down_from(state.ids.item_frame, V_PAD)
.set(state.ids.stats[0], ui);
} else {
widget::Text::new(desc)
.x_align_to(state.ids.item_frame, conrod_core::position::Align::Start)
.graphics_for(id)
.parent(id)
.with_style(self.style.desc)
.color(text_color)
.down_from(state.ids.stats[i - 1], V_PAD_STATS)
.set(state.ids.stats[i], ui);
}
}
}, },
ItemKind::ModularComponent(mc) => { ItemKind::ModularComponent(mc) => {
widget::Text::new(&util::modular_component_desc( widget::Text::new(&util::modular_component_desc(
@ -973,7 +966,7 @@ impl<'a> Widget for ItemTooltip<'a> {
.with_style(self.style.desc) .with_style(self.style.desc)
.color(conrod_core::color::GREY) .color(conrod_core::color::GREY)
.down_from( .down_from(
if stats_count(item) > 0 { if util::stats_count(item) > 0 {
state.ids.stats[state.ids.stats.len() - 1] state.ids.stats[state.ids.stats.len() - 1]
} else { } else {
state.ids.item_frame state.ids.item_frame
@ -997,7 +990,7 @@ impl<'a> Widget for ItemTooltip<'a> {
.down_from( .down_from(
if !desc.is_empty() { if !desc.is_empty() {
state.ids.desc state.ids.desc
} else if stats_count(item) > 0 { } else if util::stats_count(item) > 0 {
state.ids.stats[state.ids.stats.len() - 1] state.ids.stats[state.ids.stats.len() - 1]
} else { } else {
state.ids.item_frame state.ids.item_frame
@ -1039,31 +1032,6 @@ impl<'a> Widget for ItemTooltip<'a> {
fn default_x_dimension(&self, _ui: &Ui) -> Dimension { Dimension::Absolute(260.0) } fn default_x_dimension(&self, _ui: &Ui) -> Dimension { Dimension::Absolute(260.0) }
fn default_y_dimension(&self, ui: &Ui) -> Dimension { fn default_y_dimension(&self, ui: &Ui) -> Dimension {
fn stats_count(item: &dyn ItemDesc) -> usize {
let mut count = match item.kind() {
ItemKind::Armor(armor) => {
if matches!(armor.kind, ArmorKind::Bag(_)) {
0
} else {
5
}
},
ItemKind::Tool(_) => 4,
ItemKind::Consumable { .. } => 1,
ItemKind::ModularComponent { .. } => 1,
_ => 0,
};
let is_bag = match item.kind() {
ItemKind::Armor(armor) => matches!(armor.kind, ArmorKind::Bag(_)),
_ => false,
};
if item.num_slots() != 0 && !is_bag {
count += 1
}
count as usize
}
let item = &self.item; let item = &self.item;
let (title, desc) = (item.name().to_string(), item.description().to_string()); let (title, desc) = (item.name().to_string(), item.description().to_string());
@ -1082,13 +1050,13 @@ impl<'a> Widget for ItemTooltip<'a> {
let frame_h = ICON_SIZE[1] + V_PAD; let frame_h = ICON_SIZE[1] + V_PAD;
// Stats // Stats
let stat_h = if stats_count(self.item) > 0 { let stat_h = if util::stats_count(self.item) > 0 {
widget::Text::new(&"placeholder".to_string()) widget::Text::new(&"placeholder".to_string())
.with_style(self.style.desc) .with_style(self.style.desc)
.get_h(ui) .get_h(ui)
.unwrap_or(0.0) .unwrap_or(0.0)
* stats_count(self.item) as f64 * util::stats_count(self.item) as f64
+ (stats_count(self.item) - 1) as f64 * V_PAD_STATS + (util::stats_count(self.item) - 1) as f64 * V_PAD_STATS
+ V_PAD + V_PAD
} else { } else {
0.0 0.0