mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Renamespace
This commit is contained in:
113
osu.Game/Screens/Multi/Match/Components/GameTypePicker.cs
Normal file
113
osu.Game/Screens/Multi/Match/Components/GameTypePicker.cs
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class GameTypePicker : DisableableTabControl<GameType>
|
||||
{
|
||||
private const float height = 40;
|
||||
private const float selection_width = 3;
|
||||
|
||||
protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value);
|
||||
|
||||
protected override Dropdown<GameType> CreateDropdown() => null;
|
||||
|
||||
public GameTypePicker()
|
||||
{
|
||||
Height = height + selection_width * 2;
|
||||
TabContainer.Spacing = new Vector2(10 - selection_width * 2);
|
||||
|
||||
AddItem(new GameTypeTag());
|
||||
AddItem(new GameTypeVersus());
|
||||
AddItem(new GameTypeTagTeam());
|
||||
AddItem(new GameTypeTeamVersus());
|
||||
AddItem(new GameTypeTimeshift());
|
||||
}
|
||||
|
||||
private class GameTypePickerItem : DisableableTabItem<GameType>
|
||||
{
|
||||
private const float transition_duration = 200;
|
||||
|
||||
private readonly CircularContainer hover, selection;
|
||||
|
||||
public GameTypePickerItem(GameType value)
|
||||
: base(value)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
selection = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Alpha = 0,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
new DrawableGameType(Value)
|
||||
{
|
||||
Size = new Vector2(height),
|
||||
Margin = new MarginPadding(selection_width),
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(selection_width),
|
||||
Child = hover = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Alpha = 0,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
selection.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
hover.FadeOut(transition_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
{
|
||||
selection.FadeIn(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
selection.FadeOut(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
osu.Game/Screens/Multi/Match/Components/Header.cs
Normal file
126
osu.Game/Screens/Multi/Match/Components/Header.cs
Normal file
@ -0,0 +1,126 @@
|
||||
// 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;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class Header : Container
|
||||
{
|
||||
public const float HEIGHT = 200;
|
||||
|
||||
public readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private readonly Box tabStrip;
|
||||
|
||||
public readonly MatchTabControl Tabs;
|
||||
|
||||
public Action OnRequestSelectBeatmap;
|
||||
|
||||
public Header()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = HEIGHT;
|
||||
|
||||
BeatmapSelectButton beatmapButton;
|
||||
UpdateableBeatmapBackgroundSprite background;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Child = background = new HeaderBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0), Color4.Black.Opacity(0.5f)),
|
||||
},
|
||||
tabStrip = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 200,
|
||||
Padding = new MarginPadding { Vertical = 5 },
|
||||
Child = beatmapButton = new BeatmapSelectButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 1
|
||||
},
|
||||
},
|
||||
Tabs = new MatchTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke();
|
||||
|
||||
background.Beatmap.BindTo(Beatmap);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
tabStrip.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
private class BeatmapSelectButton : TriangleButton
|
||||
{
|
||||
private readonly IBindable<bool> createdBind = new Bindable<bool>();
|
||||
|
||||
[Resolved]
|
||||
private Room room { get; set; }
|
||||
|
||||
public BeatmapSelectButton()
|
||||
{
|
||||
Text = "Select beatmap";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
createdBind.BindTo(room.Created);
|
||||
createdBind.BindValueChanged(v => Enabled.Value = !v, true);
|
||||
}
|
||||
}
|
||||
|
||||
private class HeaderBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
protected override double FadeDuration => 0;
|
||||
}
|
||||
}
|
||||
}
|
181
osu.Game/Screens/Multi/Match/Components/Info.cs
Normal file
181
osu.Game/Screens/Multi/Match/Components/Info.cs
Normal file
@ -0,0 +1,181 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class Info : Container
|
||||
{
|
||||
public const float HEIGHT = 128;
|
||||
|
||||
private readonly OsuSpriteText availabilityStatus;
|
||||
private readonly ReadyButton readyButton;
|
||||
|
||||
private OsuColour colours;
|
||||
|
||||
public Bindable<bool> Ready => readyButton.Ready;
|
||||
|
||||
public readonly Bindable<string> Name = new Bindable<string>();
|
||||
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
|
||||
public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
public readonly Bindable<GameType> Type = new Bindable<GameType>();
|
||||
|
||||
public Info()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = HEIGHT;
|
||||
|
||||
BeatmapTypeInfo beatmapTypeInfo;
|
||||
OsuSpriteText name;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"28242d"),
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Padding = new MarginPadding { Vertical = 20 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
name = new OsuSpriteText { TextSize = 30 },
|
||||
availabilityStatus = new OsuSpriteText { TextSize = 14 },
|
||||
},
|
||||
},
|
||||
beatmapTypeInfo = new BeatmapTypeInfo
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
},
|
||||
},
|
||||
readyButton = new ReadyButton
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(200, 1),
|
||||
Padding = new MarginPadding { Vertical = 10 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
beatmapTypeInfo.Beatmap.BindTo(Beatmap);
|
||||
beatmapTypeInfo.Type.BindTo(Type);
|
||||
|
||||
Availability.BindValueChanged(_ => updateAvailabilityStatus());
|
||||
Status.BindValueChanged(_ => updateAvailabilityStatus());
|
||||
Name.BindValueChanged(n => name.Text = n);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
this.colours = colours;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateAvailabilityStatus();
|
||||
}
|
||||
|
||||
private void updateAvailabilityStatus()
|
||||
{
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
if (Status.Value != null)
|
||||
{
|
||||
availabilityStatus.FadeColour(Status.Value.GetAppropriateColour(colours), 100);
|
||||
availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private class ReadyButton : TriangleButton
|
||||
{
|
||||
public readonly Bindable<bool> Ready = new Bindable<bool>();
|
||||
|
||||
protected override SpriteText CreateText() => new OsuSpriteText
|
||||
{
|
||||
Depth = -1,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Font = @"Exo2.0-Light",
|
||||
TextSize = 30,
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundColour = OsuColour.FromHex(@"1187aa");
|
||||
Triangles.ColourLight = OsuColour.FromHex(@"277b9c");
|
||||
Triangles.ColourDark = OsuColour.FromHex(@"1f6682");
|
||||
Triangles.TriangleScale = 1.5f;
|
||||
|
||||
Container active;
|
||||
Add(active = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0f,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.15f,
|
||||
Blending = BlendingMode.Additive,
|
||||
},
|
||||
});
|
||||
|
||||
Action = () => Ready.Value = !Ready.Value;
|
||||
|
||||
Ready.BindValueChanged(value =>
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Text = "Not Ready";
|
||||
active.FadeIn(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = "Ready";
|
||||
active.FadeOut(200);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
osu.Game/Screens/Multi/Match/Components/MatchPage.cs
Normal file
28
osu.Game/Screens/Multi/Match/Components/MatchPage.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public abstract class MatchPage
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
public readonly BindableBool Enabled = new BindableBool(true);
|
||||
|
||||
public override string ToString() => Name;
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
public override bool Equals(object obj) => GetType() == obj?.GetType();
|
||||
}
|
||||
|
||||
public class SettingsMatchPage : MatchPage
|
||||
{
|
||||
public override string Name => "Settings";
|
||||
}
|
||||
|
||||
public class RoomMatchPage : MatchPage
|
||||
{
|
||||
public override string Name => "Room";
|
||||
}
|
||||
}
|
68
osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs
Normal file
68
osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class MatchTabControl : PageTabControl<MatchPage>
|
||||
{
|
||||
private readonly IBindable<bool> created = new Bindable<bool>();
|
||||
|
||||
[Resolved]
|
||||
private Room room { get; set; }
|
||||
|
||||
public MatchTabControl()
|
||||
{
|
||||
AddItem(new SettingsMatchPage());
|
||||
AddItem(new RoomMatchPage());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
created.BindTo(room.Created);
|
||||
created.BindValueChanged(v =>
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
Items.ForEach(t => t.Enabled.Value = !(t is SettingsMatchPage));
|
||||
Current.Value = new RoomMatchPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
Items.ForEach(t => t.Enabled.Value = t is SettingsMatchPage);
|
||||
Current.Value = new SettingsMatchPage();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override TabItem<MatchPage> CreateTabItem(MatchPage value) => new TabItem(value);
|
||||
|
||||
private class TabItem : PageTabItem
|
||||
{
|
||||
private readonly IBindable<bool> enabled = new BindableBool();
|
||||
|
||||
public TabItem(MatchPage value)
|
||||
: base(value)
|
||||
{
|
||||
enabled.BindTo(value.Enabled);
|
||||
enabled.BindValueChanged(v => Colour = v ? Color4.White : Color4.Gray);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!enabled.Value)
|
||||
return true;
|
||||
return base.OnClick(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
78
osu.Game/Screens/Multi/Match/Components/Participants.cs
Normal file
78
osu.Game/Screens/Multi/Match/Components/Participants.cs
Normal file
@ -0,0 +1,78 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class Participants : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<IEnumerable<User>> Users = new Bindable<IEnumerable<User>>();
|
||||
public readonly Bindable<int?> MaxParticipants = new Bindable<int?>();
|
||||
|
||||
public new MarginPadding Padding
|
||||
{
|
||||
get => base.Padding;
|
||||
set => base.Padding = value;
|
||||
}
|
||||
|
||||
public Participants()
|
||||
{
|
||||
FillFlowContainer<UserPanel> usersFlow;
|
||||
ParticipantCount count;
|
||||
|
||||
InternalChild = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
count = new ParticipantCount
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
usersFlow = new FillFlowContainer<UserPanel>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(5),
|
||||
Padding = new MarginPadding { Top = 40 },
|
||||
LayoutDuration = 200,
|
||||
LayoutEasing = Easing.OutQuint,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
count.Participants.BindTo(Users);
|
||||
count.MaxParticipants.BindTo(MaxParticipants);
|
||||
|
||||
Users.BindValueChanged(v =>
|
||||
{
|
||||
usersFlow.Children = v.Select(u => new UserPanel(u)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 300,
|
||||
OnLoadComplete = d => d.FadeInFromZero(60),
|
||||
}).ToList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class RoomAvailabilityPicker : DisableableTabControl<RoomAvailability>
|
||||
{
|
||||
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
|
||||
protected override Dropdown<RoomAvailability> CreateDropdown() => null;
|
||||
|
||||
public RoomAvailabilityPicker()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 35;
|
||||
|
||||
TabContainer.Spacing = new Vector2(10);
|
||||
|
||||
AddItem(RoomAvailability.Public);
|
||||
AddItem(RoomAvailability.FriendsOnly);
|
||||
AddItem(RoomAvailability.InviteOnly);
|
||||
}
|
||||
|
||||
private class RoomAvailabilityPickerItem : DisableableTabItem<RoomAvailability>
|
||||
{
|
||||
private const float transition_duration = 200;
|
||||
|
||||
private readonly Box hover, selection;
|
||||
|
||||
public RoomAvailabilityPickerItem(RoomAvailability value) : base(value)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Width = 102;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"3d3943"),
|
||||
},
|
||||
selection = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
},
|
||||
hover = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
Alpha = 0,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = value.GetDescription(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
selection.Colour = colours.GreenLight;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
hover.FadeOut(transition_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
{
|
||||
selection.FadeIn(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
selection.FadeOut(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
296
osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs
Normal file
296
osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs
Normal file
@ -0,0 +1,296 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class RoomSettingsOverlay : FocusedOverlayContainer
|
||||
{
|
||||
private const float transition_duration = 350;
|
||||
private const float field_padding = 45;
|
||||
|
||||
private readonly Bindable<string> nameBind = new Bindable<string>();
|
||||
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
|
||||
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
|
||||
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
|
||||
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
||||
private readonly Bindable<bool> createdBind = new Bindable<bool>();
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private readonly OsuSpriteText typeLabel;
|
||||
|
||||
protected readonly OsuTextBox NameField, MaxParticipantsField;
|
||||
protected readonly RoomAvailabilityPicker AvailabilityPicker;
|
||||
protected readonly GameTypePicker TypePicker;
|
||||
protected readonly TriangleButton ApplyButton;
|
||||
protected readonly OsuPasswordTextBox PasswordField;
|
||||
|
||||
[Resolved]
|
||||
private Room room { get; set; }
|
||||
|
||||
public RoomSettingsOverlay()
|
||||
{
|
||||
Masking = true;
|
||||
|
||||
Child = content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"28242d"),
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 35, Bottom = 75, Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
||||
Children = new[]
|
||||
{
|
||||
new SectionContainer
|
||||
{
|
||||
Padding = new MarginPadding { Right = field_padding / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("ROOM NAME")
|
||||
{
|
||||
Child = NameField = new SettingsTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
TabbableContentContainer = this,
|
||||
OnCommit = (sender, text) => apply(),
|
||||
},
|
||||
},
|
||||
new Section("ROOM VISIBILITY")
|
||||
{
|
||||
Child = AvailabilityPicker = new RoomAvailabilityPicker(),
|
||||
},
|
||||
new Section("GAME TYPE")
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(7),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
TypePicker = new GameTypePicker
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
typeLabel = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new SectionContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Padding = new MarginPadding { Left = field_padding / 2 },
|
||||
Children = new[]
|
||||
{
|
||||
new Section("MAX PARTICIPANTS")
|
||||
{
|
||||
Child = MaxParticipantsField = new SettingsNumberTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
TabbableContentContainer = this,
|
||||
OnCommit = (sender, text) => apply(),
|
||||
},
|
||||
},
|
||||
new Section("PASSWORD (OPTIONAL)")
|
||||
{
|
||||
Child = PasswordField = new SettingsPasswordTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
TabbableContentContainer = this,
|
||||
OnCommit = (sender, text) => apply()
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ApplyButton = new ApplySettingsButton
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Size = new Vector2(230, 35),
|
||||
Margin = new MarginPadding { Bottom = 20 },
|
||||
Action = apply,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
TypePicker.Current.ValueChanged += t => typeLabel.Text = t.Name;
|
||||
|
||||
nameBind.ValueChanged += n => NameField.Text = n;
|
||||
availabilityBind.ValueChanged += a => AvailabilityPicker.Current.Value = a;
|
||||
typeBind.ValueChanged += t => TypePicker.Current.Value = t;
|
||||
maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
typeLabel.Colour = colours.Yellow;
|
||||
|
||||
nameBind.BindTo(room.Name);
|
||||
beatmapBind.BindTo(room.Beatmap);
|
||||
availabilityBind.BindTo(room.Availability);
|
||||
typeBind.BindTo(room.Type);
|
||||
maxParticipantsBind.BindTo(room.MaxParticipants);
|
||||
createdBind.BindTo(room.Created);
|
||||
|
||||
MaxParticipantsField.ReadOnly = true;
|
||||
PasswordField.ReadOnly = true;
|
||||
AvailabilityPicker.ReadOnly.Value = true;
|
||||
TypePicker.ReadOnly.Value = true;
|
||||
ApplyButton.Enabled.Value = false;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
ApplyButton.Enabled.Value = hasValidSettings;
|
||||
}
|
||||
|
||||
private bool hasValidSettings => NameField.Text.Length > 0 && beatmapBind.Value != null;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
// reapply the rooms values if the overlay was completely closed
|
||||
if (content.Y == -1)
|
||||
{
|
||||
nameBind.TriggerChange();
|
||||
availabilityBind.TriggerChange();
|
||||
typeBind.TriggerChange();
|
||||
maxParticipantsBind.TriggerChange();
|
||||
}
|
||||
|
||||
content.MoveToY(0, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
content.MoveToY(-1, transition_duration, Easing.InSine);
|
||||
}
|
||||
|
||||
private void apply()
|
||||
{
|
||||
nameBind.Value = NameField.Text;
|
||||
availabilityBind.Value = AvailabilityPicker.Current.Value;
|
||||
typeBind.Value = TypePicker.Current.Value;
|
||||
|
||||
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
||||
maxParticipantsBind.Value = max;
|
||||
else
|
||||
maxParticipantsBind.Value = null;
|
||||
|
||||
// Todo: This should only be set after the room has been created server-side
|
||||
createdBind.Value = true;
|
||||
}
|
||||
|
||||
private class SettingsTextBox : OsuTextBox
|
||||
{
|
||||
protected override Color4 BackgroundUnfocused => Color4.Black;
|
||||
protected override Color4 BackgroundFocused => Color4.Black;
|
||||
}
|
||||
|
||||
private class SettingsNumberTextBox : SettingsTextBox
|
||||
{
|
||||
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
||||
}
|
||||
|
||||
private class SettingsPasswordTextBox : OsuPasswordTextBox
|
||||
{
|
||||
protected override Color4 BackgroundUnfocused => Color4.Black;
|
||||
protected override Color4 BackgroundFocused => Color4.Black;
|
||||
}
|
||||
|
||||
private class SectionContainer : FillFlowContainer<Section>
|
||||
{
|
||||
public SectionContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Width = 0.5f;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(field_padding);
|
||||
}
|
||||
}
|
||||
|
||||
private class Section : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public Section(string title)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = title.ToUpper(),
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class ApplySettingsButton : TriangleButton
|
||||
{
|
||||
public ApplySettingsButton()
|
||||
{
|
||||
Text = "Apply";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = colours.Yellow;
|
||||
Triangles.ColourLight = colours.YellowLight;
|
||||
Triangles.ColourDark = colours.YellowDark;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user