1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 00:53:22 +08:00

Refactor1, UX1

This commit is contained in:
HoutarouOreki 2018-07-18 19:32:15 +02:00
parent 837747e35f
commit 11e0732a27
11 changed files with 205 additions and 160 deletions

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual
@ -13,7 +12,7 @@ namespace osu.Game.Tests.Visual
private ChangelogOverlay changelog;
private int releaseStreamCount;
private int index;
private void indexIncrement() => index = (index == releaseStreamCount - 1) ? 0 : index + 1;
private void indexIncrement() => index = index == releaseStreamCount - 1 ? 0 : index + 1;
protected override void LoadComplete()
{
@ -21,38 +20,37 @@ namespace osu.Game.Tests.Visual
Add(changelog = new ChangelogOverlay());
releaseStreamCount = changelog.streams.badgesContainer.Children.Count;
releaseStreamCount = changelog.Streams.BadgesContainer.Children.Count;
AddStep(@"Show", changelog.Show);
AddRepeatStep(@"Toggle Release Stream", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
changelog.Streams.BadgesContainer.Children[index].Activate();
indexIncrement();
}, releaseStreamCount);
AddStep(@"Listing", changelog.ActivateListing);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddWaitStep(3);
AddStep(@"Show with Release Stream", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
changelog.Streams.BadgesContainer.Children[index].Activate();
changelog.Show();
indexIncrement();
});
AddWaitStep(4);
AddWaitStep(3);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddWaitStep(3);
AddStep(@"Show with listing", () =>
{
// .maybe changelog should have a function that does header.ActivateListing()
changelog.ActivateListing();
changelog.Show();
});
AddWaitStep(4);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddWaitStep(3);
AddStep(@"Activate release", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
changelog.Streams.BadgesContainer.Children[index].Activate();
indexIncrement();
});
AddStep(@"Show with listing", () =>
@ -61,9 +59,5 @@ namespace osu.Game.Tests.Visual
changelog.Show();
});
}
public TestCaseChangelog()
{
}
}
}

View File

@ -7,11 +7,11 @@ namespace osu.Game.Graphics
{
public class StreamColour
{
public readonly Color4 Stable = new Color4(102, 204, 255, 255);
public readonly Color4 StableFallback = new Color4(34, 153, 187, 255);
public readonly Color4 Beta = new Color4(255, 221, 85, 255);
public readonly Color4 CuttingEdge = new Color4(238, 170, 0, 255);
public readonly Color4 Lazer = new Color4(237, 18, 33, 255);
public readonly Color4 Web = new Color4(136, 102, 238, 255);
public static readonly Color4 STABLE = new Color4(102, 204, 255, 255);
public static readonly Color4 STABLEFALLBACK = new Color4(34, 153, 187, 255);
public static readonly Color4 BETA = new Color4(255, 221, 85, 255);
public static readonly Color4 CUTTINGEDGE = new Color4(238, 170, 0, 255);
public static readonly Color4 LAZER = new Color4(237, 18, 33, 255);
public static readonly Color4 WEB = new Color4(136, 102, 238, 255);
}
}

View File

@ -18,15 +18,12 @@ namespace osu.Game.Overlays.Changelog
{
public class ChangelogHeader : Container
{
protected Color4 purple = new Color4(191, 4, 255, 255);
protected Color4 Purple = new Color4(191, 4, 255, 255);
private readonly Sprite coverImage;
private readonly Sprite headerBadge; //50x50, margin-right: 20
private readonly FillFlowContainer headerTextContainer;
private readonly OsuSpriteText title, titleStream;
private readonly SpriteIcon chevron;
private readonly OsuSpriteText titleStream;
private readonly TextBadgePairListing listing;
private readonly TextBadgePairRelease releaseStream;
private readonly FillFlowContainer breadcrumbContainer;
public Action OnListingActivated;
@ -38,6 +35,7 @@ namespace osu.Game.Overlays.Changelog
public ChangelogHeader()
{
SpriteIcon chevron; // AppVeyor told me this should be a local variable..?
RelativeSizeAxes = Axes.X;
Height = cover_height;
Children = new Drawable[]
@ -45,7 +43,7 @@ namespace osu.Game.Overlays.Changelog
coverImage = new Sprite
{
RelativeSizeAxes = Axes.Both,
Size = new OpenTK.Vector2(1),
Size = new Vector2(1),
FillMode = FillMode.Fill,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -62,16 +60,16 @@ namespace osu.Game.Overlays.Changelog
{
X = icon_margin,
Masking = true,
BorderColour = purple,
BorderColour = Purple,
BorderThickness = 3,
MaskingSmoothness = 1,
Size = new OpenTK.Vector2(50),
Size = new Vector2(50),
Children = new Drawable[]
{
headerBadge = new Sprite
{
RelativeSizeAxes = Axes.Both,
Size = new OpenTK.Vector2(0.8f),
Size = new Vector2(0.8f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
@ -82,14 +80,14 @@ namespace osu.Game.Overlays.Changelog
new Box
{
RelativeSizeAxes = Axes.Both,
Size = new OpenTK.Vector2(1),
Size = new Vector2(1),
Alpha = 0,
AlwaysPresent = true,
Colour = purple,
Colour = Purple,
}
}
},
headerTextContainer = new FillFlowContainer
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
@ -98,7 +96,7 @@ namespace osu.Game.Overlays.Changelog
X = icon_size + icon_margin * 2,
Children = new Drawable[]
{
title = new OsuSpriteText
new OsuSpriteText
{
Text = "Changelog ",
Font = @"Exo2.0-Light",
@ -109,13 +107,13 @@ namespace osu.Game.Overlays.Changelog
Text = "Listing",
TextSize = 38, // web: 30
Font = @"Exo2.0-Light",
Colour = purple,
Colour = Purple,
},
}
}
}
},
breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1
new FillFlowContainer // Listing > Lazer 2018.713.1
{
X = 2 * icon_margin + icon_size - 8,
Height = version_height,
@ -124,12 +122,12 @@ namespace osu.Game.Overlays.Changelog
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
listing = new TextBadgePairListing(purple),
new Container() // without a container, moving the chevron wont work
listing = new TextBadgePairListing(Purple),
new Container // without a container, moving the chevron wont work
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding()
Margin = new MarginPadding
{
Top = 10,
Left = 7,
@ -145,19 +143,19 @@ namespace osu.Game.Overlays.Changelog
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(7),
Colour = purple,
Colour = Purple,
Icon = FontAwesome.fa_chevron_right,
Alpha = 0,
X = -200,
},
},
},
releaseStream = new TextBadgePairRelease(purple, "Lazer")
releaseStream = new TextBadgePairRelease(Purple, "Lazer")
},
},
new Box // purple line
{
Colour = purple,
Colour = Purple,
RelativeSizeAxes = Axes.X,
Height = 3,
Anchor = Anchor.BottomLeft,
@ -177,7 +175,7 @@ namespace osu.Game.Overlays.Changelog
{
releaseStream.Deactivate();
chevron.MoveToX(-20, 100).FadeOut(100);
ChangeHeaderText("Listing");
changeHeaderText("Listing");
OnListingActivated?.Invoke();
};
};
@ -186,10 +184,10 @@ namespace osu.Game.Overlays.Changelog
public void ShowReleaseStream(string headerText, string breadcrumbText)
{
releaseStream.Activate(breadcrumbText);
ChangeHeaderText(headerText);
changeHeaderText(headerText);
}
private void ChangeHeaderText(string headerText)
private void changeHeaderText(string headerText)
{
titleStream.Text = headerText;
titleStream.FlashColour(Color4.White, 500, Easing.OutQuad);
@ -197,6 +195,8 @@ namespace osu.Game.Overlays.Changelog
public void ActivateListing() => listing.Activate();
public bool IsListingActivated() => listing.IsActivated;
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{

View File

@ -3,32 +3,28 @@
using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Overlays.Changelog.Streams;
using System;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogStreams : Container
{
private const float containerHeight = 106.5f;
private const float containerTopBottomMargin = 20;
private const float containerSideMargin = 85;
private const float container_height = 106.5f;
private const float container_margin_y = 20;
private const float container_margin_x = 85;
public Bindable<ReleaseStreamInfo> SelectedRelease = new Bindable<ReleaseStreamInfo>();
private readonly StreamColour streamColour;
public readonly FillFlowContainer<StreamBadge> badgesContainer;
public readonly FillFlowContainer<StreamBadge> BadgesContainer;
public ChangelogStreams()
{
streamColour = new StreamColour();
Height = containerHeight;
Height = container_height;
RelativeSizeAxes = Axes.X;
Children = new Drawable[]
{
@ -38,39 +34,39 @@ namespace osu.Game.Overlays.Changelog
Size = new OpenTK.Vector2(1),
Colour = new Color4(32, 24, 35, 255),
},
badgesContainer = new FillFlowContainer<StreamBadge>
BadgesContainer = new FillFlowContainer<StreamBadge>
{
Direction = FillDirection.Horizontal,
RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding()
Margin = new MarginPadding
{
Top = containerTopBottomMargin,
Bottom = containerTopBottomMargin,
Left = containerSideMargin,
Right = containerSideMargin,
Top = container_margin_y,
Bottom = container_margin_y,
Left = container_margin_x,
Right = container_margin_x,
},
Children = new[]
{
new StreamBadge(streamColour.Stable, "Stable", "20180626.1", 16370, true),
new StreamBadge(streamColour.Beta, "Beta", "20180626", 186),
new StreamBadge(streamColour.Lazer, "Lazer", "2018.713.1"),
new StreamBadge(StreamColour.STABLE, "Stable", "20180626.1", 16370, true),
new StreamBadge(StreamColour.BETA, "Beta", "20180626", 186),
new StreamBadge(StreamColour.LAZER, "Lazer", "2018.713.1"),
},
},
};
badgesContainer.OnLoadComplete = d =>
BadgesContainer.OnLoadComplete = d =>
{
foreach (StreamBadge streamBadge in badgesContainer.Children)
foreach (StreamBadge streamBadge in BadgesContainer.Children)
{
streamBadge.OnActivation = () =>
{
SelectedRelease.Value = new ReleaseStreamInfo()
SelectedRelease.Value = new ReleaseStreamInfo
{
DisplayVersion = streamBadge.DisplayVersion,
IsFeatured = streamBadge.IsFeatured,
Name = streamBadge.Name,
Users = streamBadge.Users,
};
foreach (StreamBadge item in badgesContainer.Children)
foreach (StreamBadge item in BadgesContainer.Children)
{
if (item.Name != streamBadge.Name) item.Deactivate();
}
@ -82,7 +78,7 @@ namespace osu.Game.Overlays.Changelog
protected override bool OnHover(InputState state)
{
// is this nullreference-safe for badgesContainer?
foreach (StreamBadge streamBadge in badgesContainer.Children)
foreach (StreamBadge streamBadge in BadgesContainer.Children)
{
if (SelectedRelease.Value != null)
{
@ -100,7 +96,7 @@ namespace osu.Game.Overlays.Changelog
{
if (SelectedRelease.Value == null)
{
foreach (StreamBadge streamBadge in badgesContainer.Children) streamBadge.Activate(true);
foreach (StreamBadge streamBadge in BadgesContainer.Children) streamBadge.Activate(true);
}
base.OnHoverLost(state);
}

View File

@ -8,18 +8,20 @@ namespace osu.Game.Overlays.Changelog.Header
{
public class LineBadge : Circle
{
public float TransitionDuration = 100;
public float TransitionDuration = 400;
public float UncollapsedHeight;
public float CollapsedHeight;
protected bool isCollapsed;
private bool isCollapsed;
public bool IsCollapsed
{
get { return isCollapsed; }
set
{
isCollapsed = value;
this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight, TransitionDuration);
this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight,
value ? TransitionDuration / 2f : TransitionDuration,
value ? Easing.Out : Easing.OutElastic);
}
}
@ -32,7 +34,7 @@ namespace osu.Game.Overlays.Changelog.Header
Height = startCollapsed ? CollapsedHeight : UncollapsedHeight;
// this margin prevents jumps when changing text's font weight
Margin = new MarginPadding()
Margin = new MarginPadding
{
Left = 10,
Right = 10,

View File

@ -1,45 +1,51 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using System;
namespace osu.Game.Overlays.Changelog.Header
{
public class TextBadgePair : ClickableContainer
public class TextBadgePair : Container
{
protected SpriteText text;
protected LineBadge lineBadge;
protected bool startCollapsed;
protected SpriteText Text;
protected LineBadge LineBadge;
public bool IsActivated { get; protected set; }
public Action OnActivation;
public Action OnDeactivation;
private SampleChannel sampleHover;
protected SampleChannel SampleActivate;
public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None)
{
text.FadeColour(newColour, duration, easing);
Text.FadeColour(newColour, duration, easing);
}
public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None)
{
lineBadge.FadeColour(newColour, duration, easing);
LineBadge.FadeColour(newColour, duration, easing);
}
public void HideText(double duration = 0, Easing easing = Easing.InOutCubic)
{
lineBadge.IsCollapsed = true;
text.MoveToY(20, duration, easing)
LineBadge.IsCollapsed = true;
Text.MoveToY(20, duration, easing)
.FadeOut(duration, easing);
}
public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{
lineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
text.MoveToY(0, duration, easing)
LineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText;
Text.MoveToY(0, duration, easing)
.FadeIn(duration, easing);
}
@ -48,8 +54,8 @@ namespace osu.Game.Overlays.Changelog.Header
/// Full change takes double this time.</param>
public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{
lineBadge.IsCollapsed = true;
text.MoveToY(20, duration, easing)
LineBadge.IsCollapsed = true;
Text.MoveToY(20, duration, easing)
.FadeOut(duration, easing)
.Then()
.MoveToY(0, duration, easing)
@ -60,30 +66,30 @@ namespace osu.Game.Overlays.Changelog.Header
// didn't apply to transforms that come after the .finally), I'm using a scheduler here
Scheduler.AddDelayed(() =>
{
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
lineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText;
LineBadge.IsCollapsed = false;
}, duration);
}
public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startBadgeCollapsed = true)
public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new SpriteText
Text = new SpriteText
{
TextSize = 21, // web is 16, but here it looks too small?
Text = displayText,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Margin = new MarginPadding()
Margin = new MarginPadding
{
Top = 5,
Bottom = 15,
}
},
lineBadge = new LineBadge(startCollapsed)
LineBadge = new LineBadge(startCollapsed)
{
Width = 1,
Colour = badgeColour,
@ -94,14 +100,30 @@ namespace osu.Game.Overlays.Changelog.Header
public virtual void Deactivate()
{
lineBadge.IsCollapsed = true;
text.Font = "Exo2.0-Regular";
IsActivated = false;
LineBadge.IsCollapsed = true;
Text.Font = "Exo2.0-Regular";
}
public virtual void Activate()
{
lineBadge.IsCollapsed = false;
text.Font = "Exo2.0-Bold";
IsActivated = true;
LineBadge.IsCollapsed = false;
Text.Font = "Exo2.0-Bold";
SampleActivate?.Play();
}
protected override bool OnHover(InputState state)
{
if (!IsActivated) sampleHover?.Play();
return base.OnHover(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get(@"UI/generic-hover-soft");
SampleActivate = audio.Sample.Get(@"UI/generic-select-soft");
}
}
}

View File

@ -10,37 +10,41 @@ namespace osu.Game.Overlays.Changelog.Header
{
public class TextBadgePairListing : TextBadgePair
{
private ColourInfo badgeColour;
private readonly ColourInfo badgeColour;
public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing", false)
{
IsActivated = true;
this.badgeColour = badgeColour;
text.Font = "Exo2.0-Bold";
text.Anchor = Anchor.TopCentre;
text.Origin = Anchor.TopCentre;
Text.Font = "Exo2.0-Bold";
Text.Anchor = Anchor.TopCentre;
Text.Origin = Anchor.TopCentre;
// I'm using this for constant badge width here, so that the whole
// thing doesn't jump left/right when listing's size changes
// due to different font weight (and thus width)
lineBadge.RelativeSizeAxes = Axes.None;
LineBadge.RelativeSizeAxes = Axes.None;
// this doesn't work without the scheduler
// (because the text isn't yet fully drawn when it's loaded?)
text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth);
Text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth);
}
public override void Activate()
{
lineBadge.IsCollapsed = false;
text.Font = "Exo2.0-Bold";
IsActivated = true;
LineBadge.IsCollapsed = false;
Text.Font = "Exo2.0-Bold";
SetTextColour(Color4.White, 100);
SampleActivate?.Play();
OnActivation?.Invoke();
}
public override void Deactivate()
{
lineBadge.IsCollapsed = true;
text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping
IsActivated = false;
LineBadge.IsCollapsed = true;
Text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping
SetTextColour(badgeColour, 100);
OnDeactivation?.Invoke();
}
@ -53,16 +57,16 @@ namespace osu.Game.Overlays.Changelog.Header
protected override bool OnHover(InputState state)
{
lineBadge.ResizeHeightTo(lineBadge.UncollapsedHeight, lineBadge.TransitionDuration);
LineBadge.ResizeHeightTo(LineBadge.UncollapsedHeight, LineBadge.TransitionDuration, Easing.OutElastic);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration);
if (IsActivated == false) LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out);
base.OnHoverLost(state);
}
public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth);
public void UpdateBadgeWidth() => LineBadge.ResizeWidthTo(Text.DrawWidth);
}
}

View File

@ -12,29 +12,34 @@ namespace osu.Game.Overlays.Changelog.Header
public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText)
{
text.Font = "Exo2.0-Bold";
text.Y = 20;
text.Alpha = 0;
Text.Font = "Exo2.0-Bold";
Text.Y = 20;
Text.Alpha = 0;
}
public void SetText(string displayText)
{
text.Text = displayText;
Text.Text = displayText;
}
public void Activate(string displayText = null)
{
//ClearTransforms();
// not using if (!lineBadge.IsCollapsed) because the text sometimes gets reset
// when quickly switching release streams
if (text.IsPresent) ChangeText(transition_duration, displayText);
else ShowText(transition_duration, displayText);
if (IsActivated)
{
if (displayText != Text.Text) ChangeText(transition_duration, displayText);
}
else
{
ShowText(transition_duration, displayText);
IsActivated = true;
}
SampleActivate?.Play();
OnActivation?.Invoke();
}
public override void Deactivate()
{
//FinishTransforms(true);
IsActivated = false;
HideText(transition_duration);
OnDeactivation?.Invoke();
}

View File

@ -2,13 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Database;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.Changelog
{

View File

@ -1,12 +1,13 @@
// 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;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using System;
@ -15,21 +16,20 @@ namespace osu.Game.Overlays.Changelog.Streams
{
public class StreamBadge : ClickableContainer
{
private const float badgeHeight = 56.5f;
private const float badgeWidth = 100;
private const float badgeTopBottomMargin = 5;
private const float badge_height = 56.5f;
private const float badge_width = 100;
private const float transition_duration = 100;
public Action OnActivation;
private bool isActive;
private bool isActivated;
private Header.LineBadge lineBadge;
public string Name { get; private set; }
public string DisplayVersion { get; private set; }
public bool IsFeatured { get; private set; }
public float Users { get; private set; }
private readonly Header.LineBadge lineBadge;
private SampleChannel sampleHover;
public readonly string Name;
public readonly string DisplayVersion;
public readonly bool IsFeatured;
public readonly float Users;
public StreamBadge(ColourInfo colour, string streamName, string streamBuild, float onlineUsers = 0, bool isFeatured = false)
{
@ -37,10 +37,10 @@ namespace osu.Game.Overlays.Changelog.Streams
DisplayVersion = streamBuild;
IsFeatured = isFeatured;
Users = onlineUsers;
Height = badgeHeight;
Width = isFeatured ? badgeWidth * 2 : badgeWidth;
Height = badge_height;
Width = isFeatured ? badge_width * 2 : badge_width;
Margin = new MarginPadding(5);
isActive = true;
isActivated = true;
Children = new Drawable[]
{
new FillFlowContainer<SpriteText>
@ -84,13 +84,14 @@ namespace osu.Game.Overlays.Changelog.Streams
Width = 1,
Colour = colour,
RelativeSizeAxes = Axes.X,
TransitionDuration = 600,
},
};
}
public void Activate(bool withoutHeaderUpdate = false)
{
isActive = true;
isActivated = true;
this.FadeIn(transition_duration);
lineBadge.IsCollapsed = false;
if (!withoutHeaderUpdate) OnActivation?.Invoke();
@ -98,9 +99,12 @@ namespace osu.Game.Overlays.Changelog.Streams
public void Deactivate()
{
isActive = false;
this.FadeTo(0.5f, transition_duration);
lineBadge.IsCollapsed = true;
isActivated = false;
if (!IsHovered)
{
this.FadeTo(0.5f, transition_duration);
lineBadge.IsCollapsed = true;
}
}
protected override bool OnClick(InputState state)
@ -111,6 +115,7 @@ namespace osu.Game.Overlays.Changelog.Streams
protected override bool OnHover(InputState state)
{
if (!isActivated) sampleHover?.Play();
this.FadeIn(transition_duration);
lineBadge.IsCollapsed = false;
return base.OnHover(state);
@ -118,12 +123,18 @@ namespace osu.Game.Overlays.Changelog.Streams
protected override void OnHoverLost(InputState state)
{
if (!isActive)
if (!isActivated)
{
this.FadeTo(0.5f, transition_duration);
lineBadge.IsCollapsed = true;
}
base.OnHoverLost(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get(@"UI/generic-hover-soft");
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.Changelog;
using osu.Game.Overlays.Changelog.Streams;
@ -16,12 +17,10 @@ namespace osu.Game.Overlays
{
public class ChangelogOverlay : WaveOverlayContainer
{
private readonly ScrollContainer scroll;
private readonly ChangelogHeader header;
public readonly ChangelogStreams Streams;
private ChangelogHeader header;
public readonly ChangelogStreams streams;
protected Color4 purple = new Color4(191, 4, 255, 255);
protected readonly Color4 Purple = new Color4(191, 4, 255, 255);
public ChangelogOverlay()
{
@ -52,7 +51,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = new Color4(20, 18, 23, 255)
},
scroll = new ScrollContainer
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
@ -64,25 +63,25 @@ namespace osu.Game.Overlays
Children = new Drawable[]
{
header = new ChangelogHeader(),
streams = new ChangelogStreams(),
Streams = new ChangelogStreams(),
},
},
},
};
streams.SelectedRelease.ValueChanged += r =>
Streams.SelectedRelease.ValueChanged += r =>
{
if (streams.SelectedRelease.Value != null)
if (Streams.SelectedRelease.Value != null)
header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion));
};
streams.badgesContainer.OnLoadComplete += d =>
Streams.BadgesContainer.OnLoadComplete += d =>
{
header.OnListingActivated += () =>
{
streams.SelectedRelease.Value = null;
foreach (StreamBadge item in streams.badgesContainer.Children)
{
item.Activate(true);
}
Streams.SelectedRelease.Value = null;
if (!Streams.IsHovered)
foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true);
else
foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate();
};
};
}
@ -92,6 +91,24 @@ namespace osu.Game.Overlays
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
public override bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
if (header.IsListingActivated()) State = Visibility.Hidden;
// the problem here is that when hovering over the builds' container
// and pressing back, they don't lower their opacity they're rehovered on
else header.ActivateListing();
return true;
case GlobalAction.Select:
return true;
}
return false;
}
protected override void PopIn()
{
base.PopIn();