2018-12-10 17:00:57 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
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>
|
|
|
|
{
|
2018-12-12 15:20:11 +08:00
|
|
|
private readonly IBindable<int?> roomIdBind = new Bindable<int?>();
|
2018-12-10 17:00:57 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private Room room { get; set; }
|
|
|
|
|
|
|
|
public MatchTabControl()
|
|
|
|
{
|
|
|
|
AddItem(new SettingsMatchPage());
|
|
|
|
AddItem(new RoomMatchPage());
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2018-12-12 15:20:11 +08:00
|
|
|
roomIdBind.BindTo(room.RoomID);
|
|
|
|
roomIdBind.BindValueChanged(v =>
|
2018-12-10 17:00:57 +08:00
|
|
|
{
|
2018-12-12 15:20:11 +08:00
|
|
|
if (v.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);
|
|
|
|
enabled.BindValueChanged(v => Colour = v ? Color4.White : Color4.Gray);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
if (!enabled.Value)
|
|
|
|
return true;
|
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|