osu/osu.Game/Overlays/Changelog/ChangelogHeader.cs

187 lines
7.5 KiB
C#
Raw Normal View History

2018-07-16 21:50:22 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2018-07-17 13:01:53 +00:00
using OpenTK;
2018-07-16 21:50:22 +00:00
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2018-07-17 13:01:53 +00:00
using osu.Game.Graphics;
2018-07-16 21:50:22 +00:00
using osu.Game.Graphics.Sprites;
2018-07-19 17:07:24 +00:00
using osu.Game.Online.API.Requests.Responses;
2018-07-16 21:50:22 +00:00
using osu.Game.Overlays.Changelog.Header;
2018-07-17 23:35:06 +00:00
using System;
2018-07-16 21:50:22 +00:00
namespace osu.Game.Overlays.Changelog
{
public class ChangelogHeader : Container
{
2018-07-18 17:32:15 +00:00
protected Color4 Purple = new Color4(191, 4, 255, 255);
2018-07-16 21:50:22 +00:00
private readonly Sprite coverImage;
2018-07-19 19:49:13 +00:00
private readonly Sprite headerBadge;
2018-07-18 17:32:15 +00:00
private readonly OsuSpriteText titleStream;
2018-07-16 21:50:22 +00:00
private readonly TextBadgePairListing listing;
private readonly TextBadgePairRelease releaseStream;
2018-07-22 16:44:45 +00:00
public Action ListingActivated;
2018-07-19 17:07:24 +00:00
private const float cover_height = 280;
2018-07-16 21:50:22 +00:00
private const float title_height = 50;
private const float icon_size = 50;
private const float icon_margin = 20;
private const float version_height = 40;
public ChangelogHeader()
{
2018-07-18 17:32:15 +00:00
SpriteIcon chevron; // AppVeyor told me this should be a local variable..?
2018-07-16 21:50:22 +00:00
RelativeSizeAxes = Axes.X;
2018-07-17 23:35:06 +00:00
Height = cover_height;
2018-07-16 21:50:22 +00:00
Children = new Drawable[]
{
2018-07-17 23:35:06 +00:00
coverImage = new Sprite
2018-07-16 21:50:22 +00:00
{
2018-07-17 23:35:06 +00:00
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill,
},
new Container
2018-07-17 23:35:06 +00:00
{
Height = title_height,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Y = -version_height,
2018-07-16 21:50:22 +00:00
Children = new Drawable[]
{
new CircularContainer
2018-07-16 21:50:22 +00:00
{
2018-07-17 23:35:06 +00:00
X = icon_margin,
Masking = true,
2018-07-18 17:32:15 +00:00
BorderColour = Purple,
2018-07-17 23:35:06 +00:00
BorderThickness = 3,
MaskingSmoothness = 1,
2018-07-18 17:32:15 +00:00
Size = new Vector2(50),
2018-07-17 16:32:11 +00:00
Children = new Drawable[]
{
2018-07-17 23:35:06 +00:00
headerBadge = new Sprite
2018-07-16 21:50:22 +00:00
{
2018-07-17 23:35:06 +00:00
RelativeSizeAxes = Axes.Both,
2018-07-18 17:32:15 +00:00
Size = new Vector2(0.8f),
2018-07-17 23:35:06 +00:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2018-07-16 21:50:22 +00:00
},
2018-07-17 23:35:06 +00:00
// this box has 2 functions:
// - ensures the circle doesn't disappear on the X and Y edges
2018-07-19 19:49:13 +00:00
// - gets rid of the white "contamination" on the circle (due to smoothing)
// (https://i.imgur.com/SMuvWBZ.png)
2018-07-17 23:35:06 +00:00
new Box
2018-07-16 21:50:22 +00:00
{
2018-07-17 23:35:06 +00:00
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
2018-07-18 17:32:15 +00:00
Colour = Purple,
2018-07-17 16:32:11 +00:00
}
}
},
2018-07-18 17:32:15 +00:00
new FillFlowContainer
2018-07-17 16:32:11 +00:00
{
2018-07-17 23:35:06 +00:00
AutoSizeAxes = Axes.Both,
2018-07-17 16:32:11 +00:00
Direction = FillDirection.Horizontal,
2018-07-17 23:35:06 +00:00
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
X = icon_size + icon_margin * 2,
2018-07-17 16:32:11 +00:00
Children = new Drawable[]
{
2018-07-18 17:32:15 +00:00
new OsuSpriteText
2018-07-17 16:32:11 +00:00
{
2018-07-17 23:35:06 +00:00
Text = "Changelog ",
Font = @"Exo2.0-Light",
TextSize = 38, // web: 30
2018-07-16 21:50:22 +00:00
},
2018-07-17 23:35:06 +00:00
titleStream = new OsuSpriteText
{
Text = "Listing",
TextSize = 38, // web: 30
Font = @"Exo2.0-Light",
2018-07-18 17:32:15 +00:00
Colour = Purple,
2018-07-17 23:35:06 +00:00
},
}
}
}
},
2018-07-18 17:32:15 +00:00
new FillFlowContainer // Listing > Lazer 2018.713.1
2018-07-17 23:35:06 +00:00
{
X = 2 * icon_margin + icon_size - 8,
Height = version_height,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
2018-07-18 17:32:15 +00:00
listing = new TextBadgePairListing(Purple),
new Container // without a container, moving the chevron wont work
2018-07-17 16:32:11 +00:00
{
2018-07-17 23:35:06 +00:00
Anchor = Anchor.CentreLeft,
2018-07-17 16:32:11 +00:00
Origin = Anchor.CentreLeft,
2018-07-18 17:32:15 +00:00
Margin = new MarginPadding
2018-07-17 23:35:06 +00:00
{
Top = 10,
Left = 7,
2018-07-18 13:17:20 +00:00
Right = 18,
2018-07-17 23:35:06 +00:00
Bottom = 15,
},
Children = new Drawable[]
{
chevron = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(7),
2018-07-18 17:32:15 +00:00
Colour = Purple,
2018-07-17 23:35:06 +00:00
Icon = FontAwesome.fa_chevron_right,
Alpha = 0,
X = -200,
},
},
2018-07-17 16:32:11 +00:00
},
2018-07-18 17:32:15 +00:00
releaseStream = new TextBadgePairRelease(Purple, "Lazer")
2018-07-17 23:35:06 +00:00
},
},
new Box
2018-07-17 23:35:06 +00:00
{
2018-07-18 17:32:15 +00:00
Colour = Purple,
2018-07-17 23:35:06 +00:00
RelativeSizeAxes = Axes.X,
Height = 2,
2018-07-17 23:35:06 +00:00
Anchor = Anchor.BottomLeft,
Origin = Anchor.CentreLeft,
},
2018-07-16 21:50:22 +00:00
};
}
2018-07-22 16:44:45 +00:00
public void ShowBuild(string updateStream, string version)
2018-07-16 21:50:22 +00:00
{
2018-07-22 16:44:45 +00:00
listing.Deactivate();
releaseStream.Activate($"{updateStream} {version}");
titleStream.Text = updateStream;
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
2018-07-16 21:50:22 +00:00
}
2018-07-22 16:44:45 +00:00
public void ShowListing()
2018-07-16 21:50:22 +00:00
{
2018-07-22 16:44:45 +00:00
releaseStream.Deactivate();
listing.Activate();
2018-07-16 21:50:22 +00:00
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
// should be added to osu-resources?
// headerBadge.Texture = textures.Get(@"https://osu.ppy.sh/images/icons/changelog.svg"); // this is not working
headerBadge.Texture = textures.Get(@"https://i.imgur.com/HQM3Vhp.png");
coverImage.Texture = textures.Get(@"https://osu.ppy.sh/images/headers/changelog.jpg");
}
}
}