mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 03:27:21 +09:00
Split out ChangelogContent into two classes
This commit is contained in:
parent
876f108e0a
commit
dd2d58d4f7
30
osu.Game/Overlays/Changelog/ChangelogBuild.cs
Normal file
30
osu.Game/Overlays/Changelog/ChangelogBuild.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Changelog
|
||||||
|
{
|
||||||
|
public class ChangelogBuild : ChangelogContent
|
||||||
|
{
|
||||||
|
private readonly APIChangelogBuild changelogBuild;
|
||||||
|
|
||||||
|
public ChangelogBuild(APIChangelogBuild changelogBuild)
|
||||||
|
{
|
||||||
|
this.changelogBuild = changelogBuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
var changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
||||||
|
changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries);
|
||||||
|
changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion,
|
||||||
|
changelogBuild.Versions.Next?.DisplayVersion);
|
||||||
|
changelogContentGroup.BuildSelected += SelectBuild;
|
||||||
|
|
||||||
|
Add(changelogContentGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,20 +3,17 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
public class ChangelogContent : FillFlowContainer
|
public class ChangelogContent : FillFlowContainer
|
||||||
{
|
{
|
||||||
private ChangelogContentGroup changelogContentGroup;
|
|
||||||
|
|
||||||
public event Action<APIChangelogBuild> BuildSelected;
|
public event Action<APIChangelogBuild> BuildSelected;
|
||||||
|
|
||||||
|
public void SelectBuild(APIChangelogBuild build) => BuildSelected?.Invoke(build);
|
||||||
|
|
||||||
public ChangelogContent()
|
public ChangelogContent()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -24,58 +21,5 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
Padding = new MarginPadding { Bottom = 100 };
|
Padding = new MarginPadding { Bottom = 100 };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowListing(List<APIChangelogBuild> changelog)
|
|
||||||
{
|
|
||||||
DateTime currentDate = new DateTime();
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
foreach (APIChangelogBuild 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 },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
changelogContentGroup = new ChangelogContentGroup(build, true);
|
|
||||||
changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b);
|
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
|
||||||
Add(changelogContentGroup);
|
|
||||||
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 },
|
|
||||||
});
|
|
||||||
|
|
||||||
changelogContentGroup = new ChangelogContentGroup(build, false);
|
|
||||||
changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b);
|
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
|
||||||
Add(changelogContentGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowBuild(APIChangelogBuild changelogBuild)
|
|
||||||
{
|
|
||||||
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
|
||||||
changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries);
|
|
||||||
changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion,
|
|
||||||
changelogBuild.Versions.Next?.DisplayVersion);
|
|
||||||
changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
70
osu.Game/Overlays/Changelog/ChangelogListing.cs
Normal file
70
osu.Game/Overlays/Changelog/ChangelogListing.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// 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;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Changelog
|
||||||
|
{
|
||||||
|
public class ChangelogListing : ChangelogContent
|
||||||
|
{
|
||||||
|
private readonly List<APIChangelogBuild> entries;
|
||||||
|
|
||||||
|
public ChangelogListing(List<APIChangelogBuild> entries)
|
||||||
|
{
|
||||||
|
this.entries = entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
DateTime currentDate = new DateTime();
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
ChangelogContentGroup changelogContentGroup = null;
|
||||||
|
|
||||||
|
foreach (APIChangelogBuild build in entries)
|
||||||
|
{
|
||||||
|
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 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
changelogContentGroup = new ChangelogContentGroup(build, true);
|
||||||
|
changelogContentGroup.BuildSelected += SelectBuild;
|
||||||
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
||||||
|
Add(changelogContentGroup);
|
||||||
|
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 },
|
||||||
|
});
|
||||||
|
|
||||||
|
changelogContentGroup = new ChangelogContentGroup(build, false);
|
||||||
|
changelogContentGroup.BuildSelected += SelectBuild;
|
||||||
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
||||||
|
Add(changelogContentGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// 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.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
@ -23,15 +24,15 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private BadgeDisplay badges;
|
private BadgeDisplay badges;
|
||||||
|
|
||||||
private ChangelogContent listing;
|
private Container content;
|
||||||
private ChangelogContent content;
|
|
||||||
|
|
||||||
private SampleChannel sampleBack;
|
private SampleChannel sampleBack;
|
||||||
|
|
||||||
|
private List<APIChangelogBuild> builds;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuColour colour)
|
private void load(AudioManager audio, OsuColour colour)
|
||||||
{
|
{
|
||||||
// these possibly need adjusting?
|
|
||||||
Waves.FirstWaveColour = colour.Violet;
|
Waves.FirstWaveColour = colour.Violet;
|
||||||
Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF");
|
Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF");
|
||||||
Waves.ThirdWaveColour = OsuColour.FromHex(@"600280");
|
Waves.ThirdWaveColour = OsuColour.FromHex(@"600280");
|
||||||
@ -57,8 +58,11 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
header = new ChangelogHeader(),
|
header = new ChangelogHeader(),
|
||||||
badges = new BadgeDisplay(),
|
badges = new BadgeDisplay(),
|
||||||
listing = new ChangelogContent(),
|
content = new Container
|
||||||
content = new ChangelogContent()
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -73,10 +77,7 @@ namespace osu.Game.Overlays
|
|||||||
ShowBuild(e.NewValue.LatestBuild);
|
ShowBuild(e.NewValue.LatestBuild);
|
||||||
};
|
};
|
||||||
|
|
||||||
listing.BuildSelected += ShowBuild;
|
sampleBack = audio.Sample.Get(@"UI/generic-select-soft");
|
||||||
content.BuildSelected += ShowBuild;
|
|
||||||
|
|
||||||
sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -102,7 +103,7 @@ namespace osu.Game.Overlays
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GlobalAction.Back:
|
case GlobalAction.Back:
|
||||||
if (listing.Alpha == 1)
|
if (content.Child is ChangelogContent)
|
||||||
{
|
{
|
||||||
State = Visibility.Hidden;
|
State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
@ -129,7 +130,8 @@ namespace osu.Game.Overlays
|
|||||||
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
|
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
|
||||||
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
|
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
|
||||||
|
|
||||||
listing.ShowListing(res.Builds);
|
builds = res.Builds;
|
||||||
|
ShowListing();
|
||||||
badges.Populate(res.Streams);
|
badges.Populate(res.Streams);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -139,10 +141,8 @@ namespace osu.Game.Overlays
|
|||||||
public void ShowListing()
|
public void ShowListing()
|
||||||
{
|
{
|
||||||
header.ShowListing();
|
header.ShowListing();
|
||||||
|
|
||||||
content.Hide();
|
|
||||||
badges.Current.Value = null;
|
badges.Current.Value = null;
|
||||||
listing.Show();
|
content.Child = new ChangelogListing(builds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -162,13 +162,8 @@ 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;
|
||||||
|
|
||||||
listing.Hide();
|
void displayBuild(APIChangelogBuild populatedBuild) =>
|
||||||
|
content.Child = new ChangelogBuild(populatedBuild);
|
||||||
void displayBuild(APIChangelogBuild populatedBuild)
|
|
||||||
{
|
|
||||||
content.Show();
|
|
||||||
content.ShowBuild(populatedBuild);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build.Versions != null)
|
if (build.Versions != null)
|
||||||
displayBuild(build);
|
displayBuild(build);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user