@@ -14,11 +14,11 @@ use winit::{
1414 dpi:: PhysicalSize ,
1515 event:: { Event , WindowEvent } ,
1616 event_loop:: { ControlFlow , EventLoop } ,
17- platform:: run_return:: EventLoopExtRunReturn ,
17+ platform:: { run_return:: EventLoopExtRunReturn , windows :: WindowBuilderExtWindows } ,
1818} ;
1919
2020use crate :: {
21- icons:: { ICON_CONTROLLER , ICON_MICROSOFT , ICON_STEAM } ,
21+ icons:: { ICON_CONTROLLER , ICON_FOLDER_OPEN , ICON_MICROSOFT , ICON_STEAM } ,
2222 overlays:: {
2323 big_button:: BigButton ,
2424 gui:: { GuiManager , PreDrawResult } ,
@@ -29,11 +29,16 @@ use crate::{
2929
3030/// Creates a temporary window with egui to select a game installation
3131/// This function should not be called in another render loop, as it will hang until this function completes
32- pub fn select_game_installation ( event_loop : & mut EventLoop < ( ) > ) -> anyhow:: Result < String > {
32+ pub fn select_game_installation (
33+ event_loop : & mut EventLoop < ( ) > ,
34+ icon : & winit:: window:: Icon ,
35+ ) -> anyhow:: Result < String > {
3336 let window = winit:: window:: WindowBuilder :: new ( )
3437 . with_title ( "Alkahest" )
3538 . with_inner_size ( PhysicalSize :: new ( 320 , 320 ) )
3639 . with_min_inner_size ( PhysicalSize :: new ( 320 , 480 ) )
40+ . with_window_icon ( Some ( icon. clone ( ) ) )
41+ . with_taskbar_icon ( Some ( icon. clone ( ) ) )
3742 . build ( event_loop) ?;
3843
3944 let window = Arc :: new ( window) ;
@@ -124,15 +129,29 @@ pub fn select_game_installation(event_loop: &mut EventLoop<()>) -> anyhow::Resul
124129 }
125130 }
126131
127- // if BigButton::new(ICON_FOLDER_OPEN, "Browse")
128- // .full_width()
129- // .ui(ui)
130- // .clicked()
131- // {
132- // let dialog = native_dialog::FileDialog::new()
133- // .set_title("Select Destiny 2 packages directory")
134- // .show_open_single_dir()?;
135- // }
132+ if BigButton :: new ( ICON_FOLDER_OPEN , "Browse" )
133+ . full_width ( )
134+ . ui ( ui)
135+ . clicked ( )
136+ {
137+ if let Ok ( Some ( path) ) = native_dialog:: FileDialog :: new ( )
138+ . set_title ( "Select Destiny 2 packages directory" )
139+ . show_open_single_dir ( ) {
140+ if path. ends_with ( "packages" ) {
141+ selected_path = Ok ( path. parent ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) ) ;
142+ * control_flow = ControlFlow :: Exit ;
143+ } else if path. ends_with ( "Destiny 2" ) {
144+ // cohae: Idiot-proofing this a bit
145+ selected_path = Ok ( path. to_string_lossy ( ) . to_string ( ) ) ;
146+ * control_flow = ControlFlow :: Exit ;
147+ } else {
148+ native_dialog:: MessageDialog :: new ( )
149+ . set_title ( "Invalid directory" )
150+ . set_text ( "The selected directory is not a packages directory. Please select the packages directory of your game installation." )
151+ . show_alert ( ) . ok ( ) ;
152+ }
153+ }
154+ }
136155 } ) ;
137156
138157 PreDrawResult :: Continue
0 commit comments