1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 20:13:22 +08:00

Add beatmap background to multiplayer

This commit is contained in:
smoogipoo 2020-02-19 19:42:25 +09:00
parent 02f3e78b14
commit e966689044
3 changed files with 73 additions and 43 deletions

View File

@ -5,7 +5,6 @@ using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Overlays.SearchableList;
using osu.Game.Rulesets;
using osuTK.Graphics;
@ -14,7 +13,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{
public class FilterControl : SearchableListFilterControl<PrimaryFilter, SecondaryFilter>
{
protected override Color4 BackgroundColour => OsuColour.FromHex(@"362e42");
protected override Color4 BackgroundColour => Color4.Transparent;
protected override PrimaryFilter DefaultTab => PrimaryFilter.Open;
protected override SecondaryFilter DefaultCategory => SecondaryFilter.Public;

View File

@ -5,22 +5,17 @@ using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.GameTypes;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Screens.Multi.Play;
using osu.Game.Screens.Select;
using osuTK.Graphics;
using Footer = osu.Game.Screens.Multi.Match.Components.Footer;
namespace osu.Game.Screens.Multi.Match
@ -64,12 +59,6 @@ namespace osu.Game.Screens.Multi.Match
{
InternalChildren = new Drawable[]
{
new HeaderBackgroundSprite
{
RelativeSizeAxes = Axes.X,
Height = 200,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.4f), Color4.White.Opacity(0))
},
new GridContainer
{
RelativeSizeAxes = Axes.Both,
@ -252,15 +241,5 @@ namespace osu.Game.Screens.Multi.Match
if (beatmapManager != null)
beatmapManager.ItemAdded -= beatmapAdded;
}
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
{
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double TransformDuration => 200;
}
}
}
}

View File

@ -4,14 +4,16 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
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.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input;
@ -19,6 +21,7 @@ using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Multi.Lounge;
using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Screens.Multi.Match;
@ -62,6 +65,9 @@ namespace osu.Game.Screens.Multi
[Resolved(CanBeNull = true)]
private OsuLogo logo { get; set; }
private readonly Drawable header;
private readonly Drawable headerBackground;
public Multiplayer()
{
Anchor = Anchor.Centre;
@ -74,31 +80,51 @@ namespace osu.Game.Screens.Multi
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Container
new Box
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"3e3a44"),
},
new Triangles
{
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"3c3842"),
ColourDark = OsuColour.FromHex(@"393540"),
TriangleScale = 5,
},
},
Colour = OsuColour.FromHex(@"3e3a44"),
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = screenStack = new MultiplayerSubScreenStack { RelativeSizeAxes = Axes.Both }
Children = new[]
{
header = new Container
{
RelativeSizeAxes = Axes.X,
Height = 400,
Children = new[]
{
headerBackground = new Container
{
RelativeSizeAxes = Axes.Both,
Width = 1.25f,
Masking = true,
Children = new Drawable[]
{
new HeaderBackgroundSprite
{
RelativeSizeAxes = Axes.X,
Height = 400 // Keep a static height so the header doesn't change as it's resized
},
}
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Bottom = -1 }, // 1px padding to avoid a 1px gap due to masking
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(OsuColour.FromHex(@"3e3a44").Opacity(0.6f), OsuColour.FromHex(@"3e3a44"))
},
}
}
},
screenStack = new MultiplayerSubScreenStack { RelativeSizeAxes = Axes.Both }
}
},
new Header(screenStack),
createButton = new HeaderButton
@ -259,7 +285,10 @@ namespace osu.Game.Screens.Multi
Beatmap.ValueChanged -= updateTrack;
}
private void screenPushed(IScreen lastScreen, IScreen newScreen) => subScreenChanged(newScreen);
private void screenPushed(IScreen lastScreen, IScreen newScreen)
{
subScreenChanged(newScreen);
}
private void screenExited(IScreen lastScreen, IScreen newScreen)
{
@ -271,6 +300,19 @@ namespace osu.Game.Screens.Multi
private void subScreenChanged(IScreen newScreen)
{
switch (newScreen)
{
case LoungeSubScreen _:
header.ResizeHeightTo(400, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
headerBackground.MoveToX(0, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
break;
case MatchSubScreen _:
header.ResizeHeightTo(135, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
headerBackground.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
break;
}
updatePollingRate(isIdle.Value);
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);
@ -327,5 +369,15 @@ namespace osu.Game.Screens.Multi
FourthWaveColour = OsuColour.FromHex(@"392850");
}
}
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
{
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double TransformDuration => 200;
}
}
}
}