mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Fix some oversights and test failures
This commit is contained in:
parent
f014ceaead
commit
746d6a4c16
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -145,7 +144,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public new bool DownloadEnabled => base.DownloadEnabled;
|
||||
|
||||
public DownloadState DownloadState => this.ChildrenOfType<BeatmapDownloadTracker>().First().State.Value;
|
||||
public DownloadState DownloadState => State.Value;
|
||||
|
||||
public TestDownloadButton(BeatmapSetInfo beatmapSet)
|
||||
: base(beatmapSet)
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Online
|
||||
// Used to interact with manager classes that don't support interface types. Will eventually be replaced.
|
||||
var beatmapSetInfo = new BeatmapSetInfo { OnlineBeatmapSetID = TrackedItem.OnlineID };
|
||||
|
||||
if ((TrackedItem as BeatmapSetInfo)?.ID > 0 || Manager?.IsAvailableLocally(beatmapSetInfo) == true)
|
||||
if (Manager?.IsAvailableLocally(beatmapSetInfo) == true)
|
||||
UpdateState(DownloadState.LocallyAvailable);
|
||||
else if (Manager != null)
|
||||
attachDownload(Manager.GetExistingDownload(beatmapSetInfo));
|
||||
@ -122,10 +122,8 @@ namespace osu.Game.Online
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
if (!checkEquality(item, TrackedItem))
|
||||
return;
|
||||
|
||||
UpdateState(DownloadState.LocallyAvailable);
|
||||
if (checkEquality(item, TrackedItem))
|
||||
UpdateState(DownloadState.LocallyAvailable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
@ -17,10 +18,12 @@ namespace osu.Game.Online.Rooms
|
||||
/// This differs from a regular download tracking composite as this accounts for the
|
||||
/// databased beatmap set's checksum, to disallow from playing with an altered version of the beatmap.
|
||||
/// </summary>
|
||||
public class OnlinePlayBeatmapAvailabilityTracker : CompositeDrawable
|
||||
public sealed class OnlinePlayBeatmapAvailabilityTracker : CompositeDrawable
|
||||
{
|
||||
public readonly IBindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
protected override bool RequiresChildrenUpdate => true;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
@ -46,9 +49,10 @@ namespace osu.Game.Online.Rooms
|
||||
if (item.NewValue == null)
|
||||
return;
|
||||
|
||||
downloadTracker?.Expire();
|
||||
downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet);
|
||||
downloadTracker?.RemoveAndDisposeImmediately();
|
||||
|
||||
downloadTracker = new BeatmapDownloadTracker(item.NewValue.Beatmap.Value.BeatmapSet);
|
||||
downloadTracker.State.BindValueChanged(_ => updateAvailability());
|
||||
downloadTracker.Progress.BindValueChanged(_ =>
|
||||
{
|
||||
if (downloadTracker.State.Value != DownloadState.Downloading)
|
||||
@ -60,8 +64,6 @@ namespace osu.Game.Online.Rooms
|
||||
progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500);
|
||||
});
|
||||
|
||||
downloadTracker.State.BindValueChanged(_ => updateAvailability(), true);
|
||||
|
||||
AddInternal(downloadTracker);
|
||||
}, true);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
public BeatmapPanelDownloadButton(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
this.beatmapSet = beatmapSet;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
shakeContainer = new ShakeContainer
|
||||
@ -44,6 +45,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
Child = button = new DownloadButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { BindTarget = State }
|
||||
},
|
||||
},
|
||||
DownloadTracker = new BeatmapDownloadTracker(beatmapSet)
|
||||
@ -60,14 +62,6 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
((IBindable<DownloadState>)button.State).BindTo(DownloadTracker.State);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, BeatmapManager beatmaps, OsuConfigManager osuConfig)
|
||||
{
|
||||
@ -96,7 +90,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
}
|
||||
};
|
||||
|
||||
DownloadTracker.State.BindValueChanged(state =>
|
||||
State.BindValueChanged(state =>
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
@ -116,5 +110,11 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
|
||||
cover.BeatmapSet = setInfo.NewValue;
|
||||
|
||||
downloadTracker?.Expire();
|
||||
downloadTracker?.RemoveAndDisposeImmediately();
|
||||
|
||||
if (setInfo.NewValue == null)
|
||||
{
|
||||
|
@ -289,7 +289,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
// required for download tracking, as this button hides itself. can probably be removed with a bit of consideration.
|
||||
public override bool IsPresent => true;
|
||||
|
||||
public PlaylistDownloadButton(PlaylistItem playlistItem)
|
||||
: base(playlistItem.Beatmap.Value.BeatmapSet)
|
||||
@ -300,10 +301,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
State.BindValueChanged(stateChanged, true);
|
||||
base.LoadComplete();
|
||||
|
||||
DownloadTracker.State.BindValueChanged(stateChanged, true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void stateChanged(ValueChangedEvent<DownloadState> state)
|
||||
|
@ -67,8 +67,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
[Cached]
|
||||
protected OnlinePlayBeatmapAvailabilityTracker BeatmapAvailabilityTracker { get; private set; }
|
||||
|
||||
protected IBindable<BeatmapAvailability> BeatmapAvailability => BeatmapAvailabilityTracker.Availability;
|
||||
|
||||
public readonly Room Room;
|
||||
private readonly bool allowEdit;
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
SelectedItem.BindTo(client.CurrentMatchPlayingItem);
|
||||
|
||||
BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
|
||||
BeatmapAvailabilityTracker.Availability.BindValueChanged(updateBeatmapAvailability, true);
|
||||
UserMods.BindValueChanged(onUserModsChanged);
|
||||
|
||||
client.LoadRequested += onLoadRequested;
|
||||
@ -362,7 +362,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
private void onLoadRequested()
|
||||
{
|
||||
if (BeatmapAvailability.Value.State != DownloadState.LocallyAvailable)
|
||||
if (BeatmapAvailabilityTracker.Availability.Value.State != DownloadState.LocallyAvailable)
|
||||
return;
|
||||
|
||||
// In the case of spectating, IMultiplayerClient.LoadRequested can be fired while the game is still spectating a previous session.
|
||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
Score.BindValueChanged(score =>
|
||||
{
|
||||
downloadTracker?.Expire();
|
||||
downloadTracker?.RemoveAndDisposeImmediately();
|
||||
|
||||
if (score.NewValue != null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user