2019-01-24 16:43:03 +08:00
|
|
|
|
// 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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
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;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class ScreenWhiteBox : OsuScreen
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-08 13:23:13 +08:00
|
|
|
|
private readonly UnderConstructionMessage message;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private const double transition_time = 1000;
|
|
|
|
|
|
|
|
|
|
protected virtual IEnumerable<Type> PossibleChildren => null;
|
|
|
|
|
|
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
|
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
public override bool OnExiting(ScreenExitEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-08 13:23:13 +08:00
|
|
|
|
message.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
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
return base.OnExiting(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
public override void OnSuspending(ScreenTransitionEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
|
base.OnSuspending(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
message.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
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
public override void OnResuming(ScreenTransitionEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
|
base.OnResuming(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
message.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
|
|
|
|
{
|
2019-10-08 13:23:13 +08:00
|
|
|
|
message = new UnderConstructionMessage(GetType().Name),
|
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}",
|
2019-10-08 13:23:13 +08:00
|
|
|
|
BackgroundColour = getColourFor(t.Name),
|
|
|
|
|
HoverColour = getColourFor(t.Name).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
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
private static Color4 getColourFor(object type)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-08 13:23:13 +08:00
|
|
|
|
int hash = type.GetHashCode();
|
2021-05-11 17:37:41 +08:00
|
|
|
|
byte r = (byte)Math.Clamp(((hash & 0xFF0000) >> 16) * 2, 128, 255);
|
|
|
|
|
byte g = (byte)Math.Clamp(((hash & 0x00FF00) >> 8) * 2, 128, 255);
|
|
|
|
|
byte b = (byte)Math.Clamp((hash & 0x0000FF) * 2, 128, 255);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return new Color4(r, g, b, 255);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class ChildModeButton : TwoLayerButton
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public ChildModeButton()
|
|
|
|
|
{
|
2019-03-27 18:29:27 +08:00
|
|
|
|
Icon = OsuIcon.RightCircle;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-08 13:23:13 +08:00
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class UnderConstructionMessage : CompositeDrawable
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
|
|
|
|
public FillFlowContainer TextContainer { get; }
|
|
|
|
|
|
|
|
|
|
private readonly Container boxContainer;
|
|
|
|
|
|
2021-05-11 17:37:41 +08:00
|
|
|
|
public UnderConstructionMessage(string name, string description = "is not yet ready for use!")
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
2021-05-11 17:37:41 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
var colour = getColourFor(name);
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
boxContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
CornerRadius = 20,
|
|
|
|
|
Masking = true,
|
2021-05-11 17:37:41 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2019-10-08 13:23:13 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
|
2021-05-11 17:37:41 +08:00
|
|
|
|
Colour = colour.Darken(0.8f),
|
|
|
|
|
Alpha = 0.8f,
|
2019-10-08 13:23:13 +08:00
|
|
|
|
},
|
|
|
|
|
TextContainer = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2021-05-11 17:37:41 +08:00
|
|
|
|
Padding = new MarginPadding(20),
|
2019-10-08 13:23:13 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.UniversalAccess,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Size = new Vector2(50),
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Text = name,
|
2021-05-11 17:37:41 +08:00
|
|
|
|
Colour = colour,
|
2019-10-08 13:23:13 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 36),
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-05-11 17:37:41 +08:00
|
|
|
|
Text = description,
|
2019-10-08 13:23:13 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 20),
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Text = "please check back a bit later.",
|
|
|
|
|
Font = OsuFont.GetFont(size: 14),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
TextContainer.Position = new Vector2(DrawSize.X / 16, 0);
|
|
|
|
|
|
|
|
|
|
boxContainer.Hide();
|
|
|
|
|
boxContainer.ScaleTo(0.2f);
|
|
|
|
|
boxContainer.RotateTo(-20);
|
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
using (BeginDelayedSequence(300))
|
2019-10-08 13:23:13 +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);
|
|
|
|
|
boxContainer.FadeIn(transition_time, Easing.OutExpo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|