Skip to content

Commit d6a618e

Browse files
committed
feat(gui): ✨ add auto-save settings drawer
1 parent 703e083 commit d6a618e

11 files changed

Lines changed: 687 additions & 150 deletions

File tree

apps/rgsm-gui/src-tauri/src/ipc_handler.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,45 @@ pub async fn set_game_automation(
758758
Ok(())
759759
}
760760

761+
#[tauri::command]
762+
#[specta::specta]
763+
pub async fn set_game_auto_save_settings(
764+
app_handle: AppHandle,
765+
storage_key: String,
766+
auto_backup: Option<backup::AutoBackupConfig>,
767+
automation: Option<GameAutomationSettingsDraft>,
768+
) -> Result<(), String> {
769+
info!(
770+
target:"rgsm::ipc",
771+
"Setting auto-save settings for '{}': auto_backup={:?}, automation={:?}",
772+
storage_key,
773+
auto_backup,
774+
automation
775+
);
776+
if let Some(automation) = &automation {
777+
quick_actions::validate_game_automation_target(&storage_key, automation).map_err(|e| {
778+
error!(target:"rgsm::ipc", "Invalid game automation target: {:?}", e);
779+
e.to_string()
780+
})?;
781+
}
782+
783+
svc(&app_handle)
784+
.set_game_auto_save_settings(
785+
&storage_key,
786+
auto_backup,
787+
automation,
788+
HookSource::UserManual,
789+
)
790+
.await
791+
.map_err(|e| {
792+
error!(target:"rgsm::ipc", "Failed to save auto-save settings: {:?}", e);
793+
e.to_string()
794+
})?;
795+
796+
info!(target:"rgsm::ipc", "Successfully set auto-save settings for '{}'", storage_key);
797+
Ok(())
798+
}
799+
761800
#[tauri::command]
762801
#[specta::specta]
763802
pub async fn set_snapshot_created_by(

apps/rgsm-gui/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub fn run() -> anyhow::Result<()> {
124124
ipc_handler::set_quick_backup_game,
125125
ipc_handler::set_game_auto_backup,
126126
ipc_handler::set_game_automation,
127+
ipc_handler::set_game_auto_save_settings,
127128
ipc_handler::set_snapshot_created_by,
128129
ipc_handler::get_auto_backup_status,
129130
ipc_handler::list_running_processes,

apps/rgsm-gui/src/bindings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ async setGameAutomation(storageKey: string, automation: GameAutomationSettingsDr
268268
else return { status: "error", error: e as any };
269269
}
270270
},
271+
async setGameAutoSaveSettings(storageKey: string, autoBackup: AutoBackupConfig | null, automation: GameAutomationSettingsDraft | null) : Promise<Result<null, string>> {
272+
try {
273+
return { status: "ok", data: await TAURI_INVOKE("set_game_auto_save_settings", { storageKey, autoBackup, automation }) };
274+
} catch (e) {
275+
if(e instanceof Error) throw e;
276+
else return { status: "error", error: e as any };
277+
}
278+
},
271279
async setSnapshotCreatedBy(gameName: string, snapshotDate: string, createdBy: CreatedBy) : Promise<Result<GameSnapshots, string>> {
272280
try {
273281
return { status: "ok", data: await TAURI_INVOKE("set_snapshot_created_by", { gameName, snapshotDate, createdBy }) };

0 commit comments

Comments
 (0)