Skip to content

Commit 1c0be75

Browse files
authored
fixes Download bar and window buttons (#232)
1 parent 16b7292 commit 1c0be75

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

UnitystationLauncher/Services/TTSService.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
using System.IO;
55
using System.IO.Compression;
66
using System.Net.Http;
7+
using System.Reactive.Concurrency;
78
using System.Text.Json;
89
using System.Threading;
910
using System.Threading.Tasks;
1011
using Avalonia.Controls.Shapes;
1112
using Mono.Unix;
13+
using ReactiveUI;
1214
using Serilog;
1315
using SharpCompress.Archives;
1416
using SharpCompress.Archives.Tar;
@@ -130,18 +132,19 @@ public async Task CheckAndDownloadLatestVersion(Download Download)
130132

131133
Download.Active = true;
132134
Download.DownloadState = DownloadState.InProgress;
135+
133136
HttpResponseMessage request = await _httpClient.GetAsync(ApiUrls.TTSFiles + "/" + zip,
134137
HttpCompletionOption.ResponseHeadersRead);
135138

136-
Download.Size = request.Content.Headers.ContentLength ??
137-
throw new ContentLengthNullException(ApiUrls.TTSFiles + "/" + zip);
138139
using Stream responseStream = await request.Content.ReadAsStreamAsync();
139140
Log.Information("Download connection established");
140141
await using ProgressStream progressStream = new(responseStream);
141142
using IDisposable logProgressDisposable = InstallationService.LogProgress(progressStream, Download);
142143

143-
using IDisposable progressDisposable =
144-
progressStream.Progress.Subscribe(p => { Download.Downloaded = p; });
144+
Download.Size = request.Content.Headers.ContentLength ??
145+
throw new ContentLengthNullException(ApiUrls.TTSFiles + "/" + zip);
146+
147+
using IDisposable progressDisposable = progressStream.Progress.Subscribe(p => { Download.Downloaded = p; });
145148

146149
await Task.Run(() => ExtractTo(progressStream, LocalVersion, Download));
147150
}
@@ -157,18 +160,20 @@ public async Task CheckAndDownloadLatestVersion(Download Download)
157160

158161
private void ExtractTo(Stream progressStream, string LocalVersion, Download Download)
159162
{
160-
Download.DownloadState = DownloadState.Extracting;
163+
161164
switch (_environmentService.GetCurrentEnvironment())
162165
{
163166
case CurrentEnvironment.WindowsStandalone:
164167
{
165168
ZipArchive archive = new(progressStream);
169+
Download.DownloadState = DownloadState.Extracting;
166170
archive.ExtractToDirectory(LocalVersion, true);
167171
break;
168172
}
169173
case CurrentEnvironment.LinuxStandalone or CurrentEnvironment.LinuxFlatpak:
170174
{
171175
using var decompressedStream = DecompressXz(progressStream); // Decompress XZ stream to get .tar
176+
172177
ExtractTar(decompressedStream, LocalVersion);
173178
break;
174179
}
@@ -220,11 +225,13 @@ private void ExtractTar(Stream tarStream, string destinationPath)
220225
return _environmentService.GetCurrentEnvironment() switch
221226
{
222227
CurrentEnvironment.WindowsStandalone
223-
=> (Path.Combine(installationBasePath, "tts", "python-3.10.11.amd64", "python.exe"), Path.Combine(installationBasePath, "tts", "scripts")),
228+
=> (Path.Combine(installationBasePath, "tts", "python-3.10.11.amd64", "python.exe"),
229+
Path.Combine(installationBasePath, "tts", "scripts")),
224230
CurrentEnvironment.MacOsStandalone
225231
=> throw new NotImplementedException("tts Mac Support not implemented"),
226232
CurrentEnvironment.LinuxStandalone or CurrentEnvironment.LinuxFlatpak
227-
=> (Path.Combine(installationBasePath, "tts", "bin", "python"), Path.Combine(installationBasePath, "tts", "bin")),
233+
=> (Path.Combine(installationBasePath, "tts", "bin", "python"),
234+
Path.Combine(installationBasePath, "tts", "bin")),
228235
_ => (null, null)
229236
};
230237
}

UnitystationLauncher/Views/MainWindow.xaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
MinWidth="800"
1515
MinHeight="555"
1616
Background="#19212c"
17-
x:DataType="viewModels:MainWindowViewModel">
18-
17+
x:DataType="viewModels:MainWindowViewModel"
18+
SystemDecorations="None">
19+
1920
<Design.DataContext>
20-
<viewModels:MainWindowViewModel/>
21+
<viewModels:MainWindowViewModel />
2122
</Design.DataContext>
2223
<Grid>
2324
<Grid.RowDefinitions>
@@ -40,13 +41,13 @@
4041
</TextBlock>
4142
</StackPanel>
4243
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
43-
<Button Width="40" Name="MinimizeButton" ToolTip.Tip="Minimize">
44+
<!-- Minimize Button -->
45+
<Button Width="50" Height="30" Name="MinimizeButton" ToolTip.Tip="Minimize">
4446
<Button.Styles>
4547
<Style Selector="Button">
4648
<Setter Property="BorderThickness" Value="0" />
4749
</Style>
48-
<Style
49-
Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
50+
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
5051
<Setter Property="Background" Value="#44AAAAAA" />
5152
</Style>
5253
<Style
@@ -59,16 +60,14 @@
5960
Fill="White"
6061
Data="M2048 1229v-205h-2048v205h2048z" />
6162
</Button>
62-
<Button Width="40" Name="MaximizeButton">
63-
<ToolTip.Tip>
64-
<ToolTip Content="{Binding MaximizeToolTip}" />
65-
</ToolTip.Tip>
63+
64+
<!-- Maximize/Restore Button -->
65+
<Button Width="50" Height="30" Name="MaximizeButton" ToolTip.Tip="Maximize">
6666
<Button.Styles>
6767
<Style Selector="Button">
6868
<Setter Property="BorderThickness" Value="0" />
6969
</Style>
70-
<Style
71-
Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
70+
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
7271
<Setter Property="Background" Value="#44AAAAAA" />
7372
</Style>
7473
<Style
@@ -81,13 +80,14 @@
8180
Fill="#dedede"
8281
Data="{Binding MaximizeIcon}" />
8382
</Button>
84-
<Button Width="40" Name="CloseButton" ToolTip.Tip="Close">
83+
84+
<!-- Close Button -->
85+
<Button Width="50" Height="30" Name="CloseButton" ToolTip.Tip="Close">
8586
<Button.Styles>
8687
<Style Selector="Button">
8788
<Setter Property="BorderThickness" Value="0" />
8889
</Style>
89-
<Style
90-
Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
90+
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
9191
<Setter Property="Background" Value="#99810a0f" />
9292
</Style>
9393
<Style

0 commit comments

Comments
 (0)