Merge branch 'debug-coordinates' into 'master'

Add player coordinates to debug window

Closes #129

See merge request veloren/veloren!193

Former-commit-id: 51cfaee7dcff37ccf83f2386441e0e1364134ad7
This commit is contained in:
Forest Anderson 2019-05-28 18:32:38 +00:00
commit f5d42cba21
2 changed files with 18 additions and 1 deletions

View File

@ -60,6 +60,7 @@ widget_ids! {
debug_bg,
fps_counter,
ping,
coordinates,
// Game Version
version,
@ -103,6 +104,7 @@ font_ids! {
pub struct DebugInfo {
pub tps: f64,
pub ping_ms: f64,
pub coordinates: Vec3<f32>,
}
pub enum Event {
@ -391,6 +393,12 @@ impl Hud {
.font_id(self.fonts.opensans)
.font_size(14)
.set(self.ids.ping, ui_widgets);
Text::new(&format!("Coordinates: {:.1}", debug_info.coordinates))
.color(TEXT_COLOR)
.down_from(self.ids.ping, 5.0)
.font_id(self.fonts.opensans)
.font_size(14)
.set(self.ids.coordinates, ui_widgets);
}
// Add Bag-Space Button.

View File

@ -8,7 +8,7 @@ use crate::{
Direction, Error, GlobalState, PlayState, PlayStateResult,
};
use client::{self, Client};
use common::{clock::Clock, comp, msg::ClientState};
use common::{clock::Clock, comp, comp::phys::Pos, msg::ClientState};
use glutin::MouseButton;
use std::{cell::RefCell, mem, rc::Rc, time::Duration};
use vek::*;
@ -163,6 +163,15 @@ impl PlayState for SessionState {
DebugInfo {
tps: clock.get_tps(),
ping_ms: self.client.borrow().get_ping_ms(),
coordinates: self
.client
.borrow()
.state()
.ecs()
.read_storage::<Pos>()
.get(self.client.borrow().entity())
.unwrap()
.0,
},
&self.scene.camera(),
);