Skip to content

Commit 52f2efa

Browse files
committed
Merge branch 'dev' into main
2 parents 66d8446 + 392b578 commit 52f2efa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1299
-1069
lines changed

.editorconfig

Lines changed: 0 additions & 189 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ copy of the Program in return for a fee.
620620

621621
END OF TERMS AND CONDITIONS
622622

623-
Copyright (C) 2022 VolcanicArts
623+
Copyright (C) 2023 VolcanicArts
624624

625625
This program is free software: you can redistribute it and/or modify
626626
it under the terms of the GNU General Public License as published by

VRCOSC.Desktop/Updater/SquirrelUpdateManager.cs

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,103 @@
22
// See the LICENSE file in the repository root for full license text.
33

44
using System;
5+
using System.Linq;
56
using System.Threading.Tasks;
6-
using osu.Framework.Allocation;
7-
using osu.Framework.Logging;
8-
using osu.Framework.Platform;
97
using Squirrel;
10-
using VRCOSC.Game.Config;
11-
using VRCOSC.Game.Graphics.Settings;
128
using VRCOSC.Game.Graphics.Updater;
139

1410
namespace VRCOSC.Desktop.Updater;
1511

1612
public partial class SquirrelUpdateManager : VRCOSCUpdateManager
1713
{
18-
private GithubUpdateManager? updateManager;
14+
private const string repo = "https://github.com/VolcanicArts/VRCOSC";
15+
16+
private readonly GithubUpdateManager updateManager;
1917
private UpdateInfo? updateInfo;
18+
private bool useDelta;
19+
20+
public SquirrelUpdateManager()
21+
{
22+
updateManager = new GithubUpdateManager(repo);
23+
initialise();
24+
}
25+
26+
private void initialise()
27+
{
28+
updateInfo = null;
29+
useDelta = true;
30+
}
2031

21-
[Resolved]
22-
private GameHost host { get; set; } = null!;
32+
protected override Task PrepareUpdateAsync() => UpdateManager.RestartAppWhenExited();
2333

24-
[Resolved]
25-
private VRCOSCConfigManager config { get; set; } = null!;
34+
public override async Task PerformUpdateCheck() => await checkForUpdateAsync().ConfigureAwait(false);
2635

27-
public override async Task CheckForUpdate(string repo, bool useDelta = true)
36+
private async Task checkForUpdateAsync()
2837
{
38+
Log("Checking for updates");
39+
40+
if (!updateManager.IsInstalledApp)
41+
{
42+
Log("Portable app detected. Cancelled update check");
43+
return;
44+
}
45+
2946
try
3047
{
31-
updateManager ??= new GithubUpdateManager(repo);
32-
if (!updateManager.IsInstalledApp) return;
48+
updateInfo = await updateManager.CheckForUpdate(!useDelta);
3349

34-
try
50+
if (!updateInfo.ReleasesToApply.Any())
3551
{
36-
updateInfo = await updateManager.CheckForUpdate(!useDelta).ConfigureAwait(false);
37-
if (updateInfo.ReleasesToApply.Count == 0) return;
52+
Log("No updates found");
53+
initialise();
54+
return;
55+
}
3856

39-
var updateMode = config.Get<UpdateMode>(VRCOSCSetting.UpdateMode);
57+
Log($"{updateInfo.ReleasesToApply.Count} updates found");
4058

41-
if (updateMode == UpdateMode.Auto)
42-
await ApplyUpdates();
43-
else
44-
PostCheckNotification();
45-
}
46-
catch (Exception)
47-
{
48-
//delta update may have failed due to the installed version being too outdated. Retry without trying for delta
49-
if (useDelta)
50-
{
51-
await CheckForUpdate(repo, false);
52-
return;
53-
}
54-
55-
throw;
56-
}
59+
if (ApplyUpdatesImmediately)
60+
await ApplyUpdatesAsync();
61+
else
62+
PostUpdateAvailableNotification();
5763
}
5864
catch (Exception e)
5965
{
6066
PostFailNotification();
61-
Logger.Error(e, "Updater Error");
67+
LogError(e);
68+
initialise();
6269
}
6370
}
6471

65-
protected override async Task ApplyUpdates()
72+
protected override async Task ApplyUpdatesAsync()
6673
{
67-
if (updateManager is null || updateInfo is null)
74+
Log("Attempting to apply updates");
75+
76+
if (updateInfo is null)
6877
throw new InvalidOperationException("Cannot apply updates without checking");
6978

7079
try
7180
{
7281
var notification = PostProgressNotification();
73-
await updateManager.DownloadReleases(updateInfo.ReleasesToApply, p => notification.Progress = map(p / 100f, 0, 1, 0, 0.5f)).ConfigureAwait(false);
74-
await updateManager.ApplyReleases(updateInfo, p => notification.Progress = map(p / 100f, 0, 1, 0.5f, 1)).ConfigureAwait(false);
82+
await updateManager.DownloadReleases(updateInfo.ReleasesToApply, p => notification.Progress = map(p / 100f, 0, 1, 0, 0.5f));
83+
await updateManager.ApplyReleases(updateInfo, p => notification.Progress = map(p / 100f, 0, 1, 0.5f, 1));
7584
PostSuccessNotification();
85+
Log("Update successfully applied");
86+
initialise();
7687
}
77-
catch (Exception)
88+
catch (Exception e)
7889
{
90+
// Update may have failed due to the installed version being too outdated
91+
// Retry without trying for delta
92+
if (useDelta)
93+
{
94+
useDelta = false;
95+
await checkForUpdateAsync();
96+
return;
97+
}
98+
7999
PostFailNotification();
100+
LogError(e);
101+
initialise();
80102
}
81103
}
82104

@@ -85,8 +107,9 @@ private static float map(float source, float sMin, float sMax, float dMin, float
85107
return dMin + (dMax - dMin) * ((source - sMin) / (sMax - sMin));
86108
}
87109

88-
protected override void RequestRestart()
110+
protected override void Dispose(bool isDisposing)
89111
{
90-
UpdateManager.RestartAppWhenExited().ContinueWith(_ => host.Exit()).ConfigureAwait(false);
112+
base.Dispose(isDisposing);
113+
updateManager.Dispose();
91114
}
92115
}

VRCOSC.Desktop/VRCOSC.Desktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<ApplicationIcon>game.ico</ApplicationIcon>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Version>0.0.0</Version>
9-
<FileVersion>2022.1226.0</FileVersion>
9+
<FileVersion>2023.109.0</FileVersion>
1010
<Title>VRCOSC</Title>
1111
<Authors>VolcanicArts</Authors>
1212
<Company>VolcanicArts</Company>
1313
<Nullable>enable</Nullable>
14-
<AssemblyVersion>2022.1226.0</AssemblyVersion>
14+
<AssemblyVersion>2023.109.0</AssemblyVersion>
1515
</PropertyGroup>
1616
<ItemGroup Label="Project References">
1717
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />

VRCOSC.Game/Config/VRCOSCConfigManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ protected override void InitialiseDefaults()
2525
SetDefault(VRCOSCSetting.SendPort, 9000);
2626
SetDefault(VRCOSCSetting.ReceivePort, 9001);
2727
SetDefault(VRCOSCSetting.UpdateMode, UpdateMode.Auto);
28-
SetDefault(VRCOSCSetting.UpdateRepo, @"https://github.com/VolcanicArts/VRCOSC");
2928
SetDefault(VRCOSCSetting.Theme, ColourTheme.Dark);
3029
SetDefault(VRCOSCSetting.ChatBoxTimeSpan, 1500);
3130
SetDefault(VRCOSCSetting.AutoStopOpenVR, false);
@@ -40,7 +39,6 @@ public enum VRCOSCSetting
4039
SendPort,
4140
ReceivePort,
4241
UpdateMode,
43-
UpdateRepo,
4442
Theme,
4543
ChatBoxTimeSpan,
4644
AutoStopOpenVR

VRCOSC.Game/Graphics/About/AboutScreen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void load()
8888
{
8989
text.Clear();
9090
text.AddText($"VRCOSC {version.NewValue}");
91-
text.AddParagraph("Copyright VolcanicArts 2022. See license file in repository root for more information");
91+
text.AddParagraph("Copyright VolcanicArts 2023. See license file in repository root for more information");
9292
}, true);
9393
}
9494

0 commit comments

Comments
 (0)