mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'fix-invalid-player-position-for-debug-info' into 'master'
Fix debug coordinates window crashing when player has no Pos component yet Closes #136 See merge request veloren/veloren!196 Former-commit-id: d57c2307307290a15f290bc1f8affe6415ea6d36
This commit is contained in:
commit
cb6b60fefe
@ -32,6 +32,7 @@ use crate::{
|
||||
};
|
||||
use client::Client;
|
||||
use common::comp;
|
||||
use common::comp::phys::Pos;
|
||||
use conrod_core::{
|
||||
color, graph,
|
||||
widget::{self, Button, Image, Rectangle, Text},
|
||||
@ -104,7 +105,7 @@ font_ids! {
|
||||
pub struct DebugInfo {
|
||||
pub tps: f64,
|
||||
pub ping_ms: f64,
|
||||
pub coordinates: Vec3<f32>,
|
||||
pub coordinates: Option<Pos>,
|
||||
}
|
||||
|
||||
pub enum Event {
|
||||
@ -393,7 +394,11 @@ impl Hud {
|
||||
.font_id(self.fonts.opensans)
|
||||
.font_size(14)
|
||||
.set(self.ids.ping, ui_widgets);
|
||||
Text::new(&format!("Coordinates: {:.1}", debug_info.coordinates))
|
||||
let coordinates_text = match debug_info.coordinates {
|
||||
Some(coordinates) => format!("Coordinates: {:.1}", coordinates.0),
|
||||
None => "Player has no Pos component".to_owned(),
|
||||
};
|
||||
Text::new(&coordinates_text)
|
||||
.color(TEXT_COLOR)
|
||||
.down_from(self.ids.ping, 5.0)
|
||||
.font_id(self.fonts.opensans)
|
||||
|
@ -170,8 +170,7 @@ impl PlayState for SessionState {
|
||||
.ecs()
|
||||
.read_storage::<Pos>()
|
||||
.get(self.client.borrow().entity())
|
||||
.unwrap()
|
||||
.0,
|
||||
.cloned(),
|
||||
},
|
||||
&self.scene.camera(),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user