diff --git a/osu.Game/Screens/Multi/Screens/Match/Settings/GameTypePicker.cs b/osu.Game/Screens/Multi/Screens/Match/Settings/GameTypePicker.cs index 50df4ea334..9c52940cb8 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Settings/GameTypePicker.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Settings/GameTypePicker.cs @@ -2,87 +2,50 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Components; using OpenTK; namespace osu.Game.Screens.Multi.Screens.Match.Settings { - public class GameTypePicker : FillFlowContainer, IHasCurrentValue + public class GameTypePicker : TabControl { - private readonly OsuSpriteText tooltip; + private const float height = 40; + private const float selection_width = 3; - public Bindable Current { get; } = new Bindable(); + protected override TabItem CreateTabItem(GameType value) => new GameTypePickerItem(value); + protected override Dropdown CreateDropdown() => null; public GameTypePicker() { - AutoSizeAxes = Axes.Y; - RelativeSizeAxes = Axes.X; - Direction = FillDirection.Vertical; - Spacing = new Vector2(7); + Height = height + selection_width * 2; + TabContainer.Spacing = new Vector2(10 - selection_width * 2); - Picker picker; - Children = new Drawable[] - { - picker = new Picker - { - RelativeSizeAxes = Axes.X, - }, - tooltip = new OsuSpriteText - { - TextSize = 14, - }, - }; - - Current.ValueChanged += t => tooltip.Text = t.Name; - - picker.AddItem(new GameTypeTag()); - picker.AddItem(new GameTypeVersus()); - picker.AddItem(new GameTypeTagTeam()); - picker.AddItem(new GameTypeTeamVersus()); - - Current.BindTo(picker.Current); + AddItem(new GameTypeTag()); + AddItem(new GameTypeVersus()); + AddItem(new GameTypeTagTeam()); + AddItem(new GameTypeTeamVersus()); } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private class GameTypePickerItem : TabItem { - tooltip.Colour = colours.Yellow; - } + private const float transition_duration = 200; - private class Picker : TabControl - { - private const float height = 40; - private const float selection_width = 3; + private readonly Container selection; - protected override TabItem CreateTabItem(GameType value) => new PickerItem(value); - protected override Dropdown CreateDropdown() => null; - - public Picker() + public GameTypePickerItem(GameType value) : base(value) { - Height = height + selection_width * 2; - TabContainer.Spacing = new Vector2(10 - selection_width * 2); - } + AutoSizeAxes = Axes.Both; - private class PickerItem : TabItem - { - private const float transition_duration = 200; - - private readonly Container selection; - - public PickerItem(GameType value) - : base(value) + DrawableGameType icon; + Children = new Drawable[] { - AutoSizeAxes = Axes.Both; - - Child = selection = new CircularContainer + selection = new CircularContainer { RelativeSizeAxes = Axes.Both, Masking = true, @@ -91,31 +54,30 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings { RelativeSizeAxes = Axes.Both, }, - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - DrawableGameType icon; - Add(icon = new DrawableGameType(Value) + }, + icon = new DrawableGameType(Value) { Size = new Vector2(height), - }); + }, + }; - selection.Colour = colours.Yellow; - icon.Margin = new MarginPadding(selection_width); - } + icon.Margin = new MarginPadding(selection_width); + } - protected override void OnActivated() - { - selection.FadeIn(transition_duration, Easing.OutQuint); - } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + selection.Colour = colours.Yellow; + } - protected override void OnDeactivated() - { - selection.FadeOut(transition_duration, Easing.OutQuint); - } + protected override void OnActivated() + { + selection.FadeIn(transition_duration, Easing.OutQuint); + } + + protected override void OnDeactivated() + { + selection.FadeOut(transition_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Multi/Screens/Match/Settings/RoomSettingsOverlay.cs b/osu.Game/Screens/Multi/Screens/Match/Settings/RoomSettingsOverlay.cs index 2e8fba30a7..0d2cb18b7b 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Settings/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Settings/RoomSettingsOverlay.cs @@ -28,6 +28,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings private readonly Room room; private readonly Container content; + private readonly OsuSpriteText typeLabel; protected readonly OsuTextBox Name, MaxParticipants; protected readonly RoomAvailabilityPicker Availability; @@ -74,7 +75,24 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings }, new Section("GAME TYPE") { - Child = Type = new GameTypePicker(), + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Spacing = new Vector2(7), + Children = new Drawable[] + { + Type = new GameTypePicker + { + RelativeSizeAxes = Axes.X, + }, + typeLabel = new OsuSpriteText + { + TextSize = 14, + }, + }, + }, }, }, }, @@ -114,6 +132,8 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings }, }; + Type.Current.ValueChanged += t => typeLabel.Text = t.Name; + nameBind.ValueChanged += n => Name.Text = n; availabilityBind.ValueChanged += a => Availability.Current.Value = a; typeBind.ValueChanged += t => Type.Current.Value = t; @@ -125,6 +145,12 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings maxParticipantsBind.BindTo(room.MaxParticipants); } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + typeLabel.Colour = colours.Yellow; + } + protected override void PopIn() { // reapply the rooms values if the overlay was completely closed