mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 10:47:21 +08:00
Add changelog listing
This commit is contained in:
parent
8e7efafba3
commit
80808bddbf
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ using System;
|
||||
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Padding = new MarginPadding
|
||||
Padding = new MarginPadding{ Bottom = 100, };
|
||||
}
|
||||
|
||||
private void add(APIChangelog[] changelog)
|
||||
{
|
||||
DateTime currentDate = new DateTime();
|
||||
|
||||
Clear();
|
||||
|
||||
foreach (APIChangelog build in changelog)
|
||||
{
|
||||
Horizontal = 70,
|
||||
Bottom = 100,
|
||||
};
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
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 =>
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Padding = new MarginPadding { Horizontal = 70 };
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// build version, arrows
|
||||
@ -111,6 +112,67 @@ namespace osu.Game.Overlays.Changelog
|
||||
};
|
||||
}
|
||||
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
|
||||
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 @@ namespace osu.Game.Overlays.Changelog
|
||||
}
|
||||
}
|
||||
}
|
||||
//public ChangelogContentGroup() { } // for listing
|
||||
}
|
||||
}
|
||||
|
@ -93,8 +93,7 @@ namespace osu.Game.Overlays
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user