mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
in terrain.mod.rs, return name as Option in fn name
This commit is contained in:
parent
ceb3507e50
commit
51356d5fad
@ -131,7 +131,7 @@ impl TerrainChunkMeta {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str { self.name.as_deref().unwrap_or("") }
|
||||
pub fn name(&self) -> Option<&str> { self.name.as_deref() }
|
||||
|
||||
pub fn biome(&self) -> BiomeKind { self.biome }
|
||||
|
||||
|
@ -886,20 +886,22 @@ impl<'a> Widget for MiniMap<'a> {
|
||||
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 {
|
||||
15..=30 => 4.0,
|
||||
_ => 2.0,
|
||||
})
|
||||
.font_size(self.fonts.cyri.scale(match name_len {
|
||||
0..=15 => 18,
|
||||
16..=30 => 14,
|
||||
_ => 14,
|
||||
}))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.mmap_location, ui)
|
||||
if let Some(name) = chunk.meta().name() {
|
||||
let name_len = name.chars().count();
|
||||
Text::new(name)
|
||||
.mid_top_with_margin_on(state.ids.mmap_frame, match name_len {
|
||||
15..=30 => 4.0,
|
||||
_ => 2.0,
|
||||
})
|
||||
.font_size(self.fonts.cyri.scale(match name_len {
|
||||
0..=15 => 18,
|
||||
16..=30 => 14,
|
||||
_ => 14,
|
||||
}))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.mmap_location, ui)
|
||||
}
|
||||
},
|
||||
None => Text::new(" ")
|
||||
.mid_top_with_margin_on(state.ids.mmap_frame, 0.0)
|
||||
|
@ -98,23 +98,24 @@ impl<'a> Widget for Popup<'a> {
|
||||
|
||||
// Push chunk name to message queue
|
||||
if let Some(chunk) = self.client.current_chunk() {
|
||||
let current = chunk.meta().name();
|
||||
// Check if no other popup is displayed and a new one is needed
|
||||
if state.messages.is_empty()
|
||||
&& state
|
||||
.last_region_name
|
||||
.as_ref()
|
||||
.map(|l| l != current)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
// Update last_region
|
||||
state.update(|s| {
|
||||
if s.messages.is_empty() {
|
||||
s.last_message_update = Instant::now();
|
||||
}
|
||||
s.last_region_name = Some(current.to_owned());
|
||||
s.messages.push_back(current.to_owned());
|
||||
});
|
||||
if let Some(current) = chunk.meta().name() {
|
||||
// Check if no other popup is displayed and a new one is needed
|
||||
if state.messages.is_empty()
|
||||
&& state
|
||||
.last_region_name
|
||||
.as_ref()
|
||||
.map(|l| l != current)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
// Update last_region
|
||||
state.update(|s| {
|
||||
if s.messages.is_empty() {
|
||||
s.last_message_update = Instant::now();
|
||||
}
|
||||
s.last_region_name = Some(current.to_owned());
|
||||
s.messages.push_back(current.to_owned());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user