1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Add mods to the match info

This commit is contained in:
smoogipoo 2018-12-12 14:38:03 +09:00
parent 6661b5870f
commit 170955110f
3 changed files with 32 additions and 5 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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 System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -14,14 +15,16 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList; using osu.Game.Overlays.SearchableList;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Play.HUD;
using osuTK; using osuTK;
namespace osu.Game.Screens.Multi.Match.Components namespace osu.Game.Screens.Multi.Match.Components
{ {
public class Info : Container public class Info : Container
{ {
public const float HEIGHT = 128; public const float HEIGHT = 156;
private readonly OsuSpriteText availabilityStatus; private readonly OsuSpriteText availabilityStatus;
private readonly ReadyButton readyButton; private readonly ReadyButton readyButton;
@ -35,6 +38,7 @@ namespace osu.Game.Screens.Multi.Match.Components
public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>(); public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public readonly Bindable<GameType> Type = new Bindable<GameType>(); public readonly Bindable<GameType> Type = new Bindable<GameType>();
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
public Info() public Info()
{ {
@ -43,6 +47,7 @@ namespace osu.Game.Screens.Multi.Match.Components
BeatmapTypeInfo beatmapTypeInfo; BeatmapTypeInfo beatmapTypeInfo;
OsuSpriteText name; OsuSpriteText name;
ModDisplay modDisplay;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -74,11 +79,23 @@ namespace osu.Game.Screens.Multi.Match.Components
availabilityStatus = new OsuSpriteText { TextSize = 14 }, availabilityStatus = new OsuSpriteText { TextSize = 14 },
}, },
}, },
beatmapTypeInfo = new BeatmapTypeInfo new FillFlowContainer
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
beatmapTypeInfo = new BeatmapTypeInfo(),
modDisplay = new ModDisplay
{
Scale = new Vector2(0.75f),
DisplayUnrankedText = false
}, },
}
}
}, },
}, },
readyButton = new ReadyButton readyButton = new ReadyButton
@ -95,6 +112,7 @@ namespace osu.Game.Screens.Multi.Match.Components
beatmapTypeInfo.Beatmap.BindTo(Beatmap); beatmapTypeInfo.Beatmap.BindTo(Beatmap);
beatmapTypeInfo.Type.BindTo(Type); beatmapTypeInfo.Type.BindTo(Type);
modDisplay.Current.BindTo(Mods);
Availability.BindValueChanged(_ => updateAvailabilityStatus()); Availability.BindValueChanged(_ => updateAvailabilityStatus());
Status.BindValueChanged(_ => updateAvailabilityStatus()); Status.BindValueChanged(_ => updateAvailabilityStatus());

View File

@ -2,6 +2,7 @@
// 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 System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -9,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Users; using osu.Game.Users;
@ -33,6 +35,9 @@ namespace osu.Game.Screens.Multi.Match
public override string ShortTitle => "room"; public override string ShortTitle => "room";
[Cached]
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
[Cached] [Cached]
private readonly Room room; private readonly Room room;
@ -101,6 +106,7 @@ namespace osu.Game.Screens.Multi.Match
info.Status.BindTo(statusBind); info.Status.BindTo(statusBind);
info.Availability.BindTo(availabilityBind); info.Availability.BindTo(availabilityBind);
info.Type.BindTo(typeBind); info.Type.BindTo(typeBind);
info.Mods.BindTo(mods);
participants.Users.BindTo(participantsBind); participants.Users.BindTo(participantsBind);
participants.MaxParticipants.BindTo(maxParticipantsBind); participants.MaxParticipants.BindTo(maxParticipantsBind);

View File

@ -20,6 +20,8 @@ namespace osu.Game.Screens.Play.HUD
{ {
private const int fade_duration = 1000; private const int fade_duration = 1000;
public bool DisplayUnrankedText = true;
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>(); private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
public Bindable<IEnumerable<Mod>> Current => mods; public Bindable<IEnumerable<Mod>> Current => mods;
@ -29,6 +31,8 @@ namespace osu.Game.Screens.Play.HUD
public ModDisplay() public ModDisplay()
{ {
AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {
iconsContainer = new ReverseChildIDFillFlowContainer<ModIcon> iconsContainer = new ReverseChildIDFillFlowContainer<ModIcon>
@ -41,7 +45,6 @@ namespace osu.Game.Screens.Play.HUD
}, },
unrankedText = new OsuSpriteText unrankedText = new OsuSpriteText
{ {
AlwaysPresent = true,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Text = @"/ UNRANKED /", Text = @"/ UNRANKED /",
@ -77,7 +80,7 @@ namespace osu.Game.Screens.Play.HUD
private void appearTransform() private void appearTransform()
{ {
if (mods.Value.Any(m => !m.Ranked)) if (DisplayUnrankedText && mods.Value.Any(m => !m.Ranked))
unrankedText.FadeInFromZero(fade_duration, Easing.OutQuint); unrankedText.FadeInFromZero(fade_duration, Easing.OutQuint);
else else
unrankedText.Hide(); unrankedText.Hide();