Refactor the rewrite

This commit is contained in:
HoutarouOreki 2018-07-22 22:31:24 +02:00
parent 51eec0dca4
commit 391da47881
5 changed files with 12 additions and 16 deletions

View File

@ -109,8 +109,7 @@ namespace osu.Game.Overlays.Changelog
protected virtual void OnSelected(StreamBadge source) protected virtual void OnSelected(StreamBadge source)
{ {
if (Selected != null) Selected?.Invoke(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)
@ -135,7 +134,7 @@ namespace osu.Game.Overlays.Changelog
foreach (StreamBadge streamBadge in badgesContainer.Children) foreach (StreamBadge streamBadge in badgesContainer.Children)
{ {
if (selectedStreamId < 0) if (selectedStreamId < 0)
streamBadge.Activate(true); streamBadge.Activate();
else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId) else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId)
streamBadge.DisableDim(); streamBadge.DisableDim();
} }

View File

@ -2,12 +2,10 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
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.Framework.Graphics.Shapes;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using System; using System;
@ -52,7 +50,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,7 +64,7 @@ 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);
} }
} }
@ -77,10 +75,9 @@ namespace osu.Game.Overlays.Changelog
Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild);
} }
protected virtual void onBuildSelected(string updateStream, string version, EventArgs args) protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args)
{ {
if (BuildSelected != null) BuildSelected?.Invoke(updateStream, version, EventArgs.Empty);
BuildSelected(updateStream, version, EventArgs.Empty);
} }
} }
} }

View File

@ -190,8 +190,7 @@ namespace osu.Game.Overlays.Changelog
protected virtual void OnBuildSelected(string updateStream, string version) protected virtual void OnBuildSelected(string updateStream, string version)
{ {
if (BuildSelected != null) BuildSelected?.Invoke(updateStream, version, EventArgs.Empty);
BuildSelected(updateStream, version, EventArgs.Empty);
} }
public void GenerateText(List<ChangelogEntry> changelogEntries) public void GenerateText(List<ChangelogEntry> changelogEntries)

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Changelog.Header; using osu.Game.Overlays.Changelog.Header;
using System; using System;
@ -24,6 +23,7 @@ namespace osu.Game.Overlays.Changelog
private readonly Sprite headerBadge; private readonly Sprite headerBadge;
private readonly OsuSpriteText titleStream; private readonly OsuSpriteText titleStream;
private readonly TextBadgePairListing listing; private readonly TextBadgePairListing listing;
private readonly SpriteIcon chevron;
private readonly TextBadgePairRelease releaseStream; private readonly TextBadgePairRelease releaseStream;
public Action ListingActivated; public Action ListingActivated;
@ -36,7 +36,6 @@ namespace osu.Game.Overlays.Changelog
public ChangelogHeader() public ChangelogHeader()
{ {
SpriteIcon chevron; // AppVeyor told me this should be a local variable..?
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = cover_height; Height = cover_height;
Children = new Drawable[] Children = new Drawable[]
@ -166,12 +165,14 @@ namespace osu.Game.Overlays.Changelog
releaseStream.Activate($"{displayName} {displayVersion}"); releaseStream.Activate($"{displayName} {displayVersion}");
titleStream.Text = displayName; titleStream.Text = displayName;
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
chevron.MoveToX(0, 100).FadeIn(100);
} }
public void ShowListing() public void ShowListing()
{ {
releaseStream.Deactivate(); releaseStream.Deactivate();
listing.Activate(); listing.Activate();
chevron.MoveToX(-20, 100).FadeOut(100);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -90,8 +90,8 @@ namespace osu.Game.Overlays.Changelog
isActivated = true; isActivated = true;
this.FadeIn(transition_duration); this.FadeIn(transition_duration);
lineBadge.IsCollapsed = false; lineBadge.IsCollapsed = false;
if (!withoutFiringUpdates && Selected != null) if (!withoutFiringUpdates)
Selected(this, EventArgs.Empty); Selected?.Invoke(this, EventArgs.Empty);
} }
public void Deactivate() public void Deactivate()