1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +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;
public Bindable<GameType> Current { get; } = new Bindable<GameType>();
public GameTypePicker()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Direction = FillDirection.Vertical;
Spacing = new Vector2(7);
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);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
tooltip.Colour = colours.Yellow;
}
private class Picker : TabControl<GameType>
{ {
private const float height = 40; private const float height = 40;
private const float selection_width = 3; private const float selection_width = 3;
protected override TabItem<GameType> CreateTabItem(GameType value) => new PickerItem(value); protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value);
protected override Dropdown<GameType> CreateDropdown() => null; protected override Dropdown<GameType> CreateDropdown() => null;
public Picker() public GameTypePicker()
{ {
Height = height + selection_width * 2; Height = height + selection_width * 2;
TabContainer.Spacing = new Vector2(10 - selection_width * 2); TabContainer.Spacing = new Vector2(10 - selection_width * 2);
AddItem(new GameTypeTag());
AddItem(new GameTypeVersus());
AddItem(new GameTypeTagTeam());
AddItem(new GameTypeTeamVersus());
} }
private class PickerItem : TabItem<GameType> private class GameTypePickerItem : TabItem<GameType>
{ {
private const float transition_duration = 200; private const float transition_duration = 200;
private readonly Container selection; private readonly Container selection;
public PickerItem(GameType value) public GameTypePickerItem(GameType value) : base(value)
: base(value)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Child = selection = new CircularContainer DrawableGameType icon;
Children = new Drawable[]
{
selection = new CircularContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
@ -91,20 +54,20 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
},
icon = new DrawableGameType(Value)
{
Size = new Vector2(height),
},
}; };
icon.Margin = new MarginPadding(selection_width);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
DrawableGameType icon;
Add(icon = new DrawableGameType(Value)
{
Size = new Vector2(height),
});
selection.Colour = colours.Yellow; selection.Colour = colours.Yellow;
icon.Margin = new MarginPadding(selection_width);
} }
protected override void OnActivated() protected override void OnActivated()
@ -119,4 +82,3 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
} }
} }
} }
}

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