mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-01 01:10:34 +08:00
feat.支持自定义连接地址、支持蓝叠HyperV配置解析
This commit is contained in:
@@ -13,7 +13,7 @@ extern "C" {
|
||||
|
||||
bool MEOAPI AsstCatchDefault(void* p_asst);
|
||||
bool MEOAPI AsstCatchEmulator(void* p_asst);
|
||||
bool MEOAPI AsstCatchCustom(void* p_asst);
|
||||
bool MEOAPI AsstCatchCustom(void* p_asst, const char* address);
|
||||
bool MEOAPI AsstCatchFake(void* p_asst);
|
||||
|
||||
bool MEOAPI AsstAppendFight(void* p_asst, int max_mecidine, int max_stone, int max_times);
|
||||
|
||||
@@ -112,7 +112,7 @@ bool Assistance::catch_emulator(const std::string& emulator_name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool asst::Assistance::catch_custom()
|
||||
bool asst::Assistance::catch_custom(const std::string& address)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
@@ -124,6 +124,9 @@ bool asst::Assistance::catch_custom()
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
EmulatorInfo remote_info = cfg.get_emulators_info().at("Custom");
|
||||
if (!address.empty()) {
|
||||
remote_info.adb.addresses.push_back(address);
|
||||
}
|
||||
|
||||
ret = ctrler.try_capture(remote_info, true);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace asst
|
||||
// 捕获模拟器
|
||||
bool catch_emulator(const std::string& emulator_name = std::string());
|
||||
// 捕获自定义设备
|
||||
bool catch_custom();
|
||||
bool catch_custom(const std::string& address = std::string());
|
||||
// 不实际进行捕获,调试用接口
|
||||
bool catch_fake();
|
||||
|
||||
|
||||
@@ -90,13 +90,13 @@ bool AsstCatchEmulator(void* p_asst)
|
||||
return ((asst::Assistance*)p_asst)->catch_emulator();
|
||||
}
|
||||
|
||||
bool AsstCatchCustom(void* p_asst)
|
||||
bool AsstCatchCustom(void* p_asst, const char* address)
|
||||
{
|
||||
if (p_asst == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((asst::Assistance*)p_asst)->catch_custom();
|
||||
return ((asst::Assistance*)p_asst)->catch_custom(address);
|
||||
}
|
||||
|
||||
bool AsstCatchFake(void* p_asst)
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace MeoAsstGui
|
||||
|
||||
[DllImport("MeoAssistance.dll")] private static extern void AsstDestory(IntPtr ptr);
|
||||
|
||||
[DllImport("MeoAssistance.dll")] private static extern bool AsstCatchDefault(IntPtr ptr);
|
||||
[DllImport("MeoAssistance.dll")] private static extern bool AsstCatchDefault(IntPtr ptr);
|
||||
|
||||
[DllImport("MeoAssistance.dll")] private static extern bool AsstCatchCustom(IntPtr ptr, string address);
|
||||
|
||||
[DllImport("MeoAssistance.dll")] private static extern bool AsstAppendFight(IntPtr ptr, int max_medicine, int max_stone, int max_times);
|
||||
|
||||
@@ -294,46 +296,49 @@ namespace MeoAsstGui
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isCatched = false;
|
||||
|
||||
public bool AsstCatchDefault()
|
||||
|
||||
public bool AsstCatch()
|
||||
{
|
||||
if (!_isCatched)
|
||||
{
|
||||
_isCatched = AsstCatchDefault(_ptr);
|
||||
}
|
||||
return _isCatched;
|
||||
}
|
||||
|
||||
public bool AsstAppendFight(int max_medicine, int max_stone, int max_times)
|
||||
{
|
||||
return AsstAppendFight(_ptr, max_medicine, max_stone, max_times);
|
||||
var settings = _container.Get<SettingsViewModel>();
|
||||
settings.TryToSetBlueStacksHyperVAddress();
|
||||
if (settings.ConnectAddress.Length == 0)
|
||||
{
|
||||
return AsstCatchDefault(_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AsstCatchCustom(_ptr, settings.ConnectAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AsstAppendFight(int max_medicine, int max_stone, int max_times)
|
||||
{
|
||||
return AsstAppendFight(_ptr, max_medicine, max_stone, max_times);
|
||||
}
|
||||
|
||||
public bool AsstAppendAward()
|
||||
{
|
||||
return AsstAppendAward(_ptr);
|
||||
}
|
||||
|
||||
public bool AsstAppendVisit()
|
||||
{
|
||||
return AsstAppendVisit(_ptr);
|
||||
}
|
||||
|
||||
public bool AsstAppendMall(bool with_shopping)
|
||||
{
|
||||
return AsstAppendMall(_ptr, with_shopping);
|
||||
public bool AsstAppendVisit()
|
||||
{
|
||||
return AsstAppendVisit(_ptr);
|
||||
}
|
||||
|
||||
|
||||
public bool AsstAppendMall(bool with_shopping)
|
||||
{
|
||||
return AsstAppendMall(_ptr, with_shopping);
|
||||
}
|
||||
|
||||
public bool AsstAppendRecruit(int max_times, int[] required_level, int required_len, int[] confirm_level, int confirm_len, bool need_refresh)
|
||||
{
|
||||
return AsstAppendRecruit(_ptr, max_times, required_level, required_len, confirm_level, confirm_len, need_refresh);
|
||||
}
|
||||
|
||||
public bool AsstAppendInfrast(int work_mode, string[] order, int order_len, string uses_of_drones, double dorm_threshold)
|
||||
{
|
||||
return AsstAppendInfrast(_ptr, work_mode, order, order_len, uses_of_drones, dorm_threshold);
|
||||
public bool AsstAppendInfrast(int work_mode, string[] order, int order_len, string uses_of_drones, double dorm_threshold)
|
||||
{
|
||||
return AsstAppendInfrast(_ptr, work_mode, order, order_len, uses_of_drones, dorm_threshold);
|
||||
}
|
||||
|
||||
public bool AsstStart()
|
||||
@@ -341,14 +346,14 @@ namespace MeoAsstGui
|
||||
return AsstStart(_ptr);
|
||||
}
|
||||
|
||||
public bool AsstStartRecruitCalc(int[] required_level, int required_len, bool set_time)
|
||||
{
|
||||
return AsstStartRecruitCalc(_ptr, required_level, required_len, set_time);
|
||||
public bool AsstStartRecruitCalc(int[] required_level, int required_len, bool set_time)
|
||||
{
|
||||
return AsstStartRecruitCalc(_ptr, required_level, required_len, set_time);
|
||||
}
|
||||
|
||||
public bool AsstStop()
|
||||
{
|
||||
return AsstStop(_ptr);
|
||||
|
||||
public bool AsstStop()
|
||||
{
|
||||
return AsstStop(_ptr);
|
||||
}
|
||||
|
||||
public void AsstSetPenguinId(string id)
|
||||
@@ -360,41 +365,41 @@ namespace MeoAsstGui
|
||||
//{
|
||||
// AsstSetParam(_ptr, type, param, value);
|
||||
//}
|
||||
}
|
||||
|
||||
public enum AsstMsg
|
||||
{
|
||||
}
|
||||
|
||||
public enum AsstMsg
|
||||
{
|
||||
/* Error Msg */
|
||||
PtrIsNull, // 指针为空
|
||||
ImageIsEmpty, // 图像为空
|
||||
WindowMinimized, // [已弃用] 窗口被最小化了
|
||||
InitFaild, // 初始化失败
|
||||
TaskError, // 任务错误(任务一直出错,retry次数达到上限)
|
||||
OcrResultError, // Ocr识别结果错误
|
||||
PtrIsNull, // 指针为空
|
||||
ImageIsEmpty, // 图像为空
|
||||
WindowMinimized, // [已弃用] 窗口被最小化了
|
||||
InitFaild, // 初始化失败
|
||||
TaskError, // 任务错误(任务一直出错,retry次数达到上限)
|
||||
OcrResultError, // Ocr识别结果错误
|
||||
/* Info Msg: about Task */
|
||||
TaskStart = 1000, // 任务开始
|
||||
TaskMatched, // 任务匹配成功
|
||||
ReachedLimit, // 单个原子任务达到次数上限
|
||||
ReadyToSleep, // 准备开始睡眠
|
||||
EndOfSleep, // 睡眠结束
|
||||
AppendProcessTask, // 新增流程任务,Assistance内部消息,外部不需要处理
|
||||
AppendTask, // 新增任务,Assistance内部消息,外部不需要处理
|
||||
TaskCompleted, // 单个原子任务完成
|
||||
PrintWindow, // 截图消息
|
||||
ProcessTaskStopAction, // 流程任务执行到了Stop的动作
|
||||
TaskChainCompleted, // 任务链完成
|
||||
ProcessTaskNotMatched, // 流程任务识别错误
|
||||
TaskStart = 1000, // 任务开始
|
||||
TaskMatched, // 任务匹配成功
|
||||
ReachedLimit, // 单个原子任务达到次数上限
|
||||
ReadyToSleep, // 准备开始睡眠
|
||||
EndOfSleep, // 睡眠结束
|
||||
AppendProcessTask, // 新增流程任务,Assistance内部消息,外部不需要处理
|
||||
AppendTask, // 新增任务,Assistance内部消息,外部不需要处理
|
||||
TaskCompleted, // 单个原子任务完成
|
||||
PrintWindow, // 截图消息
|
||||
ProcessTaskStopAction, // 流程任务执行到了Stop的动作
|
||||
TaskChainCompleted, // 任务链完成
|
||||
ProcessTaskNotMatched, // 流程任务识别错误
|
||||
AllTasksCompleted, // 所有任务完成
|
||||
TaskChainStart, // 开始任务链
|
||||
/* Info Msg: about Identify */
|
||||
TextDetected = 2000, // 识别到文字
|
||||
ImageFindResult, // 查找图像的结果
|
||||
ImageMatched, // 图像匹配成功
|
||||
TextDetected = 2000, // 识别到文字
|
||||
ImageFindResult, // 查找图像的结果
|
||||
ImageMatched, // 图像匹配成功
|
||||
StageDrops, // 关卡掉落信息
|
||||
/* Open Recruit Msg */
|
||||
RecruitTagsDetected = 3000, // 公招识别到了Tags
|
||||
RecruitSpecialTag, // 公招识别到了特殊的Tag
|
||||
RecruitResult, // 公开招募结果
|
||||
RecruitTagsDetected = 3000, // 公招识别到了Tags
|
||||
RecruitSpecialTag, // 公招识别到了特殊的Tag
|
||||
RecruitResult, // 公开招募结果
|
||||
RecruitSelected, // 选择了Tags
|
||||
/* Infrast Msg */
|
||||
InfrastSkillsDetected = 4000, // 识别到了基建技能(当前页面)
|
||||
@@ -402,8 +407,8 @@ namespace MeoAsstGui
|
||||
InfrastComb, // 当前房间的最优干员组合
|
||||
EnterFacility, // 进入某个房间
|
||||
FacilityInfo, // 当前设施信息
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
public enum InfrastWorkMode
|
||||
{
|
||||
Invaild = -1,
|
||||
|
||||
@@ -120,6 +120,9 @@
|
||||
<Compile Include="UserControl\AutoRecruitSettingsUserControl.xaml.cs">
|
||||
<DependentUpon>AutoRecruitSettingsUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\ConnectSettingsUserControl.xaml.cs">
|
||||
<DependentUpon>ConnectSettingsUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\MallSettingsUserControl.xaml.cs">
|
||||
<DependentUpon>MallSettingsUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -157,6 +160,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\ConnectSettingsUserControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\MallSettingsUserControl.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
31
src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml
Normal file
31
src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml
Normal file
@@ -0,0 +1,31 @@
|
||||
<UserControl x:Class="MeoAsstGui.ConnectSettingsUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="550">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Text="Tips: 以下设置均需要自行下载ADB
将platform-tools文件夹解压到本软件的同级目录" Margin="10" />
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center"
|
||||
Text="自定义地址" Margin="10" />
|
||||
<TextBox Text="{Binding ConnectAddress}" Margin="10"
|
||||
Width="150" InputMethod.IsInputMethodEnabled="False" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center"
|
||||
Text="bluestacks.conf
文件路径" Margin="10" />
|
||||
<TextBox Text="{Binding BluestacksConfPath}" Margin="10"
|
||||
Width="250" InputMethod.IsInputMethodEnabled="False" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,38 @@
|
||||
// MeoAssistanceGui - A part of the MeoAssistance-Arknight project
|
||||
// Copyright (C) 2021 MistEO and Contributors
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectSettingsUserControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ConnectSettingsUserControl : UserControl
|
||||
{
|
||||
public ConnectSettingsUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace MeoAsstGui
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstCatchDefault();
|
||||
return asstProxy.AsstCatch();
|
||||
});
|
||||
bool catchd = await task;
|
||||
if (!catchd)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
@@ -42,6 +43,7 @@ namespace MeoAsstGui
|
||||
_listTitle.Add("自动公招");
|
||||
_listTitle.Add("信用商店");
|
||||
_listTitle.Add("企鹅数据");
|
||||
_listTitle.Add("连接设置");
|
||||
_listTitle.Add("软件更新");
|
||||
//_listTitle.Add("其他");
|
||||
|
||||
@@ -356,5 +358,48 @@ namespace MeoAsstGui
|
||||
ViewStatusStorage.Set("VersionUpdate.Proxy", value);
|
||||
}
|
||||
}
|
||||
|
||||
/* 连接设置 */
|
||||
|
||||
private string _connectAddress = ViewStatusStorage.Get("Connect.Address", string.Empty);
|
||||
|
||||
public string ConnectAddress
|
||||
{
|
||||
get { return _connectAddress; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _connectAddress, value);
|
||||
ViewStatusStorage.Set("Connect.Address", value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _bluestacksConfPath = ViewStatusStorage.Get("Connect.BluestacksConfPath", string.Empty);
|
||||
|
||||
public string BluestacksConfPath
|
||||
{
|
||||
get { return _bluestacksConfPath; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _bluestacksConfPath, value);
|
||||
ViewStatusStorage.Set("Connect.BluestacksConfPath", value);
|
||||
}
|
||||
}
|
||||
|
||||
public void TryToSetBlueStacksHyperVAddress()
|
||||
{
|
||||
if (BluestacksConfPath.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var all_lines = File.ReadAllLines(BluestacksConfPath);
|
||||
foreach (var line in all_lines)
|
||||
{
|
||||
if (line.StartsWith("bst.instance.Nougat64.status.adb_port"))
|
||||
{
|
||||
var sp = line.Split('"');
|
||||
ConnectAddress = "127.0.0.1:" + sp[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace MeoAsstGui
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstCatchDefault();
|
||||
return asstProxy.AsstCatch();
|
||||
});
|
||||
bool catchd = await task;
|
||||
if (!catchd)
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<local:PenguinReportSettingsUserControl Margin="20" />
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[4]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:ConnectSettingsUserControl Margin="20" />
|
||||
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding ListTitle[5]}" Foreground="Gray" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<local:VersionUpdateSettingsUserControl Margin="20" />
|
||||
<!--<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="1" />-->
|
||||
</StackPanel>
|
||||
|
||||
Reference in New Issue
Block a user