1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 10:12:53 +08:00

Move GameTypePicker label to RoomSettingsOverlay.

This commit is contained in:
DrabWeb 2018-06-07 00:39:16 -03:00
parent 5c0e40df29
commit f13f71b1e9
2 changed files with 65 additions and 77 deletions

View File

@ -2,87 +2,50 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using OpenTK; using OpenTK;
namespace osu.Game.Screens.Multi.Screens.Match.Settings namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
public class GameTypePicker : FillFlowContainer, IHasCurrentValue<GameType> public class GameTypePicker : TabControl<GameType>
{ {
private readonly OsuSpriteText tooltip; private const float height = 40;
private const float selection_width = 3;
public Bindable<GameType> Current { get; } = new Bindable<GameType>(); protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value);
protected override Dropdown<GameType> CreateDropdown() => null;
public GameTypePicker() public GameTypePicker()
{ {
AutoSizeAxes = Axes.Y; Height = height + selection_width * 2;
RelativeSizeAxes = Axes.X; TabContainer.Spacing = new Vector2(10 - selection_width * 2);
Direction = FillDirection.Vertical;
Spacing = new Vector2(7);
Picker picker; AddItem(new GameTypeTag());
Children = new Drawable[] AddItem(new GameTypeVersus());
{ AddItem(new GameTypeTagTeam());
picker = new Picker AddItem(new GameTypeTeamVersus());
{
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);
} }
[BackgroundDependencyLoader] private class GameTypePickerItem : TabItem<GameType>
private void load(OsuColour colours)
{ {
tooltip.Colour = colours.Yellow; private const float transition_duration = 200;
}
private class Picker : TabControl<GameType> private readonly Container selection;
{
private const float height = 40;
private const float selection_width = 3;
protected override TabItem<GameType> CreateTabItem(GameType value) => new PickerItem(value); public GameTypePickerItem(GameType value) : base(value)
protected override Dropdown<GameType> CreateDropdown() => null;
public Picker()
{ {
Height = height + selection_width * 2; AutoSizeAxes = Axes.Both;
TabContainer.Spacing = new Vector2(10 - selection_width * 2);
}
private class PickerItem : TabItem<GameType> DrawableGameType icon;
{ Children = new Drawable[]
private const float transition_duration = 200;
private readonly Container selection;
public PickerItem(GameType value)
: base(value)
{ {
AutoSizeAxes = Axes.Both; selection = new CircularContainer
Child = selection = new CircularContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
@ -91,31 +54,30 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
}; },
} icon = new DrawableGameType(Value)
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
DrawableGameType icon;
Add(icon = new DrawableGameType(Value)
{ {
Size = new Vector2(height), Size = new Vector2(height),
}); },
};
selection.Colour = colours.Yellow; icon.Margin = new MarginPadding(selection_width);
icon.Margin = new MarginPadding(selection_width); }
}
protected override void OnActivated() [BackgroundDependencyLoader]
{ private void load(OsuColour colours)
selection.FadeIn(transition_duration, Easing.OutQuint); {
} selection.Colour = colours.Yellow;
}
protected override void OnDeactivated() protected override void OnActivated()
{ {
selection.FadeOut(transition_duration, Easing.OutQuint); selection.FadeIn(transition_duration, Easing.OutQuint);
} }
protected override void OnDeactivated()
{
selection.FadeOut(transition_duration, Easing.OutQuint);
} }
} }
} }

View File

@ -28,6 +28,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
private readonly Room room; private readonly Room room;
private readonly Container content; private readonly Container content;
private readonly OsuSpriteText typeLabel;
protected readonly OsuTextBox Name, MaxParticipants; protected readonly OsuTextBox Name, MaxParticipants;
protected readonly RoomAvailabilityPicker Availability; protected readonly RoomAvailabilityPicker Availability;
@ -74,7 +75,24 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
}, },
new Section("GAME TYPE") 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; nameBind.ValueChanged += n => Name.Text = n;
availabilityBind.ValueChanged += a => Availability.Current.Value = a; availabilityBind.ValueChanged += a => Availability.Current.Value = a;
typeBind.ValueChanged += t => Type.Current.Value = t; typeBind.ValueChanged += t => Type.Current.Value = t;
@ -125,6 +145,12 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
maxParticipantsBind.BindTo(room.MaxParticipants); maxParticipantsBind.BindTo(room.MaxParticipants);
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
typeLabel.Colour = colours.Yellow;
}
protected override void PopIn() protected override void PopIn()
{ {
// reapply the rooms values if the overlay was completely closed // reapply the rooms values if the overlay was completely closed