Browse Source

Merge branch 'dev' into renovate/grpcio-1.x

tags/v0.1.0
Timothy Liu GitHub 2 years ago
parent
commit
65b8a60f27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 162 additions and 43 deletions
  1. +1
    -1
      CAPI/python/requirements.txt
  2. +51
    -5
      installer/Installer/MainWindow.xaml
  3. +2
    -2
      installer/Installer/Model.cs
  4. +108
    -35
      installer/Installer/ViewModel.cs

+ 1
- 1
CAPI/python/requirements.txt View File

@@ -1,3 +1,3 @@
grpcio==1.54.2
grpcio-tools==1.54.0
grpcio-tools==1.54.2
numpy

+ 51
- 5
installer/Installer/MainWindow.xaml View File

@@ -52,7 +52,7 @@
<Button Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="2" Name="UninstBtn" Content="卸载选手包" Command="{Binding ClickUninstCommand}" Visibility="{Binding MenuVis}" />
<Button Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="2" Name="MenuBackBtn" Content="回到登陆界面" Command="{Binding ClickBackCommand}" Visibility="{Binding MenuVis}" />

<TextBlock Grid.Row="3" Grid.Column="3" Text="正在处理……" Grid.ColumnSpan="2" Visibility="{Binding ProgressVis}"/>
<TextBlock Grid.Row="3" Grid.Column="3" Text="{Binding ProcessingIntro}" Grid.ColumnSpan="2" Visibility="{Binding ProgressVis}"/>
<ProgressBar Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="7" Minimum="0" Maximum="100" Name="Progress" Visibility="{Binding ProgressVis}" IsIndeterminate="True"/>

<TextBlock Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="4" Text="操作完成!你可以继续操作或退出" Visibility="{Binding CompleteVis}"/>
@@ -81,10 +81,21 @@
<TextBlock Grid.Row="5" Grid.Column="1" Foreground="Red" Text=" 用户名或密码错误!" Visibility="{Binding LoginFailVis}"/>
</Grid>
</StackPanel>
<Button Grid.Row="7" Grid.Column="1" Name="Login" Content="登录" Command="{Binding ClickLoginCommand}" Visibility="{Binding LoginVis}"/>
<Button Grid.Row="7" Grid.Column="2" Name="Launch" FontSize="11" Content="{Binding LaunchBtnCont}" Command="{Binding ClickLaunchCommand}" Visibility="{Binding LoginVis}"/>
<Button Grid.Row="7" Grid.Column="3" Name="ShiftLanguage" FontSize="11" Content="更改语言" Command="{Binding ClickShiftLanguageCommand}" Visibility="{Binding LaunchVis}"/>
<StackPanel Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Name="Login" Content="登录" Command="{Binding ClickLoginCommand}" Visibility="{Binding LoginVis}"/>
<Button Grid.Row="0" Grid.Column="1" Name="Launch" Content="{Binding LaunchBtnCont}" Command="{Binding ClickLaunchCommand}" Visibility="{Binding LoginVis}" IsEnabled="{Binding UpdatePlanned}"/>
<Button Grid.Row="0" Grid.Column="2" Name="ShiftLanguage" FontSize="11" Content="配置启动器" Command="{Binding ClickShiftLanguageCommand}" Visibility="{Binding LaunchVis}" IsEnabled="False"/>
</Grid>
</StackPanel>
<Button Grid.Row="7" Grid.Column="4" Grid.ColumnSpan="2" Name="Edit" Content="修改文件" Command="{Binding ClickEditCommand}" Visibility="{Binding LoginVis}"/>


@@ -114,5 +125,40 @@
<Button Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" Content="申请对战" IsEnabled="False" Command="{Binding ClickRequestCommand}" Visibility="{Binding WebVis}" />
<TextBox Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2" Text="暂不支持" IsEnabled="False" Visibility="{Binding WebVis}" />
<!--objects below are enabled-->
<StackPanel Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="7">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Name ="ConfigServer" Content="服务端" Command="{Binding ClickCfgServCommand}" IsEnabled="{Binding ServerCfgNotSelected}" Visibility="{Binding CfgVis}"/>
<Button Grid.Column="1" Name ="ConfigAI" Content="客户端" Command="{Binding ClickCfgCliCommand}" IsEnabled="{Binding CliCfhNotSelected}" Visibility="{Binding CfgVis}"/>
<Button Grid.Column="2" Name ="ConfigCliend" Content="图形界面" Command="{Binding ClickCfgGUICommand}" IsEnabled="{Binding GUICfgNotSelected}" Visibility="{Binding CfgVis}"/>
</Grid>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="1" Grid.RowSpan="5" Grid.ColumnSpan="7">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
</StackPanel>
</Grid>
</Window>

+ 2
- 2
installer/Installer/Model.cs View File

@@ -405,7 +405,7 @@ namespace starter.viewmodel.settings
/// <summary>
/// 关于介绍的屏幕显示信息
/// </summary>
public enum Status { newUser, menu, move, working, disconnected, error, successful, login, web };
public enum Status { newUser, menu, move, working, initializing, disconnected, error, successful, login, web, launch };
public Status status
{
get; set;
@@ -881,7 +881,7 @@ namespace Downloader
int upcnt = updateFileName.Count;
if (upcnt <= 20)
{
while (newFileName.TryDequeue(out var filename))
while (updateFileName.TryDequeue(out var filename))
{
try
{


+ 108
- 35
installer/Installer/ViewModel.cs View File

@@ -22,6 +22,7 @@ namespace starter.viewmodel.settings
//定义BackgroundWorker
BackgroundWorker asyncDownloader;
BackgroundWorker asyncUpdater;
BackgroundWorker asyncInitializer;
/// <summary>
/// Model object
/// </summary>
@@ -38,7 +39,7 @@ namespace starter.viewmodel.settings
Status = SettingsModel.Status.working;
string currentDirectory = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName)
?? throw new Exception("Fail to get current directory");
MessageBox.Show("更新器工作正常");
//MessageBox.Show("更新器工作正常");
if (!Program.Tencent_cos_download.SelfUpdateDismissed())
{
switch (Program.Tencent_cos_download.CheckSelfVersion())
@@ -53,49 +54,91 @@ namespace starter.viewmodel.settings
}
}

//实例化BackgroundWorker
asyncDownloader = new BackgroundWorker();
asyncUpdater = new BackgroundWorker();
//指示BackgroundWorker是否可以报告进度更新
//当该属性值为True是,将可以成功调用ReportProgress方法,否则将引发InvalidOperationException异常。
asyncDownloader.WorkerReportsProgress = true;
asyncUpdater.WorkerReportsProgress = true;
//挂载方法:
asyncDownloader.DoWork += AsyncDownloader_DoWork;
asyncUpdater.DoWork += AsyncUpdater_DoWork;
//完成通知器:
asyncDownloader.RunWorkerCompleted += AsyncDownloader_RunWorkerCompleted;
asyncUpdater.RunWorkerCompleted += AsyncUpdater_RunWorkerCompleted;

UpdateInfoVis = Visibility.Collapsed;

if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload())
asyncInitializer = new BackgroundWorker();
asyncInitializer.WorkerReportsProgress = true;
asyncInitializer.DoWork += AsyncInitializer_DoWork;
asyncInitializer.RunWorkerCompleted += AsyncInitializer_RunWorkerCompleted;

asyncInitializer.RunWorkerAsync();
Status = SettingsModel.Status.initializing;

}

private void AsyncInitializer_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
{
if (e.Result == null)
{
Status = SettingsModel.Status.error;
}
else if ((int)e.Result == 1)
{
obj.checkUpdate();
Status = SettingsModel.Status.login;
this.RaisePropertyChanged("WindowWidth");
this.RaisePropertyChanged("LaunchVis");
if (obj.RecallUser())
RememberMe = true;
else
RememberMe = false;
this.RaisePropertyChanged("RememberMe");
this.RaisePropertyChanged("SwitchOSBtnCont");
//在启动时立刻检查更新,确保选手启动最新版选手包
//若有更新,将启动键改为更新键;
//相应地,使用login界面启动;
//结构:上方为登录框架,下方有“修改选手包”按钮

//下面几行是用来运行测试的代码
//Program.RunProgram.StartServerForDebug("0.0.0.0",8888,4,1,600,"video");
//Program.RunProgram.RunCpp("127.0.0.1",8888,4,1,false,true,false);
//Program.RunProgram.RunGUIClient("127.0.0.1", 8888, 0, true);
this.RaisePropertyChanged("UpdateBtnCont");
this.RaisePropertyChanged("LaunchBtnCont");
this.RaisePropertyChanged("Updateinfo");
this.RaisePropertyChanged("UpdatePlanned");
}
else
{
Route = Environment.GetEnvironmentVariable("USERPROFILE") + "\\THUAI6";
Status = SettingsModel.Status.newUser;
this.RaisePropertyChanged("WindowWidth");
}
}

private void AsyncInitializer_DoWork(object? sender, DoWorkEventArgs e)
{
if (asyncInitializer.CancellationPending)
{
Status = SettingsModel.Status.error;
e.Cancel = true;
return;
}
else
{
//实例化BackgroundWorker
asyncDownloader = new BackgroundWorker();
asyncUpdater = new BackgroundWorker();
//指示BackgroundWorker是否可以报告进度更新
//当该属性值为True是,将可以成功调用ReportProgress方法,否则将引发InvalidOperationException异常。
asyncDownloader.WorkerReportsProgress = true;
asyncUpdater.WorkerReportsProgress = true;
//挂载方法:
asyncDownloader.DoWork += AsyncDownloader_DoWork;
asyncUpdater.DoWork += AsyncUpdater_DoWork;
//完成通知器:
asyncDownloader.RunWorkerCompleted += AsyncDownloader_RunWorkerCompleted;
asyncUpdater.RunWorkerCompleted += AsyncUpdater_RunWorkerCompleted;

if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload())
{
obj.checkUpdate();

if (obj.RecallUser())
RememberMe = true;
else
RememberMe = false;

//在启动时立刻检查更新,确保选手启动最新版选手包
//若有更新,将启动键改为更新键;
//相应地,使用login界面启动;
//结构:上方为登录框架,下方有“修改选手包”按钮

//下面几行是用来运行测试的代码
//Program.RunProgram.StartServerForDebug("0.0.0.0",8888,4,1,600,"video");
//Program.RunProgram.RunCpp("127.0.0.1",8888,4,1,false,true,false);
//Program.RunProgram.RunGUIClient("127.0.0.1", 8888, 0, true);

e.Result = 1;
}
else
{
e.Result = 2;
}
}
}

@@ -153,6 +196,7 @@ namespace starter.viewmodel.settings
this.RaisePropertyChanged("UpdateInfo");
this.RaisePropertyChanged("LaunchBtnCont");
}
this.RaisePropertyChanged("UpdatePlanned");
}
}

@@ -257,6 +301,7 @@ namespace starter.viewmodel.settings
this.RaisePropertyChanged("LaunchVis");
this.RaisePropertyChanged("NewUserVis");
this.RaisePropertyChanged("ConfirmBtnCont");
this.RaisePropertyChanged("ProcessingIntro");
}
}
public string Intro
@@ -298,6 +343,21 @@ namespace starter.viewmodel.settings
}
}
}
public string ProcessingIntro
{
get
{
switch (Status)
{
case SettingsModel.Status.working:
return "正在下载";
case SettingsModel.Status.initializing:
return "正在检查更新";
default:
return "";
}
}
}
public string AbortOrSelLanguage
{
get
@@ -453,7 +513,7 @@ namespace starter.viewmodel.settings
{
get
{
return Status == SettingsModel.Status.working ? Visibility.Visible : Visibility.Collapsed;
return (Status == SettingsModel.Status.working || Status == SettingsModel.Status.initializing) ? Visibility.Visible : Visibility.Collapsed;
}
}
public Visibility CompleteVis
@@ -508,6 +568,13 @@ namespace starter.viewmodel.settings
return obj.status == SettingsModel.Status.login && (!obj.UpdatePlanned) ? Visibility.Visible : Visibility.Collapsed;
}
}
public Visibility CfgVis
{
get
{
return obj.status == SettingsModel.Status.launch ? Visibility.Visible : Visibility.Collapsed;
}
}

public string UpdateBtnCont
{
@@ -534,9 +601,9 @@ namespace starter.viewmodel.settings
if (obj.UpdatePlanned)
ans = "更新";
else if (obj.launchLanguage == SettingsModel.LaunchLanguage.cpp)
ans = "启动c++包";
ans = "启动选手包";
else
ans = "启动python包";
ans = "启动选手包";
return ans;
}
}
@@ -570,6 +637,11 @@ namespace starter.viewmodel.settings
}
}

public bool UpdatePlanned
{
get { return obj.UpdatePlanned; }
}

public string RouteSelectWindow(string type)
{
if (type == "Folder")
@@ -719,6 +791,7 @@ namespace starter.viewmodel.settings
this.RaisePropertyChanged("UpdateBtnCont");
this.RaisePropertyChanged("UpdateInfo");
this.RaisePropertyChanged("LaunchVis");
this.RaisePropertyChanged("UpdatePlanned");
}
}));
}


Loading…
Cancel
Save