From ca5c8d37d1b65902815626f4afe73d244c0a502f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Feb 2019 15:42:15 +0900 Subject: [PATCH 01/22] Use leased bindables --- .../UI/Cursor/GameplayCursor.cs | 2 +- .../Visual/TestCaseEditorComposeTimeline.cs | 2 +- osu.Game.Tests/Visual/TestCaseMatchResults.cs | 2 +- osu.Game/Beatmaps/BindableBeatmap.cs | 7 +- osu.Game/Beatmaps/IBindableBeatmap.cs | 19 ----- .../Containers/BeatSyncedContainer.cs | 2 +- osu.Game/OsuGame.cs | 37 +--------- osu.Game/OsuGameBase.cs | 12 +-- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Overlays/MusicController.cs | 2 +- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 2 +- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 2 +- osu.Game/Rulesets/UI/Playfield.cs | 2 +- .../Edit/Components/BottomBarContainer.cs | 2 +- .../Timelines/Summary/Parts/TimelinePart.cs | 2 +- .../Compose/Components/Timeline/Timeline.cs | 2 +- osu.Game/Screens/Edit/Editor.cs | 3 +- osu.Game/Screens/Edit/EditorScreen.cs | 2 +- osu.Game/Screens/IOsuScreen.cs | 11 ++- osu.Game/Screens/Menu/Intro.cs | 8 +- osu.Game/Screens/Menu/LogoVisualisation.cs | 2 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 2 +- .../Multi/Match/Components/ReadyButton.cs | 2 +- .../Screens/Multi/Match/MatchSubScreen.cs | 8 +- osu.Game/Screens/Multi/Multiplayer.cs | 26 ++++--- .../Screens/Multi/MultiplayerSubScreen.cs | 17 ++++- .../Screens/Multi/Ranking/MatchResults.cs | 6 +- osu.Game/Screens/OsuScreen.cs | 74 ++++++++++++++++--- osu.Game/Screens/Play/PlayerLoader.cs | 2 + .../Play/ScreenWithBeatmapBackground.cs | 2 - osu.Game/Screens/Play/SoloResults.cs | 4 +- osu.Game/Screens/Ranking/Results.cs | 2 +- osu.Game/Screens/Select/MatchSongSelect.cs | 16 ++++ osu.Game/Screens/Select/SongSelect.cs | 26 ++++--- .../Drawables/DrawableStoryboardAnimation.cs | 3 +- .../Drawables/DrawableStoryboardSample.cs | 3 +- .../Drawables/DrawableStoryboardSprite.cs | 3 +- osu.Game/Tests/Visual/OsuTestCase.cs | 2 +- osu.sln.DotSettings | 2 + 40 files changed, 186 insertions(+), 141 deletions(-) delete mode 100644 osu.Game/Beatmaps/IBindableBeatmap.cs diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index 3fef769174..3167e93923 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, IBindableBeatmap beatmap) + private void load(OsuConfigManager config, IBindable beatmap) { InternalChild = expandTarget = new Container { diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs index 7e6edf78fc..a2f40f1903 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs @@ -85,7 +85,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(IAdjustableClock adjustableClock, IBindableBeatmap beatmap) + private void load(IAdjustableClock adjustableClock, IBindable beatmap) { this.adjustableClock = adjustableClock; this.beatmap.BindTo(beatmap); diff --git a/osu.Game.Tests/Visual/TestCaseMatchResults.cs b/osu.Game.Tests/Visual/TestCaseMatchResults.cs index 3ce03cf723..cfba5f7016 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchResults.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchResults.cs @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual this.room = room; } - protected override IEnumerable CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap, room) }; + protected override IEnumerable CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value, room) }; } private class TestRoomLeaderboardPageInfo : RoomLeaderboardPageInfo diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index bbd0fbfb06..ca03aac685 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -12,9 +12,9 @@ namespace osu.Game.Beatmaps { /// /// A for the beatmap. - /// This should be used sparingly in-favour of . + /// This should be used sparingly in-favour of . /// - public abstract class BindableBeatmap : NonNullableBindable, IBindableBeatmap + public abstract class BindableBeatmap : NonNullableBindable { private AudioManager audioManager; private WorkingBeatmap lastBeatmap; @@ -62,9 +62,6 @@ namespace osu.Game.Beatmaps lastBeatmap = beatmap; } - [NotNull] - IBindableBeatmap IBindableBeatmap.GetBoundCopy() => GetBoundCopy(); - /// /// Retrieve a new instance weakly bound to this . /// If you are further binding to events of the retrieved , ensure a local reference is held. diff --git a/osu.Game/Beatmaps/IBindableBeatmap.cs b/osu.Game/Beatmaps/IBindableBeatmap.cs deleted file mode 100644 index 22b7a5a956..0000000000 --- a/osu.Game/Beatmaps/IBindableBeatmap.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Configuration; - -namespace osu.Game.Beatmaps -{ - /// - /// Read-only interface for the beatmap. - /// - public interface IBindableBeatmap : IBindable - { - /// - /// Retrieve a new instance weakly bound to this . - /// If you are further binding to events of the retrieved , ensure a local reference is held. - /// - IBindableBeatmap GetBoundCopy(); - } -} diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index 31eea2cd0c..b929217ae4 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap) + private void load(IBindable beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b1f18341d2..3b71324644 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -292,7 +292,7 @@ namespace osu.Game return; } - if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange != true) + if ((screenStack.CurrentScreen as IOsuScreen)?.DisallowExternalBeatmapRulesetChanges != false) { notifications.Post(new SimpleNotification { @@ -723,46 +723,13 @@ namespace osu.Game { base.UpdateAfterChildren(); - // we only want to apply these restrictions when we are inside a screen stack. - // the use case for not applying is in visual/unit tests. - bool applyBeatmapRulesetRestrictions = !(screenStack.CurrentScreen as IOsuScreen)?.AllowBeatmapRulesetChange ?? false; - - ruleset.Disabled = applyBeatmapRulesetRestrictions; - Beatmap.Disabled = applyBeatmapRulesetRestrictions; - screenContainer.Padding = new MarginPadding { Top = ToolbarOffset }; overlayContent.Padding = new MarginPadding { Top = ToolbarOffset }; MenuCursorContainer.CanShowCursor = (screenStack.CurrentScreen as IOsuScreen)?.CursorVisible ?? false; } - /// - /// Sets while ignoring any beatmap. - /// - /// The beatmap to set. - public void ForcefullySetBeatmap(WorkingBeatmap beatmap) - { - var beatmapDisabled = Beatmap.Disabled; - - Beatmap.Disabled = false; - Beatmap.Value = beatmap; - Beatmap.Disabled = beatmapDisabled; - } - - /// - /// Sets while ignoring any ruleset restrictions. - /// - /// The beatmap to set. - public void ForcefullySetRuleset(RulesetInfo ruleset) - { - var rulesetDisabled = this.ruleset.Disabled; - - this.ruleset.Disabled = false; - this.ruleset.Value = ruleset; - this.ruleset.Disabled = rulesetDisabled; - } - - protected virtual void ScreenChanged(IScreen lastScreen, IScreen newScreen) + protected virtual void ScreenChanged(IScreen current, IScreen newScreen) { switch (newScreen) { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 8154466c4f..b6fe20b3a8 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -69,8 +69,9 @@ namespace osu.Game protected override Container Content => content; - private OsuBindableBeatmap beatmap; - protected BindableBeatmap Beatmap => beatmap; + private Bindable beatmap; + + protected Bindable Beatmap => beatmap; private Bindable fpsDisplayVisible; @@ -155,7 +156,6 @@ namespace osu.Game dependencies.CacheAs(API); var defaultBeatmap = new DummyWorkingBeatmap(this); - beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); @@ -174,8 +174,10 @@ namespace osu.Game // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); - dependencies.CacheAs(beatmap); - dependencies.CacheAs(beatmap); + beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); + + dependencies.CacheAs>(beatmap); + dependencies.CacheAs(beatmap); FileStore.Cleanup(); diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index b8cf7abd63..b388bb1632 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Music } [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, IBindableBeatmap beatmap) + private void load(BeatmapManager beatmaps, IBindable beatmap) { beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false, false)); beatmaps.ItemAdded += addBeatmapSet; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 7b5a59836f..5b1b7f4da9 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Music private PlaylistList list; [BackgroundDependencyLoader] - private void load(OsuColour colours, BindableBeatmap beatmap, BeatmapManager beatmaps) + private void load(OsuColour colours, Bindable beatmap, BeatmapManager beatmaps) { this.beatmap.BindTo(beatmap); this.beatmaps = beatmaps; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index a70dc63c50..5218edd7d5 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -66,7 +66,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours) + private void load(Bindable beatmap, BeatmapManager beatmaps, OsuColour colours) { this.beatmap.BindTo(beatmap); this.beatmaps = beatmaps; diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 122f74b0b1..635e32d489 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, IFrameBasedClock framedClock) + private void load(IBindable beatmap, IFrameBasedClock framedClock) { Beatmap.BindTo(beatmap); diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index cff64bc447..3ab62160cd 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Edit } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, IAdjustableClock clock) + private void load(IBindable beatmap, IAdjustableClock clock) { this.beatmap.BindTo(beatmap); diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index f0a0de6604..572f41b7e6 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.UI private WorkingBeatmap beatmap; [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap) + private void load(IBindable beatmap) { this.beatmap = beatmap.Value; } diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index 4d466d743a..726f6d2025 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Edit.Components } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, OsuColour colours) + private void load(IBindable beatmap, OsuColour colours) { Beatmap.BindTo(beatmap); background.Colour = colours.Gray1; diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs index f07fd59afd..edf7baf687 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap) + private void load(IBindable beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs index c0ad53b4bf..b00d0b0b46 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private WaveformGraph waveform; [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, IAdjustableClock adjustableClock, OsuColour colours) + private void load(IBindable beatmap, IAdjustableClock adjustableClock, OsuColour colours) { this.adjustableClock = adjustableClock; diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index ac5ff504a2..b147679cca 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -29,7 +29,8 @@ namespace osu.Game.Screens.Edit protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); public override bool HideOverlaysOnEnter => true; - public override bool AllowBeatmapRulesetChange => false; + + public override bool DisallowExternalBeatmapRulesetChanges => true; private Box bottomBackground; private Container screenContainer; diff --git a/osu.Game/Screens/Edit/EditorScreen.cs b/osu.Game/Screens/Edit/EditorScreen.cs index ededd90a14..bfe0423c8a 100644 --- a/osu.Game/Screens/Edit/EditorScreen.cs +++ b/osu.Game/Screens/Edit/EditorScreen.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Edit } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap) + private void load(IBindable beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs index 532d4963a0..f256760a0a 100644 --- a/osu.Game/Screens/IOsuScreen.cs +++ b/osu.Game/Screens/IOsuScreen.cs @@ -1,8 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Configuration; using osu.Framework.Screens; +using osu.Game.Beatmaps; using osu.Game.Overlays; +using osu.Game.Rulesets; namespace osu.Game.Screens { @@ -12,9 +15,7 @@ namespace osu.Game.Screens /// Whether the beatmap or ruleset should be allowed to be changed by the user or game. /// Used to mark exclusive areas where this is strongly prohibited, like gameplay. /// - bool AllowBeatmapRulesetChange { get; } - - bool AllowExternalScreenChange { get; } + bool DisallowExternalBeatmapRulesetChanges { get; } /// /// Whether this allows the cursor to be displayed. @@ -35,5 +36,9 @@ namespace osu.Game.Screens /// The amount of parallax to be applied while this screen is displayed. /// float BackgroundParallaxAmount { get; } + + Bindable Beatmap { get; } + + Bindable Ruleset { get; } } } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 3a347342d7..10cfc4a299 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -28,8 +28,6 @@ namespace osu.Game.Screens.Menu /// public bool DidLoadMenu; - private readonly Bindable beatmap = new Bindable(); - private MainMenu mainMenu; private SampleChannel welcome; private SampleChannel seeya; @@ -47,10 +45,8 @@ namespace osu.Game.Screens.Menu private WorkingBeatmap introBeatmap; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) + private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) { - this.beatmap.BindTo(beatmap); - menuVoice = config.GetBindable(OsuSetting.MenuVoice); menuMusic = config.GetBindable(OsuSetting.MenuMusic); @@ -95,7 +91,7 @@ namespace osu.Game.Screens.Menu if (!resuming) { - beatmap.Value = introBeatmap; + Beatmap.Value = introBeatmap; if (menuVoice) welcome.Play(); diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index a87b7aea40..2534c57b1e 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -74,7 +74,7 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(ShaderManager shaders, IBindableBeatmap beatmap) + private void load(ShaderManager shaders, IBindable beatmap) { this.beatmap.BindTo(beatmap); shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 40ae8a25c5..7288cc8db5 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, OsuColour colours) + private void load(IBindable beatmap, OsuColour colours) { this.beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs index 1bde6270f6..e2733b0cf8 100644 --- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Multi.Match.Components private readonly Room room; [Resolved] - private IBindableBeatmap gameBeatmap { get; set; } + private IBindable gameBeatmap { get; set; } [Resolved] private BeatmapManager beatmaps { get; set; } diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 980f321c92..a1346c9615 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Multi.Match { public class MatchSubScreen : MultiplayerSubScreen { - public override bool AllowBeatmapRulesetChange => false; + public override bool DisallowExternalBeatmapRulesetChanges => true; public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value; public override string ShortTitle => "room"; @@ -167,7 +167,7 @@ namespace osu.Game.Screens.Multi.Match // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID); - Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap)); + Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); } private void setRuleset(RulesetInfo ruleset) @@ -175,7 +175,7 @@ namespace osu.Game.Screens.Multi.Match if (ruleset == null) return; - Game?.ForcefullySetRuleset(ruleset); + Ruleset.Value = ruleset; } private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => @@ -190,7 +190,7 @@ namespace osu.Game.Screens.Multi.Match var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID); if (localBeatmap != null) - Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap)); + Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); }); private void addPlaylistItem(PlaylistItem item) diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 1741ac0b7b..d9a2fb7507 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -18,6 +18,7 @@ using osu.Game.Online.API; using osu.Game.Online.Multiplayer; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet.Buttons; +using osu.Game.Rulesets; using osu.Game.Screens.Menu; using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Match; @@ -28,9 +29,9 @@ namespace osu.Game.Screens.Multi [Cached] public class Multiplayer : CompositeDrawable, IOsuScreen, IOnlineComponent { - public bool AllowBeatmapRulesetChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowBeatmapRulesetChange ?? true; - public bool AllowExternalScreenChange => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true; - public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.AllowExternalScreenChange ?? true; + public bool DisallowExternalBeatmapRulesetChanges => false; + + public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true; public bool HideOverlaysOnEnter => false; public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; @@ -51,9 +52,6 @@ namespace osu.Game.Screens.Multi [Cached(Type = typeof(IRoomManager))] private RoomManager roomManager; - [Resolved] - private IBindableBeatmap beatmap { get; set; } - [Resolved] private OsuGameBase game { get; set; } @@ -63,6 +61,14 @@ namespace osu.Game.Screens.Multi [Resolved(CanBeNull = true)] private OsuLogo logo { get; set; } + public Bindable Beatmap => screenDependencies.Beatmap; + + public Bindable Ruleset => screenDependencies.Ruleset; + + private OsuScreenDependencies screenDependencies; + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); + public Multiplayer() { Anchor = Anchor.Centre; @@ -182,6 +188,8 @@ namespace osu.Game.Screens.Multi { waves.Hide(); + screenDependencies.Dispose(); + this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut(); cancelLooping(); @@ -218,7 +226,7 @@ namespace osu.Game.Screens.Multi private void cancelLooping() { - var track = beatmap.Value.Track; + var track = Beatmap.Value.Track; if (track != null) track.Looping = false; } @@ -231,7 +239,7 @@ namespace osu.Game.Screens.Multi if (screenStack.CurrentScreen is MatchSubScreen) { - var track = beatmap.Value.Track; + var track = Beatmap.Value.Track; if (track != null) { track.Looping = true; @@ -239,7 +247,7 @@ namespace osu.Game.Screens.Multi if (!track.IsRunning) { game.Audio.AddItemToList(track); - track.Seek(beatmap.Value.Metadata.PreviewTime); + track.Seek(Beatmap.Value.Metadata.PreviewTime); track.Start(); } } diff --git a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs index ddea4d5dad..1d6561622a 100644 --- a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; @@ -10,13 +11,14 @@ using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Overlays; +using osu.Game.Rulesets; namespace osu.Game.Screens.Multi { public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler { - public virtual bool AllowBeatmapRulesetChange => true; - public bool AllowExternalScreenChange => true; + public virtual bool DisallowExternalBeatmapRulesetChanges => false; + public bool CursorVisible => true; public bool HideOverlaysOnEnter => false; @@ -32,8 +34,13 @@ namespace osu.Game.Screens.Multi public abstract string Title { get; } public virtual string ShortTitle => Title; - [Resolved] - protected IBindableBeatmap Beatmap { get; private set; } + public Bindable Beatmap => screenDependencies.Beatmap; + + public Bindable Ruleset => screenDependencies.Ruleset; + + private OsuScreenDependencies screenDependencies; + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); [Resolved(CanBeNull = true)] protected OsuGame Game { get; private set; } @@ -60,6 +67,8 @@ namespace osu.Game.Screens.Multi this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + screenDependencies.Dispose(); + return false; } diff --git a/osu.Game/Screens/Multi/Ranking/MatchResults.cs b/osu.Game/Screens/Multi/Ranking/MatchResults.cs index d14d94928d..4e00b7853b 100644 --- a/osu.Game/Screens/Multi/Ranking/MatchResults.cs +++ b/osu.Game/Screens/Multi/Ranking/MatchResults.cs @@ -22,9 +22,9 @@ namespace osu.Game.Screens.Multi.Ranking protected override IEnumerable CreateResultPages() => new IResultPageInfo[] { - new ScoreOverviewPageInfo(Score, Beatmap), - new LocalLeaderboardPageInfo(Score, Beatmap), - new RoomLeaderboardPageInfo(Score, Beatmap, room), + new ScoreOverviewPageInfo(Score, Beatmap.Value), + new LocalLeaderboardPageInfo(Score, Beatmap.Value), + new RoomLeaderboardPageInfo(Score, Beatmap.Value, room), }; } } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index ba5c7b2f0a..bfed4345f1 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -50,15 +51,23 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; - public virtual bool AllowBeatmapRulesetChange => true; - protected readonly Bindable Beatmap = new Bindable(); + /// + /// Disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). + /// + public virtual bool DisallowExternalBeatmapRulesetChanges => false; + + private SampleChannel sampleExit; public virtual float BackgroundParallaxAmount => 1; - protected readonly Bindable Ruleset = new Bindable(); + public Bindable Beatmap => screenDependencies.Beatmap; - private SampleChannel sampleExit; + public Bindable Ruleset => screenDependencies.Ruleset; + + private OsuScreenDependencies screenDependencies; + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); protected BackgroundScreen Background => backgroundStack?.CurrentScreen as BackgroundScreen; @@ -77,11 +86,8 @@ namespace osu.Game.Screens } [BackgroundDependencyLoader(true)] - private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable ruleset) + private void load(OsuGame osu, AudioManager audio) { - Beatmap.BindTo(beatmap); - Ruleset.BindTo(ruleset); - sampleExit = audio.Sample.Get(@"UI/screen-back"); } @@ -134,7 +140,8 @@ namespace osu.Game.Screens if (localBackground != null && backgroundStack?.CurrentScreen == localBackground) backgroundStack?.Exit(); - Beatmap.UnbindAll(); + screenDependencies.Dispose(); + return false; } @@ -201,4 +208,53 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; } + + public class OsuScreenDependencies : DependencyContainer, IDisposable + { + private readonly bool leaseOwner; + + public Bindable Beatmap { get; private set; } + + public Bindable Ruleset { get; private set; } + + public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent) + : base(parent) + { + if (requireLease) + { + Beatmap = parent.Get>()?.GetBoundCopy(); + if (Beatmap == null) + { + leaseOwner = true; + Cache(Beatmap = parent.Get>().BeginLease(true)); + } + + Ruleset = parent.Get>()?.GetBoundCopy(); + if (Ruleset == null) + { + leaseOwner = true; + Cache(Ruleset = parent.Get>().BeginLease(true)); + } + } + else + { + Beatmap = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); + Ruleset = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); + } + } + + public void Dispose() + { + if (leaseOwner) + { + ((LeasedBindable)Beatmap).Return(); + ((LeasedBindable)Ruleset).Return(); + } + else + { + Beatmap.UnbindAll(); + Ruleset.UnbindAll(); + } + } + } } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 58e59604dd..c55c05f61c 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -37,6 +37,8 @@ namespace osu.Game.Screens.Play private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; + public override bool DisallowExternalBeatmapRulesetChanges => true; + private Task loadTask; public PlayerLoader(Func createPlayer) diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 93ec7347c8..7e01a84da2 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -18,8 +18,6 @@ namespace osu.Game.Screens.Play protected new BackgroundScreenBeatmap Background => base.Background as BackgroundScreenBeatmap; - public override bool AllowBeatmapRulesetChange => false; - protected const float BACKGROUND_FADE_DURATION = 800; protected float BackgroundOpacity => 1 - (float)DimLevel; diff --git a/osu.Game/Screens/Play/SoloResults.cs b/osu.Game/Screens/Play/SoloResults.cs index 54392abe61..2b9aec257c 100644 --- a/osu.Game/Screens/Play/SoloResults.cs +++ b/osu.Game/Screens/Play/SoloResults.cs @@ -17,8 +17,8 @@ namespace osu.Game.Screens.Play protected override IEnumerable CreateResultPages() => new IResultPageInfo[] { - new ScoreOverviewPageInfo(Score, Beatmap), - new LocalLeaderboardPageInfo(Score, Beatmap) + new ScoreOverviewPageInfo(Score, Beatmap.Value), + new LocalLeaderboardPageInfo(Score, Beatmap.Value) }; } } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 31863cea9b..a70d6bd87f 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Ranking private ResultModeTabControl modeChangeButtons; - public override bool AllowBeatmapRulesetChange => false; + public override bool DisallowExternalBeatmapRulesetChanges => true; protected readonly ScoreInfo Score; diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 298e936c1c..cfeaa1785e 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -40,5 +40,21 @@ namespace osu.Game.Screens.Select return true; } + + public override bool OnExiting(IScreen next) + { + Beatmap.Disabled = true; + Ruleset.Disabled = true; + + return base.OnExiting(next); + } + + public override void OnEntering(IScreen last) + { + base.OnEntering(last); + + Beatmap.Disabled = false; + Ruleset.Disabled = false; + } } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d800cea736..5b25cc9db7 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Select protected readonly BeatmapDetailArea BeatmapDetails; - protected new readonly Bindable Ruleset = new Bindable(); + private readonly Bindable decoupledRuleset = new Bindable(); [Cached] [Cached(Type = typeof(IBindable>))] @@ -267,8 +267,8 @@ namespace osu.Game.Screens.Select { dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); dependencies.CacheAs(this); - dependencies.CacheAs(Ruleset); - dependencies.CacheAs>(Ruleset); + dependencies.CacheAs(decoupledRuleset); + dependencies.CacheAs>(decoupledRuleset); return dependencies; } @@ -333,9 +333,9 @@ namespace osu.Game.Screens.Select if (this.IsCurrentScreen() && !Carousel.SelectBeatmap(beatmap?.BeatmapInfo, false)) // If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch - if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != Ruleset.Value) + if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != decoupledRuleset.Value) { - base.Ruleset.Value = beatmap.BeatmapInfo.Ruleset; + Ruleset.Value = beatmap.BeatmapInfo.Ruleset; Carousel.SelectBeatmap(beatmap.BeatmapInfo); } } @@ -376,12 +376,12 @@ namespace osu.Game.Screens.Select bool preview = false; - if (ruleset?.Equals(Ruleset.Value) == false) + if (ruleset?.Equals(decoupledRuleset.Value) == false) { - Logger.Log($"ruleset changed from \"{Ruleset.Value}\" to \"{ruleset}\""); + Logger.Log($"ruleset changed from \"{decoupledRuleset.Value}\" to \"{ruleset}\""); Beatmap.Value.Mods.Value = Enumerable.Empty(); - Ruleset.Value = ruleset; + decoupledRuleset.Value = ruleset; // force a filter before attempting to change the beatmap. // we may still be in the wrong ruleset as there is a debounce delay on ruleset changes. @@ -538,7 +538,7 @@ namespace osu.Game.Screens.Select { base.Dispose(isDisposing); - Ruleset.UnbindAll(); + decoupledRuleset.UnbindAll(); if (beatmaps != null) { @@ -599,9 +599,11 @@ namespace osu.Game.Screens.Select if (rulesetNoDebounce == null) { // manual binding to parent ruleset to allow for delayed load in the incoming direction. - rulesetNoDebounce = Ruleset.Value = base.Ruleset.Value; - base.Ruleset.ValueChanged += updateSelectedRuleset; - Ruleset.ValueChanged += r => base.Ruleset.Value = r; + rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value; + Ruleset.ValueChanged += updateSelectedRuleset; + + decoupledRuleset.ValueChanged += r => Ruleset.Value = r; + decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r; Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true); Beatmap.BindValueChanged(workingBeatmapChanged); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs index 22175cf24b..94bb4f2525 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs @@ -3,6 +3,7 @@ using osuTK; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Textures; @@ -63,7 +64,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, TextureStore textureStore) + private void load(IBindable beatmap, TextureStore textureStore) { var basePath = Animation.Path.ToLowerInvariant(); for (var frame = 0; frame < Animation.FrameCount; frame++) diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs index e94a03fc16..1591823bc1 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs @@ -4,6 +4,7 @@ using System.IO; using osu.Framework.Allocation; using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Beatmaps; @@ -28,7 +29,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap) + private void load(IBindable beatmap) { // Try first with the full name, then attempt with no path channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null)); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index f904d7cc28..05cde37eb7 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -3,6 +3,7 @@ using osuTK; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; @@ -62,7 +63,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(IBindableBeatmap beatmap, TextureStore textureStore) + private void load(IBindable beatmap, TextureStore textureStore) { var spritePath = Sprite.Path.ToLowerInvariant(); var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath; diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 8a723ec647..3dfcd0febd 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual beatmap.Default = new DummyWorkingBeatmap(Dependencies.Get()); Dependencies.CacheAs(beatmap); - Dependencies.CacheAs(beatmap); + Dependencies.CacheAs>(beatmap); Dependencies.CacheAs(Ruleset); Dependencies.CacheAs>(Ruleset); diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 3f5bd9d34d..5efd16c357 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -68,6 +68,7 @@ HINT HINT HINT + HINT HINT WARNING WARNING @@ -204,6 +205,7 @@ HID HUD ID + IL IP IPC LTRB From e01f342ab0b01799792310fa3679a15ca590d0e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 2 Feb 2019 17:11:25 +0900 Subject: [PATCH 02/22] wip --- osu.Game/Screens/Multi/Multiplayer.cs | 16 +++-- .../Screens/Multi/MultiplayerSubScreen.cs | 16 +++-- osu.Game/Screens/OsuScreen.cs | 67 +++---------------- osu.Game/Screens/OsuScreenDependencies.cs | 41 ++++++++++++ 4 files changed, 71 insertions(+), 69 deletions(-) create mode 100644 osu.Game/Screens/OsuScreenDependencies.cs diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index d9a2fb7507..6bd47ff810 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -61,13 +61,19 @@ namespace osu.Game.Screens.Multi [Resolved(CanBeNull = true)] private OsuLogo logo { get; set; } - public Bindable Beatmap => screenDependencies.Beatmap; + public Bindable Beatmap { get; set; } - public Bindable Ruleset => screenDependencies.Ruleset; + public Bindable Ruleset { get; set; } - private OsuScreenDependencies screenDependencies; + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); + Beatmap = deps.Beatmap; + Ruleset = deps.Ruleset; + + return deps; + } public Multiplayer() { @@ -188,8 +194,6 @@ namespace osu.Game.Screens.Multi { waves.Hide(); - screenDependencies.Dispose(); - this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut(); cancelLooping(); diff --git a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs index 1d6561622a..b0d89c9bba 100644 --- a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs @@ -34,13 +34,19 @@ namespace osu.Game.Screens.Multi public abstract string Title { get; } public virtual string ShortTitle => Title; - public Bindable Beatmap => screenDependencies.Beatmap; + public Bindable Beatmap { get; set; } - public Bindable Ruleset => screenDependencies.Ruleset; + public Bindable Ruleset { get; set; } - private OsuScreenDependencies screenDependencies; + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); + Beatmap = deps.Beatmap; + Ruleset = deps.Ruleset; + + return deps; + } [Resolved(CanBeNull = true)] protected OsuGame Game { get; private set; } @@ -67,8 +73,6 @@ namespace osu.Game.Screens.Multi this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); - screenDependencies.Dispose(); - return false; } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index bfed4345f1..86f1f3a9d9 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -51,7 +50,6 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; - /// /// Disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). /// @@ -61,13 +59,19 @@ namespace osu.Game.Screens public virtual float BackgroundParallaxAmount => 1; - public Bindable Beatmap => screenDependencies.Beatmap; + public Bindable Beatmap { get; set; } - public Bindable Ruleset => screenDependencies.Ruleset; + public Bindable Ruleset { get; set; } - private OsuScreenDependencies screenDependencies; + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); + Beatmap = deps.Beatmap; + Ruleset = deps.Ruleset; + + return deps; + } protected BackgroundScreen Background => backgroundStack?.CurrentScreen as BackgroundScreen; @@ -140,8 +144,6 @@ namespace osu.Game.Screens if (localBackground != null && backgroundStack?.CurrentScreen == localBackground) backgroundStack?.Exit(); - screenDependencies.Dispose(); - return false; } @@ -208,53 +210,4 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; } - - public class OsuScreenDependencies : DependencyContainer, IDisposable - { - private readonly bool leaseOwner; - - public Bindable Beatmap { get; private set; } - - public Bindable Ruleset { get; private set; } - - public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent) - : base(parent) - { - if (requireLease) - { - Beatmap = parent.Get>()?.GetBoundCopy(); - if (Beatmap == null) - { - leaseOwner = true; - Cache(Beatmap = parent.Get>().BeginLease(true)); - } - - Ruleset = parent.Get>()?.GetBoundCopy(); - if (Ruleset == null) - { - leaseOwner = true; - Cache(Ruleset = parent.Get>().BeginLease(true)); - } - } - else - { - Beatmap = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); - Ruleset = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); - } - } - - public void Dispose() - { - if (leaseOwner) - { - ((LeasedBindable)Beatmap).Return(); - ((LeasedBindable)Ruleset).Return(); - } - else - { - Beatmap.UnbindAll(); - Ruleset.UnbindAll(); - } - } - } } diff --git a/osu.Game/Screens/OsuScreenDependencies.cs b/osu.Game/Screens/OsuScreenDependencies.cs new file mode 100644 index 0000000000..1c355d6320 --- /dev/null +++ b/osu.Game/Screens/OsuScreenDependencies.cs @@ -0,0 +1,41 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; + +namespace osu.Game.Screens +{ + public class OsuScreenDependencies : DependencyContainer + { + public Bindable Beatmap { get; } + + public Bindable Ruleset { get; } + + public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent) + : base(parent) + { + if (requireLease) + { + Beatmap = parent.Get>()?.GetBoundCopy(); + if (Beatmap == null) + { + Cache(Beatmap = parent.Get>().BeginLease(true)); + } + + Ruleset = parent.Get>()?.GetBoundCopy(); + if (Ruleset == null) + { + Cache(Ruleset = parent.Get>().BeginLease(true)); + } + } + else + { + Beatmap = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); + Ruleset = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); + } + } + } +} \ No newline at end of file From 88ffc78103ed606b51015024c1a58408535d28a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Feb 2019 19:11:34 +0900 Subject: [PATCH 03/22] Restructure --- osu.Game.Tests/Visual/TestCaseMatchResults.cs | 2 +- .../UpdateableBeatmapBackgroundSprite.cs | 2 +- osu.Game/Online/Multiplayer/Room.cs | 16 + .../Screens/Multi/Components/BeatmapTitle.cs | 12 +- .../Multi/Components/BeatmapTypeInfo.cs | 8 +- .../Screens/Multi/Components/ModeTypeInfo.cs | 11 +- .../Components/MultiplayerBackgroundSprite.cs | 2 +- .../Screens/Multi/Lounge/LoungeSubScreen.cs | 14 +- .../Screens/Multi/Match/Components/Header.cs | 2 +- .../Screens/Multi/Match/Components/Info.cs | 8 +- .../Multi/Match/Components/ReadyButton.cs | 2 +- .../Match/Components/ViewBeatmapButton.cs | 2 +- .../Screens/Multi/Match/MatchSubScreen.cs | 353 +++++++++--------- osu.Game/Screens/Multi/Multiplayer.cs | 49 +-- .../Screens/Multi/MultiplayerComposite.cs | 37 +- .../Screens/Multi/MultiplayerSubScreen.cs | 46 +-- 16 files changed, 243 insertions(+), 323 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMatchResults.cs b/osu.Game.Tests/Visual/TestCaseMatchResults.cs index c34ad0fcbc..33469e74b7 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchResults.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchResults.cs @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual { } - protected override IEnumerable CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value, room) }; + protected override IEnumerable CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value) }; } private class TestRoomLeaderboardPageInfo : RoomLeaderboardPageInfo diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index c66052052f..d1d30a7c29 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps.Drawables /// public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable { - public readonly IBindable Beatmap = new Bindable(); + public readonly Bindable Beatmap = new Bindable(); [Resolved] private BeatmapManager beatmaps { get; set; } diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 0d5b168dcb..2dcc7369f9 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -31,6 +31,10 @@ namespace osu.Game.Online.Multiplayer [JsonProperty("playlist")] public BindableList Playlist { get; private set; } = new BindableList(); + [Cached] + [JsonIgnore] + public Bindable CurrentItem { get; private set; } = new Bindable(); + [Cached] [JsonProperty("channel_id")] public Bindable ChannelId { get; private set; } = new Bindable(); @@ -66,6 +70,18 @@ namespace osu.Game.Online.Multiplayer [Cached] public Bindable ParticipantCount { get; private set; } = new Bindable(); + public Room() + { + Playlist.ItemsAdded += updateCurrent; + Playlist.ItemsRemoved += updateCurrent; + updateCurrent(Playlist); + } + + private void updateCurrent(IEnumerable playlist) + { + CurrentItem.Value = playlist.FirstOrDefault(); + } + // todo: TEMPORARY [JsonProperty("participant_count")] private int? participantCount diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index dca0545035..ff1a1fb3a4 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi.Components [BackgroundDependencyLoader] private void load() { - CurrentBeatmap.BindValueChanged(v => updateText(), true); + CurrentItem.BindValueChanged(v => updateText(), true); } private float textSize = OsuSpriteText.FONT_SIZE; @@ -53,7 +53,9 @@ namespace osu.Game.Screens.Multi.Components textFlow.Clear(); - if (CurrentBeatmap.Value == null) + var beatmap = CurrentItem.Value?.Beatmap; + + if (beatmap == null) textFlow.AddText("No beatmap selected", s => { s.TextSize = TextSize; @@ -65,7 +67,7 @@ namespace osu.Game.Screens.Multi.Components { new OsuSpriteText { - Text = new LocalisedString((CurrentBeatmap.Value.Metadata.ArtistUnicode, CurrentBeatmap.Value.Metadata.Artist)), + Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), TextSize = TextSize, }, new OsuSpriteText @@ -75,10 +77,10 @@ namespace osu.Game.Screens.Multi.Components }, new OsuSpriteText { - Text = new LocalisedString((CurrentBeatmap.Value.Metadata.TitleUnicode, CurrentBeatmap.Value.Metadata.Title)), + Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)), TextSize = TextSize, } - }, null, LinkAction.OpenBeatmap, CurrentBeatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap"); + }, null, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap"); } } } diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 3904df2069..4f432a232c 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -51,14 +51,16 @@ namespace osu.Game.Screens.Multi.Components } }; - CurrentBeatmap.BindValueChanged(v => + CurrentItem.BindValueChanged(item => { beatmapAuthor.Clear(); - if (v != null) + var beatmap = item?.Beatmap; + + if (beatmap != null) { beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f)); - beatmapAuthor.AddLink(v.Metadata.Author.Username, null, LinkAction.OpenUserProfile, v.Metadata.Author.Id.ToString(), "View Profile"); + beatmapAuthor.AddLink(beatmap.Metadata.Author.Username, null, LinkAction.OpenUserProfile, beatmap.Metadata.Author.Id.ToString(), "View Profile"); } }, true); } diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index 97ea1b5f36..0d49f75b46 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps.Drawables; +using osu.Game.Online.Multiplayer; using osuTK; namespace osu.Game.Screens.Multi.Components @@ -45,17 +46,17 @@ namespace osu.Game.Screens.Multi.Components }, }; - CurrentBeatmap.BindValueChanged(_ => updateBeatmap()); - CurrentRuleset.BindValueChanged(_ => updateBeatmap(), true); + CurrentItem.BindValueChanged(updateBeatmap, true); + Type.BindValueChanged(v => gameTypeContainer.Child = new DrawableGameType(v) { Size = new Vector2(height) }, true); } - private void updateBeatmap() + private void updateBeatmap(PlaylistItem item) { - if (CurrentBeatmap.Value != null) + if (item?.Beatmap != null) { rulesetContainer.FadeIn(transition_duration); - rulesetContainer.Child = new DifficultyIcon(CurrentBeatmap.Value, CurrentRuleset.Value) { Size = new Vector2(height) }; + rulesetContainer.Child = new DifficultyIcon(item.Beatmap, item.Ruleset) { Size = new Vector2(height) }; } else rulesetContainer.FadeOut(transition_duration); diff --git a/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs b/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs index 8eff7b14af..06d5e585ab 100644 --- a/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs +++ b/osu.Game/Screens/Multi/Components/MultiplayerBackgroundSprite.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components InternalChild = sprite = CreateBackgroundSprite(); - sprite.Beatmap.BindTo(CurrentBeatmap); + CurrentItem.BindValueChanged(i => sprite.Beatmap.Value = i?.Beatmap, true); } protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }; diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index 1229d071ef..71205dc199 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -23,16 +22,13 @@ namespace osu.Game.Screens.Multi.Lounge protected readonly FilterControl Filter; private readonly Container content; - private readonly Action pushGameplayScreen; private readonly ProcessingOverlay processingOverlay; [Resolved] private Bindable currentRoom { get; set; } - public LoungeSubScreen(Action pushGameplayScreen) + public LoungeSubScreen() { - this.pushGameplayScreen = pushGameplayScreen; - InternalChildren = new Drawable[] { Filter = new FilterControl { Depth = -1 }, @@ -83,8 +79,8 @@ namespace osu.Game.Screens.Multi.Lounge content.Padding = new MarginPadding { Top = Filter.DrawHeight, - Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, - Right = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, + Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + HORIZONTAL_OVERFLOW_PADDING, + Right = SearchableListOverlay.WIDTH_PADDING + HORIZONTAL_OVERFLOW_PADDING, }; } @@ -114,7 +110,7 @@ namespace osu.Game.Screens.Multi.Lounge private void joinRequested(Room room) { processingOverlay.Show(); - Manager?.JoinRoom(room, r => + RoomManager?.JoinRoom(room, r => { Open(room); processingOverlay.Hide(); @@ -132,7 +128,7 @@ namespace osu.Game.Screens.Multi.Lounge currentRoom.Value = room; - this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s))); + this.Push(new MatchSubScreen(room)); } } } diff --git a/osu.Game/Screens/Multi/Match/Components/Header.cs b/osu.Game/Screens/Multi/Match/Components/Header.cs index 137c0aa939..9a0fdbd4e7 100644 --- a/osu.Game/Screens/Multi/Match/Components/Header.cs +++ b/osu.Game/Screens/Multi/Match/Components/Header.cs @@ -108,7 +108,7 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; - CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true); + CurrentItem.BindValueChanged(i => modDisplay.Current.Value = i?.RequiredMods, true); beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); } diff --git a/osu.Game/Screens/Multi/Match/Components/Info.cs b/osu.Game/Screens/Multi/Match/Components/Info.cs index ec6dbb6d12..b27c5b0ab4 100644 --- a/osu.Game/Screens/Multi/Match/Components/Info.cs +++ b/osu.Game/Screens/Multi/Match/Components/Info.cs @@ -92,8 +92,12 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; - viewBeatmapButton.Beatmap.BindTo(CurrentBeatmap); - readyButton.Beatmap.BindTo(CurrentBeatmap); + CurrentItem.BindValueChanged(item => + { + viewBeatmapButton.Beatmap.Value = item?.Beatmap; + readyButton.Beatmap.Value = item?.Beatmap; + }, true); + hostInfo.Host.BindTo(Host); } } diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs index 0f9c51af6a..50cf2addeb 100644 --- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Multi.Match.Components { public class ReadyButton : HeaderButton { - public readonly IBindable Beatmap = new Bindable(); + public readonly Bindable Beatmap = new Bindable(); [Resolved(typeof(Room), nameof(Room.EndDate))] private Bindable endDate { get; set; } diff --git a/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs b/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs index 9970894ffc..e26a6b7e20 100644 --- a/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ViewBeatmapButton.cs @@ -11,7 +11,7 @@ namespace osu.Game.Screens.Multi.Match.Components { public class ViewBeatmapButton : HeaderButton { - public readonly IBindable Beatmap = new Bindable(); + public readonly Bindable Beatmap = new Bindable(); [Resolved(CanBeNull = true)] private OsuGame osuGame { get; set; } diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index d252ddf0b9..41c498538f 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -11,11 +12,12 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer.GameTypes; -using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Play; using osu.Game.Screens.Play; using osu.Game.Screens.Select; +using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem; namespace osu.Game.Screens.Multi.Match { @@ -33,223 +35,208 @@ namespace osu.Game.Screens.Multi.Match [Resolved(typeof(Room), nameof(Room.Name))] private Bindable name { get; set; } - [Resolved(typeof(Room), nameof(Room.Playlist))] - private BindableList playlist { get; set; } + [Resolved(typeof(Room), nameof(Room.Type))] + private Bindable type { get; set; } - public MatchSubScreen(Room room, Action pushGameplayScreen) + [Resolved(typeof(Room))] + protected BindableList Playlist { get; private set; } + + [Resolved(typeof(Room))] + protected Bindable CurrentItem { get; private set; } + + [Resolved] + protected Bindable> CurrentMods { get; private set; } + + public MatchSubScreen(Room room) { Title = room.RoomID.Value == null ? "New room" : room.Name; + } - InternalChild = new Match(pushGameplayScreen) - { - RelativeSizeAxes = Axes.Both, - RequestBeatmapSelection = () => this.Push(new MatchSongSelect - { - Selected = item => - { - playlist.Clear(); - playlist.Add(item); - }, - }), - RequestExit = () => - { - if (this.IsCurrentScreen()) - this.Exit(); - } - }; + private readonly Action pushGameplayScreen; + + private MatchLeaderboard leaderboard; + + [Resolved] + private BeatmapManager beatmapManager { get; set; } + + [Resolved(CanBeNull = true)] + private OsuGame game { get; set; } + + protected override void LoadComplete() + { + base.LoadComplete(); + + CurrentItem.BindValueChanged(currentItemChanged, true); + } + + private void currentItemChanged(PlaylistItem item) + { + // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info + var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID); + + Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); + CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty(); + if (item?.Ruleset != null) + Ruleset.Value = item.Ruleset; } public override bool OnExiting(IScreen next) { - Manager?.PartRoom(); + RoomManager?.PartRoom(); return base.OnExiting(next); } - private class Match : MultiplayerComposite + [BackgroundDependencyLoader] + private void load() { - public Action RequestBeatmapSelection; - public Action RequestExit; + MatchChatDisplay chat; + Components.Header header; + Info info; + GridContainer bottomRow; + MatchSettingsOverlay settings; - private readonly Action pushGameplayScreen; - - private MatchLeaderboard leaderboard; - - [Resolved] - private IBindableBeatmap gameBeatmap { get; set; } - - [Resolved] - private BeatmapManager beatmapManager { get; set; } - - [Resolved(CanBeNull = true)] - private OsuGame game { get; set; } - - public Match(Action pushGameplayScreen) + InternalChildren = new Drawable[] { - this.pushGameplayScreen = pushGameplayScreen; - } - - [BackgroundDependencyLoader] - private void load() - { - MatchChatDisplay chat; - Components.Header header; - Info info; - GridContainer bottomRow; - MatchSettingsOverlay settings; - - InternalChildren = new Drawable[] + new GridContainer { - new GridContainer + RelativeSizeAxes = Axes.Both, + Content = new[] { - RelativeSizeAxes = Axes.Both, - Content = new[] + new Drawable[] { - new Drawable[] + header = new Components.Header { - header = new Components.Header + Depth = -1, + RequestBeatmapSelection = () => { - Depth = -1, - RequestBeatmapSelection = () => RequestBeatmapSelection?.Invoke() - } - }, - new Drawable[] { info = new Info { OnStart = onStart } }, - new Drawable[] - { - bottomRow = new GridContainer - { - RelativeSizeAxes = Axes.Both, - Content = new[] + this.Push(new MatchSongSelect { - new Drawable[] + Selected = item => { - leaderboard = new MatchLeaderboard + Playlist.Clear(); + Playlist.Add(item); + } + }); + } + } + }, + new Drawable[] { info = new Info { OnStart = onStart } }, + new Drawable[] + { + bottomRow = new GridContainer + { + RelativeSizeAxes = Axes.Both, + Content = new[] + { + new Drawable[] + { + leaderboard = new MatchLeaderboard + { + Padding = new MarginPadding + { + Left = 10 + HORIZONTAL_OVERFLOW_PADDING, + Right = 10, + Vertical = 10, + }, + RelativeSizeAxes = Axes.Both + }, + new Container + { + Padding = new MarginPadding + { + Left = 10, + Right = 10 + HORIZONTAL_OVERFLOW_PADDING, + Vertical = 10, + }, + RelativeSizeAxes = Axes.Both, + Child = chat = new MatchChatDisplay { - Padding = new MarginPadding - { - Left = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, - Right = 10, - Vertical = 10, - }, RelativeSizeAxes = Axes.Both - }, - new Container - { - Padding = new MarginPadding - { - Left = 10, - Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, - Vertical = 10, - }, - RelativeSizeAxes = Axes.Both, - Child = chat = new MatchChatDisplay - { - RelativeSizeAxes = Axes.Both - } - }, + } }, }, - } - }, + }, + } }, - RowDimensions = new[] - { - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.Distributed), - } }, - new Container + RowDimensions = new[] { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = Components.Header.HEIGHT }, - Child = settings = new MatchSettingsOverlay { RelativeSizeAxes = Axes.Both }, - }, - }; - - header.Tabs.Current.BindValueChanged(t => - { - const float fade_duration = 500; - if (t is SettingsMatchPage) - { - settings.Show(); - info.FadeOut(fade_duration, Easing.OutQuint); - bottomRow.FadeOut(fade_duration, Easing.OutQuint); + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.Distributed), } - else - { - settings.Hide(); - info.FadeIn(fade_duration, Easing.OutQuint); - bottomRow.FadeIn(fade_duration, Easing.OutQuint); - } - }, true); - - chat.Exit += () => RequestExit?.Invoke(); - - beatmapManager.ItemAdded += beatmapAdded; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - CurrentBeatmap.BindValueChanged(setBeatmap, true); - CurrentRuleset.BindValueChanged(setRuleset, true); - } - - private void setBeatmap(BeatmapInfo beatmap) - { - // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info - var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID); - - game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap)); - } - - private void setRuleset(RulesetInfo ruleset) - { - if (ruleset == null) - return; - - game?.ForcefullySetRuleset(ruleset); - } - - private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => - { - if (gameBeatmap.Value != beatmapManager.DefaultBeatmap) - return; - - if (CurrentBeatmap.Value == null) - return; - - // Try to retrieve the corresponding local beatmap - var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentBeatmap.Value.OnlineBeatmapID); - - if (localBeatmap != null) - game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap)); - }); - - private void onStart() - { - gameBeatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); - - switch (Type.Value) + }, + new Container { - default: - case GameTypeTimeshift _: - pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(Playlist.First()) - { - Exited = () => leaderboard.RefreshScores() - })); - break; + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = Components.Header.HEIGHT }, + Child = settings = new MatchSettingsOverlay { RelativeSizeAxes = Axes.Both }, + }, + }; + + header.Tabs.Current.BindValueChanged(t => + { + const float fade_duration = 500; + if (t is SettingsMatchPage) + { + settings.Show(); + info.FadeOut(fade_duration, Easing.OutQuint); + bottomRow.FadeOut(fade_duration, Easing.OutQuint); } - } + else + { + settings.Hide(); + info.FadeIn(fade_duration, Easing.OutQuint); + bottomRow.FadeIn(fade_duration, Easing.OutQuint); + } + }, true); - protected override void Dispose(bool isDisposing) + chat.Exit += () => { - base.Dispose(isDisposing); + if (this.IsCurrentScreen()) + this.Exit(); + }; - if (beatmapManager != null) - beatmapManager.ItemAdded -= beatmapAdded; + beatmapManager.ItemAdded += beatmapAdded; + } + + private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => + { + if (Beatmap.Value != beatmapManager.DefaultBeatmap) + return; + + if (Beatmap.Value == null) + return; + + // Try to retrieve the corresponding local beatmap + var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentItem.Value.Beatmap.OnlineBeatmapID); + + if (localBeatmap != null) + Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); + }); + + private void onStart() + { + //Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); + + switch (type.Value) + { + default: + case GameTypeTimeshift _: + pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem) + { + Exited = () => leaderboard.RefreshScores() + })); + break; } } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (beatmapManager != null) + beatmapManager.ItemAdded -= beatmapAdded; + } } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 42208a2165..7ea4736b04 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Logging; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; @@ -16,9 +15,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Input; using osu.Game.Online.API; using osu.Game.Online.Multiplayer; -using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet.Buttons; -using osu.Game.Rulesets; using osu.Game.Screens.Menu; using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Lounge.Components; @@ -28,19 +25,9 @@ using osuTK; namespace osu.Game.Screens.Multi { [Cached] - public class Multiplayer : CompositeDrawable, IOsuScreen, IOnlineComponent + public class Multiplayer : OsuScreen, IOnlineComponent { - public bool DisallowExternalBeatmapRulesetChanges => false; - - public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true; - - public bool HideOverlaysOnEnter => false; - public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; - - public float BackgroundParallaxAmount => 1; - - public bool ValidForResume { get; set; } = true; - public bool ValidForPush { get; set; } = true; + public override bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true; public override bool RemoveWhenNotAlive => false; @@ -70,20 +57,6 @@ namespace osu.Game.Screens.Multi [Resolved(CanBeNull = true)] private OsuLogo logo { get; set; } - public Bindable Beatmap { get; set; } - - public Bindable Ruleset { get; set; } - - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) - { - var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); - - Beatmap = deps.Beatmap; - Ruleset = deps.Ruleset; - - return deps; - } - public Multiplayer() { Anchor = Anchor.Centre; @@ -95,8 +68,8 @@ namespace osu.Game.Screens.Multi RelativeSizeAxes = Axes.Both, }; - screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen(pushGameplayScreen)) { RelativeSizeAxes = Axes.Both }; - Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING }; + screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both }; + Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING }; waves.AddRange(new Drawable[] { @@ -136,7 +109,7 @@ namespace osu.Game.Screens.Multi Margin = new MarginPadding { Top = 10, - Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, + Right = 10 + HORIZONTAL_OVERFLOW_PADDING, }, Text = "Create room", Action = () => loungeSubScreen.Open(new Room @@ -207,14 +180,14 @@ namespace osu.Game.Screens.Multi } } - public void OnEntering(IScreen last) + public override void OnEntering(IScreen last) { this.FadeIn(); waves.Show(); } - public bool OnExiting(IScreen next) + public override bool OnExiting(IScreen next) { waves.Hide(); @@ -233,17 +206,17 @@ namespace osu.Game.Screens.Multi return false; } - public void OnResuming(IScreen last) + public override void OnResuming(IScreen last) { this.FadeIn(250); this.ScaleTo(1, 250, Easing.OutSine); - logo?.AppendAnimatingAction(() => OsuScreen.ApplyLogoArrivingDefaults(logo), true); + logo?.AppendAnimatingAction(() => ApplyLogoArrivingDefaults(logo), true); updatePollingRate(isIdle.Value); } - public void OnSuspending(IScreen next) + public override void OnSuspending(IScreen next) { this.ScaleTo(1.1f, 250, Easing.InSine); this.FadeOut(250); @@ -254,7 +227,7 @@ namespace osu.Game.Screens.Multi private void cancelLooping() { - var track = beatmap?.Value?.Track; + var track = Beatmap?.Value?.Track; if (track != null) track.Looping = false; diff --git a/osu.Game/Screens/Multi/MultiplayerComposite.cs b/osu.Game/Screens/Multi/MultiplayerComposite.cs index 1a16db97a4..245a6ac358 100644 --- a/osu.Game/Screens/Multi/MultiplayerComposite.cs +++ b/osu.Game/Screens/Multi/MultiplayerComposite.cs @@ -3,14 +3,10 @@ using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; -using osu.Game.Rulesets; -using osu.Game.Rulesets.Mods; using osu.Game.Users; namespace osu.Game.Screens.Multi @@ -35,6 +31,9 @@ namespace osu.Game.Screens.Multi [Resolved(typeof(Room))] protected BindableList Playlist { get; private set; } + [Resolved(typeof(Room))] + protected Bindable CurrentItem { get; private set; } + [Resolved(typeof(Room))] protected Bindable> Participants { get; private set; } @@ -52,35 +51,5 @@ namespace osu.Game.Screens.Multi [Resolved(typeof(Room))] protected Bindable Duration { get; private set; } - - private readonly Bindable currentBeatmap = new Bindable(); - protected IBindable CurrentBeatmap => currentBeatmap; - - private readonly Bindable> currentMods = new Bindable>(); - protected IBindable> CurrentMods => currentMods; - - private readonly Bindable currentRuleset = new Bindable(); - protected IBindable CurrentRuleset => currentRuleset; - - protected override void LoadComplete() - { - base.LoadComplete(); - - Playlist.ItemsAdded += _ => updatePlaylist(); - Playlist.ItemsRemoved += _ => updatePlaylist(); - - updatePlaylist(); - } - - private void updatePlaylist() - { - // Todo: We only ever have one playlist item for now. In the future, this will be user-settable - - var playlistItem = Playlist.FirstOrDefault(); - - currentBeatmap.Value = playlistItem?.Beatmap; - currentMods.Value = playlistItem?.RequiredMods ?? Enumerable.Empty(); - currentRuleset.Value = playlistItem?.Ruleset; - } } } diff --git a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs index b0d89c9bba..ad72072981 100644 --- a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs @@ -2,57 +2,27 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; -using osu.Game.Overlays; -using osu.Game.Rulesets; namespace osu.Game.Screens.Multi { - public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler + public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen, IKeyBindingHandler { - public virtual bool DisallowExternalBeatmapRulesetChanges => false; - - public bool CursorVisible => true; - - public bool HideOverlaysOnEnter => false; - public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; - - public float BackgroundParallaxAmount => 1; - - public bool ValidForResume { get; set; } = true; - public bool ValidForPush { get; set; } = true; + public override bool DisallowExternalBeatmapRulesetChanges => false; public override bool RemoveWhenNotAlive => false; - public abstract string Title { get; } public virtual string ShortTitle => Title; - public Bindable Beatmap { get; set; } - - public Bindable Ruleset { get; set; } - - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) - { - var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent)); - - Beatmap = deps.Beatmap; - Ruleset = deps.Ruleset; - - return deps; - } - [Resolved(CanBeNull = true)] protected OsuGame Game { get; private set; } [Resolved(CanBeNull = true)] - protected IRoomManager Manager { get; private set; } + protected IRoomManager RoomManager { get; private set; } protected MultiplayerSubScreen() { @@ -61,14 +31,14 @@ namespace osu.Game.Screens.Multi RelativeSizeAxes = Axes.Both; } - public virtual void OnEntering(IScreen last) + public override void OnEntering(IScreen last) { this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } - public virtual bool OnExiting(IScreen next) + public override bool OnExiting(IScreen next) { this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); @@ -76,19 +46,19 @@ namespace osu.Game.Screens.Multi return false; } - public virtual void OnResuming(IScreen last) + public override void OnResuming(IScreen last) { this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } - public virtual void OnSuspending(IScreen next) + public override void OnSuspending(IScreen next) { this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); } - public virtual bool OnPressed(GlobalAction action) + public override bool OnPressed(GlobalAction action) { if (!this.IsCurrentScreen()) return false; From e4422167b6a77af486eb03369ff98affdbaa4497 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Feb 2019 19:13:57 +0900 Subject: [PATCH 04/22] Fix starting gameplay --- osu.Game/Screens/Multi/Match/MatchSubScreen.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 41c498538f..7a9b040e37 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -217,13 +217,14 @@ namespace osu.Game.Screens.Multi.Match private void onStart() { - //Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); + // todo: is this required? + Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); switch (type.Value) { default: case GameTypeTimeshift _: - pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem) + this.Push(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem) { Exited = () => leaderboard.RefreshScores() })); From e57409fe41623f3f1b4fac7df221bc847223559b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 10:51:39 +0900 Subject: [PATCH 05/22] Remove unnecessary bindable properties on mod lists --- osu.Game/Online/Multiplayer/PlaylistItem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Multiplayer/PlaylistItem.cs b/osu.Game/Online/Multiplayer/PlaylistItem.cs index ff3ae240cb..e47d497d94 100644 --- a/osu.Game/Online/Multiplayer/PlaylistItem.cs +++ b/osu.Game/Online/Multiplayer/PlaylistItem.cs @@ -1,9 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; -using osu.Framework.Configuration; using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; @@ -37,10 +37,10 @@ namespace osu.Game.Online.Multiplayer public RulesetInfo Ruleset { get; set; } [JsonIgnore] - public readonly BindableList AllowedMods = new BindableList(); + public readonly List AllowedMods = new List(); [JsonIgnore] - public readonly BindableList RequiredMods = new BindableList(); + public readonly List RequiredMods = new List(); [JsonProperty("beatmap")] private APIBeatmap apiBeatmap { get; set; } From 78b47f9fe3f75768b0d099fa9dfaa99b316c01b3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 11:19:34 +0900 Subject: [PATCH 06/22] Fix starting matches not working --- osu.Game/Screens/Multi/Match/MatchSubScreen.cs | 15 ++++++++------- osu.Game/Screens/Multi/Multiplayer.cs | 13 ++++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 7a9b040e37..a7a2b9003f 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -15,7 +14,6 @@ using osu.Game.Online.Multiplayer.GameTypes; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Play; -using osu.Game.Screens.Play; using osu.Game.Screens.Select; using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem; @@ -52,8 +50,6 @@ namespace osu.Game.Screens.Multi.Match Title = room.RoomID.Value == null ? "New room" : room.Name; } - private readonly Action pushGameplayScreen; - private MatchLeaderboard leaderboard; [Resolved] @@ -200,6 +196,9 @@ namespace osu.Game.Screens.Multi.Match beatmapManager.ItemAdded += beatmapAdded; } + /// + /// Handle the case where a beatmap is imported (and can be used by this match). + /// private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => { if (Beatmap.Value != beatmapManager.DefaultBeatmap) @@ -215,19 +214,21 @@ namespace osu.Game.Screens.Multi.Match Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); }); + [Resolved(canBeNull: true)] + private Multiplayer multiplayer { get; set; } + private void onStart() { - // todo: is this required? Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); switch (type.Value) { default: case GameTypeTimeshift _: - this.Push(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem) + multiplayer?.Start(() => new TimeshiftPlayer(CurrentItem) { Exited = () => leaderboard.RefreshScores() - })); + }); break; } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 7ea4736b04..afb4955c56 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -20,6 +21,7 @@ using osu.Game.Screens.Menu; using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Lounge.Components; using osu.Game.Screens.Multi.Match; +using osu.Game.Screens.Play; using osuTK; namespace osu.Game.Screens.Multi @@ -29,7 +31,7 @@ namespace osu.Game.Screens.Multi { public override bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true; - public override bool RemoveWhenNotAlive => false; + public override bool DisallowExternalBeatmapRulesetChanges => true; private readonly MultiplayerWaveContainer waves; @@ -292,5 +294,14 @@ namespace osu.Game.Screens.Multi FourthWaveColour = OsuColour.FromHex(@"392850"); } } + + /// + /// Push a to the main screen stack to begin gameplay. + /// Generally called from a via DI resolution. + /// + public void Start(Func player) + { + this.Push(new PlayerLoader(player)); + } } } From 272584eb796d7631d0798cff2178ec30b60a4766 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 13:02:33 +0900 Subject: [PATCH 07/22] Improve file layouts --- .../Screens/Multi/Match/MatchSubScreen.cs | 56 ++++---- osu.Game/Screens/Multi/Multiplayer.cs | 122 ++++++++---------- 2 files changed, 84 insertions(+), 94 deletions(-) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index a7a2b9003f..cd51aea575 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -45,41 +45,17 @@ namespace osu.Game.Screens.Multi.Match [Resolved] protected Bindable> CurrentMods { get; private set; } - public MatchSubScreen(Room room) - { - Title = room.RoomID.Value == null ? "New room" : room.Name; - } - - private MatchLeaderboard leaderboard; - [Resolved] private BeatmapManager beatmapManager { get; set; } [Resolved(CanBeNull = true)] private OsuGame game { get; set; } - protected override void LoadComplete() + private MatchLeaderboard leaderboard; + + public MatchSubScreen(Room room) { - base.LoadComplete(); - - CurrentItem.BindValueChanged(currentItemChanged, true); - } - - private void currentItemChanged(PlaylistItem item) - { - // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info - var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID); - - Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); - CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty(); - if (item?.Ruleset != null) - Ruleset.Value = item.Ruleset; - } - - public override bool OnExiting(IScreen next) - { - RoomManager?.PartRoom(); - return base.OnExiting(next); + Title = room.RoomID.Value == null ? "New room" : room.Name; } [BackgroundDependencyLoader] @@ -196,6 +172,30 @@ namespace osu.Game.Screens.Multi.Match beatmapManager.ItemAdded += beatmapAdded; } + protected override void LoadComplete() + { + base.LoadComplete(); + + CurrentItem.BindValueChanged(currentItemChanged, true); + } + + private void currentItemChanged(PlaylistItem item) + { + // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info + var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID); + + Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); + CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty(); + if (item?.Ruleset != null) + Ruleset.Value = item.Ruleset; + } + + public override bool OnExiting(IScreen next) + { + RoomManager?.PartRoom(); + return base.OnExiting(next); + } + /// /// Handle the case where a beatmap is imported (and can be used by this match). /// diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index afb4955c56..1103e781ff 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -64,64 +64,61 @@ namespace osu.Game.Screens.Multi Anchor = Anchor.Centre; Origin = Anchor.Centre; RelativeSizeAxes = Axes.Both; + Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING }; InternalChild = waves = new MultiplayerWaveContainer { RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"3e3a44"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"3c3842"), + ColourDark = OsuColour.FromHex(@"393540"), + TriangleScale = 5, + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = Header.HEIGHT }, + Child = screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both } + }, + new Header(screenStack), + createButton = new HeaderButton + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.None, + Size = new Vector2(150, Header.HEIGHT - 20), + Margin = new MarginPadding + { + Top = 10, + Right = 10 + HORIZONTAL_OVERFLOW_PADDING, + }, + Text = "Create room", + Action = () => loungeSubScreen.Open(new Room + { + Name = { Value = $"{api.LocalUser}'s awesome room" } + }), + }, + roomManager = new RoomManager() + } }; - screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both }; - Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING }; - - waves.AddRange(new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Masking = true, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"3e3a44"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"3c3842"), - ColourDark = OsuColour.FromHex(@"393540"), - TriangleScale = 5, - }, - }, - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = Header.HEIGHT }, - Child = screenStack - }, - new Header(screenStack), - createButton = new HeaderButton - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.None, - Size = new Vector2(150, Header.HEIGHT - 20), - Margin = new MarginPadding - { - Top = 10, - Right = 10 + HORIZONTAL_OVERFLOW_PADDING, - }, - Text = "Create room", - Action = () => loungeSubScreen.Open(new Room - { - Name = { Value = $"{api.LocalUser}'s awesome room" } - }), - }, - roomManager = new RoomManager() - }); - screenStack.ScreenPushed += screenPushed; screenStack.ScreenExited += screenExited; } @@ -141,11 +138,9 @@ namespace osu.Game.Screens.Multi isIdle.BindValueChanged(updatePollingRate, true); } - private CachedModelDependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - dependencies = new CachedModelDependencyContainer(base.CreateChildDependencies(parent)); + var dependencies = new CachedModelDependencyContainer(base.CreateChildDependencies(parent)); dependencies.Model.BindTo(currentRoom); return dependencies; } @@ -156,12 +151,16 @@ namespace osu.Game.Screens.Multi Logger.Log($"Polling adjusted to {roomManager.TimeBetweenPolls}"); } - private void pushGameplayScreen(IScreen gameplayScreen) + /// + /// Push a to the main screen stack to begin gameplay. + /// Generally called from a via DI resolution. + /// + public void Start(Func player) { if (!this.IsCurrentScreen()) return; - this.Push(gameplayScreen); + this.Push(new PlayerLoader(player)); } public void APIStateChanged(APIAccess api, APIState state) @@ -294,14 +293,5 @@ namespace osu.Game.Screens.Multi FourthWaveColour = OsuColour.FromHex(@"392850"); } } - - /// - /// Push a to the main screen stack to begin gameplay. - /// Generally called from a via DI resolution. - /// - public void Start(Func player) - { - this.Push(new PlayerLoader(player)); - } } } From d5cce850a8bd035f376912c72ec384ec6e8bd79b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 13:29:41 +0900 Subject: [PATCH 08/22] Revert some unnecessary complications in logo logic --- osu.Game/Screens/Multi/Match/MatchSubScreen.cs | 15 +++++++++------ osu.Game/Screens/Multi/Multiplayer.cs | 15 ++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index cd51aea575..d97b32e54a 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -179,6 +179,15 @@ namespace osu.Game.Screens.Multi.Match CurrentItem.BindValueChanged(currentItemChanged, true); } + public override bool OnExiting(IScreen next) + { + RoomManager?.PartRoom(); + return base.OnExiting(next); + } + + /// + /// Handles propagation of the current playlist item's content to game-wide mechanisms. + /// private void currentItemChanged(PlaylistItem item) { // Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info @@ -190,12 +199,6 @@ namespace osu.Game.Screens.Multi.Match Ruleset.Value = item.Ruleset; } - public override bool OnExiting(IScreen next) - { - RoomManager?.PartRoom(); - return base.OnExiting(next); - } - /// /// Handle the case where a beatmap is imported (and can be used by this match). /// diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 1103e781ff..822be0891b 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -184,7 +184,6 @@ namespace osu.Game.Screens.Multi public override void OnEntering(IScreen last) { this.FadeIn(); - waves.Show(); } @@ -201,18 +200,24 @@ namespace osu.Game.Screens.Multi updatePollingRate(isIdle.Value); - // the wave overlay transition takes longer than expected to run. - logo?.AppendAnimatingAction(() => logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(), false); - + base.OnExiting(next); return false; } + protected override void LogoExiting(OsuLogo logo) + { + base.LogoExiting(logo); + + // the wave overlay transition takes longer than expected to run. + logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(); + } + public override void OnResuming(IScreen last) { this.FadeIn(250); this.ScaleTo(1, 250, Easing.OutSine); - logo?.AppendAnimatingAction(() => ApplyLogoArrivingDefaults(logo), true); + base.OnResuming(last); updatePollingRate(isIdle.Value); } From a28689ff4c478946ab5d2cba015e58ef46058fb9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 17:58:36 +0900 Subject: [PATCH 09/22] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index e87b43ac93..c1a77a17cd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 0d8a7e3a34..c6b3494d47 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From 2ea839c475aa970ac1c22ac904d0ec681e45c272 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 19:18:22 +0900 Subject: [PATCH 10/22] Fix crashes on beatmap not being set correctly in player --- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/ReplayPlayer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 71b7b77e5d..5a2ef688ca 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -383,7 +383,7 @@ namespace osu.Game.Screens.Play return true; } - if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? true)) + if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded?.Value != false) && (!pauseContainer?.IsResuming ?? true)) { // In the case of replays, we may have changed the playback rate. applyRateFromMods(); diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 3317deca8b..3190139378 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play protected override void LoadComplete() { base.LoadComplete(); - RulesetContainer.SetReplayScore(score); + RulesetContainer?.SetReplayScore(score); } protected override ScoreInfo CreateScore() => score.ScoreInfo; From b967b93b8847060064c3f8c9476200e7dc60f58a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Feb 2019 19:53:08 +0900 Subject: [PATCH 11/22] Fix regressions in tests --- osu.Game.Tests/Visual/TestCasePlayerLoader.cs | 14 ++++++++++++-- osu.Game/Tests/Visual/OsuTestCase.cs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs index 82ce7e125a..16cb94c65e 100644 --- a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs @@ -3,6 +3,7 @@ using System.Threading; using osu.Framework.Allocation; +using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Screens.Play; @@ -12,28 +13,37 @@ namespace osu.Game.Tests.Visual public class TestCasePlayerLoader : ManualInputManagerTestCase { private PlayerLoader loader; + private ScreenStack stack; [BackgroundDependencyLoader] private void load(OsuGameBase game) { Beatmap.Value = new DummyWorkingBeatmap(game); - AddStep("load dummy beatmap", () => Add(loader = new PlayerLoader(() => new Player + InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both }); + + AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player { AllowPause = false, AllowLeadIn = false, AllowResults = false, }))); + AddUntilStep(() => loader.IsCurrentScreen(), "wait for current"); + AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre)); AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current"); + AddStep("exit loader", () => loader.Exit()); + + AddUntilStep(() => !loader.IsAlive, "wait for no longer alive"); + AddStep("load slow dummy beatmap", () => { SlowLoadPlayer slow = null; - Add(loader = new PlayerLoader(() => slow = new SlowLoadPlayer + stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer { AllowPause = false, AllowLeadIn = false, diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 3dfcd0febd..74cd4684da 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual // This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures beatmap.Default = new DummyWorkingBeatmap(Dependencies.Get()); - Dependencies.CacheAs(beatmap); + Dependencies.CacheAs>(beatmap); Dependencies.CacheAs>(beatmap); Dependencies.CacheAs(Ruleset); From 19bef01dd0d2cdbaf067a713ec9af9ec10087fce Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 11:05:02 +0900 Subject: [PATCH 12/22] Attempt to maybe fix tests --- osu.Game/Tests/Visual/ScreenTestCase.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Tests/Visual/ScreenTestCase.cs b/osu.Game/Tests/Visual/ScreenTestCase.cs index 79c57ad9f4..c0eceb84a7 100644 --- a/osu.Game/Tests/Visual/ScreenTestCase.cs +++ b/osu.Game/Tests/Visual/ScreenTestCase.cs @@ -33,5 +33,11 @@ namespace osu.Game.Tests.Visual stack.Exit(); stack.Push(screen); } + + protected override void Dispose(bool isDisposing) + { + stack.Dispose(); + base.Dispose(isDisposing); + } } } From c3ae4d7b142ac66a6a19bb7f72ec006415f7224a Mon Sep 17 00:00:00 2001 From: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com> Date: Wed, 13 Feb 2019 11:34:48 +0900 Subject: [PATCH 13/22] Improve comment Co-Authored-By: peppy --- osu.Game/Screens/OsuScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 86f1f3a9d9..b8d6fda97d 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; /// - /// Disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). + /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). /// public virtual bool DisallowExternalBeatmapRulesetChanges => false; From ab3adafafda7efedf7e36e0278b69d449fe2c302 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 14:13:54 +0900 Subject: [PATCH 14/22] Fix crashes after entering player --- osu.Game/Screens/Select/PlaySongSelect.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 982a44a8d3..7b3c3e0ec3 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -58,7 +58,6 @@ namespace osu.Game.Screens.Select } Beatmap.Value.Track.Looping = false; - Beatmap.Disabled = true; SampleConfirm?.Play(); From 166cdab2e83c37625ff6fb5a019873572cb63f0e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 14:14:57 +0900 Subject: [PATCH 15/22] Remove unnecessary null check --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 5a2ef688ca..2ab207e47a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -383,7 +383,7 @@ namespace osu.Game.Screens.Play return true; } - if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded?.Value != false) && (!pauseContainer?.IsResuming ?? true)) + if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!pauseContainer?.IsResuming ?? true)) { // In the case of replays, we may have changed the playback rate. applyRateFromMods(); From 1373e0fad078a73f5647ed43a94ac46dd2cb8027 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 14:57:40 +0900 Subject: [PATCH 16/22] Fix BeatmapTitle not always displaying --- osu.Game/Screens/Multi/Components/BeatmapTitle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index ff1a1fb3a4..7a513a7f5f 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Multi.Components private void updateText() { - if (!IsLoaded) + if (LoadState < LoadState.Loading) return; textFlow.Clear(); From 43843ac5586b2fb5e25292f80c4147e0ebab213c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 14:58:40 +0900 Subject: [PATCH 17/22] Remove explicit dispose --- osu.Game/Tests/Visual/ScreenTestCase.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Game/Tests/Visual/ScreenTestCase.cs b/osu.Game/Tests/Visual/ScreenTestCase.cs index c0eceb84a7..79c57ad9f4 100644 --- a/osu.Game/Tests/Visual/ScreenTestCase.cs +++ b/osu.Game/Tests/Visual/ScreenTestCase.cs @@ -33,11 +33,5 @@ namespace osu.Game.Tests.Visual stack.Exit(); stack.Push(screen); } - - protected override void Dispose(bool isDisposing) - { - stack.Dispose(); - base.Dispose(isDisposing); - } } } From 3ec94e4ab36c8ef02f4ca6dfce7127785c84ead0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 15:14:34 +0900 Subject: [PATCH 18/22] Remove disable setting --- osu.Game/Tests/Visual/OsuTestCase.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 74cd4684da..6bff4c0291 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -58,11 +58,7 @@ namespace osu.Game.Tests.Visual { base.Dispose(isDisposing); - if (beatmap != null) - { - beatmap.Disabled = true; - beatmap.Value.Track.Stop(); - } + beatmap?.Value.Track.Stop(); if (localStorage.IsValueCreated) { From e604806398ca26a392bea35b87e15ef0663ddca5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 19:43:01 +0900 Subject: [PATCH 19/22] Fix regression in screen change allowance logic --- osu.Game/OsuGame.cs | 2 +- osu.Game/Screens/IOsuScreen.cs | 6 ++++++ osu.Game/Screens/Select/MatchSongSelect.cs | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 3b71324644..4dc9d71d37 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -292,7 +292,7 @@ namespace osu.Game return; } - if ((screenStack.CurrentScreen as IOsuScreen)?.DisallowExternalBeatmapRulesetChanges != false) + if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false) { notifications.Post(new SimpleNotification { diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs index f256760a0a..9e28de5593 100644 --- a/osu.Game/Screens/IOsuScreen.cs +++ b/osu.Game/Screens/IOsuScreen.cs @@ -17,6 +17,12 @@ namespace osu.Game.Screens /// bool DisallowExternalBeatmapRulesetChanges { get; } + /// + /// Whether a top-level component should be allowed to exit the current screen to, for example, + /// complete an import. + /// + bool AllowExternalScreenChange { get; } + /// /// Whether this allows the cursor to be displayed. /// diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index cfeaa1785e..d7ff95be85 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -17,6 +17,8 @@ namespace osu.Game.Screens.Select public string ShortTitle => "song selection"; public override string Title => ShortTitle.Humanize(); + public override bool AllowExternalScreenChange => false; + public MatchSongSelect() { Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; From 5318de29b4d36bba60971c12e6a8a85695e9e69e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Feb 2019 19:57:54 +0900 Subject: [PATCH 20/22] Fix import logic again --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4dc9d71d37..ad6411a2d6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -311,7 +311,7 @@ namespace osu.Game void loadScore() { - if (!menuScreen.IsCurrentScreen()) + if (!menuScreen.IsCurrentScreen() || Beatmap.Disabled) { menuScreen.MakeCurrent(); this.Delay(500).Schedule(loadScore, out scoreLoad); From 94ceb1e32bc38e545a4d69349b8cf6a7370996e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Feb 2019 13:28:21 +0900 Subject: [PATCH 21/22] Move screen change allowance to local usage --- osu.Game/Screens/Select/MatchSongSelect.cs | 2 -- osu.Game/Screens/Select/PlaySongSelect.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index d7ff95be85..cfeaa1785e 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -17,8 +17,6 @@ namespace osu.Game.Screens.Select public string ShortTitle => "song selection"; public override string Title => ShortTitle.Humanize(); - public override bool AllowExternalScreenChange => false; - public MatchSongSelect() { Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7b3c3e0ec3..b5e9cd5f41 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Select private bool removeAutoModOnResume; private OsuScreen player; + public override bool AllowExternalScreenChange => true; + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index caa95ec549..3be4dd8c0b 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -45,8 +45,6 @@ namespace osu.Game.Screens.Select protected virtual bool ShowFooter => true; - public override bool AllowExternalScreenChange => true; - /// /// Can be null if is false. /// From cf66fc69242c8eeec4b3bda4a39dd6aecf29018a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Feb 2019 13:29:07 +0900 Subject: [PATCH 22/22] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c1a77a17cd..38ed6870ff 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index c6b3494d47..fb8a46992e 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + +