2018-05-16 08:14:10 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-12-11 16:32:01 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-05-16 08:14:10 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-12-19 15:56:51 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Buttons;
|
2018-05-28 11:28:11 +08:00
|
|
|
|
using osu.Game.Screens.Menu;
|
2018-12-10 18:20:41 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Lounge;
|
2018-12-18 16:07:47 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Match;
|
2018-12-19 15:56:51 +08:00
|
|
|
|
using osuTK;
|
2018-05-16 08:14:10 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi
|
|
|
|
|
{
|
2018-12-11 16:32:01 +08:00
|
|
|
|
[Cached]
|
2018-05-16 08:14:10 +08:00
|
|
|
|
public class Multiplayer : OsuScreen
|
|
|
|
|
{
|
|
|
|
|
private readonly MultiplayerWaveContainer waves;
|
|
|
|
|
|
2018-12-14 16:35:18 +08:00
|
|
|
|
public override bool AllowBeatmapRulesetChange => currentScreen?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange;
|
|
|
|
|
|
2018-12-19 15:56:51 +08:00
|
|
|
|
private readonly OsuButton createButton;
|
|
|
|
|
|
2018-12-14 16:35:18 +08:00
|
|
|
|
private OsuScreen currentScreen;
|
|
|
|
|
|
2018-05-16 08:14:10 +08:00
|
|
|
|
public Multiplayer()
|
|
|
|
|
{
|
2018-12-11 16:32:01 +08:00
|
|
|
|
Child = waves = new MultiplayerWaveContainer
|
2018-05-16 08:14:10 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-10 18:20:41 +08:00
|
|
|
|
LoungeScreen loungeScreen;
|
2018-12-11 16:32:01 +08:00
|
|
|
|
waves.AddRange(new Drawable[]
|
2018-05-16 08:14:10 +08:00
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = Header.HEIGHT },
|
2018-12-18 11:56:16 +08:00
|
|
|
|
Child = loungeScreen = new LoungeScreen(Push),
|
2018-05-16 08:14:10 +08:00
|
|
|
|
},
|
2018-12-19 15:56:51 +08:00
|
|
|
|
new Header(loungeScreen),
|
|
|
|
|
createButton = new HeaderButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Size = new Vector2(150, Header.HEIGHT - 20),
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = 10,
|
|
|
|
|
Right = 10,
|
|
|
|
|
},
|
|
|
|
|
Text = "Create room",
|
|
|
|
|
Action = () => loungeScreen.Open(new Room())
|
|
|
|
|
}
|
2018-12-11 16:32:01 +08:00
|
|
|
|
});
|
2018-05-16 08:14:10 +08:00
|
|
|
|
|
2018-12-14 16:35:18 +08:00
|
|
|
|
screenAdded(loungeScreen);
|
|
|
|
|
|
2018-12-10 18:20:41 +08:00
|
|
|
|
loungeScreen.Exited += s => Exit();
|
2018-05-16 08:14:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnEntering(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
waves.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnExiting(Screen next)
|
|
|
|
|
{
|
|
|
|
|
waves.Hide();
|
2018-12-18 16:07:47 +08:00
|
|
|
|
|
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
|
if (track != null)
|
|
|
|
|
track.Looping = false;
|
|
|
|
|
|
2018-05-16 08:14:10 +08:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResuming(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnResuming(last);
|
2018-12-11 16:32:01 +08:00
|
|
|
|
|
|
|
|
|
Content.FadeIn(250);
|
|
|
|
|
Content.ScaleTo(1, 250, Easing.OutSine);
|
2018-05-16 08:14:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnSuspending(Screen next)
|
|
|
|
|
{
|
2018-12-11 16:32:01 +08:00
|
|
|
|
Content.ScaleTo(1.1f, 250, Easing.InSine);
|
|
|
|
|
Content.FadeOut(250);
|
|
|
|
|
|
2018-05-16 08:14:10 +08:00
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 11:28:11 +08:00
|
|
|
|
protected override void LogoExiting(OsuLogo logo)
|
|
|
|
|
{
|
|
|
|
|
// the wave overlay transition takes longer than expected to run.
|
|
|
|
|
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
|
|
|
|
|
base.LogoExiting(logo);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-18 16:07:47 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
if (currentScreen is MatchScreen)
|
|
|
|
|
{
|
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
|
if (track != null)
|
|
|
|
|
{
|
|
|
|
|
track.Looping = true;
|
|
|
|
|
|
|
|
|
|
if (!track.IsRunning)
|
|
|
|
|
{
|
|
|
|
|
Game.Audio.AddItemToList(track);
|
|
|
|
|
track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
|
|
|
|
track.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-19 15:56:51 +08:00
|
|
|
|
|
|
|
|
|
createButton.Hide();
|
2018-12-18 16:07:47 +08:00
|
|
|
|
}
|
2018-12-19 15:56:51 +08:00
|
|
|
|
else
|
|
|
|
|
createButton.Show();
|
2018-12-18 16:07:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-14 16:35:18 +08:00
|
|
|
|
private void screenAdded(Screen newScreen)
|
|
|
|
|
{
|
|
|
|
|
currentScreen = (OsuScreen)newScreen;
|
|
|
|
|
|
|
|
|
|
newScreen.ModePushed += screenAdded;
|
|
|
|
|
newScreen.Exited += screenRemoved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void screenRemoved(Screen newScreen)
|
|
|
|
|
{
|
2018-12-18 16:07:47 +08:00
|
|
|
|
if (currentScreen is MatchScreen)
|
|
|
|
|
{
|
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
|
if (track != null)
|
|
|
|
|
track.Looping = false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-14 16:35:18 +08:00
|
|
|
|
currentScreen = (OsuScreen)newScreen;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 08:14:10 +08:00
|
|
|
|
private class MultiplayerWaveContainer : WaveContainer
|
|
|
|
|
{
|
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
|
|
|
|
public MultiplayerWaveContainer()
|
|
|
|
|
{
|
|
|
|
|
FirstWaveColour = OsuColour.FromHex(@"654d8c");
|
|
|
|
|
SecondWaveColour = OsuColour.FromHex(@"554075");
|
|
|
|
|
ThirdWaveColour = OsuColour.FromHex(@"44325e");
|
|
|
|
|
FourthWaveColour = OsuColour.FromHex(@"392850");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|