2018-07-17 05:50:22 +08: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 21:01:53 +08:00
|
|
|
|
using OpenTK;
|
2018-07-17 05:50:22 +08: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 21:01:53 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Overlays.Changelog.Header;
|
2018-07-18 07:35:06 +08:00
|
|
|
|
using System;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
|
|
|
|
public class ChangelogHeader : Container
|
|
|
|
|
{
|
2018-07-18 00:32:11 +08:00
|
|
|
|
protected Color4 purple = new Color4(191, 4, 255, 255);
|
2018-07-17 05:50:22 +08:00
|
|
|
|
private readonly Sprite coverImage;
|
|
|
|
|
private readonly Sprite headerBadge; //50x50, margin-right: 20
|
|
|
|
|
private readonly FillFlowContainer headerTextContainer;
|
|
|
|
|
private readonly OsuSpriteText title, titleStream;
|
2018-07-18 00:32:11 +08:00
|
|
|
|
private readonly SpriteIcon chevron;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
private readonly TextBadgePairListing listing;
|
|
|
|
|
private readonly TextBadgePairRelease releaseStream;
|
|
|
|
|
private readonly FillFlowContainer breadcrumbContainer;
|
|
|
|
|
|
2018-07-18 07:35:06 +08:00
|
|
|
|
public Action OnListingActivated;
|
|
|
|
|
|
2018-07-17 05:50:22 +08:00
|
|
|
|
private const float cover_height = 310;
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-07-18 07:35:06 +08:00
|
|
|
|
Height = cover_height;
|
2018-07-17 05:50:22 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
coverImage = new Sprite
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new OpenTK.Vector2(1),
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
new Container // this is the line badge-Changelog-Stream
|
|
|
|
|
{
|
|
|
|
|
Height = title_height,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Y = -version_height,
|
2018-07-17 05:50:22 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
new CircularContainer // a purple circle
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
X = icon_margin,
|
|
|
|
|
Masking = true,
|
|
|
|
|
BorderColour = purple,
|
|
|
|
|
BorderThickness = 3,
|
|
|
|
|
MaskingSmoothness = 1,
|
|
|
|
|
Size = new OpenTK.Vector2(50),
|
2018-07-18 00:32:11 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
headerBadge = new Sprite
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new OpenTK.Vector2(0.8f),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-07-17 05:50:22 +08:00
|
|
|
|
},
|
2018-07-18 07:35:06 +08:00
|
|
|
|
|
|
|
|
|
// this box has 2 functions:
|
|
|
|
|
// - ensures the circle doesn't disappear on the X and Y edges
|
|
|
|
|
// - lessens the white "contamination" on the circle (due to smoothing)
|
|
|
|
|
new Box
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new OpenTK.Vector2(1),
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Colour = purple,
|
2018-07-18 00:32:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-07-18 07:35:06 +08:00
|
|
|
|
headerTextContainer = new FillFlowContainer
|
2018-07-18 00:32:11 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2018-07-18 00:32:11 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2018-07-18 07:35:06 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
X = icon_size + icon_margin * 2,
|
2018-07-18 00:32:11 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
title = new OsuSpriteText
|
2018-07-18 00:32:11 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
Text = "Changelog ",
|
|
|
|
|
Font = @"Exo2.0-Light",
|
|
|
|
|
TextSize = 38, // web: 30
|
2018-07-17 05:50:22 +08:00
|
|
|
|
},
|
2018-07-18 07:35:06 +08:00
|
|
|
|
titleStream = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "Listing",
|
|
|
|
|
TextSize = 38, // web: 30
|
|
|
|
|
Font = @"Exo2.0-Light",
|
|
|
|
|
Colour = purple,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1
|
|
|
|
|
{
|
|
|
|
|
X = 2 * icon_margin + icon_size - 8,
|
|
|
|
|
Height = version_height,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
listing = new TextBadgePairListing(purple),
|
|
|
|
|
new Container() // without a container, moving the chevron wont work
|
2018-07-18 00:32:11 +08:00
|
|
|
|
{
|
2018-07-18 07:35:06 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2018-07-18 00:32:11 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
2018-07-18 07:35:06 +08:00
|
|
|
|
Margin = new MarginPadding()
|
|
|
|
|
{
|
|
|
|
|
Top = 10,
|
|
|
|
|
Left = 7,
|
|
|
|
|
Right = 9,
|
|
|
|
|
Bottom = 15,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
chevron = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(7),
|
|
|
|
|
Colour = purple,
|
|
|
|
|
Icon = FontAwesome.fa_chevron_right,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
X = -200,
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-18 00:32:11 +08:00
|
|
|
|
},
|
2018-07-18 07:35:06 +08:00
|
|
|
|
releaseStream = new TextBadgePairRelease(purple, "Lazer")
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Box // purple line
|
|
|
|
|
{
|
|
|
|
|
Colour = purple,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 3,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
},
|
2018-07-17 05:50:22 +08:00
|
|
|
|
};
|
2018-07-17 21:01:53 +08:00
|
|
|
|
|
|
|
|
|
// is this a bad way to do this?
|
|
|
|
|
OnLoadComplete = d =>
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-18 00:32:11 +08:00
|
|
|
|
releaseStream.OnActivation = () =>
|
|
|
|
|
{
|
|
|
|
|
listing.Deactivate();
|
|
|
|
|
chevron.MoveToX(0, 100).FadeIn(100);
|
|
|
|
|
};
|
2018-07-17 21:01:53 +08:00
|
|
|
|
listing.OnActivation = () =>
|
|
|
|
|
{
|
|
|
|
|
releaseStream.Deactivate();
|
2018-07-18 00:32:11 +08:00
|
|
|
|
chevron.MoveToX(-20, 100).FadeOut(100);
|
2018-07-17 21:01:53 +08:00
|
|
|
|
ChangeHeaderText("Listing");
|
2018-07-18 07:35:06 +08:00
|
|
|
|
OnListingActivated?.Invoke();
|
2018-07-17 21:01:53 +08:00
|
|
|
|
};
|
2018-07-17 05:50:22 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 21:01:53 +08:00
|
|
|
|
public void ShowReleaseStream(string headerText, string breadcrumbText)
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-17 21:01:53 +08:00
|
|
|
|
releaseStream.Activate(breadcrumbText);
|
|
|
|
|
ChangeHeaderText(headerText);
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 21:01:53 +08:00
|
|
|
|
private void ChangeHeaderText(string headerText)
|
2018-07-17 05:50:22 +08:00
|
|
|
|
{
|
2018-07-17 21:01:53 +08:00
|
|
|
|
titleStream.Text = headerText;
|
|
|
|
|
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
|
2018-07-17 05:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 21:01:53 +08:00
|
|
|
|
public void ActivateListing() => listing.Activate();
|
2018-07-18 07:35:06 +08:00
|
|
|
|
|
2018-07-17 05:50:22 +08: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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|