mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
feat: 修改linkstart逻辑,增加第一次连接失败时尝试重启模拟器 (#947)
This commit is contained in:
@@ -126,7 +126,6 @@ namespace MeoAsstGui
|
||||
var mainModel = _container.Get<TaskQueueViewModel>();
|
||||
mainModel.Idle = true;
|
||||
var settingsModel = _container.Get<SettingsViewModel>();
|
||||
|
||||
Execute.OnUIThread(async () =>
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
@@ -709,7 +708,7 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
public bool AsstConnect(ref string error)
|
||||
public bool AsstConnect(ref string error, bool firsttry = false)
|
||||
{
|
||||
if (!LoadGlobalResource())
|
||||
{
|
||||
@@ -750,7 +749,9 @@ namespace MeoAsstGui
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
error = "连接失败\n请检查连接设置";
|
||||
if (firsttry)
|
||||
error = "连接失败\n正在尝试启动模拟器";
|
||||
else error = "连接失败\n请检查连接设置";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -34,17 +34,17 @@
|
||||
Content="启动后自动开启模拟器" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10">
|
||||
<TextBlock Margin="3" Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center" Text="等待模拟器
启动时间(秒)" />
|
||||
<TextBox Margin="3" Text="{Binding EmulatorWaitSeconds}" IsEnabled="{Binding StartEmulator}" InputMethod.IsInputMethodEnabled="False" Width="50" />
|
||||
<TextBox Margin="3" Text="{Binding EmulatorWaitSeconds}" InputMethod.IsInputMethodEnabled="False" Width="50" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Margin="10" Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center" Text="模拟器路径" />
|
||||
<Button Command="{s:Action SelectEmulatorExec}" IsEnabled="{Binding StartEmulator}" Content="选择" Margin="10" />
|
||||
<Button Command="{s:Action SelectEmulatorExec}" Content="选择" Margin="10" />
|
||||
</StackPanel>
|
||||
<TextBox Text="{Binding EmulatorPath}" IsEnabled="{Binding StartEmulator}" Margin="10" />
|
||||
<TextBox Text="{Binding EmulatorPath}" Margin="10" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Margin="10" Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center" Text="附加命令" />
|
||||
</StackPanel>
|
||||
<TextBox Text="{Binding EmulatorAddCommand}" IsEnabled="{Binding StartEmulator}" Margin="10" />
|
||||
<TextBox Text="{Binding EmulatorAddCommand}" Margin="10" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -232,11 +232,12 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
public void TryToStartEmulator()
|
||||
public void TryToStartEmulator(bool manual = false)
|
||||
{
|
||||
if (!StartEmulator
|
||||
|| EmulatorPath.Length == 0
|
||||
if ((EmulatorPath.Length == 0
|
||||
|| !File.Exists(EmulatorPath))
|
||||
|| !(StartEmulator
|
||||
|| manual))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -251,14 +251,29 @@ namespace MeoAsstGui
|
||||
string errMsg = "";
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstConnect(ref errMsg);
|
||||
return asstProxy.AsstConnect(ref errMsg, true);
|
||||
});
|
||||
bool catchd = await task;
|
||||
if (!catchd)
|
||||
{
|
||||
AddLog(errMsg, "darkred");
|
||||
Idle = true;
|
||||
return;
|
||||
var settingsModel = _container.Get<SettingsViewModel>();
|
||||
var subtask = Task.Run(() =>
|
||||
{
|
||||
settingsModel.TryToStartEmulator(true);
|
||||
});
|
||||
await subtask;
|
||||
task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstConnect(ref errMsg);
|
||||
});
|
||||
catchd = await task;
|
||||
if (!catchd)
|
||||
{
|
||||
AddLog(errMsg, "darkred");
|
||||
Idle = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
|
||||
Reference in New Issue
Block a user