mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Formatting tweaks to tooltips
This commit is contained in:
parent
075fee5190
commit
085b18c07a
@ -169,7 +169,7 @@ impl Sub<Stats> for Stats {
|
|||||||
speed: self.speed - other.speed,
|
speed: self.speed - other.speed,
|
||||||
crit_chance: self.crit_chance - other.crit_chance,
|
crit_chance: self.crit_chance - other.crit_chance,
|
||||||
range: self.range - other.range,
|
range: self.range - other.range,
|
||||||
energy_efficiency: self.range - other.energy_efficiency,
|
energy_efficiency: self.energy_efficiency - other.energy_efficiency,
|
||||||
buff_strength: self.buff_strength - other.buff_strength,
|
buff_strength: self.buff_strength - other.buff_strength,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ pub fn stats_count(item: &dyn ItemDesc) -> usize {
|
|||||||
+ armor.stats.poise_resilience().is_some() as usize
|
+ armor.stats.poise_resilience().is_some() as usize
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ItemKind::Tool(_) => 4,
|
ItemKind::Tool(_) => 7,
|
||||||
ItemKind::Consumable { effects, .. } => effects.len(),
|
ItemKind::Consumable { effects, .. } => effects.len(),
|
||||||
ItemKind::ModularComponent { .. } => 7,
|
ItemKind::ModularComponent { .. } => 7,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
|
@ -12,6 +12,7 @@ use common::{
|
|||||||
item::{
|
item::{
|
||||||
armor::{ArmorKind, Protection},
|
armor::{ArmorKind, Protection},
|
||||||
item_key::ItemKey,
|
item_key::ItemKey,
|
||||||
|
modular::ModularComponent,
|
||||||
Item, ItemDesc, ItemKind, ItemTag, MaterialStatManifest, Quality,
|
Item, ItemDesc, ItemKind, ItemTag, MaterialStatManifest, Quality,
|
||||||
},
|
},
|
||||||
Energy,
|
Energy,
|
||||||
@ -586,6 +587,9 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
let speed = tool.base_speed();
|
let speed = tool.base_speed();
|
||||||
let effect_power = tool.base_effect_power() * 10.0;
|
let effect_power = tool.base_effect_power() * 10.0;
|
||||||
let crit_chance = tool.base_crit_chance() * 100.0;
|
let crit_chance = tool.base_crit_chance() * 100.0;
|
||||||
|
let range = tool.base_range();
|
||||||
|
let energy_efficiency = tool.base_energy_efficiency();
|
||||||
|
let buff_strength = tool.base_buff_strength();
|
||||||
let combat_rating = combat::weapon_rating(&item, self.msm) * 10.0;
|
let combat_rating = combat::weapon_rating(&item, self.msm) * 10.0;
|
||||||
|
|
||||||
// Combat Rating
|
// Combat Rating
|
||||||
@ -663,8 +667,47 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
.down_from(state.ids.stats[2], V_PAD_STATS)
|
.down_from(state.ids.stats[2], V_PAD_STATS)
|
||||||
.set(state.ids.stats[3], ui);
|
.set(state.ids.stats[3], ui);
|
||||||
|
|
||||||
|
// Range
|
||||||
|
widget::Text::new(&format!(
|
||||||
|
"{} : {:+.0}%",
|
||||||
|
i18n.get("common.stats.range"),
|
||||||
|
(range - 1.0) * 100.0
|
||||||
|
))
|
||||||
|
.graphics_for(id)
|
||||||
|
.parent(id)
|
||||||
|
.with_style(self.style.desc)
|
||||||
|
.color(text_color)
|
||||||
|
.down_from(state.ids.stats[3], V_PAD_STATS)
|
||||||
|
.set(state.ids.stats[4], ui);
|
||||||
|
|
||||||
|
// Energy Efficiency
|
||||||
|
widget::Text::new(&format!(
|
||||||
|
"{} : {:+.0}%",
|
||||||
|
i18n.get("common.stats.energy_efficiency"),
|
||||||
|
(energy_efficiency - 1.0) * 100.0
|
||||||
|
))
|
||||||
|
.graphics_for(id)
|
||||||
|
.parent(id)
|
||||||
|
.with_style(self.style.desc)
|
||||||
|
.color(text_color)
|
||||||
|
.down_from(state.ids.stats[4], V_PAD_STATS)
|
||||||
|
.set(state.ids.stats[5], ui);
|
||||||
|
|
||||||
|
// Buff Strength
|
||||||
|
widget::Text::new(&format!(
|
||||||
|
"{} : {:+.0}%",
|
||||||
|
i18n.get("common.stats.buff_strength"),
|
||||||
|
(buff_strength - 1.0) * 100.0
|
||||||
|
))
|
||||||
|
.graphics_for(id)
|
||||||
|
.parent(id)
|
||||||
|
.with_style(self.style.desc)
|
||||||
|
.color(text_color)
|
||||||
|
.down_from(state.ids.stats[5], V_PAD_STATS)
|
||||||
|
.set(state.ids.stats[6], ui);
|
||||||
|
|
||||||
if let Some(equipped_item) = first_equipped {
|
if let Some(equipped_item) = first_equipped {
|
||||||
if let ItemKind::Tool(equipped_tool) = equipped_item.kind() {
|
if let ItemKind::Tool(equipped_tool) = &*equipped_item.kind() {
|
||||||
let tool_stats = tool.stats;
|
let tool_stats = tool.stats;
|
||||||
let equipped_tool_stats = equipped_tool.stats;
|
let equipped_tool_stats = equipped_tool.stats;
|
||||||
let diff = tool_stats - equipped_tool_stats;
|
let diff = tool_stats - equipped_tool_stats;
|
||||||
@ -680,6 +723,16 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
tool_stats.crit_chance,
|
tool_stats.crit_chance,
|
||||||
equipped_tool_stats.crit_chance,
|
equipped_tool_stats.crit_chance,
|
||||||
);
|
);
|
||||||
|
let range_diff =
|
||||||
|
util::comparison(tool_stats.range, equipped_tool_stats.range);
|
||||||
|
let energy_efficiency_diff = util::comparison(
|
||||||
|
tool_stats.energy_efficiency,
|
||||||
|
equipped_tool_stats.energy_efficiency,
|
||||||
|
);
|
||||||
|
let buff_strength_diff = util::comparison(
|
||||||
|
tool_stats.buff_strength,
|
||||||
|
equipped_tool_stats.buff_strength,
|
||||||
|
);
|
||||||
let equipped_combat_rating =
|
let equipped_combat_rating =
|
||||||
combat::weapon_rating(&equipped_item, self.msm) * 10.0;
|
combat::weapon_rating(&equipped_item, self.msm) * 10.0;
|
||||||
let diff_main_stat =
|
let diff_main_stat =
|
||||||
@ -730,6 +783,26 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
);
|
);
|
||||||
diff_text(text, crit_chance_diff.1, 3)
|
diff_text(text, crit_chance_diff.1, 3)
|
||||||
}
|
}
|
||||||
|
if diff.range.abs() > f32::EPSILON {
|
||||||
|
let text = format!("{} {:.1}%", &range_diff.0, &diff.range * 100.0);
|
||||||
|
diff_text(text, range_diff.1, 4)
|
||||||
|
}
|
||||||
|
if diff.energy_efficiency.abs() > f32::EPSILON {
|
||||||
|
let text = format!(
|
||||||
|
"{} {:.1}%",
|
||||||
|
&energy_efficiency_diff.0,
|
||||||
|
&diff.energy_efficiency * 100.0
|
||||||
|
);
|
||||||
|
diff_text(text, energy_efficiency_diff.1, 5)
|
||||||
|
}
|
||||||
|
if diff.buff_strength.abs() > f32::EPSILON {
|
||||||
|
let text = format!(
|
||||||
|
"{} {:.1}%",
|
||||||
|
&buff_strength_diff.0,
|
||||||
|
&diff.buff_strength * 100.0
|
||||||
|
);
|
||||||
|
diff_text(text, buff_strength_diff.1, 6)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1099,19 +1172,26 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
},
|
},
|
||||||
ItemKind::ModularComponent(mc) => {
|
ItemKind::ModularComponent(mc) => {
|
||||||
if let Some(stats) = mc.tool_stats(item.components(), self.msm) {
|
if let Some(stats) = mc.tool_stats(item.components(), self.msm) {
|
||||||
|
let is_primary = matches!(mc, ModularComponent::ToolPrimaryComponent { .. });
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
widget::Text::new(&format!(
|
let power_text = if is_primary {
|
||||||
"{} : {:.1}",
|
format!("{} : {:.1}", i18n.get("common.stats.power"), stats.power)
|
||||||
i18n.get("common.stats.power"),
|
} else {
|
||||||
stats.power
|
format!(
|
||||||
))
|
"{} : {:+.0}%",
|
||||||
.x_align_to(state.ids.item_frame, conrod_core::position::Align::Start)
|
i18n.get("common.stats.power"),
|
||||||
.graphics_for(id)
|
(stats.power - 1.0) * 100.0
|
||||||
.parent(id)
|
)
|
||||||
.with_style(self.style.desc)
|
};
|
||||||
.color(text_color)
|
widget::Text::new(&power_text)
|
||||||
.down_from(state.ids.item_frame, V_PAD)
|
.x_align_to(state.ids.item_frame, conrod_core::position::Align::Start)
|
||||||
.set(state.ids.stats[0], ui);
|
.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);
|
||||||
|
|
||||||
// Speed
|
// Speed
|
||||||
widget::Text::new(&format!(
|
widget::Text::new(&format!(
|
||||||
@ -1129,34 +1209,52 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
// Effect Power
|
// Effect Power
|
||||||
// TODO: Allow effect power to have different terminology based on what it is
|
// TODO: Allow effect power to have different terminology based on what it is
|
||||||
// affecting.
|
// affecting.
|
||||||
widget::Text::new(&format!(
|
let effect_power_text = if is_primary {
|
||||||
"{} : {:.1}",
|
format!(
|
||||||
i18n.get("common.stats.poise"),
|
"{} : {:.1}",
|
||||||
stats.effect_power
|
i18n.get("common.stats.poise"),
|
||||||
))
|
stats.effect_power
|
||||||
.graphics_for(id)
|
)
|
||||||
.parent(id)
|
} else {
|
||||||
.with_style(self.style.desc)
|
format!(
|
||||||
.color(text_color)
|
"{} : {:+.0}%",
|
||||||
.down_from(state.ids.stats[1], V_PAD_STATS)
|
i18n.get("common.stats.poise"),
|
||||||
.set(state.ids.stats[2], ui);
|
(stats.effect_power - 1.0) * 100.0
|
||||||
|
)
|
||||||
|
};
|
||||||
|
widget::Text::new(&effect_power_text)
|
||||||
|
.graphics_for(id)
|
||||||
|
.parent(id)
|
||||||
|
.with_style(self.style.desc)
|
||||||
|
.color(text_color)
|
||||||
|
.down_from(state.ids.stats[1], V_PAD_STATS)
|
||||||
|
.set(state.ids.stats[2], ui);
|
||||||
|
|
||||||
// Crit chance
|
// Crit chance
|
||||||
widget::Text::new(&format!(
|
let crit_chance_text = if is_primary {
|
||||||
"{} : {:.1}%",
|
format!(
|
||||||
i18n.get("common.stats.crit_chance"),
|
"{} : {:.1}%",
|
||||||
stats.crit_chance
|
i18n.get("common.stats.crit_chance"),
|
||||||
))
|
stats.crit_chance * 100.0
|
||||||
.graphics_for(id)
|
)
|
||||||
.parent(id)
|
} else {
|
||||||
.with_style(self.style.desc)
|
format!(
|
||||||
.color(text_color)
|
"{} : {:+.0}%",
|
||||||
.down_from(state.ids.stats[2], V_PAD_STATS)
|
i18n.get("common.stats.crit_chance"),
|
||||||
.set(state.ids.stats[3], ui);
|
(stats.crit_chance - 1.0) * 100.0
|
||||||
|
)
|
||||||
|
};
|
||||||
|
widget::Text::new(&crit_chance_text)
|
||||||
|
.graphics_for(id)
|
||||||
|
.parent(id)
|
||||||
|
.with_style(self.style.desc)
|
||||||
|
.color(text_color)
|
||||||
|
.down_from(state.ids.stats[2], V_PAD_STATS)
|
||||||
|
.set(state.ids.stats[3], ui);
|
||||||
|
|
||||||
// Range
|
// Range
|
||||||
widget::Text::new(&format!(
|
widget::Text::new(&format!(
|
||||||
"{} : {:.1}%",
|
"{} : {:+.0}%",
|
||||||
i18n.get("common.stats.range"),
|
i18n.get("common.stats.range"),
|
||||||
(stats.range - 1.0) * 100.0
|
(stats.range - 1.0) * 100.0
|
||||||
))
|
))
|
||||||
@ -1169,9 +1267,9 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
|
|
||||||
// Energy Efficiency
|
// Energy Efficiency
|
||||||
widget::Text::new(&format!(
|
widget::Text::new(&format!(
|
||||||
"{} : {:.1}%",
|
"{} : {:+.0}%",
|
||||||
i18n.get("common.stats.energy_efficiency"),
|
i18n.get("common.stats.energy_efficiency"),
|
||||||
stats.energy_efficiency
|
(stats.energy_efficiency - 1.0) * 100.0
|
||||||
))
|
))
|
||||||
.graphics_for(id)
|
.graphics_for(id)
|
||||||
.parent(id)
|
.parent(id)
|
||||||
@ -1182,9 +1280,9 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
|
|
||||||
// Buff Strength
|
// Buff Strength
|
||||||
widget::Text::new(&format!(
|
widget::Text::new(&format!(
|
||||||
"{} : {:.1}%",
|
"{} : {:+.0}%",
|
||||||
i18n.get("common.stats.buff_strength"),
|
i18n.get("common.stats.buff_strength"),
|
||||||
stats.buff_strength
|
(stats.buff_strength - 1.0) * 100.0
|
||||||
))
|
))
|
||||||
.graphics_for(id)
|
.graphics_for(id)
|
||||||
.parent(id)
|
.parent(id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user