diff --git a/apps/app/build.rs b/apps/app/build.rs index a418b53..c37692b 100644 --- a/apps/app/build.rs +++ b/apps/app/build.rs @@ -538,6 +538,33 @@ fn main() { "instance_export_screenshots", "instance_move_screenshots", "instance_open_screenshot", + "instance_get_synced_options", + "instance_get_initialized_synced_options", + "instance_get_synced_options_overview", + "instance_get_synced_option_capabilities", + "instance_get_synced_option_join_preview", + "instance_set_synced_option", + "instance_set_instance_synced_option", + "instance_get_synced_command_history", + "instance_set_synced_command_history", + "instance_list_synced_servers", + "instance_update_synced_server", + "instance_remove_synced_server", + "instance_get_synced_game_options_config", + "instance_preview_synced_game_option_changes", + "instance_save_synced_game_option_changes", + "instance_list_game_options_sync_sources", + "instance_get_game_setting_locale_labels", + "instance_get_local_game_options_config", + "instance_preview_local_game_option_changes", + "instance_save_local_game_option_changes", + "instance_get_pack_sync_preview", + "instance_sync_pack", + "instance_desync_pack", + "instance_list_synced_packs", + "instance_upload_synced_pack", + "instance_set_synced_pack_enabled", + "instance_remove_synced_pack", ]) .default_permission( DefaultPermissionRule::AllowAllCommands, diff --git a/apps/app/src/api/instance/mod.rs b/apps/app/src/api/instance/mod.rs index 28b31a6..ed36656 100644 --- a/apps/app/src/api/instance/mod.rs +++ b/apps/app/src/api/instance/mod.rs @@ -135,6 +135,33 @@ pub fn init() -> tauri::plugin::TauriPlugin { instance_export_screenshots, instance_move_screenshots, instance_open_screenshot, + instance_get_synced_options, + instance_get_initialized_synced_options, + instance_get_synced_options_overview, + instance_get_synced_option_capabilities, + instance_get_synced_option_join_preview, + instance_set_synced_option, + instance_set_instance_synced_option, + instance_get_synced_command_history, + instance_set_synced_command_history, + instance_list_synced_servers, + instance_update_synced_server, + instance_remove_synced_server, + instance_get_synced_game_options_config, + instance_preview_synced_game_option_changes, + instance_save_synced_game_option_changes, + instance_list_game_options_sync_sources, + instance_get_game_setting_locale_labels, + instance_get_local_game_options_config, + instance_preview_local_game_option_changes, + instance_save_local_game_option_changes, + instance_get_pack_sync_preview, + instance_sync_pack, + instance_desync_pack, + instance_list_synced_packs, + instance_upload_synced_pack, + instance_set_synced_pack_enabled, + instance_remove_synced_pack, ]) .build() } @@ -178,6 +205,7 @@ pub struct Instance { pub linked_version_id: Option, pub linked_version_json_path: Option, pub linked_game_dir_mode: Option, + pub synced_options: theseus::instance::InstanceSyncedOptions, } #[derive(Deserialize, Debug, Clone)] @@ -362,6 +390,7 @@ impl From for Instance { .instance .linked_version_json_path, linked_game_dir_mode: metadata.instance.linked_game_dir_mode, + synced_options: metadata.synced_options, } } } @@ -1833,3 +1862,240 @@ pub async fn instance_get_backup_delete_summary( ) -> Result { Ok(theseus::instance::get_backup_delete_summary(instance_id).await?) } + +#[tauri::command] +pub async fn instance_get_synced_options() +-> Result { + Ok(theseus::instance::get_global_synced_options().await?) +} + +#[tauri::command] +pub async fn instance_get_initialized_synced_options() +-> Result { + Ok(theseus::instance::get_initialized_synced_options().await?) +} + +#[tauri::command] +pub async fn instance_get_synced_game_options_config() +-> Result { + Ok(theseus::instance::get_synced_game_options_config().await?) +} + +#[tauri::command] +pub async fn instance_preview_synced_game_option_changes( + request: theseus::instance::UpdateGameSettingsRequest, +) -> Result { + Ok(theseus::instance::preview_synced_game_option_changes(request).await?) +} + +#[tauri::command] +pub async fn instance_save_synced_game_option_changes( + request: theseus::instance::UpdateGameSettingsRequest, +) -> Result { + Ok(theseus::instance::save_synced_game_option_changes(request).await?) +} + +#[tauri::command] +pub async fn instance_list_game_options_sync_sources() +-> Result> { + Ok(theseus::instance::list_game_options_sync_sources().await?) +} + +#[tauri::command] +pub async fn instance_get_game_setting_locale_labels( + instance_id: Option, + locale: String, + option_ids: Vec, + refresh_sources: bool, +) -> Result { + Ok(theseus::instance::get_game_setting_locale_labels( + instance_id.as_deref(), + &locale, + option_ids, + refresh_sources, + ) + .await?) +} + +#[tauri::command] +pub async fn instance_get_local_game_options_config( + instance_id: String, +) -> Result { + Ok(theseus::instance::get_local_game_options_config(&instance_id).await?) +} + +#[tauri::command] +pub async fn instance_preview_local_game_option_changes( + instance_id: String, + request: theseus::instance::UpdateGameSettingsRequest, +) -> Result { + Ok(theseus::instance::preview_local_game_option_changes( + &instance_id, + request, + ) + .await?) +} + +#[tauri::command] +pub async fn instance_save_local_game_option_changes( + instance_id: String, + request: theseus::instance::UpdateGameSettingsRequest, +) -> Result { + Ok( + theseus::instance::save_local_game_option_changes( + &instance_id, + request, + ) + .await?, + ) +} + +#[tauri::command] +pub async fn instance_get_pack_sync_preview( + instance_id: String, + project_path: String, +) -> Result { + Ok( + theseus::instance::get_pack_sync_preview(&instance_id, &project_path) + .await?, + ) +} + +#[tauri::command] +pub async fn instance_sync_pack( + instance_id: String, + project_path: String, +) -> Result<()> { + Ok(theseus::instance::sync_pack(&instance_id, &project_path).await?) +} + +#[tauri::command] +pub async fn instance_desync_pack( + instance_id: String, + pack_id: String, + mode: theseus::instance::DesyncServerMode, +) -> Result<()> { + Ok(theseus::instance::desync_pack(&instance_id, &pack_id, mode).await?) +} + +#[tauri::command] +pub async fn instance_list_synced_packs( + project_type: theseus::data::ProjectType, +) -> Result> { + Ok(theseus::instance::list_synced_packs(project_type).await?) +} + +#[tauri::command] +pub async fn instance_upload_synced_pack( + path: PathBuf, + project_type: theseus::data::ProjectType, + game_versions: Vec, +) -> Result<()> { + Ok( + theseus::instance::upload_synced_pack( + path, + project_type, + game_versions, + ) + .await?, + ) +} + +#[tauri::command] +pub async fn instance_set_synced_pack_enabled( + pack_id: String, + enabled: bool, +) -> Result<()> { + Ok(theseus::instance::set_synced_pack_enabled(&pack_id, enabled).await?) +} + +#[tauri::command] +pub async fn instance_remove_synced_pack(pack_id: String) -> Result<()> { + Ok(theseus::instance::remove_synced_pack(&pack_id).await?) +} + +#[tauri::command] +pub async fn instance_get_synced_options_overview( + instance_id: String, +) -> Result { + Ok(theseus::instance::get_synced_options_overview(&instance_id).await?) +} + +#[tauri::command] +pub async fn instance_get_synced_option_capabilities( + instance_id: String, +) -> Result> { + Ok(theseus::instance::get_synced_option_capabilities(&instance_id).await?) +} + +#[tauri::command] +pub async fn instance_get_synced_option_join_preview( + instance_id: String, + option: theseus::instance::SyncedOption, +) -> Result { + Ok( + theseus::instance::get_synced_option_join_preview(&instance_id, option) + .await?, + ) +} + +#[tauri::command] +pub async fn instance_set_synced_option( + option: theseus::instance::SyncedOption, + enabled: bool, + base_instance_id: Option, +) -> Result { + Ok(theseus::instance::set_global_synced_option( + option, + enabled, + base_instance_id.as_deref(), + ) + .await?) +} + +#[tauri::command] +pub async fn instance_set_instance_synced_option( + instance_id: String, + option: theseus::instance::SyncedOption, + enabled: bool, + resolution: Option, +) -> Result { + let metadata = theseus::instance::set_instance_synced_option( + &instance_id, + option, + enabled, + resolution, + ) + .await?; + instance_from_metadata(metadata).await +} + +#[tauri::command] +pub async fn instance_get_synced_command_history() -> Result { + Ok(theseus::instance::get_synced_command_history().await?) +} + +#[tauri::command] +pub async fn instance_set_synced_command_history( + contents: String, +) -> Result { + Ok(theseus::instance::set_synced_command_history(&contents).await?) +} + +#[tauri::command] +pub async fn instance_list_synced_servers() +-> Result> { + Ok(theseus::instance::list_synced_servers().await?) +} +#[tauri::command] +pub async fn instance_update_synced_server( + server: theseus::instance::SyncedServer, +) -> Result<()> { + theseus::instance::update_synced_server(server).await?; + Ok(()) +} +#[tauri::command] +pub async fn instance_remove_synced_server(id: String) -> Result<()> { + theseus::instance::remove_synced_server(&id).await?; + Ok(()) +} \ No newline at end of file diff --git a/packages/app-lib/src/api/instance/mod.rs b/packages/app-lib/src/api/instance/mod.rs index 85da6a3..7779ae6 100644 --- a/packages/app-lib/src/api/instance/mod.rs +++ b/packages/app-lib/src/api/instance/mod.rs @@ -173,3 +173,4 @@ pub use self::upgrade::{ update_instance_upgrade_resolution, update_instance_upgrade_resolutions, }; pub use crate::state::{DailyPlaytime, DailyPlaytimeEntry}; +pub use crate::state::{InstanceSyncedOptions, SyncedOption};