mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 20:32:55 +08:00
Rewrite ChangelogOverlay.cs
This commit is contained in:
parent
421c95156b
commit
b3f789e19a
@ -13,7 +13,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Overlays.Changelog;
|
using osu.Game.Overlays.Changelog;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
@ -21,13 +20,15 @@ namespace osu.Game.Overlays
|
|||||||
public class ChangelogOverlay : WaveOverlayContainer
|
public class ChangelogOverlay : WaveOverlayContainer
|
||||||
{
|
{
|
||||||
private readonly ChangelogHeader header;
|
private readonly ChangelogHeader header;
|
||||||
public readonly ChangelogStreams Streams;
|
private readonly ChangelogBadges badges;
|
||||||
private readonly ChangelogChart chart;
|
private readonly ChangelogChart chart;
|
||||||
private APIChangelog changelogEntry;
|
private readonly ChangelogContent content;
|
||||||
|
|
||||||
|
private readonly Color4 purple = new Color4(191, 4, 255, 255);
|
||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
|
|
||||||
protected readonly Color4 Purple = new Color4(191, 4, 255, 255);
|
private bool isAtListing;
|
||||||
|
|
||||||
public ChangelogOverlay()
|
public ChangelogOverlay()
|
||||||
{
|
{
|
||||||
@ -43,8 +44,6 @@ namespace osu.Game.Overlays
|
|||||||
Width = 0.85f;
|
Width = 0.85f;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
|
||||||
ChangelogContent content; // told by appveyor to convert to local variable..
|
|
||||||
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Colour = Color4.Black.Opacity(0),
|
Colour = Color4.Black.Opacity(0),
|
||||||
@ -72,49 +71,22 @@ namespace osu.Game.Overlays
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
header = new ChangelogHeader(),
|
header = new ChangelogHeader(),
|
||||||
Streams = new ChangelogStreams(),
|
badges = new ChangelogBadges(),
|
||||||
chart = new ChangelogChart(),
|
chart = new ChangelogChart(),
|
||||||
content = new ChangelogContent()
|
content = new ChangelogContent()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
OnLoadComplete += d =>
|
// content.ShowListing();
|
||||||
{
|
// if (!Streams.IsHovered)
|
||||||
FetchChangelog();
|
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
||||||
content.ShowListing();
|
// item.Activate(true);
|
||||||
};
|
// else
|
||||||
Streams.OnSelection = () =>
|
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
||||||
{
|
// item.Deactivate();
|
||||||
if (Streams.SelectedRelease != null)
|
|
||||||
{
|
|
||||||
header.ChangelogEntry = Streams.SelectedRelease;
|
|
||||||
}
|
|
||||||
header.ShowReleaseStream();
|
|
||||||
content.ShowBuild(Streams.SelectedRelease);
|
|
||||||
chart.ShowChart(Streams.SelectedRelease);
|
|
||||||
};
|
|
||||||
header.OnListingActivated += () =>
|
|
||||||
{
|
|
||||||
Streams.SelectedRelease = null;
|
|
||||||
content.ShowListing();
|
|
||||||
if (!Streams.IsHovered)
|
|
||||||
foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
|
||||||
item.Activate(true);
|
|
||||||
else
|
|
||||||
foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
|
||||||
item.Deactivate();
|
|
||||||
chart.ShowChart();
|
|
||||||
};
|
|
||||||
content.OnBuildChanged = () =>
|
|
||||||
{
|
|
||||||
header.ChangelogEntry = content.CurrentBuild;
|
|
||||||
header.ShowReleaseStream();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ActivateListing() => header.ActivateListing();
|
|
||||||
|
|
||||||
// receive input outside our bounds so we can trigger a close event on ourselves.
|
// receive input outside our bounds so we can trigger a close event on ourselves.
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
@ -123,10 +95,10 @@ namespace osu.Game.Overlays
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GlobalAction.Back:
|
case GlobalAction.Back:
|
||||||
if (header.IsListingActivated())
|
if (isAtListing)
|
||||||
State = Visibility.Hidden;
|
State = Visibility.Hidden;
|
||||||
else
|
else
|
||||||
header.ActivateListing();
|
FetchAndShowListing();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,16 +123,30 @@ namespace osu.Game.Overlays
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FetchChangelog()
|
/// <summary>
|
||||||
|
/// Fetches and shows changelog listing.
|
||||||
|
/// </summary>
|
||||||
|
public void FetchAndShowListing()
|
||||||
{
|
{
|
||||||
var req = new GetChangelogLatestBuildsRequest();
|
var req = new GetChangelogLatestBuildsRequest();
|
||||||
req.Success += res =>
|
header.ShowListing();
|
||||||
{
|
badges.SelectNone();
|
||||||
Streams.BadgesContainer.Clear();
|
chart.ShowAllUpdateStreams();
|
||||||
foreach (APIChangelog item in res)
|
req.Success += content.ShowListing;
|
||||||
Streams.BadgesContainer.Add(new StreamBadge(item));
|
api.Queue(req);
|
||||||
chart.ShowChart();
|
}
|
||||||
};
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches and shows a specific build from a specific update stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sentByBadges">If true, will select fetched build's update stream badge.</param>
|
||||||
|
public void FetchAndShowBuild(string updateStream, string version)
|
||||||
|
{
|
||||||
|
var req = new GetChangelogBuildRequest(updateStream, version);
|
||||||
|
header.ShowBuild(updateStream, version);
|
||||||
|
badges.SelectBadge(updateStream);
|
||||||
|
chart.ShowUpdateStream(updateStream);
|
||||||
|
req.Success += content.ShowBuild;
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user