2018-07-20 01:07:24 +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
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
2018-07-21 08:58:53 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-07-20 18:22:31 +08:00
|
|
|
|
using System;
|
2018-07-21 05:57:46 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-07-20 01:07:24 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Changelog
|
|
|
|
|
{
|
|
|
|
|
public class ChangelogContentGroup : FillFlowContainer
|
|
|
|
|
{
|
2018-07-20 23:24:21 +08:00
|
|
|
|
private readonly TooltipIconButton chevronPrevious, chevronNext;
|
|
|
|
|
|
2018-07-20 18:22:31 +08:00
|
|
|
|
public Action NextRequested, PreviousRequested;
|
2018-07-21 08:58:53 +08:00
|
|
|
|
public readonly FillFlowContainer ChangelogEntries;
|
2018-07-21 05:57:46 +08:00
|
|
|
|
|
2018-07-20 01:07:24 +08:00
|
|
|
|
public ChangelogContentGroup(APIChangelog build)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// build version, arrows
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = 20,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-07-20 23:24:21 +08:00
|
|
|
|
chevronPrevious = new TooltipIconButton
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-21 01:35:38 +08:00
|
|
|
|
IsEnabled = false,
|
2018-07-20 01:07:24 +08:00
|
|
|
|
Icon = FontAwesome.fa_chevron_left,
|
|
|
|
|
Size = new Vector2(24),
|
2018-07-20 21:48:20 +08:00
|
|
|
|
Action = () => PreviousRequested(),
|
2018-07-20 01:07:24 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer<SpriteText>
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Left = 40,
|
|
|
|
|
Right = 40,
|
|
|
|
|
},
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = build.UpdateStream.DisplayName,
|
|
|
|
|
TextSize = 28, // web: 24,
|
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
|
},
|
2018-07-20 21:48:20 +08:00
|
|
|
|
new SpriteText
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
|
|
|
|
Text = " ",
|
|
|
|
|
TextSize = 28,
|
|
|
|
|
},
|
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = build.DisplayVersion,
|
|
|
|
|
TextSize = 28, // web: 24,
|
2018-07-20 03:49:13 +08:00
|
|
|
|
Font = @"Exo2.0-Light",
|
|
|
|
|
Colour = StreamColour.FromStreamName(build.UpdateStream.Name),
|
2018-07-20 01:07:24 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-07-20 23:24:21 +08:00
|
|
|
|
chevronNext = new TooltipIconButton
|
2018-07-20 01:07:24 +08:00
|
|
|
|
{
|
2018-07-21 01:35:38 +08:00
|
|
|
|
IsEnabled = false,
|
2018-07-20 01:07:24 +08:00
|
|
|
|
Icon = FontAwesome.fa_chevron_right,
|
|
|
|
|
Size = new Vector2(24),
|
2018-07-20 21:48:20 +08:00
|
|
|
|
Action = () => NextRequested(),
|
2018-07-20 01:07:24 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
// do we need .ToUniversalTime() here?
|
2018-07-20 03:49:13 +08:00
|
|
|
|
// also, this should be a temporary solution to weekdays in >localized< date strings
|
2018-07-21 08:58:53 +08:00
|
|
|
|
Text = build.CreatedAt.Value.Date.ToLongDateString().Replace(build.CreatedAt.Value.ToString("dddd") + ", ", ""),
|
2018-07-20 01:07:24 +08:00
|
|
|
|
TextSize = 17, // web: 14,
|
|
|
|
|
Colour = OsuColour.FromHex(@"FD5"),
|
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = 5,
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-21 08:58:53 +08:00
|
|
|
|
ChangelogEntries = new FillFlowContainer
|
2018-07-21 05:57:46 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-07-21 08:58:53 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2018-07-21 05:57:46 +08:00
|
|
|
|
},
|
2018-07-20 01:07:24 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-07-20 23:24:21 +08:00
|
|
|
|
|
|
|
|
|
public void UpdateChevronTooltips(string previousVersion, string nextVersion)
|
|
|
|
|
{
|
2018-07-21 00:23:25 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(previousVersion))
|
2018-07-21 01:35:38 +08:00
|
|
|
|
{
|
2018-07-20 23:24:21 +08:00
|
|
|
|
chevronPrevious.TooltipText = previousVersion;
|
2018-07-21 01:35:38 +08:00
|
|
|
|
chevronPrevious.IsEnabled = true;
|
|
|
|
|
}
|
2018-07-21 00:23:25 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(nextVersion))
|
2018-07-21 01:35:38 +08:00
|
|
|
|
{
|
2018-07-20 23:24:21 +08:00
|
|
|
|
chevronNext.TooltipText = nextVersion;
|
2018-07-21 01:35:38 +08:00
|
|
|
|
chevronNext.IsEnabled = true;
|
|
|
|
|
}
|
2018-07-20 23:24:21 +08:00
|
|
|
|
}
|
2018-07-21 05:57:46 +08:00
|
|
|
|
|
|
|
|
|
public void GenerateText(List<ChangelogEntry> changelogEntries)
|
|
|
|
|
{
|
|
|
|
|
foreach (ChangelogEntry entry in changelogEntries)
|
|
|
|
|
{
|
2018-07-21 08:58:53 +08:00
|
|
|
|
// textflowcontainer is unusable for formatting text
|
|
|
|
|
// this has to be a placeholder before we get a
|
|
|
|
|
// proper markdown/html formatting..
|
|
|
|
|
// it can't handle overflowing properly
|
|
|
|
|
ChangelogEntries.Add(new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = entry.Category,
|
|
|
|
|
TextSize = 24, // web: 18,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Margin = new MarginPadding { Top = 35, Bottom = 15, },
|
|
|
|
|
});
|
|
|
|
|
ChangelogEntries.Add(new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Icon = FontAwesome.fa_check,
|
|
|
|
|
Size = new Vector2(14),
|
|
|
|
|
Margin = new MarginPadding { Top = 2, Right = 4 },
|
|
|
|
|
},
|
|
|
|
|
new TextFlowContainer(t => t.TextSize = 18)
|
|
|
|
|
{
|
|
|
|
|
Text = entry.Title,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = !string.IsNullOrEmpty(entry.Repository) ?
|
|
|
|
|
$" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})" :
|
|
|
|
|
null,
|
|
|
|
|
TextSize = 18,
|
|
|
|
|
Colour = new Color4(153, 238, 255, 255),
|
|
|
|
|
},
|
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = $" by {entry.GithubUser.DisplayName}",
|
|
|
|
|
TextSize = 14, // web: 12;
|
|
|
|
|
Margin = new MarginPadding { Top = 4, Left = 10, },
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-07-21 05:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-20 21:48:20 +08:00
|
|
|
|
//public ChangelogContentGroup() { } // for listing
|
2018-07-20 01:07:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|