2017-02-22 20:43:29 +08:00
|
|
|
|
// Copyright (c) 2007-2017 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.Sprites;
|
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-02-27 15:37:49 +08:00
|
|
|
|
using osu.Game.Database;
|
2017-02-22 20:43:29 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
using OpenTK;
|
2017-04-29 02:05:00 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-02-22 20:43:29 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
|
|
|
|
public class PlayerLoader : OsuScreen
|
|
|
|
|
{
|
2017-04-18 12:30:51 +08:00
|
|
|
|
private Player player;
|
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly OsuLogo logo;
|
2017-02-22 20:43:29 +08:00
|
|
|
|
private BeatmapMetadataDisplay info;
|
|
|
|
|
|
2017-04-18 14:36:11 +08:00
|
|
|
|
private bool showOverlays = true;
|
2017-04-18 12:30:51 +08:00
|
|
|
|
internal override bool ShowOverlays => showOverlays;
|
|
|
|
|
|
2017-04-21 15:03:59 +08:00
|
|
|
|
internal override bool AllowRulesetChange => false;
|
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
|
|
|
|
|
|
|
|
|
public PlayerLoader(Player player)
|
|
|
|
|
{
|
2017-04-18 15:56:01 +08:00
|
|
|
|
this.player = player;
|
2017-04-18 12:30:51 +08:00
|
|
|
|
|
2017-04-18 15:56:01 +08:00
|
|
|
|
player.RestartRequested = () => {
|
|
|
|
|
showOverlays = false;
|
|
|
|
|
ValidForResume = true;
|
|
|
|
|
};
|
2017-02-22 20:43:29 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
logo = new OsuLogo
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(0.15f),
|
|
|
|
|
Interactive = false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Add(info = new BeatmapMetadataDisplay(Beatmap)
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
|
2017-04-02 14:56:12 +08:00
|
|
|
|
LoadComponentAsync(player);
|
2017-02-22 20:43:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 12:30:51 +08:00
|
|
|
|
protected override void OnResuming(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnResuming(last);
|
2017-04-18 15:56:01 +08:00
|
|
|
|
|
2017-04-18 16:00:58 +08:00
|
|
|
|
contentIn();
|
|
|
|
|
|
2017-04-18 15:56:01 +08:00
|
|
|
|
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
|
|
|
|
|
LoadComponentAsync(player = new Player
|
2017-04-18 12:30:51 +08:00
|
|
|
|
{
|
|
|
|
|
RestartCount = player.RestartCount + 1,
|
2017-04-18 15:56:01 +08:00
|
|
|
|
RestartRequested = player.RestartRequested,
|
|
|
|
|
Beatmap = player.Beatmap,
|
2017-04-18 12:30:51 +08:00
|
|
|
|
});
|
2017-04-18 16:07:02 +08:00
|
|
|
|
|
|
|
|
|
Delay(400);
|
|
|
|
|
|
|
|
|
|
Schedule(pushWhenLoaded);
|
2017-04-18 12:30:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 16:00:58 +08:00
|
|
|
|
private void contentIn()
|
|
|
|
|
{
|
2017-04-18 16:07:02 +08:00
|
|
|
|
Content.ScaleTo(1, 650, EasingTypes.OutQuint);
|
|
|
|
|
Content.FadeInFromZero(400);
|
2017-04-18 16:00:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void contentOut()
|
|
|
|
|
{
|
|
|
|
|
Content.ScaleTo(0.7f, 300, EasingTypes.InQuint);
|
|
|
|
|
Content.FadeOut(250);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
protected override void OnEntering(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
|
|
|
|
Background.FadeTo(0.4f, 250);
|
|
|
|
|
|
|
|
|
|
Content.ScaleTo(0.7f);
|
|
|
|
|
|
2017-04-18 16:00:58 +08:00
|
|
|
|
contentIn();
|
|
|
|
|
|
|
|
|
|
Delay(500, true);
|
2017-02-22 20:43:29 +08:00
|
|
|
|
|
|
|
|
|
logo.MoveToOffset(new Vector2(0, -180), 500, EasingTypes.InOutExpo);
|
|
|
|
|
Delay(250, true);
|
|
|
|
|
|
|
|
|
|
info.FadeIn(500);
|
|
|
|
|
|
2017-04-18 16:00:58 +08:00
|
|
|
|
Delay(1400, true);
|
2017-02-22 20:43:29 +08:00
|
|
|
|
|
2017-04-18 16:07:02 +08:00
|
|
|
|
Schedule(pushWhenLoaded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pushWhenLoaded()
|
|
|
|
|
{
|
|
|
|
|
if (!player.IsLoaded)
|
|
|
|
|
Schedule(pushWhenLoaded);
|
|
|
|
|
|
2017-04-18 16:00:58 +08:00
|
|
|
|
contentOut();
|
2017-02-22 20:43:29 +08:00
|
|
|
|
|
|
|
|
|
Delay(250);
|
|
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
2017-02-25 10:46:19 +08:00
|
|
|
|
if (!IsCurrentScreen) return;
|
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
if (!Push(player))
|
|
|
|
|
Exit();
|
2017-04-18 16:07:02 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//By default, we want to load the player and never be returned to.
|
|
|
|
|
//Note that this may change if the player we load requested a re-run.
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
}
|
2017-02-22 20:43:29 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnExiting(Screen next)
|
|
|
|
|
{
|
|
|
|
|
Content.ScaleTo(0.7f, 150, EasingTypes.InQuint);
|
|
|
|
|
FadeOut(150);
|
2017-02-24 19:59:21 +08:00
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private class BeatmapMetadataDisplay : Container
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private class MetadataLine : Container
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
|
|
|
|
public MetadataLine(string left, string right)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Margin = new MarginPadding { Right = 5 },
|
|
|
|
|
Colour = OsuColour.Gray(0.5f),
|
|
|
|
|
Text = left,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
Margin = new MarginPadding { Left = 5 },
|
|
|
|
|
Text = string.IsNullOrEmpty(right) ? @"-" : right,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 10:38:51 +08:00
|
|
|
|
private readonly WorkingBeatmap beatmap;
|
2017-04-29 02:05:00 +08:00
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
public BeatmapMetadataDisplay(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-05-01 10:38:51 +08:00
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(LocalisationEngine localisation)
|
|
|
|
|
{
|
|
|
|
|
var metadata = beatmap?.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
2017-02-27 15:37:49 +08:00
|
|
|
|
|
2017-02-22 20:43:29 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
new FillFlowContainer
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-02-22 20:43:29 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-01 10:38:51 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
2017-05-01 10:38:51 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title),
|
2017-02-22 20:43:29 +08:00
|
|
|
|
TextSize = 36,
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
},
|
2017-05-01 10:38:51 +08:00
|
|
|
|
new OsuSpriteText
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
2017-05-01 10:38:51 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist),
|
2017-02-22 20:43:29 +08:00
|
|
|
|
TextSize = 26,
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(300, 60),
|
|
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
CornerRadius = 10,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Sprite
|
|
|
|
|
{
|
2017-03-09 14:52:40 +08:00
|
|
|
|
Texture = beatmap?.Background,
|
2017-02-22 20:43:29 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2017-03-09 14:52:40 +08:00
|
|
|
|
Text = beatmap?.BeatmapInfo?.Version,
|
2017-02-22 20:43:29 +08:00
|
|
|
|
TextSize = 26,
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 40
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-02-27 15:37:49 +08:00
|
|
|
|
new MetadataLine("Source", metadata.Source)
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
},
|
|
|
|
|
new MetadataLine("Composer", string.Empty)
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
},
|
2017-02-27 15:37:49 +08:00
|
|
|
|
new MetadataLine("Mapper", metadata.Author)
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|