Skip to content

Commit

Permalink
Merge pull request #227 from ONLOX/dev
Browse files Browse the repository at this point in the history
Update Installer
  • Loading branch information
DragonAura authored Apr 13, 2024
2 parents 574d6df + 8804605 commit bf33933
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 124 deletions.
16 changes: 8 additions & 8 deletions installer/Data/ConfigFileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public record CommandFile

public string Port { get; set; } = "8888";

public string TeamID { get; set; } = "0";
public int TeamID { get; set; } = 0;

public string PlayerID { get; set; } = "0";
public int PlayerID { get; set; } = 0;

public string ShipType { get; set; } = "0";
public int ShipType { get; set; } = 0;

public string PlaybackFile { get; set; } = "CLGG!@#$%^&*()_+";
public string? PlaybackFile { get; set; } = "CLGG!@#$%^&*()_+";

public double PlaybackSpeed { get; set; } = 2.0;

Expand Down Expand Up @@ -94,7 +94,7 @@ public string Port
}


public string TeamID
public int TeamID
{
get => file.TeamID;
set
Expand All @@ -107,7 +107,7 @@ public string TeamID
}


public string PlayerID
public int PlayerID
{
get => file.PlayerID;
set
Expand All @@ -120,7 +120,7 @@ public string PlayerID
}


public string ShipType
public int ShipType
{
get => file.ShipType;
set
Expand All @@ -133,7 +133,7 @@ public string ShipType
}


public string PlaybackFile
public string? PlaybackFile
{
get => file.PlaybackFile;
set
Expand Down
2 changes: 1 addition & 1 deletion installer/Model/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string Color
LogLevel.Trace => "Black",
LogLevel.Debug => "Black",
LogLevel.Information => "Black",
LogLevel.Warning => "Yellow",
LogLevel.Warning => "Tan",
LogLevel.Error => "Red",
LogLevel.Critical => "DarkRed",
_ => "White",
Expand Down
42 changes: 28 additions & 14 deletions installer/Page/InstallPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
<Grid
HorizontalOptions="Center"
WidthRequest="600"
RowDefinitions="*,*,*,*,*,*,*,*,*,*,*"
RowDefinitions="20,*,*,*,*,*,*,*,*,*,*"
ColumnDefinitions="*">


<VerticalStackLayout
Grid.Row="1"
Grid.RowSpan="10"
Expand All @@ -25,12 +24,12 @@
VerticalOptions="Center"
FontSize="16"/>
<Entry
WidthRequest="400"
WidthRequest="380"
Placeholder="请输入文件路径……"
Text="{Binding DownloadPath}"
FontSize="16"/>
<Button
WidthRequest="100"
WidthRequest="120"
Text="选择文件夹"
BorderWidth="2"
Command="{Binding BrowseBtnClickedCommand}"
Expand Down Expand Up @@ -69,8 +68,28 @@
TextColor="{Binding ConstTextColor}"/>
</HorizontalStackLayout>

<HorizontalStackLayout>
<CheckBox
IsChecked="{Binding Installed}"
IsEnabled="False"/>
<Label
WidthRequest="200"
Text="是否已下载选手包"
VerticalOptions="Center"
FontSize="{Binding ConstFontSize}"/>
</HorizontalStackLayout>

<Label
Text="{Binding DebugAlert1}"/>
Text="{Binding DebugAlert}"/>

<ProgressBar
Progress="{Binding NumProgress}"
HeightRequest="10"
WidthRequest="580"/>
<ProgressBar
Progress="{Binding FileProgress}"
HeightRequest="10"
WidthRequest="580"/>

<Frame
BorderColor="Gray"
Expand All @@ -86,17 +105,12 @@
VerticalScrollBarVisibility="Always">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid
ColumnDefinitions="*,*,*,*,*,*,*,*,*,*,*,*"
WidthRequest="570">

<Label
Grid.Column="1"
Grid.ColumnSpan="10"
Text="{Binding Message}"
TextColor="{Binding Color}"/>
<Label
WidthRequest="570"
Text="{Binding Message}"
TextColor="{Binding Color}"/>

</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Expand Down
65 changes: 46 additions & 19 deletions installer/Page/LaunchPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<Grid
HorizontalOptions="Center"
WidthRequest="600"
RowDefinitions="*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*"
RowDefinitions="20,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*"
ColumnDefinitions="*">

<VerticalStackLayout
Grid.Row="1"
Grid.RowSpan="16"
Grid.RowSpan="15"
HorizontalOptions="Center">

<HorizontalStackLayout>
Expand All @@ -24,10 +24,10 @@
FontSize="{Binding ConstFontSize}"/>
<Entry
WidthRequest="400"
Placeholder=""
Text="{Binding IP}"
FontSize="16"/>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Expand All @@ -36,46 +36,71 @@
FontSize="{Binding ConstFontSize}"/>
<Entry
WidthRequest="400"
Placeholder=""
Text="{Binding Port}"
FontSize="16"/>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Text="Player ID"
VerticalOptions="Center"
FontSize="{Binding ConstFontSize}"/>
<Entry
WidthRequest="400"
Placeholder=""
Text="{Binding PlayerID}"
FontSize="16"/>
<Picker
SelectedItem="{Binding PlayerID}"
WidthRequest="400">
<Picker.ItemsSource>
<x:Array
Type="{x:Type x:Int32}">
<x:Int32>0</x:Int32>
<x:Int32>1</x:Int32>
<x:Int32>2</x:Int32>
<x:Int32>3</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Text="Team ID"
VerticalOptions="Center"
FontSize="{Binding ConstFontSize}"/>
<Entry
WidthRequest="400"
Placeholder=""
Text="{Binding TeamID}"
FontSize="16"/>
<Picker
SelectedItem="{Binding TeamID}"
WidthRequest="400">
<Picker.ItemsSource>
<x:Array
Type="{x:Type x:Int32}">
<x:Int32>0</x:Int32>
<x:Int32>1</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Text="Ship Type"
VerticalOptions="Center"
FontSize="{Binding ConstFontSize}"/>
<Entry
WidthRequest="400"
Placeholder=""
Text="{Binding ShipType}"
FontSize="16"/>
<Picker
SelectedItem="{Binding ShipType}"
WidthRequest="400">
<Picker.ItemsSource>
<x:Array
Type="{x:Type x:Int32}">
<x:Int32>0</x:Int32>
<x:Int32>1</x:Int32>
<x:Int32>2</x:Int32>
<x:Int32>3</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Expand All @@ -88,6 +113,7 @@
Text="{Binding PlaybackFile}"
FontSize="16"/>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Expand All @@ -100,6 +126,7 @@
Text="{Binding PlaybackSpeed}"
FontSize="16"/>
</HorizontalStackLayout>

<HorizontalStackLayout>
<Label
WidthRequest="170"
Expand Down
2 changes: 1 addition & 1 deletion installer/Platforms/Windows/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />
<Identity Name="maui-package-name-placeholder" Publisher="CN=小土豆" Version="0.0.0.0" />

<mp:PhoneIdentity PhoneProductId="BE521FAE-F8D4-4572-98D2-0925E2B958BB" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
52 changes: 42 additions & 10 deletions installer/ViewModel/InstallViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public InstallViewModel(IFolderPicker folderPicker, Downloader downloader)
UpdateBtnClickedCommand = new AsyncRelayCommand(UpdateBtnClicked);
}

private string? debugAlert1;
public string? DebugAlert1
private string? debugAlert;
public string? DebugAlert
{
get => debugAlert1;
get => debugAlert;
set
{
debugAlert1 = value;
debugAlert = value;
OnPropertyChanged();
}
}
Expand All @@ -59,6 +59,37 @@ public string DownloadPath
OnPropertyChanged();
}
}

private bool installed;
public bool Installed
{
get => installed;
set
{
installed = value;
OnPropertyChanged();
}
}

public double NumProgress
{
get
{
if (Downloader.CloudReport.Count == 0)
return 1;
return Downloader.CloudReport.ComCount / Downloader.CloudReport.Count;
}
}
public double FileProgress
{
get
{
if (!Downloader.CloudReport.BigFileTraceEnabled)
return 1;
return Downloader.CloudReport.Completed / Downloader.CloudReport.Total;
}
}

private bool browseEnabled = true;
public bool BrowseEnabled
{
Expand Down Expand Up @@ -104,7 +135,7 @@ public bool UpdateEnabled
public ICommand BrowseBtnClickedCommand { get; }
private async Task BrowseBtnClicked()
{
// DebugAlert1 = "Browse Button Clicked";
// DebugAlert = "Browse Button Clicked";
BrowseEnabled = false;
CheckEnabled = false;
DownloadEnabled = false;
Expand All @@ -123,20 +154,20 @@ private async Task BrowseBtnClicked()
public ICommand CheckUpdBtnClickedCommand { get; }
private async void CheckUpdBtnClicked()
{
// DebugAlert1 = "Check Button Clicked";
// DebugAlert = "Check Button Clicked";
BrowseEnabled = false;
CheckEnabled = false;
DownloadEnabled = false;
UpdateEnabled = false;
bool updated = await Task.Run(() => Downloader.CheckUpdate());
if (updated)
{
DebugAlert1 = "Need to update.";
DebugAlert = "Need to update.";
UpdateEnabled = true;
}
else
{
DebugAlert1 = "Nothing to update.";
DebugAlert = "Nothing to update.";
UpdateEnabled = false;
}
BrowseEnabled = true;
Expand All @@ -145,7 +176,7 @@ private async void CheckUpdBtnClicked()
public ICommand DownloadBtnClickedCommand { get; }
private async Task DownloadBtnClicked()
{
// DebugAlert1 = "Download Button Clicked";
// DebugAlert = "Download Button Clicked";
BrowseEnabled = false;
CheckEnabled = false;
DownloadEnabled = false;
Expand All @@ -158,13 +189,14 @@ private async Task DownloadBtnClicked()
{
await Task.Run(() => Downloader.Install(DownloadPath));
}
Installed = Downloader.Data.Installed;
CheckEnabled = true;
BrowseEnabled = true;
}
public ICommand UpdateBtnClickedCommand { get; }
private async Task UpdateBtnClicked()
{
// DebugAlert1 = "Update Button Clicked";
// DebugAlert = "Update Button Clicked";
BrowseEnabled = false;
CheckEnabled = false;
DownloadEnabled = false;
Expand Down
Loading

0 comments on commit bf33933

Please sign in to comment.