Add: just commands for release build

This commit is contained in:
DaZuo0122
2026-02-13 11:22:46 +08:00
parent 3c3ca342c9
commit 55fe53235d
21 changed files with 253 additions and 97 deletions

View File

@@ -26,6 +26,7 @@ use tracing::{error, info, warn};
const APP_NAME: &str = "sprimo";
const DEFAULT_PACK: &str = "default";
const WINDOW_PADDING: f32 = 16.0;
const STARTUP_WINDOW_SIZE: f32 = 416.0;
const MAGENTA_KEY: [u8; 3] = [255, 0, 255];
const CHROMA_KEY_TOLERANCE: u8 = 24;
const CHROMA_KEY_FORCE_RATIO: f32 = 0.15;
@@ -180,7 +181,13 @@ fn main() -> Result<(), AppError> {
.compact()
.init();
let (config_path, config) = sprimo_config::load_or_create(APP_NAME)?;
let (config_path, mut config) = sprimo_config::load_or_create(APP_NAME)?;
if config.window.click_through {
config.window.click_through = false;
if let Err(err) = save(&config_path, &config) {
warn!(%err, "failed to persist click-through disable at startup");
}
}
let platform: Arc<dyn PlatformAdapter> = create_adapter().into();
let capabilities = platform.capabilities();
@@ -188,7 +195,7 @@ fn main() -> Result<(), AppError> {
snapshot.x = config.window.x;
snapshot.y = config.window.y;
snapshot.scale = config.window.scale;
snapshot.flags.click_through = config.window.click_through;
snapshot.flags.click_through = false;
snapshot.flags.always_on_top = config.window.always_on_top;
snapshot.flags.visible = config.window.visible;
snapshot.active_sprite_pack = config.sprite.selected_pack.clone();
@@ -223,7 +230,10 @@ fn main() -> Result<(), AppError> {
decorations: false,
resizable: false,
window_level: WindowLevel::AlwaysOnTop,
resolution: bevy::window::WindowResolution::new(544.0, 544.0),
resolution: bevy::window::WindowResolution::new(
STARTUP_WINDOW_SIZE,
STARTUP_WINDOW_SIZE,
),
position: WindowPosition::At(IVec2::new(
config.window.x.round() as i32,
config.window.y.round() as i32,
@@ -721,7 +731,6 @@ fn attach_window_handle_once(
.read()
.expect("frontend snapshot lock poisoned");
let _ = platform.0.set_always_on_top(guard.flags.always_on_top);
let _ = platform.0.set_click_through(guard.flags.click_through);
let _ = platform.0.set_visible(guard.flags.visible);
let _ = platform.0.set_window_position(guard.x, guard.y);
*attached = true;
@@ -746,14 +755,14 @@ fn poll_hotkey_recovery(
) {
while ingress.0.try_recv().is_ok() {
info!("recovery hotkey received");
let _ = platform.0.set_click_through(false);
let _ = platform.0.set_always_on_top(true);
let _ = platform.0.set_visible(true);
if let Ok(mut visibility) = pet_query.get_single_mut() {
*visibility = Visibility::Visible;
}
config.config.window.click_through = false;
config.config.window.always_on_top = true;
config.config.window.visible = true;
if let Err(err) = save(&config.path, &config.config) {
warn!(%err, "failed to persist config after hotkey recovery");
@@ -761,6 +770,7 @@ fn poll_hotkey_recovery(
if let Ok(mut guard) = snapshot.0.write() {
guard.flags.click_through = false;
guard.flags.always_on_top = true;
guard.flags.visible = true;
guard.last_error = None;
}
@@ -927,9 +937,8 @@ fn poll_backend_commands(
always_on_top,
visible,
} => {
if let Some(value) = click_through {
let _ = platform.0.set_click_through(value);
config.config.window.click_through = value;
if click_through.is_some() {
config.config.window.click_through = false;
}
if let Some(value) = always_on_top {
let _ = platform.0.set_always_on_top(value);
@@ -949,9 +958,7 @@ fn poll_backend_commands(
warn!(%err, "failed to persist flag config");
}
if let Ok(mut guard) = snapshot.0.write() {
if let Some(value) = click_through {
guard.flags.click_through = value;
}
guard.flags.click_through = false;
if let Some(value) = always_on_top {
guard.flags.always_on_top = value;
}