@@ -321,25 +321,9 @@ private void SetSearching(bool state)
321
321
SearchButtonEverywhere . IsEnabled = true ;
322
322
}
323
323
}
324
- private async void Search ( string root , bool useAutoBehavior = false )
325
- {
326
- bool gamesListWasEmpty = this . games . Count == 0 ;
327
- foreach ( var it in this . games )
328
- it . SetNew ( false ) ;
329
-
330
- SetSearching ( true ) ;
331
- IntPtr foundPtr ;
332
- if ( useAutoBehavior )
333
- {
334
- foundPtr = await Task . Run ( ( ) => ThcrapDll . SearchForGamesInstalled ( null ) ) ;
335
- }
336
- else
337
- {
338
- foundPtr = await Task . Run ( ( ) => ThcrapDll . SearchForGames ( new string [ ] { root , null } , null ) ) ;
339
- }
340
-
341
- SetSearching ( false ) ;
342
324
325
+ private async void HandleGameSearchResult ( IntPtr foundPtr , bool gamesListWasEmpty )
326
+ {
343
327
var found = ThcrapHelper . ParseNullTerminatedStructArray < ThcrapDll . game_search_result > ( foundPtr ) ;
344
328
345
329
foreach ( var it in found )
@@ -362,6 +346,29 @@ private async void Search(string root, bool useAutoBehavior = false)
362
346
}
363
347
364
348
ThcrapDll . SearchForGames_free ( foundPtr ) ;
349
+ }
350
+
351
+ private async void Search ( string root , bool useAutoBehavior = false )
352
+ {
353
+ bool gamesListWasEmpty = this . games . Count == 0 ;
354
+ foreach ( var it in this . games )
355
+ it . SetNew ( false ) ;
356
+
357
+ SetSearching ( true ) ;
358
+ if ( useAutoBehavior )
359
+ {
360
+ HandleGameSearchResult ( await Task . Run ( ( ) => ThcrapDll . SearchForGamesInstalled ( null ) ) , gamesListWasEmpty ) ;
361
+ var dirInfo = new DirectoryInfo ( "." ) ;
362
+ if ( dirInfo . Parent != null )
363
+ {
364
+ HandleGameSearchResult ( await Task . Run ( ( ) => ThcrapDll . SearchForGames ( new string [ ] { dirInfo . Parent . FullName , null } , null ) ) , gamesListWasEmpty ) ;
365
+ }
366
+ }
367
+ else
368
+ {
369
+ HandleGameSearchResult ( await Task . Run ( ( ) => ThcrapDll . SearchForGames ( new string [ ] { root , null } , null ) ) , gamesListWasEmpty ) ;
370
+ }
371
+ SetSearching ( false ) ;
365
372
366
373
if ( ! gamesListWasEmpty )
367
374
GamesScroll . ScrollToBottom ( ) ;
0 commit comments