From e4bfd54d947c292832f3456b5d2d73e3a54f48b5 Mon Sep 17 00:00:00 2001
From: Weiyou Wang <44151844+Alan-Charred@users.noreply.github.com>
Date: Mon, 28 Oct 2024 02:07:16 +1100
Subject: [PATCH] fix: MuMu bridge connection (#10937)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: MuMu bridge connection
* fix: global adaptation
* chore: 调整布局,优化变量位置
* fix: 网络桥接模式设置不再与自动检测链接相关
* chore: 自动检测时禁用增强模式开关
* chore: 添加开启桥接的提示
---------
Co-authored-by: uye <99072975+ABA2396@users.noreply.github.com>
---
src/MaaCore/Controller/AdbController.cpp | 8 ++-
src/MaaWpfGui/Constants/ConfigurationKeys.cs | 1 +
src/MaaWpfGui/Res/Localizations/en-us.xaml | 2 +
src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 2 +
src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 2 +
src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 2 +
src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 2 +
.../ViewModels/UI/SettingsViewModel.cs | 50 +++++++++++++++++++
.../ConnectSettingsUserControl.xaml | 45 +++++++++++------
9 files changed, 98 insertions(+), 16 deletions(-)
diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp
index a1aa2da6a9..a262335c9b 100644
--- a/src/MaaCore/Controller/AdbController.cpp
+++ b/src/MaaCore/Controller/AdbController.cpp
@@ -231,7 +231,13 @@ void asst::AdbController::init_mumu_extras(const AdbCfg& adb_cfg, const std::str
set_mumu_package(adb_cfg.extras.get("client_type", ""));
std::filesystem::path mumu_path = utils::path(adb_cfg.extras.get("path", ""));
- m_mumu_extras.init(mumu_path, get_mumu_index(address));
+
+ if (adb_cfg.extras.contains("index")) { // MuMu index is provided directly
+ m_mumu_extras.init(mumu_path, adb_cfg.extras.get("index", 0));
+ }
+ else {
+ m_mumu_extras.init(mumu_path, get_mumu_index(address));
+ }
#endif
}
diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
index d36e4190ed..6077d93fb5 100755
--- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs
+++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
@@ -57,6 +57,7 @@ namespace MaaWpfGui.Constants
public const string AddressHistory = "Connect.AddressHistory";
public const string AutoDetect = "Connect.AutoDetect";
public const string AlwaysAutoDetect = "Connect.AlwaysAutoDetect";
+ public const string MumuBridgeConnection = "Connect.MumuBridgeConnection";
public const string ConnectAddress = "Connect.Address";
public const string AdbPath = "Connect.AdbPath";
public const string ConnectConfig = "Connect.ConnectConfig";
diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml
index 61b17da776..d9640d7fa1 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -394,6 +394,8 @@ Note:
2. If the port number of the connection address is 7555, you need to change the port number to 16384.
MuMu12 Emulator exec path
+ MuMu Network Bridge Connection
+ Unless you know what you are doing, do not enable this option
Instance Number
Display Number
Mumu screenshot enhancement not enabled, please check related settings
diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
index c6c88a01fc..8c6c0f2e44 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -394,6 +394,8 @@ C:\\Program Files\\Netease\\MuMuPlayer-12.0 を入力してください。\n
2. 接続アドレスのポート番号が 7555 の場合、ポート番号を 16384 に変更してください。
MuMu12 エミュレータパス
+ MuMu ネットワークブリッジモード
+ 自分が何をしているのか分かっていない限り、このオプションを有効にしないでください
インスタンス番号
表示番号
MuMu スクリーンショットの強化 が有効になっていません。関連する設定を確認してください
diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
index 9c6dee015b..3251bd1ec6 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -394,6 +394,8 @@ C:\\Program Files\\Netease\\MuMuPlayer-12.0으로 입력해야 합니다.\n
2. 연결 주소의 포트 번호가 7555일 경우, 포트 번호를 16384로 변경해야 합니다.
MuMu12 에뮬레이터 경로
+ MuMu 네트워크 브리지 모드
+ 무엇을 하고 있는지 모른다면 이 옵션을 활성화하지 마십시오
인스턴스 번호
표시 번호
MuMu의 스크린샷 향상가 활성화되지 않았습니다. 관련 설정을 확인하세요
diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
index 6828bb1b00..83d17b3d96 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -394,6 +394,8 @@ C:\\Program Files\\Netease\\MuMuPlayer-12.0。\n
2. 若连接地址端口号为 7555,则需将端口号改为 16384。
MuMu 安装路径
+ MuMu 网络桥接模式
+ 除非你知道自己在做什么,否则不要启用此选项
实例编号
屏幕编号
Mumu 截图增强未生效,请检查相关设置
diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
index 794d0f0539..b09af87140 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -394,6 +394,8 @@ C:\\Program Files\\Netease\\MuMuPlayer-12.0。\n
2. 若連接地址端口號為 7555,則需將端口號改為 16384。
MuMu12 模擬器路徑
+ MuMu 網路橋接模式
+ 除非你知道自己在做什麼,否則不要啟用此選項
實例號碼
螢幕號碼
Mumu 截圖增強未生效,请檢查相關設定
diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index 1790127232..0cb9fe919f 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -4281,6 +4281,50 @@ namespace MaaWpfGui.ViewModels.UI
}
}
+ private bool _mumuBridgeConnection = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.MumuBridgeConnection, bool.FalseString));
+
+ public bool MuMuBridgeConnection
+ {
+ get => _mumuBridgeConnection;
+ set
+ {
+ if (_mumuBridgeConnection == value)
+ {
+ return;
+ }
+
+ if (value)
+ {
+ var result = MessageBoxHelper.Show(LocalizationHelper.GetString("MuMuBridgeConnectionTip"), icon: MessageBoxImage.Information, buttons: MessageBoxButton.OKCancel);
+ if (result != MessageBoxResult.OK)
+ {
+ return;
+ }
+ }
+
+ SetAndNotify(ref _mumuBridgeConnection, value);
+
+ Instances.AsstProxy.Connected = false;
+ ConfigurationHelper.SetValue(ConfigurationKeys.MumuBridgeConnection, value.ToString());
+ }
+ }
+
+ private string _index = ConfigurationHelper.GetValue(ConfigurationKeys.MuMu12Index, "0");
+
+ ///
+ /// Gets or sets the index of the emulator.
+ ///
+ public string Index
+ {
+ get => _index;
+ set
+ {
+ Instances.AsstProxy.Connected = false;
+ SetAndNotify(ref _index, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.MuMu12Index, value);
+ }
+ }
+
public string Config
{
get
@@ -4295,6 +4339,12 @@ namespace MaaWpfGui.ViewModels.UI
["path"] = EmulatorPath,
["client_type"] = Instances.SettingsViewModel.ClientType,
};
+
+ if (MuMuBridgeConnection)
+ {
+ configObject["index"] = int.TryParse(Index, out var indexParse) ? indexParse : 0;
+ }
+
return JsonConvert.SerializeObject(configObject);
}
}
diff --git a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
index 498ebc2ed3..9eb1999234 100644
--- a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
@@ -53,6 +53,7 @@
+ Content="{DynamicResource Select}" />
-
+
+
@@ -127,19 +126,34 @@
HorizontalAlignment="Center"
Content="{DynamicResource MuMu12ExtrasEnabled}"
IsChecked="{Binding MuMuEmulator12Extras.Enable}" />
-
+
+
+
+
+
@@ -182,6 +196,7 @@
Visibility="{c:Binding 'TestLinkInfo!=""'}" />
+