Decouple header from matchscreen

This commit is contained in:
smoogipoo 2018-12-22 14:12:27 +09:00
parent c06cf5d379
commit 21cfe5a3e6
3 changed files with 27 additions and 40 deletions

View File

@ -3,10 +3,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
@ -20,37 +18,34 @@ namespace osu.Game.Tests.Visual
typeof(Header) typeof(Header)
}; };
private readonly Bindable<BeatmapInfo> beatmap = new Bindable<BeatmapInfo>();
private readonly Bindable<GameType> type = new Bindable<GameType>();
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
public TestCaseMatchHeader() public TestCaseMatchHeader()
{ {
var header = new Header(new Room()); var room = new Room();
header.Beatmap.BindTo(beatmap); var header = new Header(room);
header.Type.BindTo(type);
header.Mods.BindTo(mods);
beatmap.Value = new BeatmapInfo room.Playlist.Add(new PlaylistItem
{ {
Metadata = new BeatmapMetadata Beatmap = new BeatmapInfo
{ {
Title = "Title", Metadata = new BeatmapMetadata
Artist = "Artist", {
AuthorString = "Author", Title = "Title",
Artist = "Artist",
AuthorString = "Author",
},
Version = "Version",
Ruleset = new OsuRuleset().RulesetInfo
}, },
Version = "Version", RequiredMods =
Ruleset = new OsuRuleset().RulesetInfo {
}; new OsuModDoubleTime(),
new OsuModNoFail(),
new OsuModRelax(),
}
});
type.Value = new GameTypeTimeshift(); room.Type.Value = new GameTypeTimeshift();
mods.Value = new Mod[]
{
new OsuModDoubleTime(),
new OsuModNoFail(),
new OsuModRelax(),
};
Child = header; Child = header;
} }

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -10,12 +9,10 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList; using osu.Game.Overlays.SearchableList;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osuTK; using osuTK;
@ -27,9 +24,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
public const float HEIGHT = 200; public const float HEIGHT = 200;
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); private readonly RoomBindings bindings = new RoomBindings();
public readonly IBindable<GameType> Type = new Bindable<GameType>();
public readonly IBindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
private readonly Box tabStrip; private readonly Box tabStrip;
@ -42,6 +37,8 @@ namespace osu.Game.Screens.Multi.Match.Components
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = HEIGHT; Height = HEIGHT;
bindings.Room = room;
BeatmapTypeInfo beatmapTypeInfo; BeatmapTypeInfo beatmapTypeInfo;
BeatmapSelectButton beatmapButton; BeatmapSelectButton beatmapButton;
UpdateableBeatmapBackgroundSprite background; UpdateableBeatmapBackgroundSprite background;
@ -114,13 +111,12 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
}; };
beatmapTypeInfo.Beatmap.BindTo(Beatmap); beatmapTypeInfo.Beatmap.BindTo(bindings.CurrentBeatmap);
beatmapTypeInfo.Type.BindTo(Type); beatmapTypeInfo.Type.BindTo(bindings.Type);
background.Beatmap.BindTo(Beatmap); background.Beatmap.BindTo(bindings.CurrentBeatmap);
Mods.BindValueChanged(m => modDisplay.Current.Value = m, true); bindings.CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true);
beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke(); beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke();
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -104,10 +104,6 @@ namespace osu.Game.Screens.Multi.Match
else else
settings.Hide(); settings.Hide();
}; };
header.Type.BindTo(bindings.Type);
header.Beatmap.BindTo(bindings.CurrentBeatmap);
header.Mods.BindTo(bindings.CurrentMods);
} }
protected override void LoadComplete() protected override void LoadComplete()