mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:33:21 +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(ChangelogContent),
|
||||
typeof(ChangelogListing),
|
||||
typeof(ChangelogSingleBuild),
|
||||
typeof(ChangelogBuild),
|
||||
typeof(ChangelogContentGroup),
|
||||
typeof(Breadcrumb),
|
||||
typeof(BreadcrumbListing),
|
||||
typeof(BreadcrumbRelease),
|
||||
|
@ -22,7 +22,8 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
},
|
||||
date = new SpriteText
|
||||
date = new OsuSpriteText
|
||||
{
|
||||
Anchor = 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.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
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.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
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]
|
||||
private void load(CancellationToken? cancellation, IAPIProvider api)
|
||||
{
|
||||
var req = new GetChangelogBuildRequest(changelogBuild.UpdateStream.Name, changelogBuild.Version);
|
||||
bool complete = false;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Padding = new MarginPadding { Horizontal = 70 };
|
||||
|
||||
req.Success += res =>
|
||||
Children = new Drawable[]
|
||||
{
|
||||
changelogBuild = res;
|
||||
complete = true;
|
||||
CreateHeader(),
|
||||
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)
|
||||
Task.Delay(1);
|
||||
foreach (KeyValuePair<string, List<APIChangelogEntry>> category in categories)
|
||||
{
|
||||
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);
|
||||
changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries);
|
||||
changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion,
|
||||
changelogBuild.Versions.Next?.DisplayVersion);
|
||||
changelogContentGroup.BuildSelected += SelectBuild;
|
||||
foreach (APIChangelogEntry entry in category.Value)
|
||||
{
|
||||
LinkFlowContainer title = new LinkFlowContainer
|
||||
{
|
||||
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.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -23,10 +25,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
DateTime currentDate = new DateTime();
|
||||
Clear();
|
||||
|
||||
ChangelogContentGroup changelogContentGroup = null;
|
||||
DateTime currentDate = DateTime.MinValue;
|
||||
|
||||
foreach (APIChangelogBuild build in entries)
|
||||
{
|
||||
@ -43,27 +42,32 @@ namespace osu.Game.Overlays.Changelog
|
||||
});
|
||||
}
|
||||
|
||||
changelogContentGroup = new ChangelogContentGroup(build, true);
|
||||
changelogContentGroup.BuildSelected += SelectBuild;
|
||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
||||
Add(changelogContentGroup);
|
||||
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: 24),
|
||||
Colour = OsuColour.FromHex(@"FD5"),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding { Top = 15 },
|
||||
});
|
||||
|
||||
currentDate = build.CreatedAt.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
changelogContentGroup?.Add(new Box
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Colour = new Color4(32, 24, 35, 255),
|
||||
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 System;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Changelog.Components;
|
||||
|
||||
namespace osu.Game.Overlays.Changelog.Header
|
||||
@ -33,7 +34,7 @@ namespace osu.Game.Overlays.Changelog.Header
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Text = new SpriteText
|
||||
Text = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 16),
|
||||
Text = displayText,
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using System;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Changelog.Components;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -51,18 +52,18 @@ namespace osu.Game.Overlays.Changelog
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteText
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = stream.DisplayName,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
|
||||
Margin = new MarginPadding { Top = 6 },
|
||||
},
|
||||
new SpriteText
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = stream.LatestBuild.DisplayVersion,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16),
|
||||
},
|
||||
new SpriteText
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10),
|
||||
|
@ -138,7 +138,7 @@ namespace osu.Game.Overlays
|
||||
header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion);
|
||||
badges.Current.Value = build.UpdateStream;
|
||||
|
||||
loadContent(new ChangelogBuild(build));
|
||||
loadContent(new ChangelogSingleBuild(build));
|
||||
}
|
||||
|
||||
private bool initialFetchPerformed;
|
||||
|
Loading…
Reference in New Issue
Block a user