-
Notifications
You must be signed in to change notification settings - Fork 1
/
bottom_panel.rs
54 lines (46 loc) · 1.58 KB
/
bottom_panel.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use bevy::{
diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin},
prelude::*,
};
use bevy_egui::*;
use crate::top_panel::ToolbarSettings;
pub(crate) struct BottomPanel;
impl Plugin for BottomPanel {
fn build(&self, app: &mut App) {
app.add_system(bottom_panel);
}
}
pub(self) fn bottom_panel(
egui: Res<EguiContext>,
diag: Res<Diagnostics>,
mut windows: ResMut<Windows>,
mut settings: ResMut<ToolbarSettings>,
) {
let prime = windows.get_primary_mut().unwrap();
egui::TopBottomPanel::bottom("Window state").show(egui.ctx(), |ui| {
ui.horizontal(|ui| {
if settings.setting_toggles.title {
ui.label("Title:");
ui.spacing_mut().text_edit_width = 160.;
ui.text_edit_singleline(&mut settings.title);
if prime.title().ne(&settings.title) {
prime.set_title(settings.title.clone());
}
}
if settings.setting_toggles.fps {
if let Some(fps) = diag.get(FrameTimeDiagnosticsPlugin::FPS) {
if let Some(average) = fps.average() {
ui.label(format!("FPS: {:.2}", average));
}
}
}
if settings.setting_toggles.ft {
if let Some(fps) = diag.get(FrameTimeDiagnosticsPlugin::FRAME_TIME) {
if let Some(average) = fps.average() {
ui.label(format!("Frame Time: {:.2}ms", average * 1000.));
}
}
}
});
});
}