mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Further rewrite
This commit is contained in:
parent
24abec43c1
commit
51eec0dca4
@ -23,6 +23,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
public event SelectionHandler Selected;
|
public event SelectionHandler Selected;
|
||||||
|
|
||||||
private readonly FillFlowContainer<StreamBadge> badgesContainer;
|
private readonly FillFlowContainer<StreamBadge> badgesContainer;
|
||||||
|
private long selectedStreamId = -1;
|
||||||
|
|
||||||
public ChangelogBadges()
|
public ChangelogBadges()
|
||||||
{
|
{
|
||||||
@ -66,29 +67,43 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
foreach (APIChangelog updateStream in latestBuilds)
|
foreach (APIChangelog updateStream in latestBuilds)
|
||||||
{
|
{
|
||||||
var streamBadge = new StreamBadge(updateStream);
|
var streamBadge = new StreamBadge(updateStream);
|
||||||
streamBadge.Selected += OnBadgeSelected;
|
streamBadge.Selected += onBadgeSelected;
|
||||||
badgesContainer.Add(streamBadge);
|
badgesContainer.Add(streamBadge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectNone()
|
public void SelectNone()
|
||||||
{
|
{
|
||||||
foreach (StreamBadge streamBadge in badgesContainer)
|
selectedStreamId = -1;
|
||||||
streamBadge.Deactivate();
|
if (badgesContainer != null)
|
||||||
|
{
|
||||||
|
foreach (StreamBadge streamBadge in badgesContainer)
|
||||||
|
{
|
||||||
|
if (!IsHovered)
|
||||||
|
streamBadge.Activate();
|
||||||
|
else
|
||||||
|
streamBadge.Deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectUpdateStream(string updateStream)
|
public void SelectUpdateStream(string updateStream)
|
||||||
{
|
{
|
||||||
foreach (StreamBadge streamBadge in badgesContainer)
|
foreach (StreamBadge streamBadge in badgesContainer)
|
||||||
|
{
|
||||||
if (streamBadge.ChangelogEntry.UpdateStream.Name == updateStream)
|
if (streamBadge.ChangelogEntry.UpdateStream.Name == updateStream)
|
||||||
{
|
{
|
||||||
|
selectedStreamId = streamBadge.ChangelogEntry.UpdateStream.Id;
|
||||||
streamBadge.Activate();
|
streamBadge.Activate();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
streamBadge.Deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBadgeSelected(StreamBadge source, EventArgs args)
|
private void onBadgeSelected(StreamBadge source, EventArgs args)
|
||||||
{
|
{
|
||||||
|
selectedStreamId = source.ChangelogEntry.UpdateStream.Id;
|
||||||
OnSelected(source);
|
OnSelected(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,33 +113,33 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Selected(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty);
|
Selected(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
//{
|
{
|
||||||
// foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
foreach (StreamBadge streamBadge in badgesContainer.Children)
|
||||||
// {
|
{
|
||||||
// if (SelectedRelease != null)
|
if (selectedStreamId < 0)
|
||||||
// {
|
{
|
||||||
// if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id)
|
if (selectedStreamId != streamBadge.ChangelogEntry.UpdateStream.Id)
|
||||||
// streamBadge.Deactivate();
|
streamBadge.Deactivate();
|
||||||
// else
|
else
|
||||||
// streamBadge.EnableDim();
|
streamBadge.EnableDim();
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// streamBadge.Deactivate();
|
streamBadge.Deactivate();
|
||||||
// }
|
}
|
||||||
// return base.OnHover(state);
|
return base.OnHover(state);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
//{
|
{
|
||||||
// foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
foreach (StreamBadge streamBadge in badgesContainer.Children)
|
||||||
// {
|
{
|
||||||
// if (SelectedRelease == null)
|
if (selectedStreamId < 0)
|
||||||
// streamBadge.Activate(true);
|
streamBadge.Activate(true);
|
||||||
// else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id)
|
else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId)
|
||||||
// streamBadge.DisableDim();
|
streamBadge.DisableDim();
|
||||||
// }
|
}
|
||||||
// base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ 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.Online.API.Requests.Responses;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Padding = new MarginPadding{ Bottom = 100, };
|
Padding = new MarginPadding{ Bottom = 100, };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowListing(List<APIChangelog> changelog)
|
public void ShowListing(APIChangelog[] changelog)
|
||||||
{
|
{
|
||||||
DateTime currentDate = new DateTime();
|
DateTime currentDate = new DateTime();
|
||||||
|
|
||||||
|
@ -160,11 +160,11 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBuild(string updateStream, string version)
|
public void ShowBuild(string displayName, string displayVersion)
|
||||||
{
|
{
|
||||||
listing.Deactivate();
|
listing.Deactivate();
|
||||||
releaseStream.Activate($"{updateStream} {version}");
|
releaseStream.Activate($"{displayName} {displayVersion}");
|
||||||
titleStream.Text = updateStream;
|
titleStream.Text = displayName;
|
||||||
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
|
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +85,12 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(bool withoutHeaderUpdate = false)
|
public void Activate(bool withoutFiringUpdates = true)
|
||||||
{
|
{
|
||||||
isActivated = true;
|
isActivated = true;
|
||||||
this.FadeIn(transition_duration);
|
this.FadeIn(transition_duration);
|
||||||
lineBadge.IsCollapsed = false;
|
lineBadge.IsCollapsed = false;
|
||||||
if (!withoutHeaderUpdate && Selected != null)
|
if (!withoutFiringUpdates && Selected != null)
|
||||||
Selected(this, EventArgs.Empty);
|
Selected(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
Activate();
|
Activate(false);
|
||||||
return base.OnClick(state);
|
return base.OnClick(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,15 +79,8 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
badges.Selected += onBuildSelected;
|
badges.Selected += onBuildSelected;
|
||||||
// content.ShowListing();
|
header.ListingActivated += FetchAndShowListing;
|
||||||
// if (!Streams.IsHovered)
|
|
||||||
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
|
||||||
// item.Activate(true);
|
|
||||||
// else
|
|
||||||
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
|
||||||
// item.Deactivate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
@ -131,12 +124,22 @@ namespace osu.Game.Overlays
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
var req = new GetChangelogLatestBuildsRequest();
|
||||||
|
req.Success += badges.Populate;
|
||||||
|
api.Queue(req);
|
||||||
|
FetchAndShowListing();
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches and shows changelog listing.
|
/// Fetches and shows changelog listing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FetchAndShowListing()
|
public void FetchAndShowListing()
|
||||||
{
|
{
|
||||||
var req = new GetChangelogLatestBuildsRequest();
|
isAtListing = true;
|
||||||
|
var req = new GetChangelogRequest();
|
||||||
header.ShowListing();
|
header.ShowListing();
|
||||||
badges.SelectNone();
|
badges.SelectNone();
|
||||||
chart.ShowAllUpdateStreams();
|
chart.ShowAllUpdateStreams();
|
||||||
@ -147,14 +150,15 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches and shows a specific build from a specific update stream.
|
/// Fetches and shows a specific build from a specific update stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sentByBadges">If true, will select fetched build's update stream badge.</param>
|
public void FetchAndShowBuild(string updateStream, string version, bool sentByBadges = false)
|
||||||
public void FetchAndShowBuild(string updateStream, string version)
|
|
||||||
{
|
{
|
||||||
|
isAtListing = false;
|
||||||
var req = new GetChangelogBuildRequest(updateStream, version);
|
var req = new GetChangelogBuildRequest(updateStream, version);
|
||||||
header.ShowBuild(updateStream, version);
|
if (!sentByBadges)
|
||||||
badges.SelectUpdateStream(updateStream);
|
badges.SelectUpdateStream(updateStream);
|
||||||
chart.ShowUpdateStream(updateStream);
|
chart.ShowUpdateStream(updateStream);
|
||||||
req.Success += content.ShowBuild;
|
req.Success += content.ShowBuild;
|
||||||
|
req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion);
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user