-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86c6820
commit 222c8f5
Showing
8 changed files
with
388 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License. | ||
// See the LICENSE file in the repository root for full license text. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Logging; | ||
using osu.Framework.Platform; | ||
using Squirrel; | ||
using VRCOSC.Game.Graphics.Updater; | ||
|
||
namespace VRCOSC.Desktop.Updater; | ||
|
||
public class SquirrelUpdateManager : VRCOSCUpdateManager | ||
{ | ||
private GithubUpdateManager updateManager; | ||
private UpdateInfo updateInfo; | ||
|
||
[Resolved] | ||
private GameHost host { get; set; } | ||
|
||
public override async Task CheckForUpdate(bool useDelta) | ||
{ | ||
try | ||
{ | ||
Logger.Log("Attempting to find update..."); | ||
updateManager ??= new GithubUpdateManager(@"https://github.com/VolcanicArts/VRCOSC"); | ||
|
||
if (!updateManager.IsInstalledApp) | ||
{ | ||
Logger.Log("Cannot update. Not installed app"); | ||
return; | ||
} | ||
|
||
Logger.Log("Checking for update..."); | ||
updateInfo = await updateManager.CheckForUpdate(!useDelta).ConfigureAwait(false); | ||
|
||
if (updateInfo.ReleasesToApply.Count == 0) return; | ||
|
||
Logger.Log("Found updates to apply!"); | ||
|
||
Show(); | ||
|
||
ResetProgress(); | ||
UpdateText("Downloading..."); | ||
await updateManager.DownloadReleases(updateInfo.ReleasesToApply, progress => UpdateProgress(progress / 100f)).ConfigureAwait(false); | ||
|
||
ResetProgress(); | ||
UpdateText("Installing..."); | ||
await updateManager.ApplyReleases(updateInfo, progress => UpdateProgress(progress / 100f)).ConfigureAwait(false); | ||
|
||
CompleteUpdate(true); | ||
} | ||
catch (Exception) | ||
{ | ||
//delta update may have failed due to the installed version being too outdated. Retry without trying for delta | ||
if (useDelta) | ||
{ | ||
await CheckForUpdate(false).ConfigureAwait(false); | ||
return; | ||
} | ||
|
||
CompleteUpdate(false); | ||
throw; | ||
} | ||
} | ||
|
||
public override void RequestRestart() | ||
{ | ||
UpdateManager.RestartAppWhenExited().ContinueWith(_ => host.Exit()).ConfigureAwait(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License. | ||
// See the LICENSE file in the repository root for full license text. | ||
|
||
using VRCOSC.Desktop.Updater; | ||
using VRCOSC.Game; | ||
using VRCOSC.Game.Graphics.Updater; | ||
|
||
namespace VRCOSC.Desktop; | ||
|
||
public class VRCOSCGameDesktop : VRCOSCGame | ||
{ | ||
public override VRCOSCUpdateManager CreateUpdateManager() | ||
{ | ||
return new SquirrelUpdateManager(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License. | ||
// See the LICENSE file in the repository root for full license text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
|
||
namespace VRCOSC.Game.Graphics.Updater; | ||
|
||
public class UpdateBar : Container | ||
{ | ||
public Bindable<float> Progress = new(); | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
Box progressBar; | ||
|
||
Children = new Drawable[] | ||
{ | ||
new Box | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = VRCOSCColour.Gray3 | ||
}, | ||
progressBar = new Box | ||
{ | ||
Anchor = Anchor.CentreLeft, | ||
Origin = Anchor.CentreLeft, | ||
RelativeSizeAxes = Axes.Both, | ||
RelativePositionAxes = Axes.X, | ||
Colour = VRCOSCColour.Green, | ||
X = -1 | ||
} | ||
}; | ||
|
||
Progress.ValueChanged += (percentage) => progressBar.MoveToX(-1 + percentage.NewValue); | ||
} | ||
} |
Oops, something went wrong.