From fa25b362ccfea52932de1517ea19f5da4f9dc6d6 Mon Sep 17 00:00:00 2001 From: 4sval Date: Tue, 23 May 2023 00:54:56 +0200 Subject: [PATCH] problems --- FModel/ViewModels/CUE4ParseViewModel.cs | 4 +-- FModel/ViewModels/Commands/MenuCommand.cs | 4 +-- .../Commands/RightClickMenuCommand.cs | 12 +++---- FModel/ViewModels/GameSelectorViewModel.cs | 33 ++++++++++++------- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index f9eaf9d4..ef19b719 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -608,7 +608,7 @@ public class CUE4ParseViewModel : ViewModel { foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); Extract(cancellationToken, asset.FullPath, TabControl.HasNoTabs); } @@ -618,7 +618,7 @@ public class CUE4ParseViewModel : ViewModel { foreach (var asset in folder.AssetsList.Assets) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); try { diff --git a/FModel/ViewModels/Commands/MenuCommand.cs b/FModel/ViewModels/Commands/MenuCommand.cs index f61dc8df..89d870a6 100644 --- a/FModel/ViewModels/Commands/MenuCommand.cs +++ b/FModel/ViewModels/Commands/MenuCommand.cs @@ -111,7 +111,7 @@ public class MenuCommand : ViewModelCommand if (!expand && folder.IsExpanded) { folder.IsExpanded = false; - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); } @@ -129,7 +129,7 @@ public class MenuCommand : ViewModelCommand for (var node = nodes.Last; node != null; node = node.Previous) { node.Value.IsExpanded = true; - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); } } diff --git a/FModel/ViewModels/Commands/RightClickMenuCommand.cs b/FModel/ViewModels/Commands/RightClickMenuCommand.cs index ab009a4b..1da8395e 100644 --- a/FModel/ViewModels/Commands/RightClickMenuCommand.cs +++ b/FModel/ViewModels/Commands/RightClickMenuCommand.cs @@ -29,7 +29,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Extract_New_Tab": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, true); } @@ -37,7 +37,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Export_Data": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.ExportData(asset.FullPath); } @@ -45,7 +45,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Save_Properties": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Properties); } @@ -53,7 +53,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Save_Textures": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Textures); } @@ -61,7 +61,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Save_Models": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Meshes | EBulkType.Auto); } @@ -69,7 +69,7 @@ public class RightClickMenuCommand : ViewModelCommand case "Assets_Save_Animations": foreach (var asset in assetItems) { - Thread.Yield(); + Thread.Sleep(10); cancellationToken.ThrowIfCancellationRequested(); contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Animations | EBulkType.Auto); } diff --git a/FModel/ViewModels/GameSelectorViewModel.cs b/FModel/ViewModels/GameSelectorViewModel.cs index 8fac24cb..54ddaa0c 100644 --- a/FModel/ViewModels/GameSelectorViewModel.cs +++ b/FModel/ViewModels/GameSelectorViewModel.cs @@ -139,12 +139,15 @@ public class GameSelectorViewModel : ViewModel if (installationList.AppName.Equals(gameName, StringComparison.OrdinalIgnoreCase)) { var pak = Directory.GetDirectories(installationList.InstallLocation, "Paks*", SearchOption.AllDirectories); - if (pak.Length > 0) return new DetectedGame { GameName = installationList.AppName, GameDirectory = pak[0] }; + if (pak.Length > 0) + { + Log.Debug("Found {GameName} in LauncherInstalled.dat", gameName); + return new DetectedGame { GameName = installationList.AppName, GameDirectory = pak[0] }; + } } } } - Log.Warning("Could not find {GameName} in LauncherInstalled.dat", gameName); return null; } @@ -157,11 +160,13 @@ public class GameSelectorViewModel : ViewModel foreach (var (key, _) in _riotClientInstalls.AssociatedClient) { if (key.Contains(gameName, StringComparison.OrdinalIgnoreCase)) + { + Log.Debug("Found {GameName} in RiotClientInstalls.json", gameName); return new DetectedGame { GameName = gameName, GameDirectory = $"{key.Replace('/', '\\')}{pakDirectory}" }; + } } } - Log.Warning("Could not find {GameName} in RiotClientInstalls.json", gameName); return null; } @@ -170,9 +175,11 @@ public class GameSelectorViewModel : ViewModel { _launcherSettings ??= GetDataLauncherInstalls("\\.minecraft\\launcher_settings.json"); if (_launcherSettings is { ProductLibraryDir: { } }) + { + Log.Debug("Found {GameName} in launcher_settings.json", gameName); return new DetectedGame { GameName = gameName, GameDirectory = $"{_launcherSettings.ProductLibraryDir}{pakDirectory}" }; + } - Log.Warning("Could not find {GameName} in launcher_settings.json", gameName); return null; } @@ -180,9 +187,11 @@ public class GameSelectorViewModel : ViewModel { var steamInfo = SteamDetection.GetSteamGameById(id); if (steamInfo is not null) + { + Log.Debug("Found {GameName} in steam manifests", steamInfo.Name); return new DetectedGame { GameName = steamInfo.Name, GameDirectory = $"{steamInfo.GameRoot}{pakDirectory}" }; + } - Log.Warning("Could not find {GameId} in steam manifests", id); return null; } @@ -199,9 +208,11 @@ public class GameSelectorViewModel : ViewModel } if (!string.IsNullOrEmpty(installLocation)) + { + Log.Debug("Found {GameName} in the registry", key); return new DetectedGame { GameName = key, GameDirectory = $"{installLocation}{pakDirectory}" }; + } - Log.Warning("Could not find {GameName} in the registry", key); return null; } @@ -221,9 +232,11 @@ public class GameSelectorViewModel : ViewModel } if (!string.IsNullOrEmpty(installLocation)) + { + Log.Debug("Found {GameName} in the registry", key); return new DetectedGame { GameName = displayName, GameDirectory = $"{installLocation}{pakDirectory}" }; + } - Log.Warning("Could not find {GameName} in the registry", key); return null; } @@ -234,11 +247,10 @@ public class GameSelectorViewModel : ViewModel var launcher = $"{drive.Name}{jsonFile}"; if (!File.Exists(launcher)) continue; - Log.Information("\"{Launcher}\" found in drive \"{DriveName}\"", launcher, drive.Name); + Log.Debug("\"{Launcher}\" found in drive \"{DriveName}\"", launcher, drive.Name); return JsonConvert.DeserializeObject(File.ReadAllText(launcher)); } - Log.Warning("\"{JsonFile}\" not found in any drives", jsonFile); return default; } @@ -248,11 +260,10 @@ public class GameSelectorViewModel : ViewModel var launcher = $"{appData}{jsonFile}"; if (File.Exists(launcher)) { - Log.Information("\"{Launcher}\" found in \"{AppData}\"", launcher, appData); + Log.Debug("\"{Launcher}\" found in \"{AppData}\"", launcher, appData); return JsonConvert.DeserializeObject(File.ReadAllText(launcher)); } - Log.Warning("\"{Json}\" not found anywhere", jsonFile); return default; }