2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-12-10 17:00:57 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-10 17:00:57 +08:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2018-12-10 18:20:41 +08:00
|
|
|
namespace osu.Game.Screens.Multi.Match.Components
|
2018-12-10 17:00:57 +08:00
|
|
|
{
|
|
|
|
public class MatchTabControl : PageTabControl<MatchPage>
|
|
|
|
{
|
2019-02-05 18:00:01 +08:00
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
|
|
|
private Bindable<int?> roomId { get; set; }
|
2018-12-10 17:00:57 +08:00
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
public MatchTabControl()
|
2018-12-10 17:00:57 +08:00
|
|
|
{
|
|
|
|
AddItem(new RoomMatchPage());
|
2018-12-18 17:29:13 +08:00
|
|
|
AddItem(new SettingsMatchPage());
|
2018-12-10 17:00:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2019-02-22 19:13:38 +08:00
|
|
|
roomId.BindValueChanged(id =>
|
2018-12-10 17:00:57 +08:00
|
|
|
{
|
2019-02-22 19:13:38 +08:00
|
|
|
if (id.NewValue.HasValue)
|
2018-12-10 17:00:57 +08:00
|
|
|
{
|
|
|
|
Items.ForEach(t => t.Enabled.Value = !(t is SettingsMatchPage));
|
|
|
|
Current.Value = new RoomMatchPage();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Items.ForEach(t => t.Enabled.Value = t is SettingsMatchPage);
|
|
|
|
Current.Value = new SettingsMatchPage();
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override TabItem<MatchPage> CreateTabItem(MatchPage value) => new TabItem(value);
|
|
|
|
|
|
|
|
private class TabItem : PageTabItem
|
|
|
|
{
|
|
|
|
private readonly IBindable<bool> enabled = new BindableBool();
|
|
|
|
|
|
|
|
public TabItem(MatchPage value)
|
|
|
|
: base(value)
|
|
|
|
{
|
|
|
|
enabled.BindTo(value.Enabled);
|
2019-02-22 19:13:38 +08:00
|
|
|
enabled.BindValueChanged(enabled => Colour = enabled.NewValue ? Color4.White : Color4.Gray, true);
|
2018-12-10 17:00:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
if (!enabled.Value)
|
|
|
|
return true;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-12-10 17:00:57 +08:00
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|