From 11f958030f5addac6c04e783668698e3fca68501 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 1 Dec 2016 18:53:13 +0900 Subject: [PATCH] Make Triangles more flexible and more random. --- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 41 +----------- osu.Game/Graphics/Backgrounds/Triangles.cs | 63 +++++++++++++++++++ osu.Game/Overlays/Toolbar/ToolbarButton.cs | 33 ++++++++-- .../Overlays/Toolbar/ToolbarModeSelector.cs | 7 +-- .../Overlays/Toolbar/ToolbarUserButton.cs | 2 + osu.Game/osu.Game.csproj | 1 + 6 files changed, 97 insertions(+), 50 deletions(-) create mode 100644 osu.Game/Graphics/Backgrounds/Triangles.cs diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 99ba31ab6a..72d1e2f05d 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.MathUtils; using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; @@ -128,45 +129,5 @@ namespace osu.Game.Beatmaps.Drawables } }; } - - public class Triangles : Container - { - private Texture triangle; - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - triangle = textures.Get(@"Play/osu/triangle@2x"); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - for (int i = 0; i < 10; i++) - { - Add(new Sprite - { - Texture = triangle, - Origin = Anchor.TopCentre, - RelativePositionAxes = Axes.Both, - Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()), - Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f), - Alpha = RNG.NextSingle() * 0.3f - }); - } - } - - protected override void Update() - { - base.Update(); - - foreach (Drawable d in Children) - { - d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 880))); - if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0) - d.MoveToY(1); - } - } - } } } diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs new file mode 100644 index 0000000000..b4afb84114 --- /dev/null +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -0,0 +1,63 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.MathUtils; +using OpenTK; + +namespace osu.Game.Graphics.Backgrounds +{ + public class Triangles : Container + { + private Texture triangle; + + public Triangles() + { + Masking = true; + Alpha = 0.3f; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + triangle = textures.Get(@"Play/osu/triangle@2x"); + } + + private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800); + + protected override void Update() + { + base.Update(); + + foreach (Drawable d in Children) + { + d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 880))); + if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0) + d.Expire(); + } + + bool useRandomX = Children.Count() < aimTriangleCount / 2; + while (Children.Count() < aimTriangleCount) + addTriangle(useRandomX); + + } + + private void addTriangle(bool randomX) + { + Add(new Sprite + { + Texture = triangle, + Origin = Anchor.TopCentre, + RelativePositionAxes = Axes.Both, + Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1), + Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f), + Alpha = RNG.NextSingle() + }); + } + } +} diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 84bf671631..0603fe2b7b 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -6,8 +6,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; using OpenTK; using OpenTK.Graphics; @@ -64,8 +66,7 @@ namespace osu.Game.Overlays.Toolbar HoverBackground = new Box { RelativeSizeAxes = Axes.Both, - BlendingMode = BlendingMode.Additive, - Colour = new Color4(60, 60, 60, 255), + Colour = new Color4(80, 80, 80, 180), Alpha = 0, }, Flow = new FlowContainer @@ -131,21 +132,43 @@ namespace osu.Game.Overlays.Toolbar protected override bool OnClick(InputState state) { Action?.Invoke(); - HoverBackground.FlashColour(Color4.White, 400); + HoverBackground.FlashColour(new Color4(255, 255, 255, 180), 800, EasingTypes.OutQuint); return true; } protected override bool OnHover(InputState state) { - HoverBackground.FadeTo(0.4f, 200); + HoverBackground.FadeIn(200); tooltipContainer.FadeIn(100); return false; } protected override void OnHoverLost(InputState state) { - HoverBackground.FadeTo(0, 200); + HoverBackground.FadeOut(200); tooltipContainer.FadeOut(100); } } + + public class OpaqueBackground : Container + { + public OpaqueBackground() + { + RelativeSizeAxes = Axes.Both; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(30, 30, 30, 255) + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.05f, + }, + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 9eca18e9c9..be34359df4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; +using osu.Game.Graphics.Backgrounds; using osu.Game.Modes; using OpenTK; using OpenTK.Graphics; @@ -31,11 +32,7 @@ namespace osu.Game.Overlays.Toolbar Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(20, 20, 20, 255) - }, + new OpaqueBackground(), modeButtons = new FlowContainer { RelativeSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index d0bae1dbf8..3a91a007ff 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -27,6 +27,8 @@ namespace osu.Game.Overlays.Toolbar { DrawableText.Font = @"Exo2.0-MediumItalic"; + Add(new OpaqueBackground { Depth = 1 }); + Flow.Add(avatar = new Avatar()); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 001eae8432..6f56037026 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -64,6 +64,7 @@ +