mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Extract 'create_new_text' function from 'update'
This commit is contained in:
parent
875b26a93a
commit
cead9a019b
@ -309,11 +309,13 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
Text::new(&self.localized_strings.get("hud.diary"))
|
self.create_new_text(
|
||||||
.mid_top_with_margin_on(state.frame, 3.0)
|
&self.localized_strings.get("hud.diary"),
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
state.frame,
|
||||||
.font_size(self.fonts.cyri.scale(29))
|
3.0,
|
||||||
.color(TEXT_COLOR)
|
29,
|
||||||
|
TEXT_COLOR,
|
||||||
|
)
|
||||||
.set(state.title, ui);
|
.set(state.title, ui);
|
||||||
|
|
||||||
// Content Alignment
|
// Content Alignment
|
||||||
@ -457,34 +459,26 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
.mouse()
|
.mouse()
|
||||||
.map_or(false, |m| m.is_over())
|
.map_or(false, |m| m.is_over())
|
||||||
{
|
{
|
||||||
Text::new(&exp_txt)
|
self.create_new_text(&exp_txt, state.exp_bar_frame, 47.0, 14, TEXT_COLOR)
|
||||||
.mid_top_with_margin_on(state.exp_bar_frame, 47.0)
|
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
|
||||||
.font_size(self.fonts.cyri.scale(14))
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.graphics_for(state.exp_bar_frame)
|
.graphics_for(state.exp_bar_frame)
|
||||||
.set(state.exp_bar_txt, ui);
|
.set(state.exp_bar_txt, ui);
|
||||||
}
|
}
|
||||||
Text::new(&rank_txt)
|
self.create_new_text(&rank_txt, state.exp_bar_frame, 5.0, 28, TEXT_COLOR)
|
||||||
.mid_top_with_margin_on(state.exp_bar_frame, 5.0)
|
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
|
||||||
.font_size(self.fonts.cyri.scale(28))
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(state.exp_bar_rank, ui);
|
.set(state.exp_bar_rank, ui);
|
||||||
Text::new(
|
self.create_new_text(
|
||||||
&self
|
&self
|
||||||
.localized_strings
|
.localized_strings
|
||||||
.get("hud.skill.sp_available")
|
.get("hud.skill.sp_available")
|
||||||
.replace("{number}", &available_pts_txt),
|
.replace("{number}", &available_pts_txt),
|
||||||
)
|
state.content_align,
|
||||||
.mid_top_with_margin_on(state.content_align, 700.0)
|
700.0,
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
28,
|
||||||
.font_size(self.fonts.cyri.scale(28))
|
if available_pts > 0 {
|
||||||
.color(if available_pts > 0 {
|
|
||||||
Color::Rgba(0.92, 0.76, 0.0, frame_ani)
|
Color::Rgba(0.92, 0.76, 0.0, frame_ani)
|
||||||
} else {
|
} else {
|
||||||
TEXT_COLOR
|
TEXT_COLOR
|
||||||
})
|
},
|
||||||
|
)
|
||||||
.set(state.available_pts_txt, ui);
|
.set(state.available_pts_txt, ui);
|
||||||
let tree_title = match sel_tab {
|
let tree_title = match sel_tab {
|
||||||
SelectedSkillTree::General => self.localized_strings.get("common.weapons.general"),
|
SelectedSkillTree::General => self.localized_strings.get("common.weapons.general"),
|
||||||
@ -508,11 +502,7 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
},
|
},
|
||||||
_ => "Unknown",
|
_ => "Unknown",
|
||||||
};
|
};
|
||||||
Text::new(&tree_title)
|
self.create_new_text(&tree_title, state.content_align, 2.0, 34, TEXT_COLOR)
|
||||||
.mid_top_with_margin_on(state.content_align, 2.0)
|
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
|
||||||
.font_size(self.fonts.cyri.scale(34))
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(state.tree_title_txt, ui);
|
.set(state.tree_title_txt, ui);
|
||||||
// Skill Trees
|
// Skill Trees
|
||||||
// Alignment Placing
|
// Alignment Placing
|
||||||
@ -2066,6 +2056,21 @@ fn add_sp_cost_tooltip<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Diary<'a> {
|
impl<'a> Diary<'a> {
|
||||||
|
fn create_new_text<'b>(
|
||||||
|
&mut self,
|
||||||
|
text: &'b str,
|
||||||
|
state: widget::Id,
|
||||||
|
margin: f64,
|
||||||
|
scale: u32,
|
||||||
|
color: Color,
|
||||||
|
) -> Text<'b> {
|
||||||
|
Text::new(text)
|
||||||
|
.mid_top_with_margin_on(state, margin)
|
||||||
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
|
.font_size(self.fonts.cyri.scale(scale))
|
||||||
|
.color(color)
|
||||||
|
}
|
||||||
|
|
||||||
fn create_unlock_skill_button(
|
fn create_unlock_skill_button(
|
||||||
&mut self,
|
&mut self,
|
||||||
skill: Skill,
|
skill: Skill,
|
||||||
|
Loading…
Reference in New Issue
Block a user