1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 05:27:26 +08:00

Merge branch 'master' into mania-hitobject-object-conversion

This commit is contained in:
Dean Herbert 2017-05-22 08:12:09 +09:00 committed by GitHub
commit 0ad4a18c7b
20 changed files with 619 additions and 259 deletions

@ -1 +1 @@
Subproject commit f8e5b10f6883af83ffbc431b03fe4ee3e89797a6
Subproject commit d00a7df902074d0b3f1479904b7f322db9d39c1f

View File

@ -129,8 +129,6 @@ namespace osu.Desktop.VisualTests.Tests
};
Add(clockAdjustContainer);
load(mode);
}
private int depth;

View File

@ -16,7 +16,7 @@ namespace osu.Desktop.VisualTests.Tests
base.Reset();
Add(new BackButton());
Add(new SkipButton());
Add(new SkipButton(Clock.CurrentTime + 5000));
}
}
}

View File

@ -1,15 +1,16 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation;
using osu.Game.Screens.Ranking;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
@ -18,9 +19,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly Spinner spinner;
private readonly SpinnerDisc disc;
private readonly SpinnerTicks ticks;
private readonly Container mainContainer;
private readonly SpinnerBackground background;
private readonly Container circleContainer;
private readonly DrawableHitCircle circle;
private readonly CirclePiece circle;
private readonly GlowPiece glow;
private readonly TextAwesome symbol;
private Color4 normalColour;
private Color4 completeColour;
public DrawableSpinner(Spinner s) : base(s)
{
@ -29,57 +40,91 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Origin = Anchor.Centre;
Position = s.Position;
//take up full playfield.
Size = new Vector2(OsuPlayfield.BASE_SIZE.X);
RelativeSizeAxes = Axes.Both;
// we are slightly bigger than our parent, to clip the top and bottom of the circle
Height = 1.3f;
spinner = s;
Children = new Drawable[]
{
background = new SpinnerBackground
{
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
DiscColour = Color4.Black
},
disc = new SpinnerDisc
{
Alpha = 0,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
DiscColour = AccentColour
},
circleContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new []
Children = new Drawable[]
{
circle = new DrawableHitCircle(s)
glow = new GlowPiece(),
circle = new CirclePiece
{
Interactive = false,
Position = Vector2.Zero,
Anchor = Anchor.Centre,
},
new RingPiece(),
symbol = new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
UseFullGlyphHeight = true,
TextSize = 48,
Icon = FontAwesome.fa_asterisk,
Shadow = false,
},
}
},
mainContainer = new AspectContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
background = new SpinnerBackground
{
Alpha = 0.6f,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
disc = new SpinnerDisc(spinner)
{
Scale = Vector2.Zero,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
circleContainer.CreateProxy(),
ticks = new SpinnerTicks
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
}
},
};
background.Scale = scaleToCircle;
disc.Scale = scaleToCircle;
}
public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / spinner.SpinsRequired, 0, 1);
protected override void CheckJudgement(bool userTriggered)
{
if (Time.Current < HitObject.StartTime) return;
disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100);
if (Progress >= 1)
if (Progress >= 1 && !disc.Complete)
{
disc.Complete = true;
const float duration = 200;
disc.FadeAccent(completeColour, duration);
background.FadeAccent(completeColour, duration);
background.FadeOut(duration);
circle.FadeColour(completeColour, duration);
glow.FadeColour(completeColour, duration);
}
if (!userTriggered && Time.Current >= spinner.EndTime)
{
if (Progress >= 1)
@ -106,26 +151,48 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
}
private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
normalColour = colours.SpinnerBase;
public float Progress => MathHelper.Clamp(disc.RotationAbsolute / 360 / spinner.SpinsRequired, 0, 1);
background.AccentColour = normalColour;
completeColour = colours.YellowLight.Opacity(0.6f);
disc.AccentColour = colours.SpinnerFill;
circle.Colour = colours.BlueDark;
glow.Colour = colours.BlueDark;
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
circle.Rotation = disc.Rotation;
ticks.Rotation = disc.Rotation;
float relativeCircleScale = spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, EasingTypes.OutQuint);
symbol.RotateTo(disc.Rotation / 2, 500, EasingTypes.OutQuint);
}
protected override void UpdatePreemptState()
{
base.UpdatePreemptState();
circleContainer.ScaleTo(1, 400, EasingTypes.OutElastic);
circleContainer.ScaleTo(spinner.Scale * 0.3f);
circleContainer.ScaleTo(spinner.Scale, TIME_PREEMPT / 1.4f, EasingTypes.OutQuint);
background.Delay(TIME_PREEMPT - 500);
disc.RotateTo(-720);
symbol.RotateTo(-720);
background.ScaleTo(scaleToCircle * 1.2f, 400, EasingTypes.OutQuint);
background.FadeIn(200);
mainContainer.ScaleTo(0);
mainContainer.ScaleTo(spinner.Scale * circle.DrawHeight / DrawHeight * 1.4f, TIME_PREEMPT - 150, EasingTypes.OutQuint);
background.Delay(400);
background.ScaleTo(1, 250, EasingTypes.OutQuint);
disc.Delay(TIME_PREEMPT - 50);
disc.FadeIn(200);
mainContainer.Delay(TIME_PREEMPT - 150);
mainContainer.ScaleTo(1, 500, EasingTypes.OutQuint);
}
protected override void UpdateCurrentState(ArmedState state)

View File

@ -16,7 +16,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
private readonly Sprite disc;
public Func<bool> Hit;
public CirclePiece()

View File

@ -1,10 +1,55 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public class SpinnerBackground : SpinnerDisc
public class SpinnerBackground : CircularContainer, IHasAccentColour
{
public override bool HandleInput => false;
protected Box Disc;
public Color4 AccentColour
{
get
{
return Disc.Colour;
}
set
{
Disc.Colour = value;
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 14,
Colour = value.Opacity(0.3f),
};
}
}
public SpinnerBackground()
{
RelativeSizeAxes = Axes.Both;
Masking = true;
Children = new Drawable[]
{
Disc = new Box
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Alpha = 1,
},
};
}
}
}

View File

@ -2,13 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
using osu.Game.Graphics;
@ -17,104 +12,31 @@ using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public class SpinnerDisc : CircularContainer
public class SpinnerDisc : CircularContainer, IHasAccentColour
{
protected Sprite Disc;
private readonly Spinner spinner;
public SRGBColour DiscColour
public Color4 AccentColour
{
get { return Disc.Colour; }
set { Disc.Colour = value; }
get { return background.AccentColour; }
set { background.AccentColour = value; }
}
private Color4 completeColour;
private readonly SpinnerBackground background;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private const float idle_alpha = 0.2f;
private const float tracking_alpha = 0.4f;
public SpinnerDisc(Spinner s)
{
completeColour = colours.YellowLight.Opacity(0.8f);
Masking = true;
}
spinner = s;
private class SpinnerBorder : Container
{
public SpinnerBorder()
{
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
layout();
}
private int lastLayoutDotCount;
private void layout()
{
int count = (int)(MathHelper.Pi * ScreenSpaceDrawQuad.Width / 9);
if (count == lastLayoutDotCount) return;
lastLayoutDotCount = count;
while (Children.Count() < count)
{
Add(new CircularContainer
{
Colour = Color4.White,
RelativePositionAxes = Axes.Both,
Masking = true,
Origin = Anchor.Centre,
Size = new Vector2(1 / ScreenSpaceDrawQuad.Width * 2000),
Children = new[]
{
new Box
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
}
}
});
}
var size = new Vector2(1 / ScreenSpaceDrawQuad.Width * 2000);
int i = 0;
foreach (var d in Children)
{
d.Size = size;
d.Position = new Vector2(
0.5f + (float)Math.Sin((float)i / count * 2 * MathHelper.Pi) / 2,
0.5f + (float)Math.Cos((float)i / count * 2 * MathHelper.Pi) / 2
);
i++;
}
}
protected override void Update()
{
base.Update();
layout();
}
}
public SpinnerDisc()
{
AlwaysReceiveInput = true;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
Disc = new Box
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Alpha = 0.2f,
},
new SpinnerBorder()
background = new SpinnerBackground { Alpha = idle_alpha },
};
}
@ -125,10 +47,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
set
{
if (value == tracking) return;
tracking = value;
Disc.FadeTo(tracking ? 0.5f : 0.2f, 100);
background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
}
}
@ -139,31 +60,28 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
set
{
if (value == complete) return;
complete = value;
Disc.FadeColour(completeColour, 200);
updateCompleteTick();
}
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
Tracking = true;
Tracking |= state.Mouse.HasMainButtonPressed;
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
Tracking = false;
Tracking &= state.Mouse.HasMainButtonPressed;
return base.OnMouseUp(state, args);
}
protected override bool OnMouseMove(InputState state)
{
Tracking |= state.Mouse.HasMainButtonPressed;
mousePosition = state.Mouse.Position;
mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position);
return base.OnMouseMove(state);
}
@ -177,13 +95,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 360));
private bool rotationTransferred;
protected override void Update()
{
base.Update();
var thisAngle = -(float)MathHelper.RadiansToDegrees(Math.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
if (tracking)
bool validAndTracking = tracking && spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;
if (validAndTracking)
{
if (!rotationTransferred)
{
currentRotation = Rotation * 2;
rotationTransferred = true;
}
if (thisAngle - lastAngle > 180)
lastAngle += 360;
else if (lastAngle - thisAngle > 180)
@ -192,17 +121,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
currentRotation += thisAngle - lastAngle;
RotationAbsolute += Math.Abs(thisAngle - lastAngle);
}
lastAngle = thisAngle;
if (Complete && updateCompleteTick())
{
Disc.Flush(flushType: typeof(TransformAlpha));
Disc.FadeTo(0.75f, 30, EasingTypes.OutExpo);
Disc.Delay(30);
Disc.FadeTo(0.5f, 250, EasingTypes.OutQuint);
background.Flush(flushType: typeof(TransformAlpha));
background.FadeTo(tracking_alpha + 0.4f, 60, EasingTypes.OutExpo);
background.Delay(60);
background.FadeTo(tracking_alpha, 250, EasingTypes.OutQuint);
}
RotateTo(currentRotation, 100, EasingTypes.OutExpo);
RotateTo(currentRotation / 2, validAndTracking ? 500 : 1500, EasingTypes.OutExpo);
}
}
}

View File

@ -0,0 +1,71 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public class SpinnerTicks : Container
{
private Color4 glowColour;
public SpinnerTicks()
{
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
glowColour = colours.BlueDarker.Opacity(0.4f);
layout();
}
private void layout()
{
const int count = 18;
for (int i = 0; i < count; i++)
{
Add(new Container
{
Colour = Color4.Black,
Alpha = 0.4f,
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
Radius = 20,
Colour = glowColour,
},
RelativePositionAxes = Axes.Both,
Masking = true,
CornerRadius = 5,
Size = new Vector2(60, 10),
Origin = Anchor.Centre,
Position = new Vector2(
0.5f + (float)Math.Sin((float)i / count * 2 * MathHelper.Pi) / 2 * 0.86f,
0.5f + (float)Math.Cos((float)i / count * 2 * MathHelper.Pi) / 2 * 0.86f
),
Rotation = -(float)i / count * 360 + 90,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
}
}
});
}
}
}
}

View File

@ -91,25 +91,25 @@ namespace osu.Game.Rulesets.Osu.Replays
// Make the cursor stay at a hitObject as long as possible (mainly for autopilot).
if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)
{
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.Position.X, h.Position.Y, ReplayButtonState.None));
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Miss), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None));
}
else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50) > endTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)
{
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.Position.X, h.Position.Y, ReplayButtonState.None));
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit50), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit50), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None));
}
else if (h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100) > endTime + h.HitWindowFor(OsuScoreResult.Hit100) + 50)
{
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.EndPosition.X, prev.EndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.Position.X, h.Position.Y, ReplayButtonState.None));
if (!(prev is Spinner) && h.StartTime - endTime < 1000) AddFrameToReplay(new ReplayFrame(endTime + h.HitWindowFor(OsuScoreResult.Hit100), prev.StackedEndPosition.X, prev.StackedEndPosition.Y, ReplayButtonState.None));
if (!(h is Spinner)) AddFrameToReplay(new ReplayFrame(h.StartTime - h.HitWindowFor(OsuScoreResult.Hit100), h.StackedPosition.X, h.StackedPosition.Y, ReplayButtonState.None));
}
}
private void addHitObjectReplay(OsuHitObject h)
{
// Default values for circles/sliders
Vector2 startPosition = h.Position;
Vector2 startPosition = h.StackedPosition;
EasingTypes easing = preferredEasing;
float spinnerDirection = -1;
@ -238,7 +238,7 @@ namespace osu.Game.Rulesets.Osu.Replays
// TODO: Why do we delay 1 ms if the object is a spinner? There already is KEY_UP_DELAY from hEndTime.
double hEndTime = ((h as IHasEndTime)?.EndTime ?? h.StartTime) + KEY_UP_DELAY;
int endDelay = h is Spinner ? 1 : 0;
ReplayFrame endFrame = new ReplayFrame(hEndTime + endDelay, h.EndPosition.X, h.EndPosition.Y, ReplayButtonState.None);
ReplayFrame endFrame = new ReplayFrame(hEndTime + endDelay, h.StackedEndPosition.X, h.StackedEndPosition.Y, ReplayButtonState.None);
// Decrement because we want the previous frame, not the next one
int index = FindInsertionIndex(startFrame) - 1;

View File

@ -64,6 +64,7 @@
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBouncer.cs" />
<Compile Include="Objects\Drawables\Pieces\SpinnerDisc.cs" />
<Compile Include="Objects\Drawables\Pieces\SpinnerTicks.cs" />
<Compile Include="Objects\Drawables\Pieces\TrianglesPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
@ -103,9 +104,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Replays\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -26,6 +26,7 @@ namespace osu.Game.Database
public string[] SearchableTerms => new[]
{
Author,
Artist,
ArtistUnicode,
Title,

View File

@ -87,5 +87,8 @@ namespace osu.Game.Graphics
public readonly Color4 RedDarker = FromHex(@"870000");
public readonly Color4 ChatBlue = FromHex(@"17292e");
public readonly Color4 SpinnerBase = FromHex(@"002c3c");
public readonly Color4 SpinnerFill = FromHex(@"005b7c");
}
}

View File

@ -16,6 +16,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using System;
using System.Linq;
using osu.Game.Graphics;
namespace osu.Game.Overlays.Mods
{
@ -23,7 +24,7 @@ namespace osu.Game.Overlays.Mods
/// <summary>
/// Represents a clickable button which can cycle through one of more mods.
/// </summary>
public class ModButton : ModButtonEmpty
public class ModButton : ModButtonEmpty, IHasTooltip
{
private ModIcon foregroundIcon;
private readonly SpriteText text;
@ -32,6 +33,8 @@ namespace osu.Game.Overlays.Mods
public Action<Mod> Action; // Passed the selected mod or null if none
public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty;
private int _selectedIndex = -1;
private int selectedIndex
{

View File

@ -7,10 +7,10 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
namespace osu.Game.Overlays.Music
{
@ -19,9 +19,13 @@ namespace osu.Game.Overlays.Music
private const float fade_duration = 100;
private Color4 hoverColour;
private Color4 artistColour;
private TextAwesome handle;
private OsuSpriteText title;
private Paragraph text;
private IEnumerable<SpriteText> titleSprites;
private UnicodeBindableString titleBind;
private UnicodeBindableString artistBind;
public readonly BeatmapSetInfo BeatmapSetInfo;
@ -37,7 +41,8 @@ namespace osu.Game.Overlays.Music
selected = value;
Flush(true);
title.FadeColour(Selected ? hoverColour : Color4.White, fade_duration);
foreach (SpriteText s in titleSprites)
s.FadeColour(Selected ? hoverColour : Color4.White, fade_duration);
}
}
@ -53,8 +58,10 @@ namespace osu.Game.Overlays.Music
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation)
{
BeatmapMetadata metadata = BeatmapSetInfo.Metadata;
hoverColour = colours.Yellow;
artistColour = colours.Gray9;
var metadata = BeatmapSetInfo.Metadata;
FilterTerms = metadata.SearchableTerms;
Children = new Drawable[]
@ -70,33 +77,40 @@ namespace osu.Game.Overlays.Music
Margin = new MarginPadding { Left = 5 },
Padding = new MarginPadding { Top = 2 },
},
new FillFlowContainer<OsuSpriteText>
text = new Paragraph
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = 20 },
Spacing = new Vector2(5f, 0f),
Children = new []
{
title = new OsuSpriteText
{
TextSize = 16,
Font = @"Exo2.0-Regular",
Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title),
},
new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-Bold",
Colour = colours.Gray9,
Padding = new MarginPadding { Top = 1 },
Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist),
}
}
ContentIndent = 10f,
},
};
hoverColour = colours.Yellow;
titleBind = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
artistBind.ValueChanged += newText => recreateText();
artistBind.TriggerChange();
}
private void recreateText()
{
text.Clear();
//space after the title to put a space between the title and artist
titleSprites = text.AddText(titleBind.Value + @" ", sprite =>
{
sprite.TextSize = 16;
sprite.Font = @"Exo2.0-Regular";
});
text.AddText(artistBind.Value, sprite =>
{
sprite.TextSize = 14;
sprite.Font = @"Exo2.0-Bold";
sprite.Colour = artistColour;
sprite.Padding = new MarginPadding { Top = 1 };
});
}
protected override bool OnHover(Framework.Input.InputState state)

View File

@ -76,6 +76,7 @@ namespace osu.Game.Overlays
{
TextSize = 24,
Font = @"Exo2.0-Light",
Padding = new MarginPadding { Left = 10, Right = 10 },
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
},
@ -116,7 +117,7 @@ namespace osu.Game.Overlays
private void load(FrameworkConfigManager frameworkConfig)
{
trackSetting(frameworkConfig.GetBindable<FrameSync>(FrameworkSetting.FrameSync), v => display(v, "Frame Limiter", v.GetDescription(), "Ctrl+F7"));
trackSetting(frameworkConfig.GetBindable<string>(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", v, v));
trackSetting(frameworkConfig.GetBindable<string>(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", string.IsNullOrEmpty(v) ? "Default" : v, v));
trackSetting(frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay), v => display(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10"));
Action displayResolution = delegate { display(null, "Screen Resolution", frameworkConfig.Get<int>(FrameworkSetting.Width) + "x" + frameworkConfig.Get<int>(FrameworkSetting.Height)); };

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
new SettingsEnumDropdown<GCLatencyMode>
{
LabelText = "Active mode",
Bindable = config.GetBindable<GCLatencyMode>(FrameworkDebugConfig.ActiveGCMode)
Bindable = config.GetBindable<GCLatencyMode>(DebugSetting.ActiveGCMode)
},
new OsuButton
{

View File

@ -12,14 +12,19 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
protected override string Header => "General";
[BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config)
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig)
{
Children = new Drawable[]
{
new SettingsCheckbox
{
LabelText = "Bypass caching",
Bindable = config.GetBindable<bool>(FrameworkDebugConfig.BypassCaching)
Bindable = config.GetBindable<bool>(DebugSetting.BypassCaching)
},
new SettingsCheckbox
{
LabelText = "Debug logs",
Bindable = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowLogOverlay)
}
};
}

View File

@ -63,8 +63,6 @@ namespace osu.Game.Screens.Play
#endregion
private SkipButton skipButton;
private HUDOverlay hudOverlay;
private FailOverlay failOverlay;
@ -162,6 +160,7 @@ namespace osu.Game.Screens.Play
},
Children = new Drawable[]
{
new SkipButton(firstObjectTime) { AudioClock = decoupledClock },
new Container
{
RelativeSizeAxes = Axes.Both,
@ -169,11 +168,6 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
HitRenderer,
skipButton = new SkipButton
{
Alpha = 0,
Margin = new MarginPadding { Bottom = 140 } // this is temporary
},
}
},
hudOverlay = new StandardHUDOverlay
@ -219,33 +213,6 @@ namespace osu.Game.Screens.Play
scoreProcessor.Failed += onFail;
}
private void initializeSkipButton()
{
const double skip_required_cutoff = 3000;
const double fade_time = 300;
double firstHitObject = Beatmap.Beatmap.HitObjects.First().StartTime;
if (firstHitObject < skip_required_cutoff)
{
skipButton.Alpha = 0;
skipButton.Expire();
return;
}
skipButton.FadeInFromZero(fade_time);
skipButton.Action = () =>
{
decoupledClock.Seek(firstHitObject - skip_required_cutoff - fade_time);
skipButton.Action = null;
};
skipButton.Delay(firstHitObject - skip_required_cutoff - fade_time);
skipButton.FadeOut(fade_time);
skipButton.Expire();
}
public void Restart()
{
ValidForResume = false;
@ -263,7 +230,8 @@ namespace osu.Game.Screens.Play
ValidForResume = false;
Delay(1000);
using (BeginDelayedSequence(1000))
{
onCompletionEvent = Schedule(delegate
{
var score = new Score
@ -276,6 +244,7 @@ namespace osu.Game.Screens.Play
Push(new Results(score));
});
}
}
private void onFail()
{
@ -299,16 +268,17 @@ namespace osu.Game.Screens.Play
Content.ScaleTo(0.7f);
Content.Delay(250);
using (Content.BeginDelayedSequence(250))
Content.FadeIn(250);
Content.ScaleTo(1, 750, EasingTypes.OutQuint);
Delay(750);
using (BeginDelayedSequence(750))
Schedule(() =>
{
if (!pauseContainer.IsPaused)
decoupledClock.Start();
initializeSkipButton();
});
pauseContainer.Alpha = 0;

View File

@ -1,32 +1,123 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Framework.Threading;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Ranking;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Audio.Sample;
namespace osu.Game.Screens.Play
{
public class SkipButton : TwoLayerButton
public class SkipButton : Container
{
public SkipButton()
private readonly double startTime;
public IAdjustableClock AudioClock;
private Button button;
private Box remainingTimeBox;
private FadeContainer fadeContainer;
private double displayTime;
public SkipButton(double startTime)
{
Text = @"Skip";
Icon = FontAwesome.fa_osu_right_o;
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
AlwaysReceiveInput = true;
this.startTime = startTime;
RelativePositionAxes = Axes.Both;
RelativeSizeAxes = Axes.Both;
Position = new Vector2(0.5f, 0.7f);
Size = new Vector2(1, 0.14f);
Origin = Anchor.Centre;
}
protected override bool OnMouseMove(InputState state)
{
fadeContainer.State = Visibility.Visible;
return base.OnMouseMove(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours)
private void load(OsuColour colours)
{
ActivationSound = audio.Sample.Get(@"Menu/menuhit");
BackgroundColour = colours.Yellow;
HoverColour = colours.YellowDark;
var baseClock = Clock;
if (AudioClock != null)
Clock = new FramedClock(AudioClock) { ProcessSourceClockFrames = false };
Children = new Drawable[]
{
fadeContainer = new FadeContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
button = new Button
{
Clock = baseClock,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
remainingTimeBox = new Box
{
Height = 5,
RelativeSizeAxes = Axes.X,
Colour = colours.Yellow,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
}
}
}
};
}
private const double skip_required_cutoff = 3000;
private const double fade_time = 300;
private double beginFadeTime => startTime - skip_required_cutoff - fade_time;
protected override void LoadComplete()
{
base.LoadComplete();
if (startTime < skip_required_cutoff)
{
Alpha = 0;
Expire();
return;
}
FadeInFromZero(fade_time);
using (BeginAbsoluteSequence(beginFadeTime))
FadeOut(fade_time);
button.Action = () => AudioClock?.Seek(startTime - skip_required_cutoff - fade_time);
displayTime = Time.Current;
Expire();
}
protected override void Update()
{
base.Update();
remainingTimeBox.ResizeWidthTo((float)Math.Max(0, 1 - (Time.Current - displayTime) / (beginFadeTime - displayTime)), 120, EasingTypes.OutQuint);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
@ -36,11 +127,171 @@ namespace osu.Game.Screens.Play
switch (args.Key)
{
case Key.Space:
TriggerClick();
button.TriggerClick();
return true;
}
return base.OnKeyDown(state, args);
}
private class FadeContainer : Container, IStateful<Visibility>
{
private Visibility state;
private ScheduledDelegate scheduledHide;
public Visibility State
{
get
{
return state;
}
set
{
var lastState = state;
state = value;
scheduledHide?.Cancel();
switch (state)
{
case Visibility.Visible:
if (lastState == Visibility.Hidden)
FadeIn(500, EasingTypes.OutExpo);
if (!Hovering)
using (BeginDelayedSequence(1000))
scheduledHide = Schedule(() => State = Visibility.Hidden);
break;
case Visibility.Hidden:
FadeOut(1000, EasingTypes.OutExpo);
break;
}
}
}
protected override void LoadComplete()
{
base.LoadComplete();
State = Visibility.Visible;
}
}
private class Button : Container
{
public Action Action;
private Color4 colourNormal;
private Color4 colourHover;
private Box box;
private FillFlowContainer flow;
private Box background;
private AspectContainer aspect;
private SampleChannel activationSound;
public Button()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
activationSound = audio.Sample.Get(@"Menu/menuhit");
colourNormal = colours.Yellow;
colourHover = colours.YellowDark;
Children = new Drawable[]
{
background = new Box
{
Alpha = 0.2f,
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
aspect = new AspectContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Height = 0.6f,
Masking = true,
CornerRadius = 15,
Children = new Drawable[]
{
box = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourNormal,
},
flow = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
RelativePositionAxes = Axes.Y,
Y = 0.4f,
AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new []
{
new TextAwesome { Icon = FontAwesome.fa_chevron_right },
new TextAwesome { Icon = FontAwesome.fa_chevron_right },
new TextAwesome { Icon = FontAwesome.fa_chevron_right },
}
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
RelativePositionAxes = Axes.Y,
Y = 0.7f,
TextSize = 12,
Font = @"Exo2.0-Bold",
Origin = Anchor.Centre,
Text = @"SKIP",
},
}
}
};
}
protected override bool OnHover(InputState state)
{
flow.TransformSpacingTo(new Vector2(5), 500, EasingTypes.OutQuint);
box.FadeColour(colourHover, 500, EasingTypes.OutQuint);
background.FadeTo(0.4f, 500, EasingTypes.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
flow.TransformSpacingTo(new Vector2(0), 500, EasingTypes.OutQuint);
box.FadeColour(colourNormal, 500, EasingTypes.OutQuint);
background.FadeTo(0.2f, 500, EasingTypes.OutQuint);
base.OnHoverLost(state);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
aspect.ScaleTo(0.75f, 2000, EasingTypes.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
aspect.ScaleTo(1, 1000, EasingTypes.OutElastic);
return base.OnMouseUp(state, args);
}
protected override bool OnClick(InputState state)
{
Action?.Invoke();
activationSound.Play();
box.FlashColour(Color4.White, 500, EasingTypes.OutQuint);
aspect.ScaleTo(1.2f, 2000, EasingTypes.OutQuint);
return true;
}
}
}
}

View File

@ -198,8 +198,11 @@ namespace osu.Game.Screens.Select
var pendingSelection = selectionChangedDebounce;
selectionChangedDebounce = null;
if (pendingSelection?.Completed == false)
{
pendingSelection?.RunTask();
pendingSelection?.Cancel(); // cancel the already scheduled task.
}
if (Beatmap == null) return;