mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Better disabling of various controls
This commit is contained in:
parent
ec83790734
commit
e7d7e00516
@ -14,8 +14,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
|
||||||
public abstract bool IsAvailable { get; }
|
|
||||||
|
|
||||||
public abstract Drawable GetIcon(OsuColour colours, float size);
|
public abstract Drawable GetIcon(OsuColour colours, float size);
|
||||||
|
|
||||||
public override int GetHashCode() => GetType().GetHashCode();
|
public override int GetHashCode() => GetType().GetHashCode();
|
||||||
@ -26,8 +24,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public override string Name => "Tag";
|
public override string Name => "Tag";
|
||||||
|
|
||||||
public override bool IsAvailable => false;
|
|
||||||
|
|
||||||
public override Drawable GetIcon(OsuColour colours, float size)
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
{
|
{
|
||||||
return new SpriteIcon
|
return new SpriteIcon
|
||||||
@ -46,8 +42,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public override string Name => "Versus";
|
public override string Name => "Versus";
|
||||||
|
|
||||||
public override bool IsAvailable => false;
|
|
||||||
|
|
||||||
public override Drawable GetIcon(OsuColour colours, float size)
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
{
|
{
|
||||||
return new VersusRow(colours.Blue, colours.Blue, size * 0.6f)
|
return new VersusRow(colours.Blue, colours.Blue, size * 0.6f)
|
||||||
@ -62,8 +56,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public override string Name => "Tag Team";
|
public override string Name => "Tag Team";
|
||||||
|
|
||||||
public override bool IsAvailable => false;
|
|
||||||
|
|
||||||
public override Drawable GetIcon(OsuColour colours, float size)
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
{
|
{
|
||||||
return new FillFlowContainer
|
return new FillFlowContainer
|
||||||
@ -98,8 +90,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public override string Name => "Team Versus";
|
public override string Name => "Team Versus";
|
||||||
|
|
||||||
public override bool IsAvailable => false;
|
|
||||||
|
|
||||||
public override Drawable GetIcon(OsuColour colours, float size)
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
{
|
{
|
||||||
return new FillFlowContainer
|
return new FillFlowContainer
|
||||||
@ -166,8 +156,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
public override string Name => "Timeshift";
|
public override string Name => "Timeshift";
|
||||||
|
|
||||||
public override bool IsAvailable => true;
|
|
||||||
|
|
||||||
public override Drawable GetIcon(OsuColour colours, float size) => new SpriteIcon
|
public override Drawable GetIcon(OsuColour colours, float size) => new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
44
osu.Game/Screens/Multi/Components/DisableableTabControl.cs
Normal file
44
osu.Game/Screens/Multi/Components/DisableableTabControl.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi.Components
|
||||||
|
{
|
||||||
|
public abstract class DisableableTabControl<T> : TabControl<T>
|
||||||
|
{
|
||||||
|
public IEnumerable<T> DisabledItems
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
foreach (var item in value)
|
||||||
|
(TabMap[item] as DisableableTabItem<T>)?.Disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract class DisableableTabItem<T> : TabItem<T>
|
||||||
|
{
|
||||||
|
protected DisableableTabItem(T value)
|
||||||
|
: base(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isDisabled;
|
||||||
|
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
Alpha = 0.2f;
|
||||||
|
isDisabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (isDisabled)
|
||||||
|
return true;
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Components
|
namespace osu.Game.Screens.Multi.Components
|
||||||
{
|
{
|
||||||
public class GameTypePicker : TabControl<GameType>
|
public class GameTypePicker : DisableableTabControl<GameType>
|
||||||
{
|
{
|
||||||
private const float height = 40;
|
private const float height = 40;
|
||||||
private const float selection_width = 3;
|
private const float selection_width = 3;
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
AddItem(new GameTypeTimeshift());
|
AddItem(new GameTypeTimeshift());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GameTypePickerItem : TabItem<GameType>
|
private class GameTypePickerItem : DisableableTabItem<GameType>
|
||||||
{
|
{
|
||||||
private const float transition_duration = 200;
|
private const float transition_duration = 200;
|
||||||
|
|
||||||
@ -84,9 +84,6 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
selection.Colour = colours.Yellow;
|
selection.Colour = colours.Yellow;
|
||||||
|
|
||||||
if (!Value.IsAvailable)
|
|
||||||
Colour = colours.Gray5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
@ -101,13 +98,6 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
if (!Value.IsAvailable)
|
|
||||||
return true;
|
|
||||||
return base.OnClick(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnActivated()
|
protected override void OnActivated()
|
||||||
{
|
{
|
||||||
selection.FadeIn(transition_duration, Easing.OutQuint);
|
selection.FadeIn(transition_duration, Easing.OutQuint);
|
||||||
|
@ -15,7 +15,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Components
|
namespace osu.Game.Screens.Multi.Components
|
||||||
{
|
{
|
||||||
public class RoomAvailabilityPicker : TabControl<RoomAvailability>
|
public class RoomAvailabilityPicker : DisableableTabControl<RoomAvailability>
|
||||||
{
|
{
|
||||||
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
|
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
|
||||||
protected override Dropdown<RoomAvailability> CreateDropdown() => null;
|
protected override Dropdown<RoomAvailability> CreateDropdown() => null;
|
||||||
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
AddItem(RoomAvailability.InviteOnly);
|
AddItem(RoomAvailability.InviteOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RoomAvailabilityPickerItem : TabItem<RoomAvailability>
|
private class RoomAvailabilityPickerItem : DisableableTabItem<RoomAvailability>
|
||||||
{
|
{
|
||||||
private const float transition_duration = 200;
|
private const float transition_duration = 200;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
public RoomAvailabilityPickerItem(RoomAvailability value) : base(value)
|
public RoomAvailabilityPickerItem(RoomAvailability value) : base(value)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = 120;
|
Width = 102;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 5;
|
CornerRadius = 5;
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
TabbableContentContainer = this,
|
TabbableContentContainer = this,
|
||||||
OnCommit = (sender, text) => apply(),
|
OnCommit = (sender, text) => apply(),
|
||||||
|
Alpha = 0.2f,
|
||||||
|
ReadOnly = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -149,6 +151,21 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
typeBind.ValueChanged += t => TypePicker.Current.Value = t;
|
typeBind.ValueChanged += t => TypePicker.Current.Value = t;
|
||||||
maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString();
|
maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString();
|
||||||
|
|
||||||
|
AvailabilityPicker.DisabledItems = new[]
|
||||||
|
{
|
||||||
|
RoomAvailability.FriendsOnly,
|
||||||
|
RoomAvailability.InviteOnly
|
||||||
|
};
|
||||||
|
|
||||||
|
TypePicker.DisabledItems = new GameType[]
|
||||||
|
{
|
||||||
|
new GameTypeTag(),
|
||||||
|
new GameTypeVersus(),
|
||||||
|
new GameTypeTagTeam(),
|
||||||
|
new GameTypeTeamVersus(),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Room = new Room();
|
Room = new Room();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user