diff --git a/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs b/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs index c6127fc..bb7d96d 100644 --- a/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs +++ b/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs @@ -61,12 +61,34 @@ public void CheckAvailability ( RulesetIdentity ruleset ) { if ( ruleset.Source == Source.Web ) { ruleset.RequestDetail().ContinueWith( t => { - if ( !t.IsFaulted && t.Result.CanDownload ) { + if ( t.IsFaulted ) { + availability.Value |= Availability.NotAvailableOnline; + return; // TODO report this + } + + if ( t.Result.CanDownload ) { availability.Value |= Availability.AvailableOnline; } else { availability.Value |= Availability.NotAvailableOnline; } + + if ( ruleset.ListingEntry?.Status is Status s ) { + if ( File.Exists( ruleset.LocalPath ) ) { + var info = new FileInfo( ruleset.LocalPath ); + info.Refresh(); + + if ( s.LatestUpdate.HasValue && info.CreationTimeUtc < s.LatestUpdate.Value ) { + availability.Value |= Availability.Outdated; + } + else if ( info.Length != s.FileSize ) { + availability.Value |= Availability.Outdated; + } + } + else { + availability.Value |= Availability.Outdated; + } + } } ); } else { diff --git a/osu.Game.Rulesets.RurusettoAddon/UI/RulesetDownloadButton.cs b/osu.Game.Rulesets.RurusettoAddon/UI/RulesetDownloadButton.cs index df2f14b..135efb4 100644 --- a/osu.Game.Rulesets.RurusettoAddon/UI/RulesetDownloadButton.cs +++ b/osu.Game.Rulesets.RurusettoAddon/UI/RulesetDownloadButton.cs @@ -86,9 +86,18 @@ private void updateVisuals () { Icon.Alpha = 1; this.FadeTo( 1f, 200 ); Background.FadeColour( Colour4.FromHex( "#6CB946" ), 200, Easing.InOutExpo ); - Icon.Scale = new osuTK.Vector2( 1.7f ); - Icon.Icon = FontAwesome.Regular.CheckCircle; - TooltipText = Avail.Value.HasFlagFast( Availability.NotAvailableOnline ) ? "Installed, not available online" : "Installed"; + if ( Avail.Value.HasFlagFast( Availability.Outdated ) && Avail.Value.HasFlagFast( Availability.AvailableOnline ) && State.Value == DownloadState.NotDownloading ) { + Icon.Scale = new osuTK.Vector2( 1.5f ); + Icon.Icon = FontAwesome.Solid.Download; + + TooltipText = "Update"; + } + else { + Icon.Scale = new osuTK.Vector2( 1.7f ); + Icon.Icon = FontAwesome.Regular.CheckCircle; + + TooltipText = Avail.Value.HasFlagFast( Availability.NotAvailableOnline ) ? "Installed, not available online" : "Installed"; + } if ( State.Value == DownloadState.ToBeImported ) { warning.FadeIn( 200 ); @@ -156,16 +165,14 @@ private void updateVisuals () { } void onClick () { - if ( Avail.Value.HasFlagFast( Availability.AvailableLocally ) && currentRuleset is Bindable current && ruleset.LocalRulesetInfo is RulesetInfo info ) { - current.Value = info; + if ( Avail.Value.HasFlagFast( Availability.AvailableOnline ) && State.Value == DownloadState.NotDownloading && Avail.Value.HasFlagFast( Availability.Outdated ) ) { + DownloadManager.UpdateRuleset( ruleset ); } - else if ( Avail.Value.HasFlagFast( Availability.AvailableOnline ) && State.Value == DownloadState.NotDownloading ) { - if ( Avail.Value.HasFlagFast( Availability.Outdated ) ) { - DownloadManager.UpdateRuleset( ruleset ); - } - else if ( Avail.Value.HasFlagFast( Availability.NotAvailableLocally ) ) { - DownloadManager.DownloadRuleset( ruleset ); - } + else if ( Avail.Value.HasFlagFast( Availability.AvailableOnline ) && State.Value == DownloadState.NotDownloading && Avail.Value.HasFlagFast( Availability.NotAvailableLocally ) ) { + DownloadManager.DownloadRuleset( ruleset ); + } + else if ( Avail.Value.HasFlagFast( Availability.AvailableLocally ) && currentRuleset is Bindable current && ruleset.LocalRulesetInfo is RulesetInfo info ) { + current.Value = info; } }