outfly/src/common.rs

66 lines
2.3 KiB
Rust
Raw Normal View History

2024-05-12 22:44:03 +00:00
// ▄████████▄ + ███ + ▄█████████ ███ +
// ███▀ ▀███ + + ███ ███▀ + ███ + +
// ███ + ███ ███ ███ █████████ ███ ███ ███ ███
// ███ +███ ███ ███ ███ ███▐██████ ███ ███ ███
// ███ + ███ ███+ ███ +███ ███ + ███ ███ + ███
// ███▄ ▄███ ███▄ ███ ███ + ███ + ███ ███▄ ███
// ▀████████▀ + ▀███████ ███▄ ███▄ ▀████ ▀███████
// + + + ███
// + ▀████████████████████████████████████████████████████▀
//
2024-05-12 22:48:41 +00:00
// Various common functions and constants
2024-05-12 22:44:03 +00:00
use bevy::prelude::*;
2024-05-13 02:47:47 +00:00
use crate::prelude::*;
2024-05-12 22:44:03 +00:00
pub use bevy::math::{DVec3, DQuat};
2024-05-12 23:00:09 +00:00
pub use std::f32::consts::PI as PI32;
pub use std::f64::consts::PI;
pub const WINDOW_TITLE: &str = "OutFly";
2024-05-12 23:42:14 +00:00
pub const CONF_FILE: &str = "outfly.toml";
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
2024-05-12 22:48:41 +00:00
pub const EPSILON32: f32 = 1e-9;
pub const EPSILON: f64 = 1e-9;
2024-05-12 22:44:03 +00:00
#[inline]
2024-05-12 23:00:09 +00:00
pub fn bool2vis(boolean: bool) -> Visibility {
2024-05-12 22:44:03 +00:00
if boolean {
2024-05-12 23:00:09 +00:00
Visibility::Inherited
2024-05-12 22:44:03 +00:00
} else {
2024-05-12 23:00:09 +00:00
Visibility::Hidden
2024-05-12 22:44:03 +00:00
}
}
#[inline]
pub fn style_fullscreen() -> Style {
Style {
width: Val::Vw(100.0),
height: Val::Vh(100.0),
position_type: PositionType::Absolute,
top: Val::Px(0.0),
left: Val::Px(0.0),
..default()
}
}
#[inline]
pub fn style_centered() -> Style {
Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::SpaceAround,
..default()
}
}
2024-05-13 02:47:47 +00:00
pub fn alive(settings: Res<Settings>) -> bool {
return settings.alive;
}
2024-05-13 18:21:56 +00:00
pub fn in_control(settings: Res<Settings>) -> bool {
return settings.in_control();
}