Factored formatting of buff text out to a single function.

This commit is contained in:
Sam 2021-02-28 16:04:33 -05:00
parent a88ad7b971
commit 531c38c3ad
16 changed files with 92 additions and 190 deletions

View File

@ -537,8 +537,8 @@ Willenskraft
"buff.title.heal": "HoT Buff Test",
"buff.desc.heal": "HoT Buff Test",
// Debuffs
"debuff.title.bleed": "Blutung",
"debuff.desc.bleed": "Fügt regelmäßig Schaden zu.",
"buff.title.bleed": "Blutung",
"buff.desc.bleed": "Fügt regelmäßig Schaden zu.",
},
vector_map: {

View File

@ -3,6 +3,7 @@
/// Localization for "global" English
(
string_map: {
// Buffs
"buff.remove": "Click to remove",
"buff.title.missing": "Missing Title",
"buff.desc.missing": "Missing Description",
@ -14,6 +15,13 @@
"buff.desc.saturation": "Gain health over time from consumables.",
"buff.title.campfire_heal": "Campfire Heal",
"buff.desc.campfire_heal": "Resting at a campfire heals 1% per second.",
"buff.title.invulnerability": "Invulnerability",
"buff.desc.invulnerability": "You cannot be damaged by any attack.",
// Debuffs
"buff.title.bleed": "Bleeding",
"buff.desc.bleed": "Inflicts regular damage.",
"buff.title.cursed": "Cursed",
"buff.desc.cursed": "You are cursed.",
},

View File

@ -1,13 +0,0 @@
/// WARNING: Localization files shall be saved in UTF-8 format without BOM
/// Localization for "global" English
(
string_map: {
"debuff.title.bleed": "Bleeding",
"debuff.desc.bleed": "Inflicts regular damage.",
},
vector_map: {
}
)

View File

@ -554,8 +554,8 @@ Protección
"buff.title.campfire_heal": "Curación de fogata",
"buff.desc.campfire_heal": "Descansar en una fogata recupera 1% por segundo.",
// Debuffs
"debuff.title.bleed": "Sangrando",
"debuff.desc.bleed": "Inflinge daño regularmente.",
"buff.title.bleed": "Sangrando",
"buff.desc.bleed": "Inflinge daño regularmente.",
},

View File

@ -533,8 +533,8 @@ Protection
"buff.title.campfire_heal": "Soin autour d'un feu de camp",
"buff.desc.campfire_heal": "Se reposer à côté d'un feu de camp restaure 1% de santé par seconde.",
// Debuffs
"debuff.title.bleed": "Saignement",
"debuff.desc.bleed": "Inflige régulièrement des dommages.",
"buff.title.bleed": "Saignement",
"buff.desc.bleed": "Inflige régulièrement des dommages.",
},

View File

@ -534,8 +534,8 @@ Beskyttelse
"buff.title.saturation": "Metning",
"buff.desc.saturation": "Helbred over tid fra forbruksvarer.",
// Debuffs
"debuff.title.bleed": "Blør",
"debuff.desc.bleed": "Påfører regelmessig skade.",
"buff.title.bleed": "Blør",
"buff.desc.bleed": "Påfører regelmessig skade.",
},

View File

@ -14,6 +14,8 @@
"buff.desc.saturation": "Ganha vida no decorrer do tempo através de consumíveis.",
"buff.title.campfire_heal": "Cura de Acampamento",
"buff.desc.campfire_heal": "Descansar próximo a uma fogueira de acampamento cura 1% de vida por segundo.",
"buff.title.bleed": "Sangramento",
"buff.desc.bleed": "Inflige Dano contínuo.",
},

View File

@ -1,13 +0,0 @@
/// CUIDADO: Arquivos de tradução devem ser criados no formato UTF-8 sem Marca de Ordem de byte - BOM(https://pt.wikipedia.org/wiki/Marca_de_ordem_de_byte)
/// Localization for Portuguese (Brazil)
(
string_map: {
"debuff.title.bleed": "Sangramento",
"debuff.desc.bleed": "Inflige Dano contínuo.",
},
vector_map: {
}
)

View File

@ -550,8 +550,8 @@ https://veloren.net/account/."#,
"buff.title.saturation": "Сыт",
"buff.desc.saturation": "Получайте здоровье от расходников в течении времени.",
// Debuffs
"debuff.title.bleed": "Кровотечение",
"debuff.desc.bleed": "Наносит переодический урон.",
"buff.title.bleed": "Кровотечение",
"buff.desc.bleed": "Наносит переодический урон.",
},

View File

@ -14,6 +14,8 @@
"buff.desc.saturation": "Tüketilebilen maddelerden zamanla can kazan.",
"buff.title.campfire_heal": "Kamp Ateşi",
"buff.desc.campfire_heal": "Kamp ateşinin yakınında oturmak canını saniyede %1 iyileştirir.",
"buff.title.bleed": "Kanama",
"buff.desc.bleed": "Devamlı hasar verir.",
},
vector_map: {

View File

@ -1,13 +0,0 @@
/// WARNING: Localization files shall be saved in UTF-8 format without BOM
/// Localization for Turkish (Turkey)
(
string_map: {
"debuff.title.bleed": "Kanama",
"debuff.desc.bleed": "Devamlı hasar verir.",
},
vector_map: {
}
)

View File

@ -14,6 +14,8 @@
"buff.desc.saturation": "Поступово відновлює здоров'я з їжі.",
"buff.title.campfire_heal": "Відновлення біля ватри",
"buff.desc.campfire_heal": "Відпочинок біля ватри лікує на 1% за секунду.",
"buff.title.bleed": "Кровотеча",
"buff.desc.bleed": "Наносить регулярні ушкодження.",
},

View File

@ -1,13 +0,0 @@
/// WARNING: Localization files shall be saved in UTF-8 format without BOM
/// Localization for Ukrainian
(
string_map: {
"debuff.title.bleed": "Кровотеча",
"debuff.desc.bleed": "Наносить регулярні ушкодження.",
},
vector_map: {
}
)

View File

@ -3,7 +3,7 @@ use super::{
BUFF_COLOR, DEBUFF_COLOR, TEXT_COLOR,
};
use crate::{
hud::{get_buff_image, get_buff_info, BuffPosition},
hud::{self, BuffPosition},
i18n::Localization,
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
GlobalState,
@ -145,7 +145,7 @@ impl<'a> Widget for BuffsBar<'a> {
.set(state.ids.buffs_align, ui);
// Buffs and Debuffs
let (buff_count, debuff_count) = buffs.iter_active().map(get_buff_info).fold(
let (buff_count, debuff_count) = buffs.iter_active().map(hud::get_buff_info).fold(
(0, 0),
|(buff_count, debuff_count), info| {
if info.is_buff {
@ -183,7 +183,7 @@ impl<'a> Widget for BuffsBar<'a> {
.zip(
buffs
.iter_active()
.map(get_buff_info)
.map(hud::get_buff_info)
.filter(|info| info.is_buff),
)
.collect::<Vec<_>>();
@ -201,7 +201,7 @@ impl<'a> Widget for BuffsBar<'a> {
max_duration
.map_or(1000.0, |max| cur.as_secs_f32() / max.as_secs_f32() * 1000.0)
}) as u32; // Percentage to determine which frame of the timer overlay is displayed
let buff_img = get_buff_image(buff.kind, self.imgs);
let buff_img = hud::get_buff_image(buff.kind, self.imgs);
let buff_widget = Image::new(buff_img).w_h(40.0, 40.0);
// Sort buffs into rows of 11 slots
let x = i % 6;
@ -221,46 +221,10 @@ impl<'a> Widget for BuffsBar<'a> {
)
.set(*id, ui);
// Create Buff tooltip
let title = match buff.kind {
BuffKind::Regeneration { .. } => localized_strings.get("buff.title.heal"),
BuffKind::Saturation { .. } => {
localized_strings.get("buff.title.saturation")
},
BuffKind::Potion { .. } => localized_strings.get("buff.title.potion"),
BuffKind::CampfireHeal { .. } => {
localized_strings.get("buff.title.campfire_heal")
},
BuffKind::IncreaseMaxHealth { .. } => {
localized_strings.get("buff.title.IncreaseMaxHealth")
},
BuffKind::IncreaseMaxEnergy { .. } => {
localized_strings.get("buff.title.staminaup")
},
_ => localized_strings.get("buff.title.missing"),
};
let remaining_time = if current_duration.is_none() {
"Permanent".to_string()
} else {
format!("Remaining: {:.0}s", current_duration.unwrap().as_secs_f32())
};
let title = hud::get_buff_title(buff.kind, localized_strings);
let desc_txt = hud::get_buff_desc(buff.kind, localized_strings);
let remaining_time = hud::get_buff_time(*buff);
let click_to_remove = format!("<{}>", &localized_strings.get("buff.remove"));
let desc_txt = match buff.kind {
BuffKind::Regeneration { .. } => localized_strings.get("buff.desc.heal"),
BuffKind::Saturation { .. } => {
localized_strings.get("buff.desc.saturation")
},
BuffKind::Potion { .. } => localized_strings.get("buff.desc.potion"),
BuffKind::CampfireHeal { .. } => {
localized_strings.get("buff.desc.campfire_heal")
},
BuffKind::IncreaseMaxHealth { .. } => {
localized_strings.get("buff.desc.IncreaseMaxHealth")
},
BuffKind::IncreaseMaxEnergy { .. } => {
localized_strings.get("buff.desc.IncreaseMaxEnergy")
},
_ => localized_strings.get("buff.desc.missing"),
};
let desc = format!("{}\n\n{}\n\n{}", desc_txt, remaining_time, click_to_remove);
// Timer overlay
if Button::image(match duration_percentage as u64 {
@ -300,7 +264,7 @@ impl<'a> Widget for BuffsBar<'a> {
.zip(
buffs
.iter_active()
.map(get_buff_info)
.map(hud::get_buff_info)
.filter(|info| !info.is_buff),
)
.collect::<Vec<_>>();
@ -343,19 +307,9 @@ impl<'a> Widget for BuffsBar<'a> {
)
.set(*id, ui);
// Create Debuff tooltip
let title = match debuff.kind {
BuffKind::Bleeding { .. } => localized_strings.get("debuff.title.bleed"),
_ => localized_strings.get("buff.title.missing"),
};
let remaining_time = if current_duration.is_none() {
"Permanent".to_string()
} else {
format!("Remaining: {:.0}s", current_duration.unwrap().as_secs_f32())
};
let desc_txt = match debuff.kind {
BuffKind::Bleeding { .. } => localized_strings.get("debuff.desc.bleed"),
_ => localized_strings.get("debuff.desc.missing"),
};
let title = hud::get_buff_title(debuff.kind, localized_strings);
let desc_txt = hud::get_buff_desc(debuff.kind, localized_strings);
let remaining_time = hud::get_buff_time(*debuff);
let desc = format!("{}\n\n{}", desc_txt, remaining_time);
Image::new(match duration_percentage as u64 {
875..=1000 => self.imgs.nothing, // 8/8
@ -412,7 +366,7 @@ impl<'a> Widget for BuffsBar<'a> {
.copied()
.zip(state.ids.buff_timers.iter().copied())
.zip(state.ids.buff_txts.iter().copied())
.zip(buffs.iter_active().map(get_buff_info))
.zip(buffs.iter_active().map(hud::get_buff_info))
.collect::<Vec<_>>();
// Sort the buffs by kind
@ -429,7 +383,7 @@ impl<'a> Widget for BuffsBar<'a> {
max_duration
.map_or(1000.0, |max| cur.as_secs_f32() / max.as_secs_f32() * 1000.0)
}) as u32;
let buff_img = get_buff_image(buff.kind, &self.imgs);
let buff_img = hud::get_buff_image(buff.kind, &self.imgs);
let buff_widget = Image::new(buff_img).w_h(40.0, 40.0);
// Sort buffs into rows of 6 slots
let x = i % 6;
@ -449,36 +403,10 @@ impl<'a> Widget for BuffsBar<'a> {
)
.set(*id, ui);
// Create Buff tooltip
let title = match buff.kind {
BuffKind::Regeneration { .. } => localized_strings.get("buff.title.heal"),
BuffKind::Saturation { .. } => {
localized_strings.get("buff.title.saturation")
},
BuffKind::Potion { .. } => localized_strings.get("buff.title.potion"),
BuffKind::Bleeding { .. } => localized_strings.get("debuff.title.bleed"),
BuffKind::CampfireHeal { .. } => {
localized_strings.get("buff.title.campfire_heal")
},
_ => localized_strings.get("buff.title.missing"),
};
let remaining_time = if current_duration.is_none() {
"".to_string()
} else {
format!("{:.0}s", current_duration.unwrap().as_secs_f32())
};
let title = hud::get_buff_title(buff.kind, localized_strings);
let desc_txt = hud::get_buff_desc(buff.kind, localized_strings);
let remaining_time = hud::get_buff_time(*buff);
let click_to_remove = format!("<{}>", &localized_strings.get("buff.remove"));
let desc_txt = match buff.kind {
BuffKind::Regeneration { .. } => localized_strings.get("buff.desc.heal"),
BuffKind::Saturation { .. } => {
localized_strings.get("buff.desc.saturation")
},
BuffKind::Potion { .. } => localized_strings.get("buff.desc.potion"),
BuffKind::Bleeding { .. } => localized_strings.get("debuff.desc.bleed"),
BuffKind::CampfireHeal { .. } => {
localized_strings.get("buff.desc.campfire_heal")
},
_ => localized_strings.get("buff.desc.missing"),
};
let desc = if buff.is_buff {
format!("{}\n\n{}", desc_txt, click_to_remove)
} else {

View File

@ -6,7 +6,7 @@ use super::{
};
use crate::{
hud::{get_buff_image, get_buff_info},
hud,
i18n::Localization,
settings::Settings,
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
@ -16,9 +16,7 @@ use crate::{
use client::{self, Client};
use common::{
combat,
comp::{
group::Role, inventory::item::MaterialStatManifest, invite::InviteKind, BuffKind, Stats,
},
comp::{group::Role, inventory::item::MaterialStatManifest, invite::InviteKind, Stats},
uid::{Uid, UidAllocator},
};
use common_net::sync::WorldSyncExt;
@ -493,7 +491,7 @@ impl<'a> Widget for Group<'a> {
.copied()
.zip(state.ids.buff_timers.iter().copied())
.skip(total_buff_count - buff_count)
.zip(buffs.iter_active().map(get_buff_info))
.zip(buffs.iter_active().map(hud::get_buff_info))
.for_each(|((id, timer_id), buff)| {
let max_duration = buff.data.duration;
let pulsating_col = Color::Rgba(1.0, 1.0, 1.0, buff_ani);
@ -504,7 +502,7 @@ impl<'a> Widget for Group<'a> {
cur.as_secs_f32() / max.as_secs_f32() * 1000.0
})
}) as u32; // Percentage to determine which frame of the timer overlay is displayed
let buff_img = get_buff_image(buff.kind, &self.imgs);
let buff_img = hud::get_buff_image(buff.kind, &self.imgs);
let buff_widget = Image::new(buff_img).w_h(15.0, 15.0);
let buff_widget = if let Some(id) = prev_id {
buff_widget.right_from(id, 1.0)
@ -528,38 +526,9 @@ impl<'a> Widget for Group<'a> {
)
.set(id, ui);
// Create Buff tooltip
let title = match buff.kind {
BuffKind::Regeneration { .. } => {
localized_strings.get("buff.title.heal")
},
BuffKind::Saturation { .. } => {
localized_strings.get("buff.title.saturation")
},
BuffKind::Bleeding { .. } => {
localized_strings.get("debuff.title.bleed")
},
_ => localized_strings.get("buff.title.missing"),
};
let remaining_time = if current_duration.is_none() {
"Permanent".to_string()
} else {
format!(
"Remaining: {:.0}s",
current_duration.unwrap().as_secs_f32()
)
};
let desc_txt = match buff.kind {
BuffKind::Regeneration { .. } => {
localized_strings.get("buff.desc.heal")
},
BuffKind::Saturation { .. } => {
localized_strings.get("buff.desc.saturation")
},
BuffKind::Bleeding { .. } => {
localized_strings.get("debuff.desc.bleed")
},
_ => localized_strings.get("buff.desc.missing"),
};
let title = hud::get_buff_title(buff.kind, localized_strings);
let desc_txt = hud::get_buff_desc(buff.kind, localized_strings);
let remaining_time = hud::get_buff_time(buff);
let desc = format!("{}\n\n{}", desc_txt, remaining_time);
Image::new(match duration_percentage as u64 {
875..=1000 => self.imgs.nothing, // 8/8

View File

@ -3173,14 +3173,57 @@ pub fn cr_color(combat_rating: f32) -> Color {
pub fn get_buff_image(buff: BuffKind, imgs: &Imgs) -> conrod_core::image::Id {
match buff {
// Buffs
BuffKind::Regeneration { .. } => imgs.buff_plus_0,
BuffKind::Saturation { .. } => imgs.buff_saturation_0,
BuffKind::Bleeding { .. } => imgs.debuff_bleed_0,
BuffKind::Cursed { .. } => imgs.debuff_skull_0,
BuffKind::Potion { .. } => imgs.buff_potion_0,
BuffKind::CampfireHeal { .. } => imgs.buff_campfire_heal_0,
BuffKind::IncreaseMaxEnergy { .. } => imgs.buff_energyplus_0,
BuffKind::IncreaseMaxHealth { .. } => imgs.buff_healthplus_0,
// TODO: Before merge replace with actual icon
BuffKind::Invulnerability => imgs.buff_plus_0,
// Debuffs
BuffKind::Bleeding { .. } => imgs.debuff_bleed_0,
BuffKind::Cursed { .. } => imgs.debuff_skull_0,
}
}
pub fn get_buff_title(buff: BuffKind, localized_strings: &Localization) -> &str {
match buff {
// Buffs
BuffKind::Regeneration { .. } => localized_strings.get("buff.title.heal"),
BuffKind::Saturation { .. } => localized_strings.get("buff.title.saturation"),
BuffKind::Potion { .. } => localized_strings.get("buff.title.potion"),
BuffKind::CampfireHeal { .. } => localized_strings.get("buff.title.campfire_heal"),
BuffKind::IncreaseMaxHealth { .. } => localized_strings.get("buff.title.IncreaseMaxHealth"),
BuffKind::IncreaseMaxEnergy { .. } => localized_strings.get("buff.title.staminaup"),
BuffKind::Invulnerability => localized_strings.get("buff.title.invulnerability"),
// Debuffs
BuffKind::Bleeding { .. } => localized_strings.get("buff.title.bleed"),
BuffKind::Cursed { .. } => localized_strings.get("buff.title.cursed"),
}
}
pub fn get_buff_desc(buff: BuffKind, localized_strings: &Localization) -> &str {
match buff {
// Buffs
BuffKind::Regeneration { .. } => localized_strings.get("buff.desc.heal"),
BuffKind::Saturation { .. } => localized_strings.get("buff.desc.saturation"),
BuffKind::Potion { .. } => localized_strings.get("buff.desc.potion"),
BuffKind::CampfireHeal { .. } => localized_strings.get("buff.desc.campfire_heal"),
BuffKind::IncreaseMaxHealth { .. } => localized_strings.get("buff.desc.IncreaseMaxHealth"),
BuffKind::IncreaseMaxEnergy { .. } => localized_strings.get("buff.desc.IncreaseMaxEnergy"),
BuffKind::Invulnerability => localized_strings.get("buff.desc.invulnerability"),
// Debuffs
BuffKind::Bleeding { .. } => localized_strings.get("buff.desc.bleed"),
BuffKind::Cursed { .. } => localized_strings.get("buff.desc.cursed"),
}
}
pub fn get_buff_time(buff: BuffInfo) -> String {
if let Some(dur) = buff.dur {
format!("Remaining: {:.0}s", dur.as_secs_f32())
} else {
"Permanent".to_string()
}
}