Merge https://github.com/ppy/osu into song-progress-graph

This commit is contained in:
DrabWeb
2017-02-06 20:40:49 -04:00
50 changed files with 780 additions and 549 deletions

View File

@ -0,0 +1,55 @@
using osu.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using osu.Framework.Platform;
using osu.Framework.Desktop.Platform;
using osu.Game.Database;
namespace osu.Desktop
{
class OsuGameDesktop : OsuGame
{
public OsuGameDesktop(string[] args = null)
: base(args)
{
}
public override void SetHost(BasicGameHost host)
{
base.SetHost(host);
var desktopWindow = host.Window as DesktopGameWindow;
if (desktopWindow != null)
{
desktopWindow.DragEnter += dragEnter;
desktopWindow.DragDrop += dragDrop;
}
}
private void dragDrop(DragEventArgs e)
{
// this method will only be executed if e.Effect in dragEnter gets set to something other that None.
var dropData = e.Data.GetData(DataFormats.FileDrop) as object[];
var filePaths = dropData.Select(f => f.ToString()).ToArray();
ImportBeatmaps(filePaths);
}
private void dragEnter(DragEventArgs e)
{
// dragDrop will only be executed if e.Effect gets set to something other that None in this method.
bool isFile = e.Data.GetDataPresent(DataFormats.FileDrop);
if (isFile)
{
var paths = (e.Data.GetData(DataFormats.FileDrop) as object[]).Select(f => f.ToString()).ToArray();
if (paths.Any(p => !p.EndsWith(".osz")))
e.Effect = DragDropEffects.None;
else
e.Effect = DragDropEffects.Copy;
}
}
}
}

View File

@ -51,7 +51,7 @@ namespace osu.Desktop
Ruleset.Register(new ManiaRuleset()); Ruleset.Register(new ManiaRuleset());
Ruleset.Register(new CatchRuleset()); Ruleset.Register(new CatchRuleset());
BaseGame osu = new OsuGame(args); BaseGame osu = new OsuGameDesktop(args);
host.Add(osu); host.Add(osu);
host.Run(); host.Run();
} }

View File

@ -81,7 +81,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Windows.Forms" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\osu.licenseheader"> <None Include="..\osu.licenseheader">
@ -152,6 +154,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="OsuGameDesktop.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" /> <Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
</ItemGroup> </ItemGroup>

View File

@ -105,7 +105,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
//sane defaults //sane defaults
ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1; ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1;
ApproachCircle.Alpha = 0; ApproachCircle.Alpha = 0;
ApproachCircle.Scale = new Vector2(2); ApproachCircle.Scale = new Vector2(4);
explode.Alpha = 0; explode.Alpha = 0;
} }
@ -114,7 +114,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
base.UpdatePreemptState(); base.UpdatePreemptState();
ApproachCircle.FadeIn(Math.Min(TIME_FADEIN * 2, TIME_PREEMPT)); ApproachCircle.FadeIn(Math.Min(TIME_FADEIN * 2, TIME_PREEMPT));
ApproachCircle.ScaleTo(0.6f, TIME_PREEMPT); ApproachCircle.ScaleTo(1.1f, TIME_PREEMPT);
} }
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)

View File

@ -32,7 +32,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
body = new SliderBody(s) body = new SliderBody(s)
{ {
Position = s.Position, Position = s.Position,
PathWidth = s.Scale * 72, PathWidth = s.Scale * 64,
}, },
bouncer1 = new SliderBouncer(s, false) bouncer1 = new SliderBouncer(s, false)
{ {
@ -115,8 +115,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
base.UpdateInitialState(); base.UpdateInitialState();
body.Alpha = 1; body.Alpha = 1;
//we need to be visible to handle input events. note that we still don't get enough events (we don't get a position if the mouse hasn't moved since the slider appeared). //we need to be present to handle input events. note that we still don't get enough events (we don't get a position if the mouse hasn't moved since the slider appeared).
ball.Alpha = 0.01f; ball.AlwaysPresent = true;
ball.Alpha = 0;
} }
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)

View File

@ -32,7 +32,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
approachCircle.Texture = textures.Get(@"Play/osu/approachcircle@2x"); approachCircle.Texture = textures.Get(@"Play/osu/approachcircle");
} }
} }
} }

View File

@ -22,9 +22,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
public CirclePiece() public CirclePiece()
{ {
Size = new Vector2(144); Size = new Vector2(128);
Masking = true; Masking = true;
CornerRadius = DrawSize.X / 2; CornerRadius = Size.X / 2;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -47,7 +47,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
disc.Texture = textures.Get(@"Play/osu/disc@2x"); disc.Texture = textures.Get(@"Play/osu/disc");
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{ {
public ExplodePiece() public ExplodePiece()
{ {
Size = new Vector2(144); Size = new Vector2(128);
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;

View File

@ -12,7 +12,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{ {
public FlashPiece() public FlashPiece()
{ {
Size = new Vector2(144); Size = new Vector2(128);
Masking = true; Masking = true;
CornerRadius = Size.X / 2; CornerRadius = Size.X / 2;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
layer.Texture = textures.Get(@"Play/osu/ring-glow@2x"); layer.Texture = textures.Get(@"Play/osu/ring-glow");
} }
} }
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
number.Texture = textures.Get(@"Play/osu/number@2x"); number.Texture = textures.Get(@"Play/osu/number");
} }
} }
} }

View File

@ -6,32 +6,35 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{ {
public class RingPiece : Container public class RingPiece : Container
{ {
private Sprite ring;
public RingPiece() public RingPiece()
{ {
Size = new Vector2(128);
Masking = true;
CornerRadius = Size.X / 2;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
BorderThickness = 10;
BorderColour = Color4.White;
Children = new Drawable[] Children = new Drawable[]
{ {
ring = new Sprite new Box
{ {
Anchor = Anchor.Centre, AlwaysPresent = true,
Origin = Anchor.Centre Alpha = 0,
RelativeSizeAxes = Axes.Both
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
ring.Texture = textures.Get(@"Play/osu/ring@2x");
}
} }
} }

View File

@ -16,7 +16,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
private readonly Slider slider; private readonly Slider slider;
private Box follow; private Box follow;
const float width = 140; const float width = 128;
public SliderBall(Slider slider) public SliderBall(Slider slider)
{ {
@ -45,7 +45,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
BorderThickness = 14, BorderThickness = 10,
BorderColour = Color4.White, BorderColour = Color4.White,
Alpha = 1, Alpha = 1,
CornerRadius = width / 2, CornerRadius = width / 2,

View File

@ -89,7 +89,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
var bytes = upload.Data; var bytes = upload.Data;
const float aa_portion = 0.02f; const float aa_portion = 0.02f;
const float border_portion = 0.18f; const float border_portion = 0.128f;
const float gradient_portion = 1 - border_portion; const float gradient_portion = 1 - border_portion;
const float opacity_at_centre = 0.3f; const float opacity_at_centre = 0.3f;

View File

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

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using System;
namespace osu.Game.Graphics.Backgrounds 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() protected override void Update()
{ {
@ -42,20 +50,25 @@ namespace osu.Game.Graphics.Backgrounds
foreach (Drawable d in Children) 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) if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
d.Expire(); d.Expire();
} }
bool useRandomX = Children.Count() < aimTriangleCount / 2;
while (Children.Count() < aimTriangleCount) while (Children.Count() < aimTriangleCount)
addTriangle(useRandomX); addTriangle(false);
} }
protected virtual Triangle CreateTriangle() 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; const float size = 100;
return new Triangle return new Triangle
@ -72,10 +85,11 @@ namespace osu.Game.Graphics.Backgrounds
protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1); 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(); 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); Add(sprite);
} }
} }

View File

@ -74,6 +74,7 @@ namespace osu.Game.Graphics.Cursor
{ {
shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture);
texture = textures.Get(@"Cursor/cursortrail"); texture = textures.Get(@"Cursor/cursortrail");
Scale = new Vector2(1 / texture.ScaleAdjust);
} }
protected override void Update() protected override void Update()

View File

@ -2,6 +2,7 @@
//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 OpenTK; using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -41,12 +42,13 @@ namespace osu.Game.Graphics.Cursor
class OsuCursor : Container class OsuCursor : Container
{ {
private Container cursorContainer;
private BindableDouble cursorScale; private BindableDouble cursorScale;
private Sprite sprite;
public OsuCursor() public OsuCursor()
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both; Size = new Vector2(42);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -56,18 +58,66 @@ namespace osu.Game.Graphics.Cursor
Children = new Drawable[] Children = new Drawable[]
{ {
sprite = new Sprite cursorContainer = new CircularContainer
{ {
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2((float)cursorScale), 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,
AlwaysPresent = true,
},
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,
AlwaysPresent = true,
},
},
},
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; cursorScale.ValueChanged += scaleChanged;
} }
private void scaleChanged(object sender, EventArgs e) private void scaleChanged(object sender, EventArgs e)
{ {
sprite.Scale = new Vector2((float)cursorScale); cursorContainer.Scale = new Vector2((float)cursorScale);
} }
} }
} }

View File

@ -0,0 +1,114 @@
// Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
class Nub : Container, IStateful<CheckBoxState>
{
public const float COLLAPSED_SIZE = 20;
public const float EXPANDED_SIZE = 40;
private Box fill;
const float border_width = 3;
private Color4 glowingColour, idleColour;
public Nub()
{
Size = new Vector2(COLLAPSED_SIZE, 12);
Masking = true;
CornerRadius = Height / 2;
Masking = true;
BorderColour = Color4.White;
BorderThickness = border_width;
Children = new[]
{
fill = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = idleColour = colours.Pink;
glowingColour = colours.PinkLighter;
EdgeEffect = new EdgeEffect
{
Colour = colours.PinkDarker,
Type = EdgeEffectType.Glow,
Radius = 10,
Roundness = 8,
};
FadeGlowTo(0);
}
public bool Glowing
{
set
{
if (value)
{
FadeColour(glowingColour, 500, EasingTypes.OutQuint);
FadeGlowTo(1, 500, EasingTypes.OutQuint);
}
else
{
FadeGlowTo(0, 500);
FadeColour(idleColour, 500);
}
}
}
public bool Expanded
{
set
{
ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, EasingTypes.OutQuint);
}
}
private CheckBoxState state;
public CheckBoxState State
{
get
{
return state;
}
set
{
state = value;
switch (state)
{
case CheckBoxState.Checked:
fill.FadeIn(200, EasingTypes.OutQuint);
break;
case CheckBoxState.Unchecked:
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
break;
}
}
}
}
}

View File

@ -66,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
private Light light; private Nub nub;
private SpriteText labelSpriteText; private SpriteText labelSpriteText;
private AudioSample sampleChecked; private AudioSample sampleChecked;
private AudioSample sampleUnchecked; private AudioSample sampleUnchecked;
@ -79,7 +79,7 @@ namespace osu.Game.Graphics.UserInterface
Children = new Drawable[] Children = new Drawable[]
{ {
labelSpriteText = new OsuSpriteText(), labelSpriteText = new OsuSpriteText(),
light = new Light nub = new Nub
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
@ -102,13 +102,15 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
light.Glowing = true; nub.Glowing = true;
nub.Expanded = true;
return base.OnHover(state); return base.OnHover(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
light.Glowing = false; nub.Glowing = false;
nub.Expanded = false;
base.OnHoverLost(state); base.OnHoverLost(state);
} }
@ -125,7 +127,7 @@ namespace osu.Game.Graphics.UserInterface
bindable.Value = true; bindable.Value = true;
sampleChecked?.Play(); sampleChecked?.Play();
light.State = CheckBoxState.Checked; nub.State = CheckBoxState.Checked;
} }
protected override void OnUnchecked() protected override void OnUnchecked()
@ -134,97 +136,7 @@ namespace osu.Game.Graphics.UserInterface
bindable.Value = false; bindable.Value = false;
sampleUnchecked?.Play(); sampleUnchecked?.Play();
light.State = CheckBoxState.Unchecked; nub.State = CheckBoxState.Unchecked;
} }
private class Light : Container, IStateful<CheckBoxState>
{
private Box fill;
const float border_width = 3;
private Color4 glowingColour, idleColour;
public Light()
{
Size = new Vector2(20, 12);
Masking = true;
CornerRadius = Height / 2;
Masking = true;
BorderColour = Color4.White;
BorderThickness = border_width;
Children = new[]
{
fill = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.01f, //todo: remove once we figure why containers aren't drawing at all times
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = idleColour = colours.Pink;
glowingColour = colours.PinkLighter;
EdgeEffect = new EdgeEffect
{
Colour = colours.PinkDarker,
Type = EdgeEffectType.Glow,
Radius = 10,
Roundness = 8,
};
FadeGlowTo(0);
}
public bool Glowing
{
set
{
if (value)
{
ResizeTo(new Vector2(40, 12), 500, EasingTypes.OutQuint);
FadeColour(glowingColour, 500, EasingTypes.OutQuint);
FadeGlowTo(1, 500, EasingTypes.OutQuint);
}
else
{
ResizeTo(new Vector2(20, 12), 500, EasingTypes.OutQuint);
FadeGlowTo(0, 500);
FadeColour(idleColour, 500);
}
}
}
private CheckBoxState state;
public CheckBoxState State
{
get
{
return state;
}
set
{
state = value;
switch (state)
{
case CheckBoxState.Checked:
fill.FadeIn(200, EasingTypes.OutQuint);
break;
case CheckBoxState.Unchecked:
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
break;
}
}
}
}
} }
} }

View File

@ -0,0 +1,57 @@
//Copyright (c) 2007-2016 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.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public class OsuDropDownHeader : DropDownHeader
{
private SpriteText label;
protected override string Label
{
get { return label.Text; }
set { label.Text = value; }
}
public OsuDropDownHeader()
{
Foreground.Padding = new MarginPadding(4);
AutoSizeAxes = Axes.None;
Margin = new MarginPadding { Bottom = 4 };
CornerRadius = 4;
Height = 40;
Children = new[]
{
label = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TextAwesome
{
Icon = FontAwesome.fa_chevron_down,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 },
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
}
}
}

View File

@ -0,0 +1,55 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public class OsuDropDownMenu<U> : DropDownMenu<U>
{
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader();
protected override IEnumerable<DropDownMenuItem<U>> GetDropDownItems(IEnumerable<U> values)
{
return values.Select(v =>
{
var field = typeof(U).GetField(Enum.GetName(typeof(U), v));
return new OsuDropDownMenuItem<U>(
field.GetCustomAttribute<DescriptionAttribute>()?.Description ?? field.Name, v);
});
}
public OsuDropDownMenu()
{
ContentContainer.CornerRadius = 4;
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
}
protected override void AnimateOpen()
{
ContentContainer.FadeIn(300, EasingTypes.OutQuint);
}
protected override void AnimateClose()
{
ContentContainer.FadeOut(300, EasingTypes.OutQuint);
}
protected override void UpdateContentHeight()
{
if (State == DropDownMenuState.Opened)
ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint);
else
ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint);
}
}
}

View File

@ -0,0 +1,57 @@
//Copyright (c) 2007-2016 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public class OsuDropDownMenuItem<U> : DropDownMenuItem<U>
{
public OsuDropDownMenuItem(string text, U value) : base(text, value)
{
Foreground.Padding = new MarginPadding(2);
Children = new[]
{
new FlowContainer
{
Direction = FlowDirection.HorizontalOnly,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new TextAwesome
{
Icon = FontAwesome.fa_chevron_right,
Colour = Color4.Black,
TextSize = 12,
Margin = new MarginPadding { Right = 3 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
},
new OsuSpriteText {
Text = text,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
}
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
}
}
}

View File

@ -0,0 +1,133 @@
// Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using OpenTK;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
public class OsuSliderBar<U> : SliderBar<U> where U : struct
{
private AudioSample sample;
private double lastSampleTime;
private Nub nub;
private Box leftBox, rightBox;
public OsuSliderBar()
{
Height = 12;
RangePadding = 20;
Children = new Drawable[]
{
leftBox = new Box
{
Height = 2,
EdgeSmoothness = new Vector2(0, 0.5f),
Position = new Vector2(2, 0),
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
rightBox = new Box
{
Height = 2,
EdgeSmoothness = new Vector2(0, 0.5f),
Position = new Vector2(-2, 0),
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Alpha = 0.5f,
},
nub = new Nub
{
Origin = Anchor.TopCentre,
State = CheckBoxState.Unchecked,
Expanded = true,
}
};
}
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours)
{
sample = audio.Sample.Get(@"Sliderbar/sliderbar");
leftBox.Colour = colours.Pink;
rightBox.Colour = colours.Pink;
}
private void playSample()
{
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;
sample.Play();
}
protected override bool OnHover(InputState state)
{
nub.Glowing = true;
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
nub.Glowing = false;
base.OnHoverLost(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == Key.Left || args.Key == Key.Right)
playSample();
return base.OnKeyDown(state, args);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
nub.State = CheckBoxState.Checked;
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
nub.State = CheckBoxState.Unchecked;
return base.OnMouseUp(state, args);
}
protected override bool OnClick(InputState state)
{
playSample();
return base.OnClick(state);
}
protected override bool OnDrag(InputState state)
{
playSample();
return base.OnDrag(state);
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
leftBox.Scale = new Vector2(MathHelper.Clamp(
nub.DrawPosition.X - nub.DrawWidth / 2, 0, DrawWidth), 1);
rightBox.Scale = new Vector2(MathHelper.Clamp(
DrawWidth - nub.DrawPosition.X - nub.DrawWidth / 2, 0, DrawWidth), 1);
}
protected override void UpdateValue(float value)
{
nub.MoveToX(RangePadding + UsableWidth * value, 250, EasingTypes.OutQuint);
}
}
}

View File

@ -83,6 +83,7 @@ namespace osu.Game.Graphics.UserInterface
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0), Shear = new Vector2(shear, 0),
Masking = true, Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffect { EdgeEffect = new EdgeEffect {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(0.2f), Colour = Color4.Black.Opacity(0.2f),
@ -93,7 +94,7 @@ namespace osu.Game.Graphics.UserInterface
IconLayer = new Box IconLayer = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(1.5f, 0), EdgeSmoothness = new Vector2(2, 0),
}, },
} }
}, },
@ -116,6 +117,7 @@ namespace osu.Game.Graphics.UserInterface
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0), Shear = new Vector2(shear, 0),
Masking = true, Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffect { EdgeEffect = new EdgeEffect {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(0.2f), Colour = Color4.Black.Opacity(0.2f),
@ -128,7 +130,7 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.TopLeft, Origin = Anchor.TopLeft,
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(1.5f, 0), EdgeSmoothness = new Vector2(2, 0),
}, },
} }
}, },

View File

@ -70,7 +70,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
public void Adjust(InputState state) public void Adjust(InputState state)
{ {
if (!IsVisible) if (State == Visibility.Hidden)
{ {
Show(); Show();
return; return;

View File

@ -22,6 +22,7 @@ using osu.Game.Overlays.Toolbar;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using OpenTK; using OpenTK;
using System.Linq;
namespace osu.Game namespace osu.Game
{ {
@ -63,13 +64,18 @@ namespace osu.Game
} }
if (args?.Length > 0) if (args?.Length > 0)
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(args); }); ImportBeatmaps(args);
Dependencies.Cache(this); Dependencies.Cache(this);
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode); PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode);
} }
public void ImportBeatmaps(params string[] paths)
{
Schedule(delegate { Dependencies.Get<BeatmapDatabase>().Import(paths); });
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();

View File

@ -45,7 +45,7 @@ namespace osu.Game
Dependencies.Cache(new OsuColour()); Dependencies.Cache(new OsuColour());
//this completely overrides the framework default. will need to change once we make a proper FontStore. //this completely overrides the framework default. will need to change once we make a proper FontStore.
Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true); Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }, true);
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));

View File

@ -0,0 +1,81 @@
using System;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionDropDown<T> : FlowContainer
{
private DropDownMenu<T> dropdown;
private SpriteText text;
public string LabelText
{
get { return text.Text; }
set
{
text.Text = value;
}
}
public Bindable<T> Bindable
{
get { return bindable; }
set
{
if (bindable != null)
bindable.ValueChanged -= Bindable_ValueChanged;
bindable = value;
bindable.ValueChanged += Bindable_ValueChanged;
Bindable_ValueChanged(null, null);
}
}
private Bindable<T> bindable;
void Bindable_ValueChanged(object sender, EventArgs e)
{
dropdown.SelectedValue = bindable.Value;
}
void Dropdown_ValueChanged(object sender, EventArgs e)
{
bindable.Value = dropdown.SelectedValue;
}
protected override void Dispose(bool isDisposing)
{
bindable.ValueChanged -= Bindable_ValueChanged;
dropdown.ValueChanged -= Dropdown_ValueChanged;
base.Dispose(isDisposing);
}
public OptionDropDown()
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument");
Direction = FlowDirection.VerticalOnly;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText {
Alpha = 0,
},
dropdown = new OsuDropDownMenu<T>
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Items = (T[])Enum.GetValues(typeof(T)),
}
};
dropdown.ValueChanged += Dropdown_ValueChanged;
}
}
}

View File

@ -1,221 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Options
{
public class OptionDropdown<T> : FlowContainer
{
private DropDownMenu<T> dropdown;
private SpriteText text;
public string LabelText
{
get { return text.Text; }
set
{
text.Text = value;
text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
}
}
public Bindable<T> Bindable
{
get { return bindable; }
set
{
if (bindable != null)
bindable.ValueChanged -= Bindable_ValueChanged;
bindable = value;
bindable.ValueChanged += Bindable_ValueChanged;
Bindable_ValueChanged(null, null);
}
}
private Bindable<T> bindable;
void Bindable_ValueChanged(object sender, EventArgs e)
{
dropdown.SelectedValue = bindable.Value;
}
void Dropdown_ValueChanged(object sender, EventArgs e)
{
bindable.Value = dropdown.SelectedValue;
}
protected override void Dispose(bool isDisposing)
{
bindable.ValueChanged -= Bindable_ValueChanged;
dropdown.ValueChanged -= Dropdown_ValueChanged;
base.Dispose(isDisposing);
}
public OptionDropdown()
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("OptionsDropdown only supports enums as the generic type argument");
Direction = FlowDirection.VerticalOnly;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText {
Alpha = 0,
},
dropdown = new StyledDropDownMenu<T>
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Items = (T[])Enum.GetValues(typeof(T)),
}
};
dropdown.ValueChanged += Dropdown_ValueChanged;
}
private class StyledDropDownMenu<U> : DropDownMenu<U>
{
protected override float DropDownListSpacing => 4;
protected override DropDownComboBox CreateComboBox()
{
return new StyledDropDownComboBox();
}
protected override IEnumerable<DropDownMenuItem<U>> GetDropDownItems(IEnumerable<U> values)
{
return values.Select(v =>
{
var field = typeof(U).GetField(Enum.GetName(typeof(U), v));
return new StyledDropDownMenuItem<U>(
field.GetCustomAttribute<DescriptionAttribute>()?.Description ?? field.Name, v);
});
}
public StyledDropDownMenu()
{
ComboBox.CornerRadius = 4;
DropDown.CornerRadius = 4;
}
protected override void AnimateOpen()
{
foreach (StyledDropDownMenuItem<U> child in DropDownItemsContainer.Children)
{
child.FadeIn(200);
child.ResizeTo(new Vector2(1, 24), 200);
}
DropDown.Show();
}
protected override void AnimateClose()
{
foreach (StyledDropDownMenuItem<U> child in DropDownItemsContainer.Children)
{
child.ResizeTo(new Vector2(1, 0), 200);
child.FadeOut(200);
}
}
}
private class StyledDropDownComboBox : DropDownComboBox
{
private SpriteText label;
protected override string Label
{
get { return label.Text; }
set { label.Text = value; }
}
public StyledDropDownComboBox()
{
Foreground.Padding = new MarginPadding(4);
AutoSizeAxes = Axes.None;
Height = 40;
Children = new[]
{
label = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TextAwesome
{
Icon = FontAwesome.fa_chevron_down,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 },
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
}
}
private class StyledDropDownMenuItem<U> : DropDownMenuItem<U>
{
public StyledDropDownMenuItem(string text, U value) : base(text, value)
{
AutoSizeAxes = Axes.None;
Height = 0;
Foreground.Padding = new MarginPadding(2);
Children = new[]
{
new FlowContainer
{
Direction = FlowDirection.HorizontalOnly,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new TextAwesome
{
Icon = FontAwesome.fa_chevron_right,
Colour = Color4.Black,
TextSize = 12,
Margin = new MarginPadding { Right = 3 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
},
new OsuSpriteText {
Text = text,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
}
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0.5f);
BackgroundColourHover = colours.PinkDarker;
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
}
}
}
}

View File

@ -1,24 +1,14 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 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 System;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using System.Linq;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options namespace osu.Game.Overlays.Options
{ {
@ -48,128 +38,20 @@ namespace osu.Game.Overlays.Options
Direction = FlowDirection.VerticalOnly; Direction = FlowDirection.VerticalOnly;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Right = 5 };
Children = new Drawable[] Children = new Drawable[]
{ {
text = new OsuSpriteText { text = new OsuSpriteText
{
Alpha = 0, Alpha = 0,
}, },
slider = new OsuSliderBar<T> slider = new OsuSliderBar<T>
{ {
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X
} }
}; };
} }
private class OsuSliderBar<U> : SliderBar<U> where U : struct
{
private AudioSample sample;
private double lastSampleTime;
private Container nub;
private Box leftBox, rightBox;
private float innerWidth
{
get
{
return DrawWidth - Height;
}
}
public OsuSliderBar()
{
Height = 20;
Padding = new MarginPadding { Left = Height / 2, Right = Height / 2 };
Children = new Drawable[]
{
leftBox = new Box
{
Height = 2,
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
rightBox = new Box
{
Height = 2,
RelativeSizeAxes = Axes.None,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Alpha = 0.5f,
},
nub = new Container
{
Width = Height,
Height = Height,
CornerRadius = Height / 2,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.None,
RelativeSizeAxes = Axes.None,
Masking = true,
BorderThickness = 3,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
}
};
}
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours)
{
sample = audio.Sample.Get(@"Sliderbar/sliderbar");
leftBox.Colour = colours.Pink;
rightBox.Colour = colours.Pink;
nub.BorderColour = colours.Pink;
(nub.Children.First() as Box).Colour = colours.Pink.Opacity(0);
}
private void playSample()
{
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;
sample.Play();
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Key == Key.Left || args.Key == Key.Right)
playSample();
return base.OnKeyDown(state, args);
}
protected override bool OnClick(InputState state)
{
playSample();
return base.OnClick(state);
}
protected override bool OnDrag(InputState state)
{
playSample();
return base.OnDrag(state);
}
protected override void Update()
{
base.Update();
leftBox.Scale = new Vector2(MathHelper.Clamp(
nub.DrawPosition.X - nub.DrawWidth / 2 + 2, 0, innerWidth), 1);
rightBox.Scale = new Vector2(MathHelper.Clamp(
innerWidth - nub.DrawPosition.X - nub.DrawWidth / 2 + 2, 0, innerWidth), 1);
}
protected override void UpdateValue(float value)
{
nub.MoveToX(innerWidth * value);
}
}
} }
} }

View File

@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay
LabelText = "Background dim", LabelText = "Background dim",
Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.DimLevel) Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.DimLevel)
}, },
new OptionDropdown<ProgressBarType> new OptionDropDown<ProgressBarType>
{ {
LabelText = "Progress display", LabelText = "Progress display",
Bindable = config.GetBindable<ProgressBarType>(OsuConfig.ProgressBarType) Bindable = config.GetBindable<ProgressBarType>(OsuConfig.ProgressBarType)
}, },
new OptionDropdown<ScoreMeterType> new OptionDropDown<ScoreMeterType>
{ {
LabelText = "Score meter type", LabelText = "Score meter type",
Bindable = config.GetBindable<ScoreMeterType>(OsuConfig.ScoreMeter) Bindable = config.GetBindable<ScoreMeterType>(OsuConfig.ScoreMeter)

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Options.Sections.General
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new OptionDropdown<ReleaseStream> new OptionDropDown<ReleaseStream>
{ {
LabelText = "Release stream", LabelText = "Release stream",
Bindable = config.GetBindable<ReleaseStream>(OsuConfig.ReleaseStream), Bindable = config.GetBindable<ReleaseStream>(OsuConfig.ReleaseStream),

View File

@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
LabelText = "Softening filter", LabelText = "Softening filter",
Bindable = config.GetBindable<bool>(OsuConfig.BloomSoftening) Bindable = config.GetBindable<bool>(OsuConfig.BloomSoftening)
}, },
new OptionDropdown<ScreenshotFormat> new OptionDropDown<ScreenshotFormat>
{ {
LabelText = "Screenshot", LabelText = "Screenshot",
Bindable = config.GetBindable<ScreenshotFormat>(OsuConfig.ScreenshotFormat) Bindable = config.GetBindable<ScreenshotFormat>(OsuConfig.ScreenshotFormat)

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
Children = new Drawable[] Children = new Drawable[]
{ {
// TODO: this needs to be a custom dropdown at some point // TODO: this needs to be a custom dropdown at some point
new OptionDropdown<FrameSync> new OptionDropDown<FrameSync>
{ {
LabelText = "Frame limiter", LabelText = "Frame limiter",
Bindable = config.GetBindable<FrameSync>(FrameworkConfig.FrameSync) Bindable = config.GetBindable<FrameSync>(FrameworkConfig.FrameSync)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Options.Sections.Input
LabelText = "Map absolute raw input to the osu! window", LabelText = "Map absolute raw input to the osu! window",
Bindable = config.GetBindable<bool>(OsuConfig.AbsoluteToOsuWindow) Bindable = config.GetBindable<bool>(OsuConfig.AbsoluteToOsuWindow)
}, },
new OptionDropdown<ConfineMouseMode> new OptionDropDown<ConfineMouseMode>
{ {
LabelText = "Confine mouse cursor", LabelText = "Confine mouse cursor",
Bindable = config.GetBindable<ConfineMouseMode>(OsuConfig.ConfineMouse), Bindable = config.GetBindable<ConfineMouseMode>(OsuConfig.ConfineMouse),

View File

@ -1,4 +1,7 @@
using OpenTK; //Copyright (c) 2007-2016 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 OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
@ -61,7 +64,7 @@ namespace osu.Game.Overlays.Pause
public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args) protected override bool OnClick(Framework.Input.InputState state)
{ {
didClick = true; didClick = true;
colourContainer.ResizeTo(new Vector2(1.5f, 1f), clickDuration, EasingTypes.In); colourContainer.ResizeTo(new Vector2(1.5f, 1f), clickDuration, EasingTypes.In);
@ -79,8 +82,6 @@ namespace osu.Game.Overlays.Pause
return true; return true;
} }
protected override bool OnClick(Framework.Input.InputState state) => false;
protected override bool OnHover(Framework.Input.InputState state) protected override bool OnHover(Framework.Input.InputState state)
{ {
colourContainer.ResizeTo(new Vector2(hoverWidth, 1f), hoverDuration, EasingTypes.OutElastic); colourContainer.ResizeTo(new Vector2(hoverWidth, 1f), hoverDuration, EasingTypes.OutElastic);
@ -187,6 +188,7 @@ namespace osu.Game.Overlays.Pause
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Width = 0.8f, Width = 0.8f,
Masking = true, Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffect EdgeEffect = new EdgeEffect
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
@ -202,15 +204,23 @@ namespace osu.Game.Overlays.Pause
EdgeSmoothness = new Vector2(2, 0), EdgeSmoothness = new Vector2(2, 0),
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, },
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
MaskingSmoothness = 0,
Children = new[]
{
new Triangles new Triangles
{ {
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
TriangleScale = 4, TriangleScale = 4,
Alpha = 0.05f, ColourDark = OsuColour.Gray(0.88f),
Shear = new Vector2(-0.2f, 0) Shear = new Vector2(-0.2f, 0)
} }
} }
},
}
} }
} }
}, },

View File

@ -69,6 +69,9 @@ namespace osu.Game.Overlays.Pause
protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In);
protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In);
// Don't let mouse down events through the overlay or people can click circles while paused.
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{ {
if (args.Key == Key.Escape) if (args.Key == Key.Escape)

View File

@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Toolbar
tooltipContainer = new FlowContainer tooltipContainer = new FlowContainer
{ {
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both, //stops us being considered in parent's autosize
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(5, 5), Position = new Vector2(5, 5),
Alpha = 0, Alpha = 0,
@ -132,14 +132,6 @@ namespace osu.Game.Overlays.Toolbar
sampleClick = audio.Sample.Get(@"Menu/menuclick"); 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 OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
@ -170,6 +162,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Masking = true; Masking = true;
MaskingSmoothness = 0;
EdgeEffect = new EdgeEffect EdgeEffect = new EdgeEffect
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
@ -187,7 +180,8 @@ namespace osu.Game.Overlays.Toolbar
new Triangles new Triangles
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0.05f, ColourLight = OsuColour.Gray(40),
ColourDark = OsuColour.Gray(20),
}, },
}; };
} }

View File

@ -17,11 +17,10 @@ namespace osu.Game.Overlays.Toolbar
public override bool Contains(Vector2 screenSpacePos) => true; public override bool Contains(Vector2 screenSpacePos) => true;
public override Vector2 Size => button.Size;
public ToolbarUserArea() public ToolbarUserArea()
{ {
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
Children = new Drawable[] { Children = new Drawable[] {
button = new ToolbarUserButton button = new ToolbarUserButton
@ -30,6 +29,7 @@ namespace osu.Game.Overlays.Toolbar
}, },
loginOverlay = new LoginOverlay loginOverlay = new LoginOverlay
{ {
BypassAutoSizeAxes = Axes.Both,
Position = new Vector2(0, 1), Position = new Vector2(0, 1),
RelativePositionAxes = Axes.Y, RelativePositionAxes = Axes.Y,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,

View File

@ -79,7 +79,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
this.game = game; this.game = game;
guestTexture = textures.Get(@"Online/avatar-guest@2x"); guestTexture = textures.Get(@"Online/avatar-guest");
} }
public int UserId public int UserId

View File

@ -62,6 +62,7 @@ namespace osu.Game.Screens.Menu
box = new Container box = new Container
{ {
Masking = true, Masking = true,
MaskingSmoothness = 2,
EdgeEffect = new EdgeEffect EdgeEffect = new EdgeEffect
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
@ -75,12 +76,11 @@ namespace osu.Game.Screens.Menu
Scale = new Vector2(0, 1), Scale = new Vector2(0, 1),
Size = boxSize, Size = boxSize,
Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0), Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
{ {
EdgeSmoothness = new Vector2(2, 0), EdgeSmoothness = new Vector2(1.5f, 0),
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
} }

View File

@ -132,7 +132,6 @@ namespace osu.Game.Screens.Menu
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Scale = new Vector2(0.5f),
}, },
} }
}, },
@ -147,7 +146,6 @@ namespace osu.Game.Screens.Menu
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
BlendingMode = BlendingMode.Additive, BlendingMode = BlendingMode.Additive,
Scale = new Vector2(0.5f),
Alpha = 0.15f Alpha = 0.15f
} }
} }
@ -170,8 +168,8 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
logo.Texture = textures.Get(@"Menu/logo@2x"); logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo@2x"); ripple.Texture = textures.Get(@"Menu/logo");
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -202,7 +202,7 @@ namespace osu.Game.Screens.Select
/// <param name="halfHeight">Half the draw height of the carousel container.</param> /// <param name="halfHeight">Half the draw height of the carousel container.</param>
private void updatePanel(Panel p, float halfHeight) private void updatePanel(Panel p, float halfHeight)
{ {
var height = p.IsVisible ? p.DrawHeight : 0; var height = p.IsPresent ? p.DrawHeight : 0;
float panelDrawY = p.Position.Y - Current + height / 2; float panelDrawY = p.Position.Y - Current + height / 2;
float dist = Math.Abs(1f - panelDrawY / halfHeight); float dist = Math.Abs(1f - panelDrawY / halfHeight);

View File

@ -61,13 +61,13 @@ namespace osu.Game.Screens.Select
public void Deactivate() public void Deactivate()
{ {
searchTextBox.GrabFocus = false; searchTextBox.HoldFocus = false;
searchTextBox.TriggerFocusLost(); searchTextBox.TriggerFocusLost();
} }
public void Activate() public void Activate()
{ {
searchTextBox.GrabFocus = true; searchTextBox.HoldFocus = true;
} }
private class TabItem : ClickableContainer private class TabItem : ClickableContainer

View File

@ -97,7 +97,6 @@ namespace osu.Game.Screens.Select
HoverLost?.Invoke(); HoverLost?.Invoke();
light.ScaleTo(new Vector2(1, 1), Footer.TRANSITION_LENGTH, EasingTypes.OutQuint); light.ScaleTo(new Vector2(1, 1), Footer.TRANSITION_LENGTH, EasingTypes.OutQuint);
light.FadeColour(DeselectedColour, Footer.TRANSITION_LENGTH, EasingTypes.OutQuint); light.FadeColour(DeselectedColour, Footer.TRANSITION_LENGTH, EasingTypes.OutQuint);
box.FadeOut(Footer.TRANSITION_LENGTH, EasingTypes.OutQuint);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -106,6 +105,12 @@ namespace osu.Game.Screens.Select
return base.OnMouseDown(state, args); return base.OnMouseDown(state, args);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
box.FadeOut(Footer.TRANSITION_LENGTH, EasingTypes.OutQuint);
return base.OnMouseUp(state, args);
}
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
{ {
box.ClearTransformations(); box.ClearTransformations();

View File

@ -17,7 +17,18 @@ namespace osu.Game.Screens.Select
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
public Action Exit; public Action Exit;
public bool GrabFocus = false;
private bool focus;
public bool HoldFocus
{
get { return focus; }
set
{
focus = value;
if (!focus)
TriggerFocusLost();
}
}
private SpriteText placeholder; private SpriteText placeholder;
@ -64,8 +75,7 @@ namespace osu.Game.Screens.Select
protected override void Update() protected override void Update()
{ {
if (GrabFocus && !HasFocus && IsVisible) if (HoldFocus) RequestFocus();
TriggerFocus();
base.Update(); base.Update();
} }

View File

@ -68,6 +68,8 @@
<Compile Include="Graphics\Cursor\CursorTrail.cs" /> <Compile Include="Graphics\Cursor\CursorTrail.cs" />
<Compile Include="Graphics\Sprites\OsuSpriteText.cs" /> <Compile Include="Graphics\Sprites\OsuSpriteText.cs" />
<Compile Include="Graphics\UserInterface\BackButton.cs" /> <Compile Include="Graphics\UserInterface\BackButton.cs" />
<Compile Include="Graphics\UserInterface\Nub.cs" />
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
<Compile Include="Graphics\UserInterface\OsuTextBox.cs" /> <Compile Include="Graphics\UserInterface\OsuTextBox.cs" />
<Compile Include="Graphics\UserInterface\TwoLayerButton.cs" /> <Compile Include="Graphics\UserInterface\TwoLayerButton.cs" />
<Compile Include="Modes\Objects\HitObjectParser.cs" /> <Compile Include="Modes\Objects\HitObjectParser.cs" />
@ -98,6 +100,9 @@
<Compile Include="Beatmaps\Timing\TimingChange.cs" /> <Compile Include="Beatmaps\Timing\TimingChange.cs" />
<Compile Include="Configuration\OsuConfigManager.cs" /> <Compile Include="Configuration\OsuConfigManager.cs" />
<Compile Include="Overlays\Options\OptionLabel.cs" /> <Compile Include="Overlays\Options\OptionLabel.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownHeader.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownMenu.cs" />
<Compile Include="Graphics\UserInterface\OsuDropDownMenuItem.cs" />
<Compile Include="Overlays\Toolbar\ToolbarHomeButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarHomeButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarMusicButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarMusicButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarSettingsButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarSettingsButton.cs" />
@ -234,7 +239,7 @@
<Compile Include="Overlays\Options\OptionTextBox.cs" /> <Compile Include="Overlays\Options\OptionTextBox.cs" />
<Compile Include="Overlays\Options\OptionSlider.cs" /> <Compile Include="Overlays\Options\OptionSlider.cs" />
<Compile Include="Configuration\ProgressBarType.cs" /> <Compile Include="Configuration\ProgressBarType.cs" />
<Compile Include="Overlays\Options\OptionDropdown.cs" /> <Compile Include="Overlays\Options\OptionDropDown.cs" />
<Compile Include="Configuration\RankingType.cs" /> <Compile Include="Configuration\RankingType.cs" />
<Compile Include="Configuration\ScoreMeterType.cs" /> <Compile Include="Configuration\ScoreMeterType.cs" />
<Compile Include="Configuration\ReleaseStream.cs" /> <Compile Include="Configuration\ReleaseStream.cs" />