2021-08-10 12:43:11 +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.
|
|
|
|
|
2021-08-12 21:36:47 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2021-08-10 14:21:23 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-08-10 12:43:11 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-10 13:11:21 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2021-08-10 12:43:11 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-08-10 14:21:23 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-08-10 15:07:20 +08:00
|
|
|
using osu.Framework.Graphics.Textures;
|
2021-08-10 14:21:23 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-08-12 21:36:47 +08:00
|
|
|
using osu.Game.Online.Chat;
|
2021-08-10 14:21:23 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2021-08-10 13:11:21 +08:00
|
|
|
using osuTK;
|
2021-08-10 12:43:11 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
{
|
|
|
|
public class ChangelogSupporterPromo : CompositeDrawable
|
|
|
|
{
|
2021-08-10 15:07:20 +08:00
|
|
|
private const float image_container_width = 164;
|
2021-08-15 09:48:57 +08:00
|
|
|
private const float heart_size = 75;
|
2021-08-10 14:53:06 +08:00
|
|
|
|
2021-08-11 13:49:22 +08:00
|
|
|
private readonly FillFlowContainer textContainer;
|
2021-08-10 15:07:20 +08:00
|
|
|
private readonly Container imageContainer;
|
2021-08-10 14:21:23 +08:00
|
|
|
|
2021-08-10 12:43:11 +08:00
|
|
|
public ChangelogSupporterPromo()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Vertical = 20,
|
|
|
|
Horizontal = 50,
|
|
|
|
};
|
2021-08-10 14:21:23 +08:00
|
|
|
|
2021-08-10 12:43:11 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-08-10 13:11:21 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 6,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
Offset = new Vector2(0, 1),
|
|
|
|
Radius = 3,
|
|
|
|
},
|
2021-08-10 12:43:11 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black.Opacity(0.3f),
|
|
|
|
},
|
2021-08-10 14:53:06 +08:00
|
|
|
new Container
|
2021-08-10 12:43:11 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 200,
|
2021-08-10 14:21:23 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = 75 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-08-11 13:49:22 +08:00
|
|
|
textContainer = new FillFlowContainer
|
2021-08-10 14:21:23 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-08-10 15:07:20 +08:00
|
|
|
Padding = new MarginPadding { Right = 50 + image_container_width },
|
2021-08-10 14:21:23 +08:00
|
|
|
},
|
2021-08-10 15:07:20 +08:00
|
|
|
imageContainer = new Container
|
2021-08-10 14:53:06 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2021-08-10 15:07:20 +08:00
|
|
|
Width = image_container_width,
|
2021-08-10 14:53:06 +08:00
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
}
|
2021-08-10 14:21:23 +08:00
|
|
|
}
|
2021-08-10 12:43:11 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-08-10 14:21:23 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-08-10 15:07:20 +08:00
|
|
|
private void load(OsuColour colour, TextureStore textures)
|
2021-08-10 14:21:23 +08:00
|
|
|
{
|
2021-08-12 21:36:47 +08:00
|
|
|
SupporterPromoLinkFlowContainer supportLinkText;
|
2021-08-11 13:49:22 +08:00
|
|
|
textContainer.Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = ChangelogStrings.SupportHeading,
|
|
|
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Light),
|
|
|
|
Margin = new MarginPadding { Bottom = 20 },
|
|
|
|
},
|
2021-08-12 21:36:47 +08:00
|
|
|
supportLinkText = new SupporterPromoLinkFlowContainer(t =>
|
2021-08-11 13:49:22 +08:00
|
|
|
{
|
|
|
|
t.Font = t.Font.With(size: 14);
|
|
|
|
t.Colour = colour.PinkLighter;
|
|
|
|
})
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
},
|
2021-08-12 20:34:44 +08:00
|
|
|
new OsuTextFlowContainer(t =>
|
2021-08-11 13:49:22 +08:00
|
|
|
{
|
|
|
|
t.Font = t.Font.With(size: 12);
|
|
|
|
t.Colour = colour.PinkLighter;
|
|
|
|
})
|
|
|
|
{
|
2021-08-12 17:54:58 +08:00
|
|
|
Text = ChangelogStrings.SupportText2.ToString(),
|
2021-08-11 13:49:22 +08:00
|
|
|
Margin = new MarginPadding { Top = 10 },
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
}
|
|
|
|
};
|
2021-08-10 14:21:23 +08:00
|
|
|
|
2021-08-11 13:49:22 +08:00
|
|
|
supportLinkText.AddText("Support further development of osu! and ");
|
2021-08-12 21:36:47 +08:00
|
|
|
supportLinkText.AddLink("become and osu!supporter", "https://osu.ppy.sh/home/support", t => t.Font = t.Font.With(weight: FontWeight.Bold));
|
2021-08-11 13:49:22 +08:00
|
|
|
supportLinkText.AddText(" today!");
|
2021-08-10 15:07:20 +08:00
|
|
|
|
|
|
|
imageContainer.Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-08-15 08:36:43 +08:00
|
|
|
Margin = new MarginPadding { Bottom = 28 },
|
2021-08-10 15:07:20 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
Texture = textures.Get(@"Online/supporter-pippi"),
|
|
|
|
},
|
2021-08-15 08:00:26 +08:00
|
|
|
new Container
|
2021-08-10 15:07:20 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-08-16 22:38:13 +08:00
|
|
|
Size = new Vector2(heart_size),
|
2021-08-15 08:36:43 +08:00
|
|
|
Margin = new MarginPadding { Top = 70 },
|
2021-08-15 08:00:26 +08:00
|
|
|
Masking = true,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
2021-08-15 08:32:38 +08:00
|
|
|
Colour = colour.Pink,
|
2021-08-15 09:48:57 +08:00
|
|
|
Radius = 10,
|
|
|
|
Roundness = heart_size / 2,
|
2021-08-15 08:00:26 +08:00
|
|
|
},
|
|
|
|
Child = new Sprite
|
|
|
|
{
|
2021-08-16 22:38:13 +08:00
|
|
|
Size = new Vector2(heart_size),
|
2021-08-15 08:00:26 +08:00
|
|
|
Texture = textures.Get(@"Online/supporter-heart"),
|
|
|
|
},
|
2021-08-10 15:07:20 +08:00
|
|
|
},
|
|
|
|
};
|
2021-08-10 14:21:23 +08:00
|
|
|
}
|
2021-08-12 21:36:47 +08:00
|
|
|
|
|
|
|
private class SupporterPromoLinkFlowContainer : LinkFlowContainer
|
|
|
|
{
|
|
|
|
public SupporterPromoLinkFlowContainer(Action<SpriteText> defaultCreationParameters)
|
|
|
|
: base(defaultCreationParameters)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public new void AddLink(string text, string url, Action<SpriteText> creationParameters) =>
|
|
|
|
AddInternal(new SupporterPromoLinkCompiler(AddText(text, creationParameters)) { Url = url });
|
|
|
|
|
|
|
|
private class SupporterPromoLinkCompiler : DrawableLinkCompiler
|
|
|
|
{
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private OsuGame game { get; set; }
|
|
|
|
|
|
|
|
public string Url;
|
|
|
|
|
|
|
|
public SupporterPromoLinkCompiler(IEnumerable<Drawable> parts)
|
|
|
|
: base(parts)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colour)
|
|
|
|
{
|
|
|
|
TooltipText = Url;
|
|
|
|
Action = () => game?.HandleLink(Url);
|
|
|
|
IdleColour = colour.PinkDark;
|
|
|
|
HoverColour = Color4.White;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 12:43:11 +08:00
|
|
|
}
|
|
|
|
}
|