use crate::app_config::AppConfig;
pub(super) fn with_dev_overrides(config: AppConfig) -> AppConfig {
#[cfg(not(feature = "hot-reload"))]
return config;
#[cfg(feature = "hot-reload")]
{
let AppConfig {
mut window,
font_paths,
font_data,
font_family,
} = config;
apply_dev_window_overrides(&mut window);
AppConfig {
window,
font_paths,
font_data,
font_family,
}
}
}
#[cfg(feature = "hot-reload")]
pub(super) fn apply_dev_window_overrides(config: &mut platform_core::WindowConfig) {
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_TITLE") {
config.title = v;
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_WIDTH") {
if let Ok(n) = v.parse() {
config.width = n;
}
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_HEIGHT") {
if let Ok(n) = v.parse() {
config.height = n;
}
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_DECORATIONS") {
config.has_decorations = v == "1";
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_RESIZABLE") {
config.is_resizable = v == "1";
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_TRANSPARENT") {
config.is_transparent = v == "1";
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_FULLSCREEN") {
config.fullscreen = match v.as_str() {
"borderless" => platform_core::FullscreenMode::Borderless,
"exclusive" => platform_core::FullscreenMode::Exclusive,
_ => platform_core::FullscreenMode::Disabled,
};
}
if let Ok(v) = std::env::var("TELAR_DEV_WINDOW_POSITION") {
config.position = parse_dev_window_position(&v);
}
}
#[cfg(feature = "hot-reload")]
fn parse_dev_window_position(value: &str) -> platform_core::WindowPosition {
let value = value.trim();
if let Some((x, y)) = value.split_once(',')
&& let (Ok(x), Ok(y)) = (x.trim().parse::<i32>(), y.trim().parse::<i32>())
{
return platform_core::WindowPosition::At(x, y);
}
platform_core::WindowPosition::Centered
}
#[cfg(test)]
#[path = "dev_window_test.rs"]
mod tests;