Add: global factor controlling fps base interval
This commit is contained in:
@@ -31,6 +31,7 @@ const MENU_ID_TOGGLE_DEBUG_OVERLAY: &str = "toggle_debug_overlay";
|
||||
const MENU_ID_QUIT: &str = "quit";
|
||||
const EVENT_RUNTIME_SNAPSHOT: &str = "runtime:snapshot";
|
||||
const EVENT_RUNTIME_DEBUG_OVERLAY_VISIBLE: &str = "runtime:debug-overlay-visible";
|
||||
const EVENT_RUNTIME_ANIMATION_SLOWDOWN_FACTOR: &str = "runtime:animation-slowdown-factor";
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
struct UiAnimationClip {
|
||||
@@ -80,6 +81,7 @@ struct UiSettingsSnapshot {
|
||||
scale: f32,
|
||||
visible: bool,
|
||||
always_on_top: bool,
|
||||
tauri_animation_slowdown_factor: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
@@ -183,9 +185,37 @@ fn settings_snapshot(state: tauri::State<'_, AppState>) -> Result<UiSettingsSnap
|
||||
scale: snapshot.scale,
|
||||
visible: snapshot.flags.visible,
|
||||
always_on_top: snapshot.flags.always_on_top,
|
||||
tauri_animation_slowdown_factor: state
|
||||
.runtime_core
|
||||
.frontend_tauri_animation_slowdown_factor()
|
||||
.map_err(|err| err.to_string())?,
|
||||
})
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn tauri_animation_slowdown_factor(state: tauri::State<'_, AppState>) -> Result<u8, String> {
|
||||
state
|
||||
.runtime_core
|
||||
.frontend_tauri_animation_slowdown_factor()
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn set_tauri_animation_slowdown_factor(
|
||||
app_handle: tauri::AppHandle,
|
||||
state: tauri::State<'_, AppState>,
|
||||
factor: u8,
|
||||
) -> Result<u8, String> {
|
||||
let persisted = state
|
||||
.runtime_core
|
||||
.set_frontend_tauri_animation_slowdown_factor(factor)
|
||||
.map_err(|err| err.to_string())?;
|
||||
app_handle
|
||||
.emit(EVENT_RUNTIME_ANIMATION_SLOWDOWN_FACTOR, persisted)
|
||||
.map_err(|err| err.to_string())?;
|
||||
Ok(persisted)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn list_sprite_packs(state: tauri::State<'_, AppState>) -> Result<Vec<UiSpritePackOption>, String> {
|
||||
let root = sprite_pack_root(state.runtime_core.as_ref())?;
|
||||
@@ -349,6 +379,8 @@ fn main() -> Result<(), AppError> {
|
||||
debug_overlay_visible,
|
||||
set_debug_overlay_visible,
|
||||
settings_snapshot,
|
||||
tauri_animation_slowdown_factor,
|
||||
set_tauri_animation_slowdown_factor,
|
||||
list_sprite_packs,
|
||||
set_sprite_pack,
|
||||
set_scale,
|
||||
|
||||
Reference in New Issue
Block a user