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