Address issue #808: Add Frame Time in DebugInfo

This commit is contained in:
NathanW 2020-10-21 23:38:45 -06:00
parent ff57d2a79d
commit 7e92e21f8b
2 changed files with 13 additions and 8 deletions

View File

@ -22,7 +22,6 @@ mod util;
pub use hotbar::{SlotContents as HotbarSlotContents, State as HotbarState};
pub use settings_window::ScaleChange;
use std::time::Duration;
use bag::Bag;
use buttons::Buttons;
@ -74,7 +73,7 @@ use specs::{Join, WorldExt};
use std::{
collections::{HashMap, VecDeque},
sync::Arc,
time::Instant,
time::{Duration, Instant},
};
use vek::*;
@ -267,6 +266,7 @@ widget_ids! {
pub struct DebugInfo {
pub tps: f64,
pub frame_time: Duration,
pub ping_ms: f64,
pub coordinates: Option<comp::Pos>,
pub velocity: Option<comp::Vel>,
@ -1482,12 +1482,16 @@ impl Hud {
.color(TEXT_COLOR)
.set(self.ids.version, ui_widgets);
// Ticks per second
Text::new(&format!("FPS: {:.0}", debug_info.tps))
.color(TEXT_COLOR)
.down_from(self.ids.version, 5.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.set(self.ids.fps_counter, ui_widgets);
Text::new(&format!(
"FPS: {:.0} ({}ms)",
debug_info.tps,
debug_info.frame_time.as_millis()
))
.color(TEXT_COLOR)
.down_from(self.ids.version, 5.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.set(self.ids.fps_counter, ui_widgets);
// Ping
Text::new(&format!("Ping: {:.0}ms", debug_info.ping_ms))
.color(TEXT_COLOR)

View File

@ -712,6 +712,7 @@ impl PlayState for SessionState {
.toggle_debug
.then(|| DebugInfo {
tps: global_state.clock.get_tps(),
frame_time: global_state.clock.get_avg_delta(),
ping_ms: self.client.borrow().get_ping_ms_rolling_avg(),
coordinates: self
.client