Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
VolcanicArts committed Jan 9, 2023
2 parents 66d8446 + 392b578 commit 52f2efa
Show file tree
Hide file tree
Showing 64 changed files with 1,299 additions and 1,069 deletions.
189 changes: 0 additions & 189 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

Copyright (C) 2022 VolcanicArts
Copyright (C) 2023 VolcanicArts

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
105 changes: 64 additions & 41 deletions VRCOSC.Desktop/Updater/SquirrelUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,103 @@
// See the LICENSE file in the repository root for full license text.

using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Platform;
using Squirrel;
using VRCOSC.Game.Config;
using VRCOSC.Game.Graphics.Settings;
using VRCOSC.Game.Graphics.Updater;

namespace VRCOSC.Desktop.Updater;

public partial class SquirrelUpdateManager : VRCOSCUpdateManager
{
private GithubUpdateManager? updateManager;
private const string repo = "https://github.com/VolcanicArts/VRCOSC";

private readonly GithubUpdateManager updateManager;
private UpdateInfo? updateInfo;
private bool useDelta;

public SquirrelUpdateManager()
{
updateManager = new GithubUpdateManager(repo);
initialise();
}

private void initialise()
{
updateInfo = null;
useDelta = true;
}

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

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

public override async Task CheckForUpdate(string repo, bool useDelta = true)
private async Task checkForUpdateAsync()
{
Log("Checking for updates");

if (!updateManager.IsInstalledApp)
{
Log("Portable app detected. Cancelled update check");
return;
}

try
{
updateManager ??= new GithubUpdateManager(repo);
if (!updateManager.IsInstalledApp) return;
updateInfo = await updateManager.CheckForUpdate(!useDelta);

try
if (!updateInfo.ReleasesToApply.Any())
{
updateInfo = await updateManager.CheckForUpdate(!useDelta).ConfigureAwait(false);
if (updateInfo.ReleasesToApply.Count == 0) return;
Log("No updates found");
initialise();
return;
}

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

if (updateMode == UpdateMode.Auto)
await ApplyUpdates();
else
PostCheckNotification();
}
catch (Exception)
{
//delta update may have failed due to the installed version being too outdated. Retry without trying for delta
if (useDelta)
{
await CheckForUpdate(repo, false);
return;
}

throw;
}
if (ApplyUpdatesImmediately)
await ApplyUpdatesAsync();
else
PostUpdateAvailableNotification();
}
catch (Exception e)
{
PostFailNotification();
Logger.Error(e, "Updater Error");
LogError(e);
initialise();
}
}

protected override async Task ApplyUpdates()
protected override async Task ApplyUpdatesAsync()
{
if (updateManager is null || updateInfo is null)
Log("Attempting to apply updates");

if (updateInfo is null)
throw new InvalidOperationException("Cannot apply updates without checking");

try
{
var notification = PostProgressNotification();
await updateManager.DownloadReleases(updateInfo.ReleasesToApply, p => notification.Progress = map(p / 100f, 0, 1, 0, 0.5f)).ConfigureAwait(false);
await updateManager.ApplyReleases(updateInfo, p => notification.Progress = map(p / 100f, 0, 1, 0.5f, 1)).ConfigureAwait(false);
await updateManager.DownloadReleases(updateInfo.ReleasesToApply, p => notification.Progress = map(p / 100f, 0, 1, 0, 0.5f));
await updateManager.ApplyReleases(updateInfo, p => notification.Progress = map(p / 100f, 0, 1, 0.5f, 1));
PostSuccessNotification();
Log("Update successfully applied");
initialise();
}
catch (Exception)
catch (Exception e)
{
// Update may have failed due to the installed version being too outdated
// Retry without trying for delta
if (useDelta)
{
useDelta = false;
await checkForUpdateAsync();
return;
}

PostFailNotification();
LogError(e);
initialise();
}
}

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

protected override void RequestRestart()
protected override void Dispose(bool isDisposing)
{
UpdateManager.RestartAppWhenExited().ContinueWith(_ => host.Exit()).ConfigureAwait(false);
base.Dispose(isDisposing);
updateManager.Dispose();
}
}
4 changes: 2 additions & 2 deletions VRCOSC.Desktop/VRCOSC.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<ApplicationIcon>game.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>0.0.0</Version>
<FileVersion>2022.1226.0</FileVersion>
<FileVersion>2023.109.0</FileVersion>
<Title>VRCOSC</Title>
<Authors>VolcanicArts</Authors>
<Company>VolcanicArts</Company>
<Nullable>enable</Nullable>
<AssemblyVersion>2022.1226.0</AssemblyVersion>
<AssemblyVersion>2023.109.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions VRCOSC.Game/Config/VRCOSCConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ protected override void InitialiseDefaults()
SetDefault(VRCOSCSetting.SendPort, 9000);
SetDefault(VRCOSCSetting.ReceivePort, 9001);
SetDefault(VRCOSCSetting.UpdateMode, UpdateMode.Auto);
SetDefault(VRCOSCSetting.UpdateRepo, @"https://github.com/VolcanicArts/VRCOSC");
SetDefault(VRCOSCSetting.Theme, ColourTheme.Dark);
SetDefault(VRCOSCSetting.ChatBoxTimeSpan, 1500);
SetDefault(VRCOSCSetting.AutoStopOpenVR, false);
Expand All @@ -40,7 +39,6 @@ public enum VRCOSCSetting
SendPort,
ReceivePort,
UpdateMode,
UpdateRepo,
Theme,
ChatBoxTimeSpan,
AutoStopOpenVR
Expand Down
2 changes: 1 addition & 1 deletion VRCOSC.Game/Graphics/About/AboutScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void load()
{
text.Clear();
text.AddText($"VRCOSC {version.NewValue}");
text.AddParagraph("Copyright VolcanicArts 2022. See license file in repository root for more information");
text.AddParagraph("Copyright VolcanicArts 2023. See license file in repository root for more information");
}, true);
}

Expand Down
Loading

0 comments on commit 52f2efa

Please sign in to comment.