From 2de6ec3e512913f1bd5e216962a3541ef17ffb52 Mon Sep 17 00:00:00 2001 From: Gliese Date: Tue, 1 Aug 2023 15:12:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E7=89=B9=E5=AE=9A=E7=9B=AE=E5=BD=95=E4=B8=8B=E7=9A=84bluestack?= =?UTF-8?q?s.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/UI/SettingsViewModel.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 123b28c013..1259f122e2 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -2439,6 +2439,11 @@ namespace MaaWpfGui.ViewModels.UI { "WSA", new List { "127.0.0.1:58526" } }, }; + /// + /// Gets the default bluestack conf. + /// + public static List DafaultBluestacksConfPath { get; } = new List { "C:\\ProgramData\\BlueStacks_nxt\\bluestacks.conf", "D:\\BlueStacks_nxt\\bluestacks.conf" }; + /// /// Refreshes ADB config. /// @@ -2506,6 +2511,30 @@ namespace MaaWpfGui.ViewModels.UI return true; } + + /// + /// Get the path of bluestacks.conf + /// + /// path + public static string GetBluestacksConfig() + { + var conf = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigPath, string.Empty); + if (!string.IsNullOrEmpty(conf)) + { + return conf; + } + + foreach (var confPath in DafaultBluestacksConfPath) + { + if (File.Exists(confPath)) + { + return confPath; + } + } + + return null; + } + /// /// Selects ADB program file. /// @@ -2572,7 +2601,7 @@ namespace MaaWpfGui.ViewModels.UI rvm.WindowTitle = $"{prefix}MAA ({CurrentConfiguration}) - {VersionId}{poolString} - {connectConfigName} ({ConnectAddress}) - {ClientName}"; } - private readonly string _bluestacksConfig = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigPath, string.Empty); + private readonly string _bluestacksConfig = GetBluestacksConfig(); private string _bluestacksKeyWord = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigKeyword, string.Empty); ///