@@ -26,7 +26,7 @@ pub const DEFAULT_STEAM_NAME: &str = "production";
2626
2727mod webview2;
2828
29- use tauri:: Manager ;
29+ use tauri:: { Emitter , Manager } ;
3030
3131use auth:: {
3232 background_refresh_task, get_access_token, get_auth_state, get_hub_oauth_providers, hub_login,
@@ -46,7 +46,7 @@ use relays::{get_relays, get_selected_relay, set_selected_relay};
4646use servers:: get_servers;
4747use settings:: {
4848 get_settings, save_filter_settings, set_age_verified, set_auth_mode, set_last_played_server,
49- set_locale, set_rendering_pipeline, set_theme, toggle_favorite_server,
49+ set_last_view_mode , set_locale, set_rendering_pipeline, set_theme, toggle_favorite_server,
5050 toggle_server_notifications,
5151} ;
5252
@@ -191,6 +191,7 @@ pub fn build_specta() -> tauri_specta::Builder<tauri::Wry> {
191191 toggle_server_notifications,
192192 set_rendering_pipeline,
193193 set_last_played_server,
194+ set_last_view_mode,
194195 toggle_favorite_server,
195196 save_filter_settings,
196197 get_control_server_port,
@@ -252,6 +253,7 @@ pub fn build_specta() -> tauri_specta::Builder<tauri::Wry> {
252253 toggle_server_notifications,
253254 set_rendering_pipeline,
254255 set_last_played_server,
256+ set_last_view_mode,
255257 toggle_favorite_server,
256258 save_filter_settings,
257259 get_control_server_port,
@@ -287,6 +289,26 @@ pub fn build_specta() -> tauri_specta::Builder<tauri::Wry> {
287289 ] )
288290}
289291
292+ #[ cfg( target_os = "windows" ) ]
293+ fn register_deep_link_protocol ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
294+ use winreg:: enums:: HKEY_CURRENT_USER ;
295+ use winreg:: RegKey ;
296+
297+ let exe_path = std:: env:: current_exe ( ) ?;
298+ let exe_str = exe_path. to_string_lossy ( ) ;
299+
300+ let hkcu = RegKey :: predef ( HKEY_CURRENT_USER ) ;
301+ let ( key, _) = hkcu. create_subkey ( r"Software\Classes\ss13" ) ?;
302+ key. set_value ( "" , & "SS13 Launcher" ) ?;
303+ key. set_value ( "URL Protocol" , & "" ) ?;
304+
305+ let ( command_key, _) = hkcu. create_subkey ( r"Software\Classes\ss13\shell\open\command" ) ?;
306+ command_key. set_value ( "" , & format ! ( "\" {exe_str}\" \" %1\" " ) ) ?;
307+
308+ tracing:: info!( "Registered ss13:// protocol handler" ) ;
309+ Ok ( ( ) )
310+ }
311+
290312#[ cfg_attr( mobile, tauri:: mobile_entry_point) ]
291313pub fn run ( ) {
292314 let _guard = logging:: init_logging ( ) ;
@@ -302,6 +324,10 @@ pub fn run() {
302324 let _ = open:: that ( "https://go.microsoft.com/fwlink/p/?LinkId=2124703" ) ;
303325 std:: process:: exit ( 1 ) ;
304326 }
327+
328+ if let Err ( e) = register_deep_link_protocol ( ) {
329+ tracing:: error!( "Failed to register ss13:// protocol: {}" , e) ;
330+ }
305331 }
306332
307333 let specta_builder = build_specta ( ) ;
@@ -322,6 +348,22 @@ pub fn run() {
322348 . plugin ( tauri_plugin_opener:: init ( ) )
323349 . plugin ( tauri_plugin_notification:: init ( ) )
324350 . plugin ( tauri_plugin_process:: init ( ) )
351+ . plugin ( tauri_plugin_deep_link:: init ( ) )
352+ . plugin ( tauri_plugin_single_instance:: init ( |app, argv, _cwd| {
353+ let deep_link_urls: Vec < String > = argv
354+ . iter ( )
355+ . filter ( |arg| arg. starts_with ( "ss13://" ) )
356+ . cloned ( )
357+ . collect ( ) ;
358+
359+ if !deep_link_urls. is_empty ( ) {
360+ let _ = app. emit ( "deep-link://new-url" , deep_link_urls) ;
361+ }
362+
363+ if let Some ( window) = app. get_webview_window ( "main" ) {
364+ let _ = window. set_focus ( ) ;
365+ }
366+ } ) )
325367 . invoke_handler ( specta_builder. invoke_handler ( ) ) ;
326368
327369 // Only include updater for non-CM builds (CM uses Steam for updates)
0 commit comments