mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 01:22:55 +08:00
Streams2
This commit is contained in:
parent
523d47e815
commit
6baa761b9c
@ -1,7 +1,6 @@
|
|||||||
// Copyright(c) 2007-2018 ppy Pty Ltd<contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// 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 NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
|
@ -1,62 +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 NUnit.Framework;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Overlays.Changelog.Header;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestCaseTextBadgePair : OsuTestCase
|
|
||||||
{
|
|
||||||
private readonly Container container;
|
|
||||||
private readonly Box bottomLine;
|
|
||||||
private readonly TextBadgePair textBadgePair;
|
|
||||||
|
|
||||||
public TestCaseTextBadgePair()
|
|
||||||
{
|
|
||||||
|
|
||||||
Add(container = new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Size = new OpenTK.Vector2(300, 40),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
Colour = Color4.Gray,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
bottomLine = new Box // purple line
|
|
||||||
{
|
|
||||||
Colour = Color4.Purple,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 3,
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
},
|
|
||||||
textBadgePair = new TextBadgePair(Color4.White, "testing")
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep(@"deactivate", () => textBadgePair.Deactivate());
|
|
||||||
AddStep(@"activate", () => textBadgePair.Activate());
|
|
||||||
AddStep(@"purple text", () => textBadgePair.SetTextColour(Color4.Purple, 100));
|
|
||||||
AddStep(@"white text", () => textBadgePair.SetTextColour(Color4.White, 100));
|
|
||||||
AddStep(@"purple badge", () => textBadgePair.SetBadgeColour(Color4.Purple, 100));
|
|
||||||
AddStep(@"white badge", () => textBadgePair.SetBadgeColour(Color4.White, 100));
|
|
||||||
AddStep(@"hide text", () => textBadgePair.HideText(250));
|
|
||||||
AddStep(@"show text", () => textBadgePair.ShowText(250));
|
|
||||||
AddStep(@"change text", () => textBadgePair.ChangeText(250));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
|||||||
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.Framework.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Changelog.Streams;
|
using osu.Game.Overlays.Changelog.Streams;
|
||||||
using System;
|
using System;
|
||||||
@ -23,7 +24,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private readonly StreamColour streamColour;
|
private readonly StreamColour streamColour;
|
||||||
public readonly FillFlowContainer<StreamBadge> badgesContainer;
|
public readonly FillFlowContainer<StreamBadge> badgesContainer;
|
||||||
|
|
||||||
public ChangelogStreams()
|
public ChangelogStreams()
|
||||||
{
|
{
|
||||||
streamColour = new StreamColour();
|
streamColour = new StreamColour();
|
||||||
@ -77,5 +78,31 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
// is this nullreference-safe for badgesContainer?
|
||||||
|
foreach (StreamBadge streamBadge in badgesContainer.Children)
|
||||||
|
{
|
||||||
|
if (SelectedRelease.Value != null)
|
||||||
|
{
|
||||||
|
if (SelectedRelease.Value.Name != streamBadge.Name)
|
||||||
|
{
|
||||||
|
streamBadge.Deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else streamBadge.Deactivate();
|
||||||
|
}
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
if (SelectedRelease.Value == null)
|
||||||
|
{
|
||||||
|
foreach (StreamBadge streamBadge in badgesContainer.Children) streamBadge.Activate(true);
|
||||||
|
}
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using System;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog.Header
|
namespace osu.Game.Overlays.Changelog.Header
|
||||||
{
|
{
|
||||||
|
|
||||||
public class TextBadgePair : ClickableContainer
|
public class TextBadgePair : ClickableContainer
|
||||||
{
|
{
|
||||||
protected SpriteText text;
|
protected SpriteText text;
|
||||||
@ -18,7 +17,7 @@ namespace osu.Game.Overlays.Changelog.Header
|
|||||||
|
|
||||||
public Action OnActivation;
|
public Action OnActivation;
|
||||||
public Action OnDeactivation;
|
public Action OnDeactivation;
|
||||||
|
|
||||||
public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None)
|
public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None)
|
||||||
{
|
{
|
||||||
text.FadeColour(newColour, duration, easing);
|
text.FadeColour(newColour, duration, easing);
|
||||||
|
@ -13,7 +13,7 @@ using System;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog.Streams
|
namespace osu.Game.Overlays.Changelog.Streams
|
||||||
{
|
{
|
||||||
public class StreamBadge : Container
|
public class StreamBadge : ClickableContainer
|
||||||
{
|
{
|
||||||
private const float badgeHeight = 56.5f;
|
private const float badgeHeight = 56.5f;
|
||||||
private const float badgeWidth = 100;
|
private const float badgeWidth = 100;
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Changelog.Streams
|
|||||||
TextSize = 16,
|
TextSize = 16,
|
||||||
Margin = new MarginPadding
|
Margin = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = 5,
|
Top = 7,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new SpriteText
|
new SpriteText
|
||||||
@ -80,6 +80,7 @@ namespace osu.Game.Overlays.Changelog.Streams
|
|||||||
lineBadge = new Header.LineBadge(false, 2, 4)
|
lineBadge = new Header.LineBadge(false, 2, 4)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
Width = 1,
|
Width = 1,
|
||||||
Colour = colour,
|
Colour = colour,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
@ -71,13 +71,14 @@ namespace osu.Game.Overlays
|
|||||||
};
|
};
|
||||||
streams.SelectedRelease.ValueChanged += r =>
|
streams.SelectedRelease.ValueChanged += r =>
|
||||||
{
|
{
|
||||||
if (streams.SelectedRelease != null)
|
if (streams.SelectedRelease.Value != null)
|
||||||
header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion));
|
header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion));
|
||||||
};
|
};
|
||||||
streams.badgesContainer.OnLoadComplete += d =>
|
streams.badgesContainer.OnLoadComplete += d =>
|
||||||
{
|
{
|
||||||
header.OnListingActivated += () =>
|
header.OnListingActivated += () =>
|
||||||
{
|
{
|
||||||
|
streams.SelectedRelease.Value = null;
|
||||||
foreach (StreamBadge item in streams.badgesContainer.Children)
|
foreach (StreamBadge item in streams.badgesContainer.Children)
|
||||||
{
|
{
|
||||||
item.Activate(true);
|
item.Activate(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user