mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Avoid cloning armor/tool in tooltip generation, add temporary case for legacy item descriptions
This commit is contained in:
parent
44febaabdf
commit
d74a1d371e
@ -20,8 +20,8 @@ pub fn loadout_slot_text<'a>(
|
|||||||
|
|
||||||
pub fn item_text<'a>(item: &'a Item) -> (&'_ str, Cow<'a, str>) {
|
pub fn item_text<'a>(item: &'a Item) -> (&'_ str, Cow<'a, str>) {
|
||||||
let desc = match &item.kind {
|
let desc = match &item.kind {
|
||||||
ItemKind::Armor(armor) => Cow::Owned(armor_desc(armor.clone(), item.description())),
|
ItemKind::Armor(armor) => Cow::Owned(armor_desc(&armor, item.description())),
|
||||||
ItemKind::Tool(tool) => Cow::Owned(tool_desc(tool.clone(), item.description())),
|
ItemKind::Tool(tool) => Cow::Owned(tool_desc(&tool, item.description())),
|
||||||
/*ItemKind::Consumable(kind, effect, ..) => {
|
/*ItemKind::Consumable(kind, effect, ..) => {
|
||||||
Cow::Owned(consumable_desc(consumable, item.description()))
|
Cow::Owned(consumable_desc(consumable, item.description()))
|
||||||
},*/
|
},*/
|
||||||
@ -35,7 +35,7 @@ pub fn item_text<'a>(item: &'a Item) -> (&'_ str, Cow<'a, str>) {
|
|||||||
(item.name(), desc)
|
(item.name(), desc)
|
||||||
}
|
}
|
||||||
// Armor Description
|
// Armor Description
|
||||||
fn armor_desc(armor: Armor, desc: &str) -> String {
|
fn armor_desc(armor: &Armor, desc: &str) -> String {
|
||||||
// TODO: localization
|
// TODO: localization
|
||||||
let kind = match armor.kind {
|
let kind = match armor.kind {
|
||||||
ArmorKind::Shoulder(_) => "Shoulders",
|
ArmorKind::Shoulder(_) => "Shoulders",
|
||||||
@ -55,6 +55,13 @@ fn armor_desc(armor: Armor, desc: &str) -> String {
|
|||||||
Protection::Invincible => "Inf".to_string(),
|
Protection::Invincible => "Inf".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: remove when legacy descriptions are fixed by persistence overhaul
|
||||||
|
let desc = if desc.contains("<Right-Click to use>") {
|
||||||
|
"Legacy item."
|
||||||
|
} else {
|
||||||
|
desc
|
||||||
|
};
|
||||||
|
|
||||||
if !desc.is_empty() {
|
if !desc.is_empty() {
|
||||||
format!(
|
format!(
|
||||||
"{}\n\nArmor: {}\n\n{}\n\n<Right-Click to use>",
|
"{}\n\nArmor: {}\n\n{}\n\n<Right-Click to use>",
|
||||||
@ -65,7 +72,7 @@ fn armor_desc(armor: Armor, desc: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Weapon/Tool Description
|
// Weapon/Tool Description
|
||||||
fn tool_desc(tool: Tool, desc: &str) -> String {
|
fn tool_desc(tool: &Tool, desc: &str) -> String {
|
||||||
// TODO: localization
|
// TODO: localization
|
||||||
let kind = match tool.kind {
|
let kind = match tool.kind {
|
||||||
ToolKind::Sword(_) => "Sword",
|
ToolKind::Sword(_) => "Sword",
|
||||||
@ -81,6 +88,13 @@ fn tool_desc(tool: Tool, desc: &str) -> String {
|
|||||||
};
|
};
|
||||||
let power = tool.base_power();
|
let power = tool.base_power();
|
||||||
|
|
||||||
|
// TODO: remove when legacy descriptions are fixed by persistence overhaul
|
||||||
|
let desc = if desc.contains("<Right-Click to use>") {
|
||||||
|
"Legacy item."
|
||||||
|
} else {
|
||||||
|
desc
|
||||||
|
};
|
||||||
|
|
||||||
if !desc.is_empty() {
|
if !desc.is_empty() {
|
||||||
format!(
|
format!(
|
||||||
"{}\n\nPower: {:0.1}\n\n{}\n\n<Right-Click to use>",
|
"{}\n\nPower: {:0.1}\n\n{}\n\n<Right-Click to use>",
|
||||||
|
Loading…
Reference in New Issue
Block a user