1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 00:52:59 +08:00
osu-lazer/osu.Game/Screens/ScreenWhiteBox.cs

199 lines
7.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System;
using System.Collections.Generic;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Backgrounds;
using osu.Game.Graphics.UserInterface;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens
{
public class ScreenWhiteBox : OsuScreen
{
private readonly BackButton popButton;
private const double transition_time = 1000;
protected virtual IEnumerable<Type> PossibleChildren => null;
private readonly FillFlowContainer textContainer;
private readonly Container boxContainer;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
2019-01-23 19:52:00 +08:00
public override void OnEntering(IScreen last)
2018-04-13 17:19:50 +08:00
{
base.OnEntering(last);
//only show the pop button if we are entered form another screen.
if (last != null)
popButton.Alpha = 1;
2019-01-23 19:52:00 +08:00
Alpha = 0;
2018-04-13 17:19:50 +08:00
textContainer.Position = new Vector2(DrawSize.X / 16, 0);
boxContainer.ScaleTo(0.2f);
boxContainer.RotateTo(-20);
2019-01-23 19:52:00 +08:00
using (BeginDelayedSequence(300, true))
2018-04-13 17:19:50 +08:00
{
boxContainer.ScaleTo(1, transition_time, Easing.OutElastic);
boxContainer.RotateTo(0, transition_time / 2, Easing.OutQuint);
textContainer.MoveTo(Vector2.Zero, transition_time, Easing.OutExpo);
2019-01-23 19:52:00 +08:00
this.FadeIn(transition_time, Easing.OutExpo);
2018-04-13 17:19:50 +08:00
}
}
2019-01-23 19:52:00 +08:00
public override bool OnExiting(IScreen next)
2018-04-13 17:19:50 +08:00
{
textContainer.MoveTo(new Vector2(DrawSize.X / 16, 0), transition_time, Easing.OutExpo);
2019-01-23 19:52:00 +08:00
this.FadeOut(transition_time, Easing.OutExpo);
2018-04-13 17:19:50 +08:00
return base.OnExiting(next);
}
2019-01-23 19:52:00 +08:00
public override void OnSuspending(IScreen next)
2018-04-13 17:19:50 +08:00
{
base.OnSuspending(next);
textContainer.MoveTo(new Vector2(-(DrawSize.X / 16), 0), transition_time, Easing.OutExpo);
2019-01-23 19:52:00 +08:00
this.FadeOut(transition_time, Easing.OutExpo);
2018-04-13 17:19:50 +08:00
}
2019-01-23 19:52:00 +08:00
public override void OnResuming(IScreen last)
2018-04-13 17:19:50 +08:00
{
base.OnResuming(last);
textContainer.MoveTo(Vector2.Zero, transition_time, Easing.OutExpo);
2019-01-23 19:52:00 +08:00
this.FadeIn(transition_time, Easing.OutExpo);
2018-04-13 17:19:50 +08:00
}
public ScreenWhiteBox()
{
FillFlowContainer childModeButtons;
2019-01-23 19:52:00 +08:00
InternalChildren = new Drawable[]
2018-04-13 17:19:50 +08:00
{
boxContainer = new Container
{
Size = new Vector2(0.3f),
RelativeSizeAxes = Axes.Both,
CornerRadius = 20,
Masking = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = getColourFor(GetType()),
Alpha = 0.2f,
Blending = BlendingMode.Additive,
},
textContainer = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new SpriteIcon
{
2019-04-02 18:55:24 +08:00
Icon = FontAwesome.Solid.UniversalAccess,
2018-04-13 17:19:50 +08:00
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Size = new Vector2(50),
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = GetType().Name,
Colour = getColourFor(GetType()).Lighten(0.8f),
Font = OsuFont.GetFont(size: 50),
2018-04-13 17:19:50 +08:00
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "is not yet ready for use!",
Font = OsuFont.GetFont(size: 20),
2018-04-13 17:19:50 +08:00
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "please check back a bit later.",
Font = OsuFont.GetFont(size: 14),
2018-04-13 17:19:50 +08:00
},
}
},
}
},
popButton = new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Alpha = 0,
2019-01-23 19:52:00 +08:00
Action = this.Exit
2018-04-13 17:19:50 +08:00
},
childModeButtons = new FillFlowContainer
{
Direction = FillDirection.Vertical,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Size = new Vector2(TwoLayerButton.SIZE_RETRACTED.X, 1)
}
};
if (PossibleChildren != null)
{
foreach (Type t in PossibleChildren)
{
childModeButtons.Add(new ChildModeButton
{
Text = $@"{t.Name}",
BackgroundColour = getColourFor(t),
HoverColour = getColourFor(t).Lighten(0.2f),
2019-02-28 12:31:40 +08:00
Action = delegate { this.Push(Activator.CreateInstance(t) as Screen); }
2018-04-13 17:19:50 +08:00
});
}
}
}
private Color4 getColourFor(Type type)
{
int hash = type.Name.GetHashCode();
byte r = (byte)MathHelper.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255);
byte g = (byte)MathHelper.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255);
byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
return new Color4(r, g, b, 255);
}
public class ChildModeButton : TwoLayerButton
{
public ChildModeButton()
{
Icon = OsuIcon.RightCircle;
2018-04-13 17:19:50 +08:00
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
}
}
}
}