1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 16:12:57 +08:00

Rewrite improvements

This commit is contained in:
HoutarouOreki 2018-07-22 20:27:50 +02:00
parent 23309b3b00
commit 61a8b98d32
4 changed files with 24 additions and 118 deletions

View File

@ -43,15 +43,9 @@ namespace osu.Game.Overlays.Changelog
};
}
/// <summary>
/// Draw the graph with all builds
/// </summary>
public void ShowChart() => fetchAndShowChangelogChart();
/// <summary>
/// Draw the graph for a specific build
/// </summary>
public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream);
private bool isEmpty(APIChangelogChart changelogChart)
{
@ -81,14 +75,14 @@ namespace osu.Game.Overlays.Changelog
this.api = api;
}
private void fetchAndShowChangelogChart(APIChangelog build)
public void ShowUpdateStream(string updateStream)
{
var req = new GetChangelogChartRequest(build.UpdateStream.Name);
req.Success += res => showChart(res, build.UpdateStream.Name);
var req = new GetChangelogChartRequest(updateStream);
req.Success += res => showChart(res, updateStream);
api.Queue(req);
}
private void fetchAndShowChangelogChart()
public void ShowAllUpdateStreams()
{
var req = new GetChangelogChartRequest();
req.Success += res => showChart(res);

View File

@ -10,6 +10,7 @@ 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
{
@ -30,7 +31,7 @@ namespace osu.Game.Overlays.Changelog
Padding = new MarginPadding{ Bottom = 100, };
}
private void add(APIChangelog[] changelog)
public void ShowListing(List<APIChangelog> changelog)
{
DateTime currentDate = new DateTime();
@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Changelog
}
// watch out for this?
Add(changelogContentGroup = new ChangelogContentGroup(build, true));
changelogContentGroup.BuildSelected += OnBuildSelected;
changelogContentGroup.BuildSelected += onBuildSelected;
changelogContentGroup.GenerateText(build.ChangelogEntries);
currentDate = build.CreatedAt.Date;
}
@ -66,20 +67,21 @@ namespace osu.Game.Overlays.Changelog
Margin = new MarginPadding { Top = 30, },
});
Add(changelogContentGroup = new ChangelogContentGroup(build, false));
changelogContentGroup.BuildSelected += OnBuildSelected;
changelogContentGroup.BuildSelected += onBuildSelected;
changelogContentGroup.GenerateText(build.ChangelogEntries);
}
}
}
private void OnBuildSelected(string updateStream, string version, EventArgs args)
{
throw new NotImplementedException();
}
private void add(APIChangelog changelogBuild)
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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -14,6 +14,7 @@ using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Changelog;
using System;
namespace osu.Game.Overlays
{
@ -78,6 +79,8 @@ namespace osu.Game.Overlays
},
},
};
badges.Selected += onBuildSelected;
// content.ShowListing();
// if (!Streams.IsHovered)
// foreach (StreamBadge item in Streams.BadgesContainer.Children)
@ -117,6 +120,11 @@ namespace osu.Game.Overlays
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
}
private void onBuildSelected(string updateStream, string version, EventArgs e)
{
FetchAndShowBuild(updateStream, version);
}
[BackgroundDependencyLoader]
private void load(APIAccess api)
{
@ -144,7 +152,7 @@ namespace osu.Game.Overlays
{
var req = new GetChangelogBuildRequest(updateStream, version);
header.ShowBuild(updateStream, version);
badges.SelectBadge(updateStream);
badges.SelectUpdateStream(updateStream);
chart.ShowUpdateStream(updateStream);
req.Success += content.ShowBuild;
api.Queue(req);