mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
(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:
parent
eb61b23d04
commit
d4c61ae2f3
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "",
|
||||
kind: Consumable(
|
||||
kind: Drink,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Potion,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "",
|
||||
kind: Consumable(
|
||||
kind: Drink,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Potion,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "",
|
||||
kind: Consumable(
|
||||
kind: Drink,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Potion,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Red and juicy",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Who could say no to that?",
|
||||
kind: Consumable(
|
||||
kind: ComplexFood,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "The stick makes it easier to carry!",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Giving you that special prickle.",
|
||||
kind: Consumable(
|
||||
kind: Drink,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Aromatic and nutritious",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -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: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Make sure to brush your teeth after eating.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Meat. The lifeblood of mankind.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Medium Rare.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Chunk of beastly animal meat, best after cooking.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Medium Rare.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Best enjoyed with one in each hand.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Makes for a legendary meal.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "It's magificent.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "A hefty drumstick.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "A fresh cooked seafood steak.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Tastes exotic.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Peculiar bit of meat, best after cooking.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Hopefully this one is not poisonous",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Roasted mushrooms on a stick for easy carrying",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "A herb commonly used in tea.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "Brewed from freshly shelled sunflower seeds",
|
||||
kind: Consumable(
|
||||
kind: Drink,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -3,7 +3,7 @@ ItemDef(
|
||||
description: "A red fruit. Not actually a vegetable.",
|
||||
kind: Consumable(
|
||||
kind: Food,
|
||||
effect: [
|
||||
effects: [
|
||||
Buff((
|
||||
kind: Saturation,
|
||||
data: (
|
||||
|
@ -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: (
|
||||
|
@ -251,7 +251,7 @@ pub enum ItemKind {
|
||||
Glider(Glider),
|
||||
Consumable {
|
||||
kind: ConsumableKind,
|
||||
effect: Vec<Effect>,
|
||||
effects: Vec<Effect>,
|
||||
},
|
||||
Throwable {
|
||||
kind: Throwable,
|
||||
|
@ -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 {
|
||||
|
@ -285,8 +285,8 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
&state.ecs().read_resource::<item::MaterialStatManifest>(),
|
||||
) {
|
||||
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, .. } => {
|
||||
|
@ -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;
|
||||
},
|
||||
|
@ -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<String> {
|
||||
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user