2017-02-07 12:59:30 +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
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-02-17 17:59:30 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2016-11-27 09:21:12 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-04-21 14:41:22 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
namespace osu.Game.Screens
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-02-17 17:59:30 +08:00
|
|
|
|
public class ScreenWhiteBox : OsuScreen
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly BackButton popButton;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
2017-03-09 14:52:40 +08:00
|
|
|
|
private const double transition_time = 1000;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
|
|
|
|
protected virtual IEnumerable<Type> PossibleChildren => null;
|
|
|
|
|
|
2017-04-21 14:41:22 +08:00
|
|
|
|
private readonly FillFlowContainer textContainer;
|
|
|
|
|
private readonly Container boxContainer;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
|
2016-10-05 15:35:10 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnEntering(Screen last)
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
//only show the pop button if we are entered form another screen.
|
2016-09-29 22:52:51 +08:00
|
|
|
|
if (last != null)
|
|
|
|
|
popButton.Alpha = 1;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
2016-10-01 16:01:09 +08:00
|
|
|
|
Content.Alpha = 0;
|
2016-10-19 00:53:31 +08:00
|
|
|
|
textContainer.Position = new Vector2(DrawSize.X / 16, 0);
|
2016-10-01 16:01:09 +08:00
|
|
|
|
|
2017-04-21 14:41:22 +08:00
|
|
|
|
boxContainer.ScaleTo(0.2f);
|
|
|
|
|
boxContainer.RotateTo(-20);
|
2016-10-05 15:35:10 +08:00
|
|
|
|
|
|
|
|
|
Content.Delay(300, true);
|
|
|
|
|
|
2017-04-21 14:41:22 +08:00
|
|
|
|
boxContainer.ScaleTo(1, transition_time, EasingTypes.OutElastic);
|
|
|
|
|
boxContainer.RotateTo(0, transition_time / 2, EasingTypes.OutQuint);
|
2016-10-05 15:35:10 +08:00
|
|
|
|
|
2016-10-01 16:01:09 +08:00
|
|
|
|
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
|
|
|
|
|
Content.FadeIn(transition_time, EasingTypes.OutExpo);
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override bool OnExiting(Screen next)
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
textContainer.MoveTo(new Vector2(DrawSize.X / 16, 0), transition_time, EasingTypes.OutExpo);
|
2016-10-01 16:01:09 +08:00
|
|
|
|
Content.FadeOut(transition_time, EasingTypes.OutExpo);
|
2016-10-07 17:58:20 +08:00
|
|
|
|
|
|
|
|
|
return base.OnExiting(next);
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnSuspending(Screen next)
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
|
2016-10-19 00:53:31 +08:00
|
|
|
|
textContainer.MoveTo(new Vector2(-(DrawSize.X / 16), 0), transition_time, EasingTypes.OutExpo);
|
2016-10-01 16:01:09 +08:00
|
|
|
|
Content.FadeOut(transition_time, EasingTypes.OutExpo);
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnResuming(Screen last)
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
|
2016-10-01 16:01:09 +08:00
|
|
|
|
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
|
|
|
|
|
Content.FadeIn(transition_time, EasingTypes.OutExpo);
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
public ScreenWhiteBox()
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-03-09 13:24:16 +08:00
|
|
|
|
FillFlowContainer childModeButtons;
|
|
|
|
|
|
2016-09-29 19:13:58 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-04-21 14:41:22 +08:00
|
|
|
|
boxContainer = new Container
|
2016-11-13 01:34:36 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(0.3f),
|
2017-04-21 14:41:22 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = 20,
|
|
|
|
|
Masking = true,
|
2016-11-13 01:34:36 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-04-21 14:41:22 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-04-21 14:41:22 +08:00
|
|
|
|
new Box
|
2016-10-01 16:01:09 +08:00
|
|
|
|
{
|
2017-04-21 14:41:22 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
|
|
|
|
|
Colour = getColourFor(GetType()),
|
|
|
|
|
Alpha = 0.2f,
|
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-11-13 01:34:36 +08:00
|
|
|
|
},
|
2017-04-21 14:41:22 +08:00
|
|
|
|
textContainer = new FillFlowContainer
|
2016-11-13 01:34:36 +08:00
|
|
|
|
{
|
2017-04-21 14:41:22 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-11-13 01:34:36 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-04-21 14:41:22 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.fa_universal_access,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
TextSize = 50,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = GetType().Name,
|
|
|
|
|
Colour = getColourFor(GetType()).Lighten(0.8f),
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
TextSize = 50,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "is not yet ready for use!",
|
|
|
|
|
TextSize = 20,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "please check back a bit later.",
|
|
|
|
|
TextSize = 14,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
},
|
|
|
|
|
}
|
2016-11-13 01:34:36 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-11-27 09:21:12 +08:00
|
|
|
|
popButton = new BackButton
|
2016-11-13 01:34:36 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Alpha = 0,
|
2017-04-21 14:41:22 +08:00
|
|
|
|
Action = Exit
|
2016-11-13 01:34:36 +08:00
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
childModeButtons = new FillFlowContainer
|
2016-11-13 01:34:36 +08:00
|
|
|
|
{
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2016-11-13 01:34:36 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2017-04-21 14:41:22 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Size = new Vector2(TwoLayerButton.SIZE_RETRACTED.X, 1)
|
2016-11-13 01:34:36 +08:00
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (PossibleChildren != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (Type t in PossibleChildren)
|
|
|
|
|
{
|
2017-04-21 14:41:22 +08:00
|
|
|
|
childModeButtons.Add(new ChildModeButton
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
|
|
|
|
Text = $@"{t.Name}",
|
2017-02-13 23:35:24 +08:00
|
|
|
|
BackgroundColour = getColourFor(t),
|
2017-04-21 14:41:22 +08:00
|
|
|
|
HoverColour = getColourFor(t).Lighten(0.2f),
|
2016-09-29 19:13:58 +08:00
|
|
|
|
Action = delegate
|
|
|
|
|
{
|
2017-02-17 17:59:30 +08:00
|
|
|
|
Push(Activator.CreateInstance(t) as Screen);
|
2016-09-29 19:13:58 +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);
|
|
|
|
|
}
|
2017-04-21 14:41:22 +08:00
|
|
|
|
|
|
|
|
|
public class ChildModeButton : TwoLayerButton
|
|
|
|
|
{
|
|
|
|
|
public ChildModeButton()
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.fa_osu_right_o;
|
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|