Add changelog listing

This commit is contained in:
HoutarouOreki 2018-07-22 05:28:43 +02:00
parent 8e7efafba3
commit 80808bddbf
4 changed files with 124 additions and 16 deletions

View File

@ -8,6 +8,6 @@ namespace osu.Game.Online.API.Requests
public class GetChangelogRequest : APIRequest<APIChangelog[]>
{
protected override string Target => @"changelog";
protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing
protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}/index"; // for testing
}
}

View File

@ -1,9 +1,11 @@
// 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.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@ -11,7 +13,7 @@
namespace osu.Game.Overlays.Changelog
{
public class ChangelogContent : FillFlowContainer<ChangelogContentGroup>
public class ChangelogContent : FillFlowContainer
{
public APIChangelog CurrentBuild { get; private set; }
public Action OnBuildChanged;
@ -23,11 +25,52 @@ public ChangelogContent()
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding
Padding = new MarginPadding{ Bottom = 100, };
}
private void add(APIChangelog[] changelog)
{
Horizontal = 70,
Bottom = 100,
};
DateTime currentDate = new DateTime();
Clear();
foreach (APIChangelog build in changelog)
{
if (build.CreatedAt.Date != currentDate)
{
if (Children.Count != 0)
{
Add(new Box
{
RelativeSizeAxes = Axes.X,
Height = 2,
Colour = new Color4(17, 17, 17, 255),
Margin = new MarginPadding { Top = 30, },
});
}
Add(changelogContentGroup = new ChangelogContentGroup(build, true)
{
BuildRequested = () => showBuild(build),
});
changelogContentGroup.GenerateText(build.ChangelogEntries);
currentDate = build.CreatedAt.Date;
}
else
{
changelogContentGroup.Add(new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Colour = new Color4(32, 24, 35, 255),
Margin = new MarginPadding { Top = 30, },
});
Add(changelogContentGroup = new ChangelogContentGroup(build, false)
{
BuildRequested = () => ShowBuild(build),
});
changelogContentGroup.GenerateText(build.ChangelogEntries);
}
}
}
private void add(APIChangelog changelogBuild)
@ -41,10 +84,12 @@ private void add(APIChangelog changelogBuild)
public void ShowBuild(APIChangelog changelog)
{
fetchAndShowChangelogBuild(changelog);
CurrentBuild = changelog;
fetchChangelogBuild(changelog);
}
public void ShowListing() => fetchAndShowChangelog();
private void showBuild(APIChangelog changelog)
{
ShowBuild(changelog);
@ -75,7 +120,14 @@ private void load(APIAccess api)
this.api = api;
}
private void fetchChangelogBuild(APIChangelog build)
private void fetchAndShowChangelog()
{
var req = new GetChangelogRequest();
req.Success += res => add(res);
api.Queue(req);
}
private void fetchAndShowChangelogBuild(APIChangelog build)
{
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
req.Success += res =>

View File

@ -21,7 +21,7 @@ public class ChangelogContentGroup : FillFlowContainer
private readonly SortedDictionary<string, List<ChangelogEntry>> categories =
new SortedDictionary<string, List<ChangelogEntry>>();
public Action NextRequested, PreviousRequested;
public Action NextRequested, PreviousRequested, BuildRequested;
public readonly FillFlowContainer ChangelogEntries;
public ChangelogContentGroup(APIChangelog build)
@ -29,6 +29,7 @@ public ChangelogContentGroup(APIChangelog build)
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Horizontal = 70 };
Children = new Drawable[]
{
// build version, arrows
@ -111,6 +112,67 @@ public ChangelogContentGroup(APIChangelog build)
};
}
public ChangelogContentGroup(APIChangelog build, bool newDate = false)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Horizontal = 70 };
Children = new Drawable[]
{
new SpriteText
{
// do we need .ToUniversalTime() here?
// also, this should be a temporary solution to weekdays in >localized< date strings
Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""),
TextSize = 28, // web: 24,
Colour = OsuColour.FromHex(@"FD5"),
Font = @"Exo2.0-Light",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding{ Top = 20, },
Alpha = newDate ? 1 : 0,
},
new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding{ Top = 20, },
Spacing = new Vector2(5),
Children = new Drawable[]
{
new SpriteText
{
Text = build.UpdateStream.DisplayName,
TextSize = 20, // web: 18,
Font = @"Exo2.0-Medium",
},
new SpriteText
{
Text = build.DisplayVersion,
TextSize = 20, // web: 18,
Font = @"Exo2.0-Light",
Colour = StreamColour.FromStreamName(build.UpdateStream.Name),
},
new ClickableText
{
Text = " ok ",
TextSize = 20,
Action = BuildRequested,
},
}
},
ChangelogEntries = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
},
};
}
public void UpdateChevronTooltips(string previousVersion, string nextVersion)
{
if (!string.IsNullOrEmpty(previousVersion))
@ -138,10 +200,6 @@ public void GenerateText(List<ChangelogEntry> changelogEntries)
foreach (KeyValuePair<string, List<ChangelogEntry>> category in categories)
{
// 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 = category.Key,
@ -183,6 +241,5 @@ public void GenerateText(List<ChangelogEntry> changelogEntries)
}
}
}
//public ChangelogContentGroup() { } // for listing
}
}

View File

@ -93,8 +93,7 @@ public ChangelogOverlay()
header.OnListingActivated += () =>
{
Streams.SelectedRelease = null;
content.Clear();
// should add listing to content here
content.ShowListing();
if (!Streams.IsHovered)
foreach (StreamBadge item in Streams.BadgesContainer.Children)
item.Activate(true);