1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

Merge branch 'api-chat-read' of https://github.com/Craftplacer/osu into api-chat-read

This commit is contained in:
Craftplacer 2020-01-11 19:47:40 +01:00
commit 5d5c635b1b
145 changed files with 971 additions and 569 deletions

View File

@ -54,6 +54,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1227.1" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.111.0" />
</ItemGroup>
</Project>

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Mods;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;

View File

@ -135,6 +135,8 @@ namespace osu.Game.Rulesets.Catch
public override string ShortName => SHORT_NAME;
public override string PlayingVerb => "Catching fruit";
public override Drawable CreateIcon() => new SpriteIcon { Icon = OsuIcon.RulesetCatch };
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(this, beatmap);

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 0;
case HitResult.Perfect:
return 0.008;
return 0.01;
}
}

View File

@ -18,17 +18,5 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 30;
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return base.HealthIncreaseFor(result);
case HitResult.Perfect:
return 0.007;
}
}
}
}

View File

@ -23,18 +23,6 @@ namespace osu.Game.Rulesets.Catch.Judgements
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
default:
return -0.02;
case HitResult.Perfect:
return 0.01;
}
}
/// <summary>
/// Whether fruit on the platter should explode or drop.
/// Note that this is only checked if the owning object is also <see cref="IHasComboInformation.LastInCombo" />

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Judgements
return 0;
case HitResult.Perfect:
return 0.004;
return 0.02;
}
}
}

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Objects.Drawable.Pieces;
using osuTK;
using osuTK.Graphics;

View File

@ -3,7 +3,7 @@
using System;
using System.Linq;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Catch.Beatmaps;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Input.StateChanges;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;

View File

@ -7,7 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;

View File

@ -5,7 +5,7 @@ using osu.Game.Rulesets.Mania.Objects;
using System;
using System.Linq;
using System.Collections.Generic;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.MathUtils;

View File

@ -15,11 +15,11 @@ namespace osu.Game.Rulesets.Mania.Judgements
{
switch (result)
{
case HitResult.Miss:
default:
return 0;
default:
return 0.040;
case HitResult.Perfect:
return 0.01;
}
}
}

View File

@ -29,32 +29,5 @@ namespace osu.Game.Rulesets.Mania.Judgements
return 300;
}
}
protected override double HealthIncreaseFor(HitResult result)
{
switch (result)
{
case HitResult.Miss:
return -0.125;
case HitResult.Meh:
return 0.005;
case HitResult.Ok:
return 0.010;
case HitResult.Good:
return 0.035;
case HitResult.Great:
return 0.055;
case HitResult.Perfect:
return 0.065;
default:
return 0;
}
}
}
}

View File

@ -179,6 +179,8 @@ namespace osu.Game.Rulesets.Mania
public override string ShortName => SHORT_NAME;
public override string PlayingVerb => "Smashing keys";
public override Drawable CreateIcon() => new SpriteIcon { Icon = OsuIcon.RulesetMania };
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new ManiaDifficultyCalculator(this, beatmap);

View File

@ -4,7 +4,7 @@
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Beatmaps;

View File

@ -1,68 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
{
public class GlowPiece : CompositeDrawable, IHasAccentColour
{
private const float glow_alpha = 0.7f;
private const float glow_radius = 5;
public GlowPiece()
{
RelativeSizeAxes = Axes.Both;
Masking = true;
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
};
}
protected override void LoadComplete()
{
base.LoadComplete();
updateGlow();
}
private Color4 accentColour;
public Color4 AccentColour
{
get => accentColour;
set
{
if (accentColour == value)
return;
accentColour = value;
updateGlow();
}
}
private void updateGlow()
{
if (!IsLoaded)
return;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = AccentColour.Opacity(glow_alpha),
Radius = glow_radius,
Hollow = true
};
}
}
}

View File

@ -1,85 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
{
public class LaneGlowPiece : CompositeDrawable, IHasAccentColour
{
private const float total_height = 100;
private const float glow_height = 50;
private const float glow_alpha = 0.4f;
private const float edge_alpha = 0.3f;
public LaneGlowPiece()
{
BypassAutoSizeAxes = Axes.Both;
RelativeSizeAxes = Axes.X;
Height = total_height;
InternalChildren = new[]
{
new Container
{
Name = "Left edge",
RelativeSizeAxes = Axes.Y,
Width = 1,
Children = createGradient(edge_alpha)
},
new Container
{
Name = "Right edge",
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = 1,
Children = createGradient(edge_alpha)
},
new Container
{
Name = "Glow",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = glow_height,
Children = createGradient(glow_alpha)
}
};
}
private Drawable[] createGradient(float alpha) => new Drawable[]
{
new Box
{
Name = "Top",
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Blending = BlendingParameters.Additive,
Colour = ColourInfo.GradientVertical(Color4.Transparent, Color4.White.Opacity(alpha))
},
new Box
{
Name = "Bottom",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Blending = BlendingParameters.Additive,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(alpha), Color4.Transparent)
}
};
public Color4 AccentColour
{
get => Colour;
set => Colour = value;
}
}
}

View File

@ -18,8 +18,6 @@ namespace osu.Game.Rulesets.Mania.UI.Components
{
public class ColumnHitObjectArea : CompositeDrawable, IHasAccentColour
{
private const float hit_target_bar_height = 2;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly Drawable hitTarget;
@ -67,6 +65,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
private class DefaultHitTarget : CompositeDrawable, IHasAccentColour
{
private const float hit_target_bar_height = 2;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly Container hitTargetLine;

View File

@ -5,7 +5,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osuTK;
using osuTK.Graphics;

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Beatmaps;

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[BackgroundDependencyLoader]
private void load(AudioManager audio, SkinManager skinManager)
{
var dllStore = new DllResourceStore("osu.Game.Rulesets.Osu.Tests.dll");
var dllStore = new DllResourceStore(typeof(SkinnableTestScene).Assembly);
metricsSkin = new TestLegacySkin(new SkinInfo(), new NamespacedResourceStore<byte[]>(dllStore, "Resources/metrics_skin"), audio, true);
defaultSkin = skinManager.GetSkin(DefaultLegacySkin.Info);

View File

@ -9,7 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Beatmaps;

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects;

View File

@ -4,7 +4,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<PropertyGroup Label="Project">

View File

@ -8,7 +8,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;

View File

@ -7,7 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Scoring;
@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
break;
}
float aimRotation = MathHelper.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
float aimRotation = MathUtils.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
while (Math.Abs(aimRotation - Rotation) > 180)
aimRotation += aimRotation < Rotation ? 360 : -360;

View File

@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private void setRange(double p0, double p1)
{
if (p0 > p1)
MathHelper.Swap(ref p0, ref p1);
(p0, p1) = (p1, p0);
if (SnakedStart == p0 && SnakedEnd == p1) return;

View File

@ -8,6 +8,7 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Utils;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
@ -93,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
base.Update();
var thisAngle = -(float)MathHelper.RadiansToDegrees(Math.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
var thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
bool validAndTracking = tracking && spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;

View File

@ -175,6 +175,8 @@ namespace osu.Game.Rulesets.Osu
public override string ShortName => SHORT_NAME;
public override string PlayingVerb => "Clicking circles";
public override RulesetSettingsSubsection CreateSettings() => new OsuSettingsSubsection(this);
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new OsuLegacySkinTransformer(source);

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osuTK;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using System;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Input.StateChanges;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;
using osuTK;

View File

@ -3,7 +3,7 @@
using System;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osuTK.Graphics;

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Tests.Beatmaps;

View File

@ -7,7 +7,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;

View File

@ -4,7 +4,7 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;

View File

@ -121,41 +121,13 @@ namespace osu.Game.Rulesets.Taiko.Replays
var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button
bool canDelayKeyUp = nextHitObject == null || nextHitObject.StartTime > endTime + KEY_UP_DELAY;
double calculatedDelay = canDelayKeyUp ? KEY_UP_DELAY : (nextHitObject.StartTime - endTime) * 0.9;
Frames.Add(new TaikoReplayFrame(endTime + calculatedDelay));
if (i < Beatmap.HitObjects.Count - 1)
{
double waitTime = Beatmap.HitObjects[i + 1].StartTime - 1000;
if (waitTime > endTime)
Frames.Add(new TaikoReplayFrame(waitTime));
}
hitButton = !hitButton;
}
return Replay;
}
protected override HitObject GetNextObject(int currentIndex)
{
Type desiredType = Beatmap.HitObjects[currentIndex].GetType();
for (int i = currentIndex + 1; i < Beatmap.HitObjects.Count; i++)
{
var currentObj = Beatmap.HitObjects[i];
if (currentObj.GetType() == desiredType ||
// Un-press all keys before a DrumRoll or Swell
currentObj is DrumRoll || currentObj is Swell)
{
return Beatmap.HitObjects[i];
}
}
return null;
}
}
}

View File

@ -139,6 +139,8 @@ namespace osu.Game.Rulesets.Taiko
public override string ShortName => SHORT_NAME;
public override string PlayingVerb => "Bashing drums";
public override Drawable CreateIcon() => new SpriteIcon { Icon = OsuIcon.RulesetTaiko };
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new TaikoDifficultyCalculator(this, beatmap);

View File

@ -4,7 +4,7 @@
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;

View File

@ -8,6 +8,7 @@ using NUnit.Framework;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Skinning;
using osu.Game.Tests.Resources;
@ -15,6 +16,7 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Gameplay
{
[HeadlessTest]
public class TestSceneStoryboardSamples : OsuTestScene
{
[Test]

View File

@ -0,0 +1,51 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Notifications;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Online
{
[HeadlessTest]
public class TestSceneBeatmapManager : OsuTestScene
{
private BeatmapManager beatmaps;
private ProgressNotification recentNotification;
private static readonly BeatmapSetInfo test_model = new BeatmapSetInfo { OnlineBeatmapSetID = 1 };
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps)
{
this.beatmaps = beatmaps;
beatmaps.PostNotification = n => recentNotification = n as ProgressNotification;
}
[Test]
public void TestCancelDownloadFromRequest()
{
AddStep("download beatmap", () => beatmaps.Download(test_model));
AddStep("cancel download from request", () => beatmaps.GetExistingDownload(test_model).Cancel());
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
}
[Test]
public void TestCancelDownloadFromNotification()
{
AddStep("download beatmap", () => beatmaps.Download(test_model));
AddStep("cancel download from notification", () => recentNotification.Close());
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_model) == null);
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
}
}
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Tests.Resources
{
public static class TestResources
{
public static DllResourceStore GetStore() => new DllResourceStore("osu.Game.Tests.dll");
public static DllResourceStore GetStore() => new DllResourceStore(typeof(TestResources).Assembly);
public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}");

View File

@ -7,7 +7,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Testing;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;

View File

@ -6,7 +6,7 @@ using osu.Game.Rulesets.Objects;
using System;
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;

View File

@ -7,7 +7,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Screens.Play;
using osuTK.Input;

View File

@ -5,7 +5,7 @@ using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu;

View File

@ -12,7 +12,7 @@ using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
@ -146,6 +146,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player mods applied", () => playerMod2.Applied);
}
[Test]
public void TestModDisplayChanges()
{
var testMod = new TestMod();
AddStep("load player", () => ResetPlayer(true));
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
AddStep("set test mod in loader", () => loader.Mods.Value = new[] { testMod });
AddAssert("test mod is displayed", () => (TestMod)loader.DisplayedMods.Single() == testMod);
}
[Test]
public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault);
@ -221,6 +233,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Task DisposalTask => base.DisposalTask;
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods.Value;
public TestPlayerLoader(Func<Player> createPlayer)
: base(createPlayer)
{

View File

@ -4,7 +4,7 @@
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play.HUD;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Play;

View File

@ -7,7 +7,7 @@ using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Match.Components;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Framework.Allocation;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Screens.Select.Details;

View File

@ -8,7 +8,7 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Screens.Select.Details;

View File

@ -9,7 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osu.Game.Overlays.Chat.Tabs;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets.Osu.Mods;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Overlays.Comments;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
namespace osu.Game.Tests.Visual.Online
{

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(ProfileHeader),
typeof(RankGraph),
typeof(LineGraph),
typeof(OverlayHeaderTabControl),
typeof(TabControlOverlayHeader.OverlayHeaderTabControl),
typeof(CentreHeaderContainer),
typeof(BottomHeaderContainer),
typeof(DetailHeaderContainer),

View File

@ -3,10 +3,13 @@
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Online.Placeholders;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
@ -28,8 +31,16 @@ namespace osu.Game.Tests.Visual.SongSelect
private readonly FailableLeaderboard leaderboard;
[Cached]
private readonly DialogOverlay dialogOverlay;
public TestSceneBeatmapLeaderboard()
{
Add(dialogOverlay = new DialogOverlay
{
Depth = -1
});
Add(leaderboard = new FailableLeaderboard
{
Origin = Anchor.Centre,

View File

@ -11,7 +11,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Beatmaps;

View File

@ -1,11 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Scoring;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Select.Leaderboards;
@ -15,10 +17,18 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public class TestSceneUserTopScoreContainer : OsuTestScene
{
[Cached]
private readonly DialogOverlay dialogOverlay;
public TestSceneUserTopScoreContainer()
{
UserTopScoreContainer topScoreContainer;
Add(dialogOverlay = new DialogOverlay
{
Depth = -1
});
Add(new Container
{
Origin = Anchor.BottomCentre,

View File

@ -10,11 +10,11 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public class TestSceneBreadcrumbs : OsuTestScene
public class TestSceneBreadcrumbControl : OsuTestScene
{
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
public TestSceneBreadcrumbs()
public TestSceneBreadcrumbControl()
{
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
{

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites;
using osuTK;

View File

@ -0,0 +1,181 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Leaderboards;
using osu.Game.Online.Placeholders;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Tests.Resources;
using osu.Game.Users;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneDeleteLocalScore : ManualInputManagerTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(Placeholder),
typeof(MessagePlaceholder),
typeof(RetrievalFailurePlaceholder),
typeof(UserTopScoreContainer),
typeof(Leaderboard<BeatmapLeaderboardScope, ScoreInfo>),
typeof(LeaderboardScore),
};
private readonly ContextMenuContainer contextMenuContainer;
private readonly BeatmapLeaderboard leaderboard;
private RulesetStore rulesetStore;
private BeatmapManager beatmapManager;
private ScoreManager scoreManager;
private readonly List<ScoreInfo> scores = new List<ScoreInfo>();
private BeatmapInfo beatmap;
[Cached]
private readonly DialogOverlay dialogOverlay;
public TestSceneDeleteLocalScore()
{
Children = new Drawable[]
{
contextMenuContainer = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Child = leaderboard = new BeatmapLeaderboard
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f),
Scope = BeatmapLeaderboardScope.Local,
Beatmap = new BeatmapInfo
{
ID = 1,
Metadata = new BeatmapMetadata
{
ID = 1,
Title = "TestSong",
Artist = "TestArtist",
Author = new User
{
Username = "TestAuthor"
},
},
Version = "Insane"
},
}
},
dialogOverlay = new DialogOverlay()
};
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, Audio, dependencies.Get<GameHost>(), Beatmap.Default));
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory));
beatmap = beatmapManager.Import(TestResources.GetTestBeatmapForImport()).Result.Beatmaps[0];
for (int i = 0; i < 50; i++)
{
var score = new ScoreInfo
{
OnlineScoreID = i,
Beatmap = beatmap,
BeatmapInfoID = beatmap.ID,
Accuracy = RNG.NextDouble(),
TotalScore = RNG.Next(1, 1000000),
MaxCombo = RNG.Next(1, 1000),
Rank = ScoreRank.XH,
User = new User { Username = "TestUser" },
};
scores.Add(scoreManager.Import(score).Result);
}
scores.Sort(Comparer<ScoreInfo>.Create((s1, s2) => s2.TotalScore.CompareTo(s1.TotalScore)));
return dependencies;
}
[SetUp]
public void Setup() => Schedule(() =>
{
// Due to soft deletions, we can re-use deleted scores between test runs
scoreManager.Undelete(scoreManager.QueryScores(s => s.DeletePending).ToList());
leaderboard.Scores = null;
leaderboard.FinishTransforms(true); // After setting scores, we may be waiting for transforms to expire drawables
leaderboard.Beatmap = beatmap;
leaderboard.RefreshScores(); // Required in the case that the beatmap hasn't changed
});
[SetUpSteps]
public void SetupSteps()
{
// Ensure the leaderboard has finished async-loading drawables
AddUntilStep("wait for drawables", () => leaderboard.ChildrenOfType<LeaderboardScore>().Any());
// Ensure the leaderboard items have finished showing up
AddStep("finish transforms", () => leaderboard.FinishTransforms(true));
}
[Test]
public void TestDeleteViaRightClick()
{
AddStep("open menu for top score", () =>
{
InputManager.MoveMouseTo(leaderboard.ChildrenOfType<LeaderboardScore>().First());
InputManager.Click(MouseButton.Right);
});
// Ensure the context menu has finished showing
AddStep("finish transforms", () => contextMenuContainer.FinishTransforms(true));
AddStep("click delete option", () =>
{
InputManager.MoveMouseTo(contextMenuContainer.ChildrenOfType<DrawableOsuMenuItem>().First(i => i.Item.Text.Value.ToLowerInvariant() == "delete"));
InputManager.Click(MouseButton.Left);
});
// Ensure the dialog has finished showing
AddStep("finish transforms", () => dialogOverlay.FinishTransforms(true));
AddStep("click delete button", () =>
{
InputManager.MoveMouseTo(dialogOverlay.ChildrenOfType<DialogButton>().First());
InputManager.Click(MouseButton.Left);
});
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scores[0].OnlineScoreID));
}
[Test]
public void TestDeleteViaDatabase()
{
AddStep("delete top score", () => scoreManager.Delete(scores[0]));
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scores[0].OnlineScoreID));
}
}
}

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Menu;

View File

@ -8,7 +8,7 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;

View File

@ -4,8 +4,10 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.UserInterface
{
@ -15,22 +17,48 @@ namespace osu.Game.Tests.Visual.UserInterface
[Cached]
private MusicController musicController = new MusicController();
public TestSceneNowPlayingOverlay()
{
Clock = new FramedClock();
private WorkingBeatmap currentBeatmap;
var np = new NowPlayingOverlay
private NowPlayingOverlay nowPlayingOverlay;
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
nowPlayingOverlay = new NowPlayingOverlay
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre
};
Add(musicController);
Add(np);
Add(nowPlayingOverlay);
}
AddStep(@"show", () => np.Show());
[Test]
public void TestShowHideDisable()
{
AddStep(@"show", () => nowPlayingOverlay.Show());
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
AddStep(@"show", () => np.Hide());
AddStep(@"hide", () => nowPlayingOverlay.Hide());
}
[Test]
public void TestPrevTrackBehavior()
{
AddStep(@"Play track", () =>
{
musicController.NextTrack();
currentBeatmap = Beatmap.Value;
});
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
AddUntilStep(@"Wait for current time to update", () => currentBeatmap.Track.CurrentTime > 5000);
AddAssert(@"Check action is restart track", () => musicController.PreviousTrack() == PreviousTrackResult.Restart);
AddUntilStep("Wait for current time to update", () => Precision.AlmostEquals(currentBeatmap.Track.CurrentTime, 0));
AddAssert(@"Check track didn't change", () => currentBeatmap == Beatmap.Value);
AddAssert(@"Check action is not restart", () => musicController.PreviousTrack() != PreviousTrackResult.Restart);
}
}
}

View File

@ -9,7 +9,7 @@ using osu.Framework.Graphics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Rulesets;
namespace osu.Game.Tests.Visual.UserInterface

View File

@ -3,7 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Gameplay.Components;

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
namespace osu.Game.Tournament.Screens.Drawings.Components
{

View File

@ -52,7 +52,7 @@ namespace osu.Game.Tournament
[BackgroundDependencyLoader]
private void load(Storage storage, FrameworkConfigManager frameworkConfig)
{
Resources.AddStore(new DllResourceStore(@"osu.Game.Tournament.dll"));
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));
AddFont(Resources, @"Resources/Fonts/Aquatico-Regular");
AddFont(Resources, @"Resources/Fonts/Aquatico-Light");

View File

@ -48,11 +48,9 @@ namespace osu.Game.Beatmaps.Drawables
InternalChild = iconContainer = new Container { Size = new Vector2(20f) };
}
public string TooltipText { get; set; }
public ITooltip GetCustomTooltip() => new DifficultyIconTooltip();
public object TooltipContent { get; set; }
public object TooltipContent { get; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics;
using osu.Game.IO;
using osu.Game.Storyboards;
using osu.Game.Beatmaps.Legacy;
using osu.Framework.Utils;
namespace osu.Game.Beatmaps.Formats
{
@ -190,7 +191,7 @@ namespace osu.Game.Beatmaps.Formats
{
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathHelper.RadiansToDegrees(startValue), MathHelper.RadiansToDegrees(endValue));
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathUtils.RadiansToDegrees(startValue), MathUtils.RadiansToDegrees(endValue));
break;
}

View File

@ -92,8 +92,6 @@ namespace osu.Game.Database
notification.CancelRequested += () =>
{
request.Cancel();
currentDownloads.Remove(request);
notification.State = ProgressNotificationState.Cancelled;
return true;
};
@ -109,11 +107,11 @@ namespace osu.Game.Database
{
DownloadFailed?.Invoke(request);
if (error is OperationCanceledException) return;
notification.State = ProgressNotificationState.Cancelled;
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
currentDownloads.Remove(request);
notification.State = ProgressNotificationState.Cancelled;
if (!(error is OperationCanceledException))
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
}
}

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osuTK;
using osuTK.Graphics;
using System;
@ -29,8 +29,33 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
private const float edge_smoothness = 1;
public Color4 ColourLight = Color4.White;
public Color4 ColourDark = Color4.Black;
private Color4 colourLight = Color4.White;
public Color4 ColourLight
{
get => colourLight;
set
{
if (colourLight == value) return;
colourLight = value;
updateColours();
}
}
private Color4 colourDark = Color4.Black;
public Color4 ColourDark
{
get => colourDark;
set
{
if (colourDark == value) return;
colourDark = value;
updateColours();
}
}
/// <summary>
/// Whether we want to expire triangles as they exit our draw area completely.
@ -151,7 +176,8 @@ namespace osu.Game.Graphics.Backgrounds
TriangleParticle particle = CreateTriangle();
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
particle.Colour = CreateTriangleShade();
particle.ColourShade = RNG.NextSingle();
particle.Colour = CreateTriangleShade(particle.ColourShade);
return particle;
}
@ -177,7 +203,17 @@ namespace osu.Game.Graphics.Backgrounds
/// Creates a shade of colour for the triangles.
/// </summary>
/// <returns>The colour.</returns>
protected virtual Color4 CreateTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1);
protected virtual Color4 CreateTriangleShade(float shade) => Interpolation.ValueAt(shade, colourDark, colourLight, 0, 1);
private void updateColours()
{
for (int i = 0; i < parts.Count; i++)
{
TriangleParticle newParticle = parts[i];
newParticle.Colour = CreateTriangleShade(newParticle.ColourShade);
parts[i] = newParticle;
}
}
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
@ -264,6 +300,12 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
public Vector2 Position;
/// <summary>
/// The colour shade of the triangle.
/// This is needed for colour recalculation of visible triangles when <see cref="ColourDark"/> or <see cref="ColourLight"/> is changed.
/// </summary>
public float ColourShade;
/// <summary>
/// The colour of the triangle.
/// </summary>

View File

@ -4,7 +4,7 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Screens.Menu;
using osuTK;

View File

@ -123,8 +123,6 @@ namespace osu.Game.Graphics.Containers
Masking = true;
Child = box = new Box { RelativeSizeAxes = Axes.Both };
ResizeTo(1);
}
[BackgroundDependencyLoader]

View File

@ -9,7 +9,7 @@ using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
namespace osu.Game.Graphics.Containers
{

View File

@ -14,6 +14,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osuTK.Input;
using osu.Framework.Utils;
namespace osu.Game.Graphics.Cursor
{
@ -55,7 +56,7 @@ namespace osu.Game.Graphics.Cursor
if (dragRotationState == DragRotationState.Rotating && distance > 0)
{
Vector2 offset = e.MousePosition - positionMouseDown;
float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;
float degrees = MathUtils.RadiansToDegrees(MathF.Atan2(-offset.X, offset.Y)) + 24.3f;
// Always rotate in the direction of least distance
float diff = (degrees - activeCursor.Rotation) % 360;

View File

@ -15,14 +15,13 @@ namespace osu.Game.Graphics.UserInterface
public class BreadcrumbControl<T> : OsuTabControl<T>
{
private const float padding = 10;
private const float item_chevron_size = 10;
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value)
{
AccentColour = AccentColour,
};
protected override float StripWidth() => base.StripWidth() - (padding + item_chevron_size);
protected override float StripWidth => base.StripWidth - TabContainer.FirstOrDefault()?.Padding.Right ?? 0;
public BreadcrumbControl()
{
@ -41,8 +40,10 @@ namespace osu.Game.Graphics.UserInterface
};
}
private class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
{
protected virtual float ChevronSize => 10;
public event Action<Visibility> StateChanged;
public readonly SpriteIcon Chevron;
@ -90,12 +91,12 @@ namespace osu.Game.Graphics.UserInterface
{
Text.Font = Text.Font.With(size: 18);
Text.Margin = new MarginPadding { Vertical = 8 };
Padding = new MarginPadding { Right = padding + item_chevron_size };
Padding = new MarginPadding { Right = padding + ChevronSize };
Add(Chevron = new SpriteIcon
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
Size = new Vector2(item_chevron_size),
Size = new Vector2(ChevronSize),
Icon = FontAwesome.Solid.ChevronRight,
Margin = new MarginPadding { Left = padding },
Alpha = 0f,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.Color4Extensions;
using osuTK;
using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface
{
@ -41,5 +42,17 @@ namespace osu.Game.Graphics.UserInterface
this.FadeOut(transition_duration, Easing.OutQuint);
loading.Hide();
}
protected override bool Handle(UIEvent e)
{
switch (e)
{
// blocking scroll can cause weird behaviour when this layer is used within a ScrollContainer.
case ScrollEvent _:
return false;
}
return base.Handle(e);
}
}
}

View File

@ -15,7 +15,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
@ -28,8 +28,7 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
protected virtual float StripHeight() => 1;
protected virtual float StripWidth => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
/// <summary>
/// Whether entries should be automatically populated if <typeparamref name="T"/> is an <see cref="Enum"/> type.
@ -46,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Height = StripHeight(),
Height = 1,
Colour = Color4.White.Opacity(0),
});
@ -99,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface
// dont bother calculating if the strip is invisible
if (strip.Colour.MaxAlpha > 0)
strip.Width = Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, 1000), strip.Width, StripWidth(), 0, 500, Easing.OutQuint);
strip.Width = Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, 1000), strip.Width, StripWidth, 0, 500, Easing.OutQuint);
}
public class OsuTabItem : TabItem<T>, IHasAccentColour

View File

@ -4,7 +4,7 @@
using osuTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using System;
using System.Linq;
using osu.Framework.Graphics.Sprites;

View File

@ -32,6 +32,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleDirect),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),

View File

@ -14,7 +14,7 @@ namespace osu.Game.Online.API
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
public abstract class APIRequest<T> : APIRequest
{
protected override WebRequest CreateWebRequest() => new JsonWebRequest<T>(Uri);
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
public T Result => ((JsonWebRequest<T>)WebRequest).ResponseObject;
@ -30,6 +30,16 @@ namespace osu.Game.Online.API
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
/// </summary>
public new event APISuccessHandler<T> Success;
private class OsuJsonWebRequest<U> : JsonWebRequest<U>
{
public OsuJsonWebRequest(string uri)
: base(uri)
{
}
protected override string UserAgent => "osu!";
}
}
/// <summary>
@ -39,7 +49,7 @@ namespace osu.Game.Online.API
{
protected abstract string Target { get; }
protected virtual WebRequest CreateWebRequest() => new WebRequest(Uri);
protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
@ -152,6 +162,16 @@ namespace osu.Game.Online.API
[JsonProperty("error")]
public string ErrorMessage { get; set; }
}
private class OsuWebRequest : WebRequest
{
public OsuWebRequest(string uri)
: base(uri)
{
}
protected override string UserAgent => "osu!";
}
}
public class APIException : InvalidOperationException

View File

@ -12,8 +12,10 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.Placeholders;
using osuTK;
using osuTK.Graphics;
@ -150,7 +152,7 @@ namespace osu.Game.Online.Leaderboards
break;
case PlaceholderState.NotLoggedIn:
replacePlaceholder(new MessagePlaceholder(@"Please sign in to view online leaderboards!"));
replacePlaceholder(new LoginPlaceholder());
break;
case PlaceholderState.NotSupporter:
@ -180,10 +182,14 @@ namespace osu.Game.Online.Leaderboards
{
new Drawable[]
{
scrollContainer = new OsuScrollContainer
new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = scrollContainer = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
}
}
},
new Drawable[]

View File

@ -11,11 +11,15 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Select;
using osu.Game.Scoring;
using osu.Game.Users.Drawables;
using osuTK;
@ -25,7 +29,7 @@ using osu.Game.Online.API;
namespace osu.Game.Online.Leaderboards
{
public class LeaderboardScore : OsuClickableContainer
public class LeaderboardScore : OsuClickableContainer, IHasContextMenu
{
public const float HEIGHT = 60;
@ -51,6 +55,9 @@ namespace osu.Game.Online.Leaderboards
private List<ScoreComponentLabel> statisticsLabels;
[Resolved]
private DialogOverlay dialogOverlay { get; set; }
public LeaderboardScore(ScoreInfo score, int rank, bool allowHighlight = true)
{
this.score = score;
@ -359,5 +366,18 @@ namespace osu.Game.Online.Leaderboards
Value = value;
}
}
public MenuItem[] ContextMenuItems
{
get
{
List<MenuItem> items = new List<MenuItem>();
if (score.ID != 0)
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay?.Push(new LocalScoreDeleteDialog(score))));
return items.ToArray();
}
}
}
}

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Placeholders;
using osuTK;
namespace osu.Game.Online.Leaderboards

View File

@ -0,0 +1,46 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Overlays;
namespace osu.Game.Online.Placeholders
{
public sealed class LoginPlaceholder : Placeholder
{
[Resolved(CanBeNull = true)]
private LoginOverlay login { get; set; }
public LoginPlaceholder()
{
AddIcon(FontAwesome.Solid.UserLock, cp =>
{
cp.Font = cp.Font.With(size: TEXT_SIZE);
cp.Padding = new MarginPadding { Right = 10 };
});
AddText(@"Please sign in to view online leaderboards!");
}
protected override bool OnMouseDown(MouseDownEvent e)
{
this.ScaleTo(0.8f, 4000, Easing.OutQuint);
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
{
this.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(e);
}
protected override bool OnClick(ClickEvent e)
{
login?.Show();
return base.OnClick(e);
}
}
}

View File

@ -4,7 +4,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Online.Leaderboards
namespace osu.Game.Online.Placeholders
{
public class MessagePlaceholder : Placeholder
{

View File

@ -5,7 +5,7 @@ using System;
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Online.Leaderboards
namespace osu.Game.Online.Placeholders
{
public abstract class Placeholder : OsuTextFlowContainer, IEquatable<Placeholder>
{

View File

@ -29,6 +29,7 @@ using osu.Game.Database;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.IO;
using osu.Game.Resources;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
@ -125,7 +126,7 @@ namespace osu.Game
[BackgroundDependencyLoader]
private void load()
{
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));
Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly));
dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));

View File

@ -9,7 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Graphics;
@ -196,7 +196,7 @@ namespace osu.Game.Overlays.AccountCreation
return;
}
api.Login(emailTextBox.Text, passwordTextBox.Text);
api.Login(usernameTextBox.Text, passwordTextBox.Text);
});
});
}

View File

@ -0,0 +1,39 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays
{
public abstract class BreadcrumbControlOverlayHeader : OverlayHeader
{
protected OverlayHeaderBreadcrumbControl BreadcrumbControl;
protected override TabControl<string> CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl();
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
{
public OverlayHeaderBreadcrumbControl()
{
RelativeSizeAxes = Axes.X;
}
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value);
private class ControlTabItem : BreadcrumbTabItem
{
protected override float ChevronSize => 8;
public ControlTabItem(string value)
: base(value)
{
Text.Font = Text.Font.With(size: 14);
Chevron.Y = 3;
Bar.Height = 0;
}
}
}
}
}

View File

@ -15,7 +15,7 @@ using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogHeader : OverlayHeader
public class ChangelogHeader : BreadcrumbControlOverlayHeader
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Changelog
public UpdateStreamBadgeArea Streams;
private const string listing_string = "Listing";
private const string listing_string = "listing";
public ChangelogHeader()
{
TabControl.AddItem(listing_string);
TabControl.Current.ValueChanged += e =>
BreadcrumbControl.AddItem(listing_string);
BreadcrumbControl.Current.ValueChanged += e =>
{
if (e.NewValue == listing_string)
ListingSelected?.Invoke();
@ -46,7 +46,7 @@ namespace osu.Game.Overlays.Changelog
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
TabControl.AccentColour = colours.Violet;
BreadcrumbControl.AccentColour = colours.Violet;
TitleBackgroundColour = colours.GreyVioletDarker;
ControlBackgroundColour = colours.GreyVioletDark;
}
@ -56,12 +56,12 @@ namespace osu.Game.Overlays.Changelog
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
{
if (e.OldValue != null)
TabControl.RemoveItem(e.OldValue.ToString());
BreadcrumbControl.RemoveItem(e.OldValue.ToString());
if (e.NewValue != null)
{
TabControl.AddItem(e.NewValue.ToString());
TabControl.Current.Value = e.NewValue.ToString();
BreadcrumbControl.AddItem(e.NewValue.ToString());
BreadcrumbControl.Current.Value = e.NewValue.ToString();
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name);
@ -69,7 +69,7 @@ namespace osu.Game.Overlays.Changelog
}
else
{
TabControl.Current.Value = listing_string;
BreadcrumbControl.Current.Value = listing_string;
Streams.Current.Value = null;
title.Version = null;
}

Some files were not shown because too many files have changed in this diff Show More