mirror of
https://github.com/osukey/osukey.git
synced 2025-05-03 20:57:28 +09:00
Fix various crashes due to bindable being disabled
This commit is contained in:
parent
ad124bfeec
commit
cbb3fdaca8
@ -35,10 +35,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private WorkingBeatmap defaultBeatmap;
|
private WorkingBeatmap defaultBeatmap;
|
||||||
private DatabaseContextFactory factory;
|
private DatabaseContextFactory factory;
|
||||||
|
|
||||||
[Cached]
|
|
||||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
|
||||||
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(Screens.Select.SongSelect),
|
typeof(Screens.Select.SongSelect),
|
||||||
@ -185,7 +181,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
||||||
AddAssert("empty mods", () => !selectedMods.Value.Any());
|
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
||||||
|
|
||||||
void onModChange(ValueChangedEvent<IEnumerable<Mod>> e) => modChangeIndex = actionIndex++;
|
void onModChange(ValueChangedEvent<IEnumerable<Mod>> e) => modChangeIndex = actionIndex++;
|
||||||
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex--;
|
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex--;
|
||||||
@ -218,7 +214,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private static int importId;
|
private static int importId;
|
||||||
private int getImportId() => ++importId;
|
private int getImportId() => ++importId;
|
||||||
|
|
||||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => selectedMods.Value = mods);
|
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods);
|
||||||
|
|
||||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -42,9 +41,6 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
|
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
protected Bindable<IEnumerable<Mod>> SelectedMods { get; private set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -14,7 +13,6 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Multi.Ranking;
|
using osu.Game.Screens.Multi.Ranking;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -37,9 +35,6 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private Bindable<IEnumerable<Mod>> selectedMods { get; set; }
|
|
||||||
|
|
||||||
public TimeshiftPlayer(PlaylistItem playlistItem)
|
public TimeshiftPlayer(PlaylistItem playlistItem)
|
||||||
{
|
{
|
||||||
this.playlistItem = playlistItem;
|
this.playlistItem = playlistItem;
|
||||||
@ -61,7 +56,7 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
||||||
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
||||||
|
|
||||||
if (!playlistItem.RequiredMods.All(m => selectedMods.Value.Contains(m)))
|
if (!playlistItem.RequiredMods.All(m => SelectedMods.Value.Contains(m)))
|
||||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||||
|
|
||||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||||
|
@ -66,6 +66,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
Beatmap.Disabled = true;
|
Beatmap.Disabled = true;
|
||||||
Ruleset.Disabled = true;
|
Ruleset.Disabled = true;
|
||||||
|
SelectedMods.Disabled = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,6 +77,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
Beatmap.Disabled = false;
|
Beatmap.Disabled = false;
|
||||||
Ruleset.Disabled = false;
|
Ruleset.Disabled = false;
|
||||||
|
SelectedMods.Disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
|
[Cached]
|
||||||
|
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||||
|
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
|
||||||
|
|
||||||
protected SongSelect()
|
protected SongSelect()
|
||||||
{
|
{
|
||||||
@ -217,6 +219,8 @@ namespace osu.Game.Screens.Select
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins)
|
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins)
|
||||||
{
|
{
|
||||||
|
selectedMods.BindTo(SelectedMods);
|
||||||
|
|
||||||
if (Footer != null)
|
if (Footer != null)
|
||||||
{
|
{
|
||||||
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
|
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
|
||||||
@ -265,11 +269,6 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
SelectedMods.BindTo(base.SelectedMods);
|
|
||||||
|
|
||||||
dependencies.CacheAs(SelectedMods);
|
|
||||||
dependencies.CacheAs<IBindable<IEnumerable<Mod>>>(SelectedMods);
|
|
||||||
|
|
||||||
dependencies.CacheAs(this);
|
dependencies.CacheAs(this);
|
||||||
dependencies.CacheAs(decoupledRuleset);
|
dependencies.CacheAs(decoupledRuleset);
|
||||||
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
|
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
|
||||||
@ -395,7 +394,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
Logger.Log($"ruleset changed from \"{decoupledRuleset.Value}\" to \"{ruleset}\"");
|
Logger.Log($"ruleset changed from \"{decoupledRuleset.Value}\" to \"{ruleset}\"");
|
||||||
|
|
||||||
SelectedMods.Value = Enumerable.Empty<Mod>();
|
selectedMods.Value = Enumerable.Empty<Mod>();
|
||||||
decoupledRuleset.Value = ruleset;
|
decoupledRuleset.Value = ruleset;
|
||||||
|
|
||||||
// force a filter before attempting to change the beatmap.
|
// force a filter before attempting to change the beatmap.
|
||||||
@ -530,8 +529,8 @@ namespace osu.Game.Screens.Select
|
|||||||
if (Beatmap.Value.Track != null)
|
if (Beatmap.Value.Track != null)
|
||||||
Beatmap.Value.Track.Looping = false;
|
Beatmap.Value.Track.Looping = false;
|
||||||
|
|
||||||
SelectedMods.UnbindAll();
|
selectedMods.UnbindAll();
|
||||||
base.SelectedMods.Value = Enumerable.Empty<Mod>();
|
SelectedMods.Value = Enumerable.Empty<Mod>();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user