1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 07:32:58 +08:00

Merge pull request #312 from peppy/general-fixes

General fixes.
This commit is contained in:
Thomas Müller 2017-02-04 15:08:35 +01:00 committed by GitHub
commit 52f6a09319
9 changed files with 91 additions and 30 deletions

@ -1 +1 @@
Subproject commit 99955eecba415328c3e2b4055afb10aeb8a4ceb9
Subproject commit f9627494e444d8b35eb20d418539ada15f258c4d

View File

@ -69,6 +69,7 @@ namespace osu.Game.Beatmaps.Drawables
},
triangles = new Triangles
{
TriangleScale = 2,
RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"3a7285"),
ColourDark = OsuColour.FromHex(@"123744")

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using OpenTK;
using OpenTK.Graphics;
using System;
namespace osu.Game.Graphics.Backgrounds
{
@ -34,7 +35,14 @@ namespace osu.Game.Graphics.Backgrounds
}
}
private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800 / triangleScale);
protected override void LoadComplete()
{
base.LoadComplete();
for (int i = 0; i < aimTriangleCount; i++)
addTriangle(true);
}
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale));
protected override void Update()
{
@ -42,20 +50,25 @@ namespace osu.Game.Graphics.Backgrounds
foreach (Drawable d in Children)
{
d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 880)) / triangleScale);
d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
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);
addTriangle(false);
}
protected virtual Triangle CreateTriangle()
{
var scale = triangleScale * RNG.NextSingle() * 0.4f + 0.2f;
float stdDev = 0.16f;
float mean = 0.5f;
float u1 = 1 - RNG.NextSingle(); //uniform(0,1] random floats
float u2 = 1 - RNG.NextSingle();
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); //random normal(0,1)
var scale = Math.Max(triangleScale * (mean + stdDev * randStdNormal), 0.1f); //random normal(mean,stdDev^2)
const float size = 100;
return new Triangle
@ -72,10 +85,11 @@ namespace osu.Game.Graphics.Backgrounds
protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1);
private void addTriangle(bool randomX)
private void addTriangle(bool randomY)
{
var sprite = CreateTriangle();
sprite.Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1);
var triangleHeight = sprite.DrawHeight / DrawHeight;
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? (RNG.NextSingle() * (1 + triangleHeight) - triangleHeight) : 1);
Add(sprite);
}
}

View File

@ -2,6 +2,7 @@
//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.Configuration;
using osu.Framework.Graphics;
@ -41,12 +42,13 @@ namespace osu.Game.Graphics.Cursor
class OsuCursor : Container
{
private Container cursorContainer;
private BindableDouble cursorScale;
private Sprite sprite;
public OsuCursor()
{
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
Size = new Vector2(42);
}
[BackgroundDependencyLoader]
@ -56,18 +58,64 @@ namespace osu.Game.Graphics.Cursor
Children = new Drawable[]
{
sprite = new Sprite
cursorContainer = new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2((float)cursorScale),
Texture = textures.Get(@"Cursor/cursor")
}
Masking = true,
BorderThickness = Size.X / 6,
BorderColour = Color4.White,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.01f,
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 3,
BorderColour = Color4.White.Opacity(0.5f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.01f,
},
},
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.1f),
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
},
},
}
},
};
cursorScale.ValueChanged += scaleChanged;
}
private void scaleChanged(object sender, EventArgs e)
{
sprite.Scale = new Vector2((float)cursorScale);
cursorContainer.Scale = new Vector2((float)cursorScale);
}
}
}

View File

@ -39,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
fill = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.01f, //todo: remove once we figure why containers aren't drawing at all times
Alpha = 0.01f,
},
};
}

View File

@ -31,6 +31,7 @@ namespace osu.Game.Graphics.UserInterface
leftBox = new Box
{
Height = 2,
EdgeSmoothness = new Vector2(0, 0.5f),
Position = new Vector2(2, 0),
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreLeft,
@ -39,6 +40,7 @@ namespace osu.Game.Graphics.UserInterface
rightBox = new Box
{
Height = 2,
EdgeSmoothness = new Vector2(0, 0.5f),
Position = new Vector2(-2, 0),
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreRight,
@ -114,9 +116,9 @@ namespace osu.Game.Graphics.UserInterface
return base.OnDrag(state);
}
protected override void Update()
protected override void UpdateAfterChildren()
{
base.Update();
base.UpdateAfterChildren();
leftBox.Scale = new Vector2(MathHelper.Clamp(
nub.DrawPosition.X - nub.DrawWidth / 2, 0, DrawWidth), 1);
rightBox.Scale = new Vector2(MathHelper.Clamp(

View File

@ -48,8 +48,8 @@ namespace osu.Game.Overlays.Options
},
slider = new OsuSliderBar<T>
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X
}
};
}

View File

@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Toolbar
tooltipContainer = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.Both, //stops us being considered in parent's autosize
Anchor = Anchor.BottomLeft,
Position = new Vector2(5, 5),
Alpha = 0,
@ -123,6 +123,7 @@ namespace osu.Game.Overlays.Toolbar
};
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
}
[BackgroundDependencyLoader]
@ -131,14 +132,6 @@ namespace osu.Game.Overlays.Toolbar
sampleClick = audio.Sample.Get(@"Menu/menuclick");
}
protected override void Update()
{
base.Update();
//todo: find a way to avoid using this (autosize needs to be able to ignore certain drawables.. in this case the tooltip)
Size = new Vector2(Flow.DrawSize.X, 1);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnClick(InputState state)
@ -169,6 +162,7 @@ namespace osu.Game.Overlays.Toolbar
{
RelativeSizeAxes = Axes.Both;
Masking = true;
MaskingSmoothness = 0;
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
@ -186,7 +180,8 @@ namespace osu.Game.Overlays.Toolbar
new Triangles
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.05f,
ColourLight = OsuColour.Gray(40),
ColourDark = OsuColour.Gray(20),
},
};
}

View File

@ -22,6 +22,7 @@ namespace osu.Game.Overlays.Toolbar
public ToolbarUserArea()
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
Children = new Drawable[] {
button = new ToolbarUserButton