From 4fcb6cd025fa660921edce21e3d3a5fe68f7824f Mon Sep 17 00:00:00 2001 From: JMS <3364564-JMS55@users.noreply.gitlab.com> Date: Tue, 28 May 2019 14:23:24 -0400 Subject: [PATCH] Add player coordinates to debug window Former-commit-id: 00285712652ed97c7f18a5f4834f1eaef269afc7 --- voxygen/src/hud/mod.rs | 8 ++++++++ voxygen/src/session.rs | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 4efbdaf41a..fded2beb82 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -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, } 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. diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 1b51b9d4f0..12c79c80c9 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -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::() + .get(self.client.borrow().entity()) + .unwrap() + .0, }, &self.scene.camera(), );