mirror of
https://github.com/ppy/osu.git
synced 2025-02-11 10:12:58 +08:00
Rewrite improvements
This commit is contained in:
parent
23309b3b00
commit
61a8b98d32
@ -43,15 +43,9 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Draw the graph with all builds
|
|
||||||
/// </summary>
|
|
||||||
public void ShowChart() => fetchAndShowChangelogChart();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the graph for a specific build
|
/// Draw the graph for a specific build
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream);
|
|
||||||
|
|
||||||
private bool isEmpty(APIChangelogChart changelogChart)
|
private bool isEmpty(APIChangelogChart changelogChart)
|
||||||
{
|
{
|
||||||
@ -81,14 +75,14 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchAndShowChangelogChart(APIChangelog build)
|
public void ShowUpdateStream(string updateStream)
|
||||||
{
|
{
|
||||||
var req = new GetChangelogChartRequest(build.UpdateStream.Name);
|
var req = new GetChangelogChartRequest(updateStream);
|
||||||
req.Success += res => showChart(res, build.UpdateStream.Name);
|
req.Success += res => showChart(res, updateStream);
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchAndShowChangelogChart()
|
public void ShowAllUpdateStreams()
|
||||||
{
|
{
|
||||||
var req = new GetChangelogChartRequest();
|
var req = new GetChangelogChartRequest();
|
||||||
req.Success += res => showChart(res);
|
req.Success += res => showChart(res);
|
||||||
|
@ -10,6 +10,7 @@ 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
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Padding = new MarginPadding{ Bottom = 100, };
|
Padding = new MarginPadding{ Bottom = 100, };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(APIChangelog[] changelog)
|
public void ShowListing(List<APIChangelog> changelog)
|
||||||
{
|
{
|
||||||
DateTime currentDate = new DateTime();
|
DateTime currentDate = new DateTime();
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
}
|
}
|
||||||
// watch out for this?
|
// watch out for this?
|
||||||
Add(changelogContentGroup = new ChangelogContentGroup(build, true));
|
Add(changelogContentGroup = new ChangelogContentGroup(build, true));
|
||||||
changelogContentGroup.BuildSelected += OnBuildSelected;
|
changelogContentGroup.BuildSelected += onBuildSelected;
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
||||||
currentDate = build.CreatedAt.Date;
|
currentDate = build.CreatedAt.Date;
|
||||||
}
|
}
|
||||||
@ -66,20 +67,21 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
Margin = new MarginPadding { Top = 30, },
|
Margin = new MarginPadding { Top = 30, },
|
||||||
});
|
});
|
||||||
Add(changelogContentGroup = new ChangelogContentGroup(build, false));
|
Add(changelogContentGroup = new ChangelogContentGroup(build, false));
|
||||||
changelogContentGroup.BuildSelected += OnBuildSelected;
|
changelogContentGroup.BuildSelected += onBuildSelected;
|
||||||
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
changelogContentGroup.GenerateText(build.ChangelogEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBuildSelected(string updateStream, string version, EventArgs args)
|
public void ShowBuild(APIChangelog changelogBuild)
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void add(APIChangelog changelogBuild)
|
|
||||||
{
|
{
|
||||||
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void onBuildSelected(string updateStream, string version, EventArgs args)
|
||||||
|
{
|
||||||
|
if (BuildSelected != null)
|
||||||
|
BuildSelected(updateStream, version, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
// 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.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
|
||||||
{
|
|
||||||
public class ChangelogStreams : Container
|
|
||||||
{
|
|
||||||
private const float container_height = 106.5f;
|
|
||||||
private const float padding_y = 20;
|
|
||||||
private const float padding_x = 85;
|
|
||||||
public Action OnSelection;
|
|
||||||
|
|
||||||
public APIChangelog SelectedRelease;
|
|
||||||
// not using SelectedRelease as a Bindable and then using .OnValueChange instead of OnSelection
|
|
||||||
// because it doesn't "refresh" the selection if the same stream is chosen
|
|
||||||
|
|
||||||
public readonly FillFlowContainer<StreamBadge> BadgesContainer;
|
|
||||||
|
|
||||||
public ChangelogStreams()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = new Color4(32, 24, 35, 255),
|
|
||||||
},
|
|
||||||
BadgesContainer = new FillFlowContainer<StreamBadge>
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Top = padding_y,
|
|
||||||
Bottom = padding_y,
|
|
||||||
Left = padding_x,
|
|
||||||
Right = padding_x,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
// ok, so this is probably not the best.
|
|
||||||
// how else can this be done?
|
|
||||||
BadgesContainer.OnUpdate = d =>
|
|
||||||
{
|
|
||||||
foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
|
||||||
{
|
|
||||||
streamBadge.OnActivation = () =>
|
|
||||||
{
|
|
||||||
SelectedRelease = streamBadge.ChangelogEntry;
|
|
||||||
foreach (StreamBadge item in BadgesContainer.Children)
|
|
||||||
if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id)
|
|
||||||
item.Deactivate();
|
|
||||||
OnSelection?.Invoke();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(InputState state)
|
|
||||||
{
|
|
||||||
foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
|
||||||
{
|
|
||||||
if (SelectedRelease != null)
|
|
||||||
{
|
|
||||||
if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id)
|
|
||||||
streamBadge.Deactivate();
|
|
||||||
else
|
|
||||||
streamBadge.EnableDim();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
streamBadge.Deactivate();
|
|
||||||
}
|
|
||||||
return base.OnHover(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
|
||||||
{
|
|
||||||
foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
|
||||||
{
|
|
||||||
if (SelectedRelease == null)
|
|
||||||
streamBadge.Activate(true);
|
|
||||||
else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id)
|
|
||||||
streamBadge.DisableDim();
|
|
||||||
}
|
|
||||||
base.OnHoverLost(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,7 @@ 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.Overlays.Changelog;
|
using osu.Game.Overlays.Changelog;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -78,6 +79,8 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
badges.Selected += onBuildSelected;
|
||||||
// content.ShowListing();
|
// content.ShowListing();
|
||||||
// if (!Streams.IsHovered)
|
// if (!Streams.IsHovered)
|
||||||
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
|
||||||
@ -117,6 +120,11 @@ namespace osu.Game.Overlays
|
|||||||
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onBuildSelected(string updateStream, string version, EventArgs e)
|
||||||
|
{
|
||||||
|
FetchAndShowBuild(updateStream, version);
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(APIAccess api)
|
||||||
{
|
{
|
||||||
@ -144,7 +152,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
var req = new GetChangelogBuildRequest(updateStream, version);
|
var req = new GetChangelogBuildRequest(updateStream, version);
|
||||||
header.ShowBuild(updateStream, version);
|
header.ShowBuild(updateStream, version);
|
||||||
badges.SelectBadge(updateStream);
|
badges.SelectUpdateStream(updateStream);
|
||||||
chart.ShowUpdateStream(updateStream);
|
chart.ShowUpdateStream(updateStream);
|
||||||
req.Success += content.ShowBuild;
|
req.Success += content.ShowBuild;
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
Loading…
Reference in New Issue
Block a user