From b79f3c6afabba2fb4822b01eaca82f229347f7dd Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Mon, 22 Apr 2019 19:31:59 -0500 Subject: [PATCH] Added restart button for when mods are installed after an update --- BSIPA-ModList/DownloadController.cs | 15 +++++----- .../DownloadProgressViewController.cs | 28 +++++++++++++++---- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/BSIPA-ModList/DownloadController.cs b/BSIPA-ModList/DownloadController.cs index 5d08bebf..4891ebc6 100644 --- a/BSIPA-ModList/DownloadController.cs +++ b/BSIPA-ModList/DownloadController.cs @@ -64,7 +64,7 @@ namespace BSIPA_ModList private enum States { - Start, Checking, UpdatesFound, Downloading, Done + Start, Checking, UpdatesFound, Downloading, Done, DoneWithNoUpdates } private States _state = States.Start; @@ -78,12 +78,13 @@ namespace BSIPA_ModList } } - public bool CanCheck => State == States.Start || State == States.Done; + public bool CanCheck => State == States.Start || IsDone; public bool CanDownload => State == States.UpdatesFound; public bool CanReset => State == States.UpdatesFound; public bool IsChecking => State == States.Checking; public bool IsDownloading => State == States.Downloading; - public bool IsDone => State == States.Done; + public bool IsDone => State == States.Done || State == States.DoneWithNoUpdates; + public bool HadUpdates => State == States.Done; public void Awake() => DontDestroyOnLoad(this); @@ -147,7 +148,7 @@ namespace BSIPA_ModList OnDownloaderListChanged?.Invoke(); if (downloads.Count == 0) - OnAllDownloadsCompleted(); + OnAllDownloadsCompleted(false); else if (SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate) StartDownloads(); } @@ -204,12 +205,12 @@ namespace BSIPA_ModList Remove(obj); if (downloads.Count == 0) - OnAllDownloadsCompleted(); + OnAllDownloadsCompleted(true); } - private void OnAllDownloadsCompleted() + private void OnAllDownloadsCompleted(bool hadUpdates) { - State = States.Done; + State = hadUpdates ? States.Done : States.DoneWithNoUpdates; } } } diff --git a/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs b/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs index cb60390a..c5fe5416 100644 --- a/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs +++ b/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using CustomUI.BeatSaber; using CustomUI.Utilities; @@ -19,11 +21,16 @@ namespace BSIPA_ModList.UI.ViewControllers private Button _checkForUpdates; private Button _downloadUpdates; + private Button _restartGame; private TableView _currentlyUpdatingTableView; private LevelListTableCell _songListTableCellInstance; private Button _pageUpButton; private Button _pageDownButton; + private const float TableXOffset = -20f; + private const float ButtonXOffset = 36f; + private static readonly Vector2 ButtonSize = new Vector2(40f, 10f); + protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation && type == ActivationType.AddedToHierarchy) @@ -40,7 +47,7 @@ namespace BSIPA_ModList.UI.ViewControllers _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll