mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Huge refactor pass focusing on ChangelogContent
This commit is contained in:
parent
5d6c599129
commit
3fa1545ea4
@ -23,8 +23,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(ChangelogHeader),
|
typeof(ChangelogHeader),
|
||||||
typeof(ChangelogContent),
|
typeof(ChangelogContent),
|
||||||
typeof(ChangelogListing),
|
typeof(ChangelogListing),
|
||||||
|
typeof(ChangelogSingleBuild),
|
||||||
typeof(ChangelogBuild),
|
typeof(ChangelogBuild),
|
||||||
typeof(ChangelogContentGroup),
|
|
||||||
typeof(Breadcrumb),
|
typeof(Breadcrumb),
|
||||||
typeof(BreadcrumbListing),
|
typeof(BreadcrumbListing),
|
||||||
typeof(BreadcrumbRelease),
|
typeof(BreadcrumbRelease),
|
||||||
|
@ -22,7 +22,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
|
if (Action != null)
|
||||||
|
EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
date = new SpriteText
|
date = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
|
@ -1,50 +1,168 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Threading;
|
using osu.Framework.Graphics;
|
||||||
using System.Threading.Tasks;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
public class ChangelogBuild : ChangelogContent
|
public class ChangelogBuild : FillFlowContainer
|
||||||
{
|
{
|
||||||
private APIChangelogBuild changelogBuild;
|
public Action<APIChangelogBuild> SelectBuild;
|
||||||
|
|
||||||
public ChangelogBuild(APIChangelogBuild changelogBuild)
|
protected readonly APIChangelogBuild Build;
|
||||||
|
|
||||||
|
public readonly FillFlowContainer ChangelogEntries;
|
||||||
|
|
||||||
|
public ChangelogBuild(APIChangelogBuild build)
|
||||||
{
|
{
|
||||||
this.changelogBuild = changelogBuild;
|
Build = build;
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
RelativeSizeAxes = Axes.X;
|
||||||
private void load(CancellationToken? cancellation, IAPIProvider api)
|
AutoSizeAxes = Axes.Y;
|
||||||
{
|
Direction = FillDirection.Vertical;
|
||||||
var req = new GetChangelogBuildRequest(changelogBuild.UpdateStream.Name, changelogBuild.Version);
|
Padding = new MarginPadding { Horizontal = 70 };
|
||||||
bool complete = false;
|
|
||||||
|
|
||||||
req.Success += res =>
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
changelogBuild = res;
|
CreateHeader(),
|
||||||
complete = true;
|
ChangelogEntries = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
req.Failure += _ => complete = true;
|
var categories = new SortedDictionary<string, List<APIChangelogEntry>>();
|
||||||
|
|
||||||
api.Queue(req);
|
// sort entries by category
|
||||||
|
foreach (APIChangelogEntry entry in build.ChangelogEntries)
|
||||||
|
{
|
||||||
|
if (!categories.ContainsKey(entry.Category))
|
||||||
|
categories.Add(entry.Category, new List<APIChangelogEntry> { entry });
|
||||||
|
else
|
||||||
|
categories[entry.Category].Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
while (!complete && cancellation?.IsCancellationRequested != true)
|
foreach (KeyValuePair<string, List<APIChangelogEntry>> category in categories)
|
||||||
Task.Delay(1);
|
{
|
||||||
|
ChangelogEntries.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = category.Key,
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24),
|
||||||
|
Margin = new MarginPadding { Top = 35, Bottom = 15 },
|
||||||
|
});
|
||||||
|
|
||||||
var changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
foreach (APIChangelogEntry entry in category.Value)
|
||||||
changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries);
|
{
|
||||||
changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion,
|
LinkFlowContainer title = new LinkFlowContainer
|
||||||
changelogBuild.Versions.Next?.DisplayVersion);
|
{
|
||||||
changelogContentGroup.BuildSelected += SelectBuild;
|
Direction = FillDirection.Full,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Vertical = 5 },
|
||||||
|
};
|
||||||
|
|
||||||
Add(changelogContentGroup);
|
title.AddIcon(FontAwesome.Solid.Check, t =>
|
||||||
|
{
|
||||||
|
t.Font = OsuFont.GetFont(size: 12);
|
||||||
|
t.Padding = new MarginPadding { Left = -17, Right = 5 };
|
||||||
|
});
|
||||||
|
|
||||||
|
title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); });
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.Repository))
|
||||||
|
{
|
||||||
|
title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18));
|
||||||
|
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}",
|
||||||
|
entry.GithubUrl, Online.Chat.LinkAction.External, null,
|
||||||
|
null, t => { t.Font = OsuFont.GetFont(size: 18); });
|
||||||
|
title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18));
|
||||||
|
}
|
||||||
|
|
||||||
|
title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14));
|
||||||
|
|
||||||
|
if (entry.GithubUser.GithubUrl != null)
|
||||||
|
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl,
|
||||||
|
Online.Chat.LinkAction.External, null, null,
|
||||||
|
t => t.Font = OsuFont.GetFont(size: 14));
|
||||||
|
else
|
||||||
|
title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12));
|
||||||
|
|
||||||
|
ChangelogEntries.Add(title);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.MessageHtml))
|
||||||
|
{
|
||||||
|
TextFlowContainer messageContainer = new TextFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
};
|
||||||
|
|
||||||
|
// todo: use markdown parsing once API returns markdown
|
||||||
|
messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t =>
|
||||||
|
{
|
||||||
|
t.Font = OsuFont.GetFont(size: 12);
|
||||||
|
t.Colour = new Color4(235, 184, 254, 255);
|
||||||
|
});
|
||||||
|
|
||||||
|
ChangelogEntries.Add(messageContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Margin = new MarginPadding { Top = 20 },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuHoverContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Action = () => SelectBuild?.Invoke(Build),
|
||||||
|
Child = new FillFlowContainer<SpriteText>
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Margin = new MarginPadding { Horizontal = 40 },
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = Build.UpdateStream.DisplayName,
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = " ",
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = Build.DisplayVersion,
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19),
|
||||||
|
Colour = Build.UpdateStream.Colour,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,280 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using osu.Game.Overlays.Changelog.Components;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
|
||||||
{
|
|
||||||
public class ChangelogContentGroup : FillFlowContainer
|
|
||||||
{
|
|
||||||
private readonly TooltipIconButton chevronPrevious, chevronNext;
|
|
||||||
|
|
||||||
private readonly SortedDictionary<string, List<APIChangelogEntry>> categories =
|
|
||||||
new SortedDictionary<string, List<APIChangelogEntry>>();
|
|
||||||
|
|
||||||
public event Action<APIChangelogBuild> BuildSelected;
|
|
||||||
|
|
||||||
public readonly FillFlowContainer ChangelogEntries;
|
|
||||||
|
|
||||||
public ChangelogContentGroup(APIChangelogBuild build)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
Direction = FillDirection.Vertical;
|
|
||||||
Padding = new MarginPadding { Horizontal = 70 };
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Margin = new MarginPadding { Top = 20 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
chevronPrevious = new TooltipIconButton
|
|
||||||
{
|
|
||||||
IsEnabled = false,
|
|
||||||
Icon = FontAwesome.Solid.ChevronLeft,
|
|
||||||
Size = new Vector2(24),
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
BuildSelected?.Invoke(build.Versions.Previous);
|
|
||||||
chevronPrevious.IsEnabled = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new FillFlowContainer<SpriteText>
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding { Horizontal = 40 },
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = build.UpdateStream.DisplayName,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24),
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = " ",
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24),
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = build.DisplayVersion,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24),
|
|
||||||
Colour = build.UpdateStream.Colour,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
chevronNext = new TooltipIconButton
|
|
||||||
{
|
|
||||||
IsEnabled = false,
|
|
||||||
Icon = FontAwesome.Solid.ChevronRight,
|
|
||||||
Size = new Vector2(24),
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
BuildSelected?.Invoke(build.Versions.Next);
|
|
||||||
chevronNext.IsEnabled = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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") + ", ", ""),
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 14),
|
|
||||||
Colour = OsuColour.FromHex(@"FD5"),
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Margin = new MarginPadding { Top = 5 },
|
|
||||||
},
|
|
||||||
ChangelogEntries = new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangelogContentGroup(APIChangelogBuild build, bool newDate)
|
|
||||||
{
|
|
||||||
OsuHoverContainer clickableBuildText;
|
|
||||||
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") + ", ", ""),
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24),
|
|
||||||
Colour = OsuColour.FromHex(@"FD5"),
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Margin = new MarginPadding { Top = 20 },
|
|
||||||
Alpha = newDate ? 1 : 0,
|
|
||||||
},
|
|
||||||
clickableBuildText = new OsuHoverContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding { Top = 20 },
|
|
||||||
Action = () => BuildSelected?.Invoke(build),
|
|
||||||
Child = new FillFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(5),
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = build.UpdateStream.DisplayName,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Text = build.DisplayVersion,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19),
|
|
||||||
Colour = build.UpdateStream.Colour,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ChangelogEntries = new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// we may not want double clicks,
|
|
||||||
// can be clicked again only after a delay
|
|
||||||
clickableBuildText.Action += () =>
|
|
||||||
{
|
|
||||||
clickableBuildText.Action = null;
|
|
||||||
clickableBuildText.FadeTo(0.5f, 500);
|
|
||||||
Scheduler.AddDelayed(() =>
|
|
||||||
{
|
|
||||||
clickableBuildText.Action = () => BuildSelected?.Invoke(build);
|
|
||||||
clickableBuildText.FadeIn(500);
|
|
||||||
}, 2000);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateChevronTooltips(string previousVersion, string nextVersion)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(previousVersion))
|
|
||||||
{
|
|
||||||
chevronPrevious.TooltipText = previousVersion;
|
|
||||||
chevronPrevious.IsEnabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(nextVersion))
|
|
||||||
{
|
|
||||||
chevronNext.TooltipText = nextVersion;
|
|
||||||
chevronNext.IsEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GenerateText(List<APIChangelogEntry> changelogEntries)
|
|
||||||
{
|
|
||||||
// sort entries by category
|
|
||||||
foreach (APIChangelogEntry entry in changelogEntries)
|
|
||||||
{
|
|
||||||
if (!categories.ContainsKey(entry.Category))
|
|
||||||
categories.Add(entry.Category, new List<APIChangelogEntry> { entry });
|
|
||||||
else
|
|
||||||
categories[entry.Category].Add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, List<APIChangelogEntry>> category in categories)
|
|
||||||
{
|
|
||||||
ChangelogEntries.Add(new SpriteText
|
|
||||||
{
|
|
||||||
Text = category.Key,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24),
|
|
||||||
Margin = new MarginPadding { Top = 35, Bottom = 15 },
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (APIChangelogEntry entry in category.Value)
|
|
||||||
{
|
|
||||||
LinkFlowContainer title = new LinkFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Full,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Margin = new MarginPadding { Vertical = 5 },
|
|
||||||
};
|
|
||||||
|
|
||||||
title.AddIcon(FontAwesome.Solid.Check, t =>
|
|
||||||
{
|
|
||||||
t.Font = OsuFont.GetFont(size: 12);
|
|
||||||
t.Padding = new MarginPadding { Left = -17, Right = 5 };
|
|
||||||
});
|
|
||||||
|
|
||||||
title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); });
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(entry.Repository))
|
|
||||||
{
|
|
||||||
title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18));
|
|
||||||
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}",
|
|
||||||
entry.GithubUrl, Online.Chat.LinkAction.External, null,
|
|
||||||
null, t => { t.Font = OsuFont.GetFont(size: 18); });
|
|
||||||
title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18));
|
|
||||||
}
|
|
||||||
|
|
||||||
title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14));
|
|
||||||
|
|
||||||
if (entry.GithubUser.GithubUrl != null)
|
|
||||||
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl,
|
|
||||||
Online.Chat.LinkAction.External, null, null,
|
|
||||||
t => t.Font = OsuFont.GetFont(size: 14));
|
|
||||||
else
|
|
||||||
title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12));
|
|
||||||
|
|
||||||
ChangelogEntries.Add(title);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(entry.MessageHtml))
|
|
||||||
{
|
|
||||||
TextFlowContainer messageContainer = new TextFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
};
|
|
||||||
|
|
||||||
// todo: use markdown parsing once API returns markdown
|
|
||||||
messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t =>
|
|
||||||
{
|
|
||||||
t.Font = OsuFont.GetFont(size: 12);
|
|
||||||
t.Colour = new Color4(235, 184, 254, 255);
|
|
||||||
});
|
|
||||||
|
|
||||||
ChangelogEntries.Add(messageContainer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,8 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -23,10 +25,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
DateTime currentDate = new DateTime();
|
DateTime currentDate = DateTime.MinValue;
|
||||||
Clear();
|
|
||||||
|
|
||||||
ChangelogContentGroup changelogContentGroup = null;
|
|
||||||
|
|
||||||
foreach (APIChangelogBuild build in entries)
|
foreach (APIChangelogBuild build in entries)
|
||||||
{
|
{
|
||||||
@ -43,27 +42,32 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
changelogContentGroup = new ChangelogContentGroup(build, true);
|
Add(new OsuSpriteText
|
||||||
changelogContentGroup.BuildSelected += SelectBuild;
|
{
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
// do we need .ToUniversalTime() here?
|
||||||
Add(changelogContentGroup);
|
// also, this should be a temporary solution to weekdays in >localized< date strings
|
||||||
|
Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""),
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24),
|
||||||
|
Colour = OsuColour.FromHex(@"FD5"),
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Margin = new MarginPadding { Top = 15 },
|
||||||
|
});
|
||||||
|
|
||||||
currentDate = build.CreatedAt.Date;
|
currentDate = build.CreatedAt.Date;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changelogContentGroup?.Add(new Box
|
Add(new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 1,
|
Height = 1,
|
||||||
Colour = new Color4(32, 24, 35, 255),
|
Colour = new Color4(32, 24, 35, 255),
|
||||||
Margin = new MarginPadding { Top = 30 },
|
Margin = new MarginPadding { Top = 30 },
|
||||||
});
|
});
|
||||||
|
|
||||||
changelogContentGroup = new ChangelogContentGroup(build, false);
|
|
||||||
changelogContentGroup.BuildSelected += SelectBuild;
|
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
|
||||||
Add(changelogContentGroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Add(new ChangelogBuild(build) { SelectBuild = SelectBuild });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
118
osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs
Normal file
118
osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays.Changelog.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Changelog
|
||||||
|
{
|
||||||
|
public class ChangelogSingleBuild : ChangelogContent
|
||||||
|
{
|
||||||
|
private APIChangelogBuild build;
|
||||||
|
|
||||||
|
public ChangelogSingleBuild(APIChangelogBuild build)
|
||||||
|
{
|
||||||
|
this.build = build;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(CancellationToken? cancellation, IAPIProvider api)
|
||||||
|
{
|
||||||
|
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
|
||||||
|
bool complete = false;
|
||||||
|
|
||||||
|
req.Success += res =>
|
||||||
|
{
|
||||||
|
build = res;
|
||||||
|
complete = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
req.Failure += _ => complete = true;
|
||||||
|
|
||||||
|
api.Queue(req);
|
||||||
|
|
||||||
|
while (!complete && cancellation?.IsCancellationRequested != true)
|
||||||
|
Task.Delay(1);
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ChangelogBuildWithNavigation : ChangelogBuild
|
||||||
|
{
|
||||||
|
public ChangelogBuildWithNavigation(APIChangelogBuild build)
|
||||||
|
: base(build)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override FillFlowContainer CreateHeader()
|
||||||
|
{
|
||||||
|
var fill = base.CreateHeader();
|
||||||
|
|
||||||
|
foreach (var existing in fill.Children.OfType<OsuHoverContainer>())
|
||||||
|
{
|
||||||
|
existing.Scale = new Vector2(1.25f);
|
||||||
|
existing.Action = null;
|
||||||
|
|
||||||
|
existing.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
// 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") + ", ", ""),
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 14),
|
||||||
|
Colour = OsuColour.FromHex(@"FD5"),
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Margin = new MarginPadding { Top = 5 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TooltipIconButton left, right;
|
||||||
|
|
||||||
|
fill.AddRange(new[]
|
||||||
|
{
|
||||||
|
left = new TooltipIconButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Icon = FontAwesome.Solid.ChevronLeft,
|
||||||
|
Size = new Vector2(24),
|
||||||
|
TooltipText = Build.Versions?.Previous?.DisplayVersion,
|
||||||
|
IsEnabled = Build.Versions?.Previous != null,
|
||||||
|
Action = () => { SelectBuild?.Invoke(Build.Versions.Previous); },
|
||||||
|
},
|
||||||
|
right = new TooltipIconButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
|
Size = new Vector2(24),
|
||||||
|
TooltipText = Build.Versions?.Next?.DisplayVersion,
|
||||||
|
IsEnabled = Build.Versions?.Next != null,
|
||||||
|
Action = () => { SelectBuild?.Invoke(Build.Versions.Next); },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fill.SetLayoutPosition(left, -1);
|
||||||
|
fill.SetLayoutPosition(right, 1);
|
||||||
|
|
||||||
|
return fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Changelog.Components;
|
using osu.Game.Overlays.Changelog.Components;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog.Header
|
namespace osu.Game.Overlays.Changelog.Header
|
||||||
@ -33,7 +34,7 @@ namespace osu.Game.Overlays.Changelog.Header
|
|||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Text = new SpriteText
|
Text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: 16),
|
Font = OsuFont.GetFont(size: 16),
|
||||||
Text = displayText,
|
Text = displayText,
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Changelog.Components;
|
using osu.Game.Overlays.Changelog.Components;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -51,18 +52,18 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new SpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = stream.DisplayName,
|
Text = stream.DisplayName,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||||
Margin = new MarginPadding { Top = 6 },
|
Margin = new MarginPadding { Top = 6 },
|
||||||
},
|
},
|
||||||
new SpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = stream.LatestBuild.DisplayVersion,
|
Text = stream.LatestBuild.DisplayVersion,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16),
|
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16),
|
||||||
},
|
},
|
||||||
new SpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null,
|
Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10),
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10),
|
||||||
|
@ -138,7 +138,7 @@ namespace osu.Game.Overlays
|
|||||||
header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion);
|
header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion);
|
||||||
badges.Current.Value = build.UpdateStream;
|
badges.Current.Value = build.UpdateStream;
|
||||||
|
|
||||||
loadContent(new ChangelogBuild(build));
|
loadContent(new ChangelogSingleBuild(build));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool initialFetchPerformed;
|
private bool initialFetchPerformed;
|
||||||
|
Loading…
Reference in New Issue
Block a user