1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 17:43:20 +08:00
osu-lazer/osu.Game/Overlays/Changelog/ChangelogContent.cs
2018-07-22 20:27:50 +02:00

88 lines
3.1 KiB
C#

// 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;
using System;
using System.Collections.Generic;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogContent : FillFlowContainer
{
private APIAccess api;
private ChangelogContentGroup changelogContentGroup;
public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args);
public event BuildSelectedEventHandler BuildSelected;
public ChangelogContent()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding{ Bottom = 100, };
}
public void ShowListing(List<APIChangelog> changelog)
{
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, },
});
}
// watch out for this?
Add(changelogContentGroup = new ChangelogContentGroup(build, true));
changelogContentGroup.BuildSelected += onBuildSelected;
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));
changelogContentGroup.BuildSelected += onBuildSelected;
changelogContentGroup.GenerateText(build.ChangelogEntries);
}
}
}
public void ShowBuild(APIChangelog changelogBuild)
{
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
}
protected virtual void onBuildSelected(string updateStream, string version, EventArgs args)
{
if (BuildSelected != null)
BuildSelected(updateStream, version, EventArgs.Empty);
}
}
}