1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 07:23:20 +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
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<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()
{
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<GameType>
{
tooltip.Colour = colours.Yellow;
}
private const float transition_duration = 200;
private class Picker : TabControl<GameType>
{
private const float height = 40;
private const float selection_width = 3;
private readonly Container selection;
protected override TabItem<GameType> CreateTabItem(GameType value) => new PickerItem(value);
protected override Dropdown<GameType> 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<GameType>
{
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);
}
}
}

View File

@ -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