diff --git a/assets/common/items/boss_drops/potions.ron b/assets/common/items/boss_drops/potions.ron index bccc411161..d1e43691d9 100644 --- a/assets/common/items/boss_drops/potions.ron +++ b/assets/common/items/boss_drops/potions.ron @@ -2,8 +2,8 @@ ItemDef( name: "Potent Potion", description: "A potent healing potion.", kind: Consumable( - kind: Potion, - effect: [ + kind: Drink, + effects: [ Buff(( kind: Potion, data: ( diff --git a/assets/common/items/consumable/potion_big.ron b/assets/common/items/consumable/potion_big.ron index 487206c222..b764679cf8 100644 --- a/assets/common/items/consumable/potion_big.ron +++ b/assets/common/items/consumable/potion_big.ron @@ -3,7 +3,7 @@ ItemDef( description: "", kind: Consumable( kind: Drink, - effect: [ + effects: [ Buff(( kind: Potion, data: ( diff --git a/assets/common/items/consumable/potion_med.ron b/assets/common/items/consumable/potion_med.ron index d0d64c03c3..ab65a31465 100644 --- a/assets/common/items/consumable/potion_med.ron +++ b/assets/common/items/consumable/potion_med.ron @@ -3,7 +3,7 @@ ItemDef( description: "", kind: Consumable( kind: Drink, - effect: [ + effects: [ Buff(( kind: Potion, data: ( diff --git a/assets/common/items/consumable/potion_minor.ron b/assets/common/items/consumable/potion_minor.ron index ea3e76debf..f7afeb164e 100644 --- a/assets/common/items/consumable/potion_minor.ron +++ b/assets/common/items/consumable/potion_minor.ron @@ -3,7 +3,7 @@ ItemDef( description: "", kind: Consumable( kind: Drink, - effect: [ + effects: [ Buff(( kind: Potion, data: ( diff --git a/assets/common/items/food/apple.ron b/assets/common/items/food/apple.ron index c55d36de55..8ad3069011 100644 --- a/assets/common/items/food/apple.ron +++ b/assets/common/items/food/apple.ron @@ -3,7 +3,7 @@ ItemDef( description: "Red and juicy", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/apple_mushroom_curry.ron b/assets/common/items/food/apple_mushroom_curry.ron index 078a706930..f98c61d942 100644 --- a/assets/common/items/food/apple_mushroom_curry.ron +++ b/assets/common/items/food/apple_mushroom_curry.ron @@ -3,7 +3,7 @@ ItemDef( description: "Who could say no to that?", kind: Consumable( kind: ComplexFood, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/apple_stick.ron b/assets/common/items/food/apple_stick.ron index d42eb216da..c8596c90cc 100644 --- a/assets/common/items/food/apple_stick.ron +++ b/assets/common/items/food/apple_stick.ron @@ -3,7 +3,7 @@ ItemDef( description: "The stick makes it easier to carry!", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/cactus_colada.ron b/assets/common/items/food/cactus_colada.ron index 9eb97fe43e..e974721a78 100644 --- a/assets/common/items/food/cactus_colada.ron +++ b/assets/common/items/food/cactus_colada.ron @@ -3,7 +3,7 @@ ItemDef( description: "Giving you that special prickle.", kind: Consumable( kind: Drink, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/carrot.ron b/assets/common/items/food/carrot.ron index 38853ac127..96fba22146 100644 --- a/assets/common/items/food/carrot.ron +++ b/assets/common/items/food/carrot.ron @@ -3,7 +3,7 @@ ItemDef( description: "An orange root vegetable. They say it'll improve your vision!", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/cheese.ron b/assets/common/items/food/cheese.ron index 406e048d8b..ccc674a8ec 100644 --- a/assets/common/items/food/cheese.ron +++ b/assets/common/items/food/cheese.ron @@ -3,7 +3,7 @@ ItemDef( description: "Aromatic and nutritious", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/coconut.ron b/assets/common/items/food/coconut.ron index 6fcef657e0..2a161e1bf6 100644 --- a/assets/common/items/food/coconut.ron +++ b/assets/common/items/food/coconut.ron @@ -3,7 +3,7 @@ ItemDef( description: "Reliable source of water and fat.\n\nNaturally growing at the top of palm trees.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/coltsfoot.ron b/assets/common/items/food/coltsfoot.ron index 5e30d94430..5cf2795ee8 100644 --- a/assets/common/items/food/coltsfoot.ron +++ b/assets/common/items/food/coltsfoot.ron @@ -3,7 +3,7 @@ ItemDef( description: "A daisy-like flower often used in herbal teas.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/dandelion.ron b/assets/common/items/food/dandelion.ron index e6a3d334bc..7b9f7fd8e3 100644 --- a/assets/common/items/food/dandelion.ron +++ b/assets/common/items/food/dandelion.ron @@ -3,7 +3,7 @@ ItemDef( description: "A small, yellow flower. Uses the wind to spread its seeds.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/garlic.ron b/assets/common/items/food/garlic.ron index be8493b7d5..a55159d5c5 100644 --- a/assets/common/items/food/garlic.ron +++ b/assets/common/items/food/garlic.ron @@ -3,7 +3,7 @@ ItemDef( description: "Make sure to brush your teeth after eating.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/lettuce.ron b/assets/common/items/food/lettuce.ron index 25bee72caf..1d8c5a3c03 100644 --- a/assets/common/items/food/lettuce.ron +++ b/assets/common/items/food/lettuce.ron @@ -3,7 +3,7 @@ ItemDef( description: "A vibrant green leafy vegetable. Lettuce make some salads!", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat.ron b/assets/common/items/food/meat.ron index 221fb5182f..84fcd698e8 100644 --- a/assets/common/items/food/meat.ron +++ b/assets/common/items/food/meat.ron @@ -3,7 +3,7 @@ ItemDef( description: "Meat. The lifeblood of mankind.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/beast_large_cooked.ron b/assets/common/items/food/meat/beast_large_cooked.ron index adcd36e952..6e8650b15d 100644 --- a/assets/common/items/food/meat/beast_large_cooked.ron +++ b/assets/common/items/food/meat/beast_large_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "Medium Rare.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/beast_large_raw.ron b/assets/common/items/food/meat/beast_large_raw.ron index b160ba22ba..79aea5c67c 100644 --- a/assets/common/items/food/meat/beast_large_raw.ron +++ b/assets/common/items/food/meat/beast_large_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "Chunk of beastly animal meat, best after cooking.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/beast_small_cooked.ron b/assets/common/items/food/meat/beast_small_cooked.ron index 474caddd36..7f5d04f9a9 100644 --- a/assets/common/items/food/meat/beast_small_cooked.ron +++ b/assets/common/items/food/meat/beast_small_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "Medium Rare.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/beast_small_raw.ron b/assets/common/items/food/meat/beast_small_raw.ron index c147bc2798..7573c6f108 100644 --- a/assets/common/items/food/meat/beast_small_raw.ron +++ b/assets/common/items/food/meat/beast_small_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "Small hunk of beastly animal meat, best after cooking.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/bird_cooked.ron b/assets/common/items/food/meat/bird_cooked.ron index 8aede55dc7..34d096b5d6 100644 --- a/assets/common/items/food/meat/bird_cooked.ron +++ b/assets/common/items/food/meat/bird_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "Best enjoyed with one in each hand.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/bird_large_cooked.ron b/assets/common/items/food/meat/bird_large_cooked.ron index 00081a8730..1f8593776f 100644 --- a/assets/common/items/food/meat/bird_large_cooked.ron +++ b/assets/common/items/food/meat/bird_large_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "Makes for a legendary meal.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/bird_large_raw.ron b/assets/common/items/food/meat/bird_large_raw.ron index b54389f36e..7bcfb67469 100644 --- a/assets/common/items/food/meat/bird_large_raw.ron +++ b/assets/common/items/food/meat/bird_large_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "It's magificent.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/bird_raw.ron b/assets/common/items/food/meat/bird_raw.ron index 4feb3db030..0c9b0508d9 100644 --- a/assets/common/items/food/meat/bird_raw.ron +++ b/assets/common/items/food/meat/bird_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "A hefty drumstick.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/fish_cooked.ron b/assets/common/items/food/meat/fish_cooked.ron index ed4c83579a..0042d1fbf7 100644 --- a/assets/common/items/food/meat/fish_cooked.ron +++ b/assets/common/items/food/meat/fish_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "A fresh cooked seafood steak.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/fish_raw.ron b/assets/common/items/food/meat/fish_raw.ron index 730808377f..e2dd887b82 100644 --- a/assets/common/items/food/meat/fish_raw.ron +++ b/assets/common/items/food/meat/fish_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "A steak chopped from a fish, best after cooking.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/tough_cooked.ron b/assets/common/items/food/meat/tough_cooked.ron index b575a7f934..450e673fd0 100644 --- a/assets/common/items/food/meat/tough_cooked.ron +++ b/assets/common/items/food/meat/tough_cooked.ron @@ -3,7 +3,7 @@ ItemDef( description: "Tastes exotic.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/meat/tough_raw.ron b/assets/common/items/food/meat/tough_raw.ron index d9c75d0d59..0114539484 100644 --- a/assets/common/items/food/meat/tough_raw.ron +++ b/assets/common/items/food/meat/tough_raw.ron @@ -3,7 +3,7 @@ ItemDef( description: "Peculiar bit of meat, best after cooking.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/mushroom.ron b/assets/common/items/food/mushroom.ron index 255b04e111..8d90dff0c5 100644 --- a/assets/common/items/food/mushroom.ron +++ b/assets/common/items/food/mushroom.ron @@ -3,7 +3,7 @@ ItemDef( description: "Hopefully this one is not poisonous", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/mushroom_stick.ron b/assets/common/items/food/mushroom_stick.ron index f6ba282de5..e19c0f1ef6 100644 --- a/assets/common/items/food/mushroom_stick.ron +++ b/assets/common/items/food/mushroom_stick.ron @@ -3,7 +3,7 @@ ItemDef( description: "Roasted mushrooms on a stick for easy carrying", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/onion.ron b/assets/common/items/food/onion.ron index f07d61c8ef..023a1f9f7d 100644 --- a/assets/common/items/food/onion.ron +++ b/assets/common/items/food/onion.ron @@ -3,7 +3,7 @@ ItemDef( description: "A vegetable that's made the toughest men cry.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/plainsalad.ron b/assets/common/items/food/plainsalad.ron index 3693776fb1..21f8412201 100644 --- a/assets/common/items/food/plainsalad.ron +++ b/assets/common/items/food/plainsalad.ron @@ -3,7 +3,7 @@ ItemDef( description: "Literally just chopped lettuce. Does this even count as a salad?", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/sage.ron b/assets/common/items/food/sage.ron index b54c851eee..38c46a67bf 100644 --- a/assets/common/items/food/sage.ron +++ b/assets/common/items/food/sage.ron @@ -3,7 +3,7 @@ ItemDef( description: "A herb commonly used in tea.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/spore_corruption.ron b/assets/common/items/food/spore_corruption.ron index 9d0e65ef5a..f847f81e59 100644 --- a/assets/common/items/food/spore_corruption.ron +++ b/assets/common/items/food/spore_corruption.ron @@ -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...", kind: Consumable( kind: ComplexFood, - effect: [ + effects: [ Buff(( kind: Frenzied, data: ( diff --git a/assets/common/items/food/sunflower_icetea.ron b/assets/common/items/food/sunflower_icetea.ron index 6e05c847ee..7c74fd904a 100644 --- a/assets/common/items/food/sunflower_icetea.ron +++ b/assets/common/items/food/sunflower_icetea.ron @@ -3,7 +3,7 @@ ItemDef( description: "Brewed from freshly shelled sunflower seeds", kind: Consumable( kind: Drink, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/tomato.ron b/assets/common/items/food/tomato.ron index 00d8ddfc42..c1fde8cd6f 100644 --- a/assets/common/items/food/tomato.ron +++ b/assets/common/items/food/tomato.ron @@ -3,7 +3,7 @@ ItemDef( description: "A red fruit. Not actually a vegetable.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/assets/common/items/food/tomatosalad.ron b/assets/common/items/food/tomatosalad.ron index fe90256e3b..4bf41d8f8a 100644 --- a/assets/common/items/food/tomatosalad.ron +++ b/assets/common/items/food/tomatosalad.ron @@ -3,7 +3,7 @@ ItemDef( description: "Leafy salad with some chopped, juicy tomatoes mixed in.", kind: Consumable( kind: Food, - effect: [ + effects: [ Buff(( kind: Saturation, data: ( diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 9e2b30e12c..7861660d60 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -251,7 +251,7 @@ pub enum ItemKind { Glider(Glider), Consumable { kind: ConsumableKind, - effect: Vec, + effects: Vec, }, Throwable { kind: Throwable, diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index b75f5dad26..b8ea4298ee 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -526,8 +526,8 @@ impl TradePricing { } }); printvec("Potions", &self.potions.entries, |i, p| { - if let ItemKind::Consumable { kind: _, effect } = &i.kind { - effect + if let ItemKind::Consumable { kind: _, effects } = &i.kind { + effects .iter() .map(|e| { if let crate::effect::Effect::Buff(b) = e { @@ -543,8 +543,8 @@ impl TradePricing { } }); printvec("Food", &self.food.entries, |i, p| { - if let ItemKind::Consumable { kind: _, effect } = &i.kind { - effect + if let ItemKind::Consumable { kind: _, effects } = &i.kind { + effects .iter() .map(|e| { if let crate::effect::Effect::Buff(b) = e { diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index c2243e9395..7a29c7caae 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -285,8 +285,8 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv &state.ecs().read_resource::(), ) { match item.kind() { - ItemKind::Consumable { effect, .. } => { - maybe_effect = Some(effect.clone()); + ItemKind::Consumable { effects, .. } => { + maybe_effect = Some(effects.clone()); Some(comp::InventoryUpdateEvent::Consumed(item.name().to_owned())) }, ItemKind::Throwable { kind, .. } => { diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index f141b59cca..f8696a0b87 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -1452,10 +1452,10 @@ impl<'a> AgentData<'a> { let mut value = 0; #[allow(clippy::single_match)] match item.kind() { - ItemKind::Consumable { effect, .. } => { - for e in effect.iter() { + ItemKind::Consumable { effects, .. } => { + for effect in effects.iter() { use BuffKind::*; - match e { + match effect { Effect::Health(HealthChange { amount, .. }) => { value += *amount; }, diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index 5f9f15142b..39b67f9056 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -4,7 +4,7 @@ use common::{ item::{ armor::{Armor, ArmorKind, Protection}, tool::{Hands, StatKind, Stats, Tool, ToolKind}, - Item, ItemKind, MaterialKind, MaterialStatManifest, ModularComponent, + Item, ItemDesc, ItemKind, MaterialKind, MaterialStatManifest, ModularComponent, }, BuffKind, }, @@ -104,10 +104,41 @@ pub fn modular_component_desc( result } -pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { - let mut description = String::new(); +pub 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 { 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 { + let mut descriptions = Vec::new(); for effect in effects { + let mut description = String::new(); if let Effect::Buff(buff) = effect { let strength = buff.data.strength * 0.1; 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 { BuffKind::Saturation | BuffKind::Regeneration | BuffKind::Potion => i18n .get("buff.stat.health") - .replace("{str_total}", &*format!("{:.1}", &str_total)), + .replace("{str_total}", &str_total.to_string()), BuffKind::IncreaseMaxEnergy => i18n .get("buff.stat.increase_max_stamina") - .replace("{strength}", &*format!("{:.1}", &strength)), + .replace("{strength}", &strength.to_string()), BuffKind::IncreaseMaxHealth => i18n .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::Bleeding | BuffKind::Burning @@ -133,7 +164,7 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { | BuffKind::Frenzied | BuffKind::Frozen | BuffKind::Wet - | BuffKind::Ensnared => continue, + | BuffKind::Ensnared => "".to_owned(), }; write!(&mut description, "{}", buff_desc).unwrap(); @@ -158,19 +189,20 @@ pub fn consumable_desc(effects: &[Effect], i18n: &Localization) -> String { | BuffKind::Frenzied | BuffKind::Frozen | BuffKind::Wet - | BuffKind::Ensnared => continue, + | BuffKind::Ensnared => "".to_owned(), } } else if let BuffKind::Saturation | BuffKind::Regeneration = buff.kind { i18n.get("buff.text.every_second").to_string() } else { - continue; + "".to_owned() }; write!(&mut description, " {}", dur_desc).unwrap(); } + descriptions.push(description); } - description + descriptions } // Armor diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index c1a64ed74b..656aec8519 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -427,26 +427,6 @@ impl<'a> Widget for ItemTooltip<'a> { .. } = 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 inventories = self.client.inventories(); @@ -503,13 +483,13 @@ impl<'a> Widget for ItemTooltip<'a> { state.update(|s| { s.ids .stats - .resize(stats_count(item), &mut ui.widget_id_generator()) + .resize(util::stats_count(item), &mut ui.widget_id_generator()) }); state.update(|s| { s.ids .diffs - .resize(stats_count(item), &mut ui.widget_id_generator()) + .resize(util::stats_count(item), &mut ui.widget_id_generator()) }); // Background image frame @@ -936,15 +916,28 @@ impl<'a> Widget for ItemTooltip<'a> { } } }, - ItemKind::Consumable { effect, .. } => { - widget::Text::new(&util::consumable_desc(effect, i18n)) - .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.item_frame, V_PAD) - .set(state.ids.stats[0], ui); + ItemKind::Consumable { effects, .. } => { + for (i, desc) in util::consumable_desc(effects, i18n).iter().enumerate() { + if i == 0 { + 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.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) => { widget::Text::new(&util::modular_component_desc( @@ -973,7 +966,7 @@ impl<'a> Widget for ItemTooltip<'a> { .with_style(self.style.desc) .color(conrod_core::color::GREY) .down_from( - if stats_count(item) > 0 { + if util::stats_count(item) > 0 { state.ids.stats[state.ids.stats.len() - 1] } else { state.ids.item_frame @@ -997,7 +990,7 @@ impl<'a> Widget for ItemTooltip<'a> { .down_from( if !desc.is_empty() { state.ids.desc - } else if stats_count(item) > 0 { + } else if util::stats_count(item) > 0 { state.ids.stats[state.ids.stats.len() - 1] } else { 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_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 (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; // 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()) .with_style(self.style.desc) .get_h(ui) .unwrap_or(0.0) - * stats_count(self.item) as f64 - + (stats_count(self.item) - 1) as f64 * V_PAD_STATS + * util::stats_count(self.item) as f64 + + (util::stats_count(self.item) - 1) as f64 * V_PAD_STATS + V_PAD } else { 0.0