mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Merge https://github.com/ppy/osu into channel-selection
This commit is contained in:
commit
b9292b6240
@ -23,6 +23,13 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
public class Triangles : Drawable
|
public class Triangles : Drawable
|
||||||
{
|
{
|
||||||
private const float triangle_size = 100;
|
private const float triangle_size = 100;
|
||||||
|
private const float base_velocity = 50;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How many screen-space pixels are smoothed over.
|
||||||
|
/// Same behavior as Sprite's EdgeSmoothness.
|
||||||
|
/// </summary>
|
||||||
|
private const float edge_smoothness = 1;
|
||||||
|
|
||||||
public override bool HandleInput => false;
|
public override bool HandleInput => false;
|
||||||
|
|
||||||
@ -103,31 +110,34 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
Invalidate(Invalidation.DrawNode, shallPropagate: false);
|
Invalidate(Invalidation.DrawNode, shallPropagate: false);
|
||||||
|
|
||||||
for (int i = 0; i < parts.Count; i++)
|
if (CreateNewTriangles)
|
||||||
{
|
addTriangles(false);
|
||||||
TriangleParticle newParticle = parts[i];
|
|
||||||
|
|
||||||
float adjustedAlpha = HideAlphaDiscrepancies ?
|
float adjustedAlpha = HideAlphaDiscrepancies ?
|
||||||
// Cubically scale alpha to make it drop off more sharply.
|
// Cubically scale alpha to make it drop off more sharply.
|
||||||
(float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) :
|
(float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) :
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
float elapsedSeconds = (float)Time.Elapsed / 1000;
|
||||||
|
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
|
||||||
|
// Since we will later multiply by the scale of individual triangles we normalize by
|
||||||
|
// dividing by triangleScale.
|
||||||
|
float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * triangleScale);
|
||||||
|
|
||||||
newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950);
|
for (int i = 0; i < parts.Count; i++)
|
||||||
|
{
|
||||||
|
TriangleParticle newParticle = parts[i];
|
||||||
|
|
||||||
|
// Scale moved distance by the size of the triangle. Smaller triangles should move more slowly.
|
||||||
|
newParticle.Position.Y += parts[i].Scale * movedDistance;
|
||||||
newParticle.Colour.A = adjustedAlpha;
|
newParticle.Colour.A = adjustedAlpha;
|
||||||
|
|
||||||
parts[i] = newParticle;
|
parts[i] = newParticle;
|
||||||
|
|
||||||
if (!CreateNewTriangles)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight;
|
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight;
|
||||||
|
|
||||||
if (bottomPos < 0)
|
if (bottomPos < 0)
|
||||||
parts.RemoveAt(i);
|
parts.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
addTriangles(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTriangles(bool randomY)
|
private void addTriangles(bool randomY)
|
||||||
@ -211,20 +221,28 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
Shader.Bind();
|
Shader.Bind();
|
||||||
Texture.TextureGL.Bind();
|
Texture.TextureGL.Bind();
|
||||||
|
|
||||||
|
Vector2 localInflationAmount = edge_smoothness * DrawInfo.MatrixInverse.ExtractScale().Xy;
|
||||||
|
|
||||||
foreach (TriangleParticle particle in Parts)
|
foreach (TriangleParticle particle in Parts)
|
||||||
{
|
{
|
||||||
var offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f);
|
var offset = triangle_size * new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f);
|
||||||
|
var size = new Vector2(2 * offset.X, offset.Y);
|
||||||
|
|
||||||
var triangle = new Triangle(
|
var triangle = new Triangle(
|
||||||
particle.Position * Size * DrawInfo.Matrix,
|
particle.Position * Size * DrawInfo.Matrix,
|
||||||
(particle.Position * Size + offset * triangle_size) * DrawInfo.Matrix,
|
(particle.Position * Size + offset) * DrawInfo.Matrix,
|
||||||
(particle.Position * Size + new Vector2(-offset.X, offset.Y) * triangle_size) * DrawInfo.Matrix
|
(particle.Position * Size + new Vector2(-offset.X, offset.Y)) * DrawInfo.Matrix
|
||||||
);
|
);
|
||||||
|
|
||||||
ColourInfo colourInfo = DrawInfo.Colour;
|
ColourInfo colourInfo = DrawInfo.Colour;
|
||||||
colourInfo.ApplyChild(particle.Colour);
|
colourInfo.ApplyChild(particle.Colour);
|
||||||
|
|
||||||
Texture.DrawTriangle(triangle, colourInfo, null, Shared.VertexBatch.Add);
|
Texture.DrawTriangle(
|
||||||
|
triangle,
|
||||||
|
colourInfo,
|
||||||
|
null,
|
||||||
|
Shared.VertexBatch.Add,
|
||||||
|
Vector2.Divide(localInflationAmount, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
Shader.Unbind();
|
Shader.Unbind();
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
{
|
{
|
||||||
@ -23,6 +24,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
private const float shear_width = 10;
|
private const float shear_width = 10;
|
||||||
|
|
||||||
|
public readonly Bindable<bool> ChannelSelectorActive = new Bindable<bool>();
|
||||||
|
|
||||||
public ChatTabControl()
|
public ChatTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Margin = new MarginPadding { Left = 50 };
|
TabContainer.Margin = new MarginPadding { Left = 50 };
|
||||||
@ -37,6 +40,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
TextSize = 20,
|
TextSize = 20,
|
||||||
Padding = new MarginPadding(10),
|
Padding = new MarginPadding(10),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, ChannelSelectorActive));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelTabItem : TabItem<Channel>
|
private class ChannelTabItem : TabItem<Channel>
|
||||||
@ -49,6 +54,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
private readonly SpriteText textBold;
|
private readonly SpriteText textBold;
|
||||||
private readonly Box box;
|
private readonly Box box;
|
||||||
private readonly Box highlightBox;
|
private readonly Box highlightBox;
|
||||||
|
private readonly TextAwesome icon;
|
||||||
|
|
||||||
public override bool Active
|
public override bool Active
|
||||||
{
|
{
|
||||||
@ -114,6 +120,11 @@ namespace osu.Game.Overlays.Chat
|
|||||||
backgroundHover = colours.Gray7;
|
backgroundHover = colours.Gray7;
|
||||||
|
|
||||||
highlightBox.Colour = colours.Yellow;
|
highlightBox.Colour = colours.Yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
@ -159,7 +170,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new TextAwesome
|
icon = new TextAwesome
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.fa_hashtag,
|
Icon = FontAwesome.fa_hashtag,
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
@ -191,6 +202,40 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ChannelSelectorTabItem : ChannelTabItem
|
||||||
|
{
|
||||||
|
public override bool Active
|
||||||
|
{
|
||||||
|
get { return base.Active; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
activeBindable.Value = value;
|
||||||
|
base.Active = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Bindable<bool> activeBindable;
|
||||||
|
|
||||||
|
public ChannelSelectorTabItem(Channel value, Bindable<bool> active) : base(value)
|
||||||
|
{
|
||||||
|
activeBindable = active;
|
||||||
|
Depth = float.MaxValue;
|
||||||
|
Width = 45;
|
||||||
|
|
||||||
|
icon.Alpha = 0;
|
||||||
|
|
||||||
|
text.TextSize = 45;
|
||||||
|
textBold.TextSize = 45;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private new void load(OsuColour colour)
|
||||||
|
{
|
||||||
|
backgroundInactive = colour.Gray2;
|
||||||
|
backgroundActive = colour.Gray3;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,8 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (currentChannel == value) return;
|
if (currentChannel == value) return;
|
||||||
|
|
||||||
|
if (channelTabs.ChannelSelectorActive) return;
|
||||||
|
|
||||||
if (currentChannel != null)
|
if (currentChannel != null)
|
||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user