fix overly long names clipping on the minimap

This commit is contained in:
Monty Marz 2020-11-19 22:27:19 +01:00 committed by Joshua Barretto
parent 7850b0bcaf
commit 82da969707

View File

@ -331,13 +331,26 @@ impl<'a> Widget for MiniMap<'a> {
// TODO: Subregion name display
// Title
match self.client.current_chunk() {
Some(chunk) => Text::new(chunk.meta().name())
.mid_top_with_margin_on(state.ids.mmap_frame, 2.0)
.font_size(self.fonts.cyri.scale(18))
match self.client.current_chunk() {
Some(chunk) =>
{
// Count characters in the name to avoid clipping with the name display
let name_len = chunk.meta().name().chars().count();
Text::new(chunk.meta().name())
.mid_top_with_margin_on(state.ids.mmap_frame, match name_len {
16..=30 => 4.0,
_ => 2.0,
})
.font_size(self.fonts.cyri.scale(
match name_len {
0..=16 => 18,
16..=30 => 14,
_ => 14,
}))
.font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR)
.set(state.ids.mmap_location, ui),
.set(state.ids.mmap_location, ui)},
None => Text::new(" ")
.mid_top_with_margin_on(state.ids.mmap_frame, 0.0)
.font_size(self.fonts.cyri.scale(18))