56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
use bevy::{
|
|
prelude::{Plugin, Res, ResMut},
|
|
window::Windows,
|
|
};
|
|
use bevy_egui::EguiPlugin;
|
|
use bevy_framepace::FramepacePlugin;
|
|
|
|
use self::{client_settings::Settings, diagnosis::diag_ui, stats::stats_ui, wiki::wiki_ui};
|
|
use crate::client_settings;
|
|
pub mod client_settings;
|
|
pub mod diagnosis;
|
|
pub mod stats;
|
|
pub mod wiki;
|
|
|
|
pub struct UIInfo {
|
|
pub mouse_grabbed: bool,
|
|
}
|
|
impl Default for UIInfo {
|
|
fn default() -> Self {
|
|
Self {
|
|
mouse_grabbed: true,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct UIPlugin;
|
|
|
|
impl Plugin for UIPlugin {
|
|
fn build(&self, app: &mut bevy::prelude::App) {
|
|
app.insert_resource(Settings::default())
|
|
.insert_resource(UIInfo::default())
|
|
.add_plugin(EguiPlugin)
|
|
.add_system(client_settings)
|
|
.add_system(settings_handler)
|
|
.add_system(wiki_ui)
|
|
.add_system(stats_ui)
|
|
.add_system(diag_ui);
|
|
}
|
|
}
|
|
|
|
fn settings_handler(
|
|
mut plugin: ResMut<FramepacePlugin>,
|
|
mut windows: ResMut<Windows>,
|
|
|
|
settings: Res<Settings>,
|
|
) {
|
|
let window = windows.primary_mut();
|
|
|
|
plugin.framerate_limit = bevy_framepace::FramerateLimit::Manual(settings.target_fps);
|
|
use bevy::window::WindowMode::{BorderlessFullscreen, Windowed};
|
|
match settings.fullscreen {
|
|
true => window.set_mode(BorderlessFullscreen),
|
|
false => window.set_mode(Windowed),
|
|
}
|
|
}
|