1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

Add Match Info.

This commit is contained in:
DrabWeb 2018-05-29 01:51:04 -03:00
parent 98819880c4
commit c8ce34b6d4
4 changed files with 234 additions and 6 deletions

View File

@ -1,22 +1,37 @@
// 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.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Screens.Multi.Screens.Match;
namespace osu.Game.Tests.Visual
{
public class TestCaseMatch : OsuTestCase
{
public TestCaseMatch()
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
Room room = new Room
{
Name = { Value = @"One Awesome Room" },
Status = { Value = new RoomStatusOpen() },
Availability = { Value = RoomAvailability.Public },
Type = { Value = new GameTypeTeamVersus() },
Beatmap =
{
Value = new BeatmapInfo
{
StarDifficulty = 5.02,
Ruleset = rulesets.GetRuleset(1),
Metadata = new BeatmapMetadata
{
Title = @"Paradigm Shift",
Artist = @"Morimori Atsushi",
AuthorString = @"eiri-",
},
BeatmapSet = new BeatmapSetInfo
{
OnlineInfo = new BeatmapSetOnlineInfo

View File

@ -20,6 +20,8 @@ namespace osu.Game.Screens.Multi.Screens.Match
{
public class Header : Container
{
public const float HEIGHT = 200;
private readonly Box tabStrip;
private readonly UpdateableBeatmapSetCover cover;
@ -33,10 +35,11 @@ namespace osu.Game.Screens.Multi.Screens.Match
public Header()
{
RelativeSizeAxes = Axes.X;
Height = 200;
Height = HEIGHT;
Children = new Drawable[]
{
// todo: gradient over the cover
cover = new UpdateableBeatmapSetCover
{
RelativeSizeAxes = Axes.Both,

View File

@ -0,0 +1,194 @@
// 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;
namespace osu.Game.Screens.Multi.Screens.Match
{
public class Info : Container
{
public const float HEIGHT = 128;
private readonly OsuSpriteText name, availabilityStatus;
private readonly BeatmapTypeInfo beatmapTypeInfo;
private OsuColour colours;
public string Name
{
set { name.Text = value; }
}
private RoomAvailability availability;
public RoomAvailability Availability
{
set
{
if (value == availability) return;
availability = value;
if (IsLoaded)
updateAvailabilityStatus();
}
}
private RoomStatus status;
public RoomStatus Status
{
set
{
if (value == status) return;
status = value;
if (IsLoaded)
updateAvailabilityStatus();
}
}
public BeatmapInfo Beatmap
{
set { beatmapTypeInfo.Beatmap = value; }
}
public GameType Type
{
set { beatmapTypeInfo.Type = value; }
}
public Info()
{
RelativeSizeAxes = Axes.X;
Height = HEIGHT;
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,
},
},
},
new ReadyButton
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 200,
Padding = new MarginPadding { Vertical = 10 },
},
},
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
this.colours = colours;
}
protected override void LoadComplete()
{
base.LoadComplete();
updateAvailabilityStatus();
}
private void updateAvailabilityStatus()
{
if (status != null)
{
availabilityStatus.FadeColour(status.GetAppropriateColour(colours));
availabilityStatus.Text = $"{availability.GetDescription()}, {status.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,
};
public ReadyButton()
{
Height = 1;
Text = "Ready";
Action = () => Ready.Value = !Ready.Value;
}
[BackgroundDependencyLoader]
private void load()
{
BackgroundColour = OsuColour.FromHex(@"1187aa");
Triangles.ColourLight = OsuColour.FromHex(@"277b9c");
Triangles.ColourDark = OsuColour.FromHex(@"1f6682");
Triangles.TriangleScale = 1.5f;
// todo: visually select
Ready.ValueChanged += value =>
{
if (value)
Text = "Not Ready";
else
Text = "Ready";
};
}
}
}
}

View File

@ -12,6 +12,11 @@ namespace osu.Game.Screens.Multi.Screens.Match
public class Match : MultiplayerScreen
{
private readonly Room room;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
public override string Title => room.Name.Value;
@ -20,22 +25,33 @@ namespace osu.Game.Screens.Multi.Screens.Match
{
this.room = room;
Header header;
Info info;
Children = new Drawable[]
{
header = new Header(),
info = new Info
{
Margin = new MarginPadding { Top = Header.HEIGHT },
},
};
header.BeatmapButton.Action = () =>
{
Push(new MatchSongSelect());
};
header.BeatmapButton.Action = () => Push(new MatchSongSelect());
nameBind.ValueChanged += n => info.Name = n;
statusBind.ValueChanged += s => info.Status = s;
availabilityBind.ValueChanged += a => info.Availability = a;
typeBind.ValueChanged += t => info.Type = t;
beatmapBind.ValueChanged += b =>
{
header.BeatmapSet = b.BeatmapSet;
info.Beatmap = b;
};
nameBind.BindTo(room.Name);
statusBind.BindTo(room.Status);
availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type);
beatmapBind.BindTo(room.Beatmap);
}
}