1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Merge branch 'master' into sharpen

This commit is contained in:
Huo Yaoyuan 2019-11-21 23:42:46 +08:00
commit 818553027b
77 changed files with 752 additions and 223 deletions

View File

@ -17,6 +17,8 @@
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a</AndroidSupportedAbis>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<MandroidI18n>cjk,mideast,other,rare,west</MandroidI18n>
<AndroidHttpClientHandlerType>System.Net.Http.HttpClientHandler</AndroidHttpClientHandlerType>
<AndroidTlsProvider>legacy</AndroidTlsProvider>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
@ -54,6 +56,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1112.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1121.0" />
</ItemGroup>
</Project>

View File

@ -8,7 +8,6 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
using osu.Game.Rulesets.Catch.MathUtils;
using osu.Game.Rulesets.Mods;
@ -78,7 +77,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
catchObject.XOffset = 0;
if (catchObject is TinyDroplet)
catchObject.XOffset = MathHelper.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -catchObject.X, 1 - catchObject.X);
catchObject.XOffset = Math.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -catchObject.X, 1 - catchObject.X);
else if (catchObject is Droplet)
rng.Next(); // osu!stable retrieved a random droplet rotation
}
@ -230,7 +229,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
else
{
currentObject.DistanceToHyperDash = distanceToHyper;
lastExcess = MathHelper.Clamp(distanceToHyper, 0, halfCatcherWidth);
lastExcess = Math.Clamp(distanceToHyper, 0, halfCatcherWidth);
}
lastDirection = thisDirection;

View File

@ -10,7 +10,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
using osuTK;
namespace osu.Game.Rulesets.Catch.Difficulty
{
@ -96,7 +95,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty
return value;
}
private float accuracy() => totalHits() == 0 ? 0 : MathHelper.Clamp((float)totalSuccessfulHits() / totalHits(), 0f, 1f);
private float accuracy() => totalHits() == 0 ? 0 : Math.Clamp((float)totalSuccessfulHits() / totalHits(), 0f, 1f);
private int totalHits() => tinyTicksHit + ticksHit + fruitsHit + misses + tinyTicksMissed;
private int totalSuccessfulHits() => tinyTicksHit + ticksHit + fruitsHit;
private int totalComboHits() => misses + ticksHit + fruitsHit;

View File

@ -6,7 +6,6 @@ using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osuTK;
namespace osu.Game.Rulesets.Catch.Difficulty.Skills
{
@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
if (lastPlayerPosition == null)
lastPlayerPosition = catchCurrent.LastNormalizedPosition;
float playerPosition = MathHelper.Clamp(
float playerPosition = Math.Clamp(
lastPlayerPosition.Value,
catchCurrent.NormalizedPosition - (normalized_hitobject_radius - absolute_player_positioning_error),
catchCurrent.NormalizedPosition + (normalized_hitobject_radius - absolute_player_positioning_error)

View File

@ -278,7 +278,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
base.Update();
border.Alpha = (float)MathHelper.Clamp((HitObject.StartTime - Time.Current) / 500, 0, 1);
border.Alpha = (float)Math.Clamp((HitObject.StartTime - Time.Current) / 500, 0, 1);
}
private Color4 colourForRepresentation(FruitVisualRepresentation representation)

View File

@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.Y -= RNG.NextSingle() * diff;
}
fruit.X = MathHelper.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
fruit.X = Math.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
caughtFruit.Add(fruit);
}
@ -378,7 +378,7 @@ namespace osu.Game.Rulesets.Catch.UI
double speed = BASE_SPEED * dashModifier * hyperDashModifier;
Scale = new Vector2(Math.Abs(Scale.X) * direction, Scale.Y);
X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * speed, 0, 1);
X = (float)Math.Clamp(X + direction * Clock.ElapsedFrameTime * speed, 0, 1);
// Correct overshooting.
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||

View File

@ -7,7 +7,6 @@ using JetBrains.Annotations;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.MathUtils;
using osu.Game.Rulesets.Objects;
using osuTK;
namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
{
@ -54,11 +53,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
if (allowSpecial && TotalColumns == 8)
{
const float local_x_divisor = 512f / 7;
return MathHelper.Clamp((int)Math.Floor(position / local_x_divisor), 0, 6) + 1;
return Math.Clamp((int)Math.Floor(position / local_x_divisor), 0, 6) + 1;
}
float localXDivisor = 512f / TotalColumns;
return MathHelper.Clamp((int)Math.Floor(position / localXDivisor), 0, TotalColumns - 1);
return Math.Clamp((int)Math.Floor(position / localXDivisor), 0, TotalColumns - 1);
}
/// <summary>
@ -113,7 +112,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
drainTime = 10000;
BeatmapDifficulty difficulty = OriginalBeatmap.BeatmapInfo.BaseDifficulty;
conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + (double)OriginalBeatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15;
conversionDifficulty = ((difficulty.DrainRate + Math.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + (double)OriginalBeatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15;
conversionDifficulty = Math.Min(conversionDifficulty.Value, 12);
return conversionDifficulty.Value;

View File

@ -1,6 +1,7 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Timing;
@ -9,7 +10,6 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit
{
@ -119,7 +119,7 @@ namespace osu.Game.Rulesets.Mania.Edit
maxColumn = obj.Column;
}
columnDelta = MathHelper.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
columnDelta = Math.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
foreach (var obj in SelectedHitObjects.OfType<ManiaHitObject>())
obj.Column += columnDelta;

View File

@ -14,12 +14,13 @@ using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
public class PathControlPointPiece : BlueprintPiece<Slider>
{
public Action<int> RequestSelection;
public Action<int, MouseButtonEvent> RequestSelection;
public Action<Vector2[]> ControlPointsChanged;
public readonly BindableBool IsSelected = new BindableBool();
@ -129,10 +130,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
protected override bool OnMouseDown(MouseDownEvent e)
{
if (RequestSelection != null)
if (RequestSelection == null)
return false;
switch (e.Button)
{
RequestSelection.Invoke(Index);
return true;
case MouseButton.Left:
RequestSelection.Invoke(Index, e);
return true;
case MouseButton.Right:
if (!IsSelected.Value)
RequestSelection.Invoke(Index, e);
return false; // Allow context menu to show
}
return false;
@ -142,7 +152,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
protected override bool OnClick(ClickEvent e) => RequestSelection != null;
protected override bool OnDragStart(DragStartEvent e) => true;
protected override bool OnDragStart(DragStartEvent e) => e.Button == MouseButton.Left;
protected override bool OnDrag(DragEvent e)
{

View File

@ -3,19 +3,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler<PlatformAction>
public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IHasContextMenu
{
public Action<Vector2[]> ControlPointsChanged;
@ -73,9 +79,22 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return false;
}
private void selectPiece(int index)
public bool OnPressed(PlatformAction action)
{
if (inputManager.CurrentState.Keyboard.ControlPressed)
switch (action.ActionMethod)
{
case PlatformActionMethod.Delete:
return deleteSelected();
}
return false;
}
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
private void selectPiece(int index, MouseButtonEvent e)
{
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
Pieces[index].IsSelected.Toggle();
else
{
@ -84,50 +103,60 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
}
}
public bool OnPressed(PlatformAction action)
private bool deleteSelected()
{
switch (action.ActionMethod)
var newControlPoints = new List<Vector2>();
foreach (var piece in Pieces)
{
case PlatformActionMethod.Delete:
var newControlPoints = new List<Vector2>();
foreach (var piece in Pieces)
{
if (!piece.IsSelected.Value)
newControlPoints.Add(slider.Path.ControlPoints[piece.Index]);
}
// Ensure that there are any points to be deleted
if (newControlPoints.Count == slider.Path.ControlPoints.Length)
return false;
// If there are 0 remaining control points, treat the slider as being deleted
if (newControlPoints.Count == 0)
{
placementHandler?.Delete(slider);
return true;
}
// Make control points relative
Vector2 first = newControlPoints[0];
for (int i = 0; i < newControlPoints.Count; i++)
newControlPoints[i] = newControlPoints[i] - first;
// The slider's position defines the position of the first control point, and all further control points are relative to that point
slider.Position += first;
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
foreach (var piece in Pieces)
piece.IsSelected.Value = false;
ControlPointsChanged?.Invoke(newControlPoints.ToArray());
return true;
if (!piece.IsSelected.Value)
newControlPoints.Add(slider.Path.ControlPoints[piece.Index]);
}
return false;
// Ensure that there are any points to be deleted
if (newControlPoints.Count == slider.Path.ControlPoints.Length)
return false;
// If there are 0 remaining control points, treat the slider as being deleted
if (newControlPoints.Count == 0)
{
placementHandler?.Delete(slider);
return true;
}
// Make control points relative
Vector2 first = newControlPoints[0];
for (int i = 0; i < newControlPoints.Count; i++)
newControlPoints[i] = newControlPoints[i] - first;
// The slider's position defines the position of the first control point, and all further control points are relative to that point
slider.Position += first;
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
foreach (var piece in Pieces)
piece.IsSelected.Value = false;
ControlPointsChanged?.Invoke(newControlPoints.ToArray());
return true;
}
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
public MenuItem[] ContextMenuItems
{
get
{
if (!Pieces.Any(p => p.IsHovered))
return null;
int selectedPoints = Pieces.Count(p => p.IsSelected.Value);
if (selectedPoints == 0)
return null;
return new MenuItem[]
{
new OsuMenuItem($"Delete {"control point".ToQuantity(selectedPoints)}", MenuItemType.Destructive, () => deleteSelected())
};
}
}
}
}

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -13,7 +14,6 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Mods
@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Mods
};
}
private float calculateGap(float value) => MathHelper.Clamp(value, 0, target_clamp) * targetBreakMultiplier;
private float calculateGap(float value) => Math.Clamp(value, 0, target_clamp) * targetBreakMultiplier;
// lagrange polinominal for (0,0) (0.6,0.4) (1,1) should make a good curve
private static float applyAdjustmentCurve(float value) => 0.6f * value * value + 0.4f * value;

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Bindables;
@ -55,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Mods
var destination = e.MousePosition;
FlashlightPosition = Interpolation.ValueAt(
MathHelper.Clamp(Clock.ElapsedFrameTime, 0, follow_delay), position, destination, 0, follow_delay, Easing.Out);
Math.Clamp(Clock.ElapsedFrameTime, 0, follow_delay), position, destination, 0, follow_delay, Easing.Out);
return base.OnMouseMove(e);
}

View File

@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
else
{
// If we're already snaking, interpolate to smooth out sharp curves (linear sliders, mainly).
Rotation = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 50, Easing.OutQuint);
Rotation = Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 50, Easing.OutQuint);
}
}
}

View File

@ -1,6 +1,7 @@
// 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 osuTK;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
@ -165,7 +166,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Tracking.Value = Ball.Tracking;
double completionProgress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
double completionProgress = Math.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
Ball.UpdateProgress(completionProgress);
Body.UpdateProgress(completionProgress);

View File

@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
base.Update();
double completionProgress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
double completionProgress = Math.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
//todo: we probably want to reconsider this before adding scoring, but it looks and feels nice.
if (!IsHit)

View File

@ -1,6 +1,7 @@
// 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.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -136,7 +137,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
positionBindable.BindTo(HitObject.PositionBindable);
}
public float Progress => MathHelper.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1);
public float Progress => Math.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1);
protected override void CheckForResult(bool userTriggered, double timeOffset)
{

View File

@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
var spanProgress = slider.ProgressAt(completionProgress);
double start = 0;
double end = SnakingIn.Value ? MathHelper.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / (slider.TimePreempt / 3), 0, 1) : 1;
double end = SnakingIn.Value ? Math.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / (slider.TimePreempt / 3), 0, 1) : 1;
if (span >= slider.SpanCount() - 1)
{

View File

@ -1,12 +1,12 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Graphics;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osu.Framework.Graphics;
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
else
rollingHits--;
rollingHits = MathHelper.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
rollingHits = Math.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
MainPiece.FadeAccent(newColour, 100);

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
@ -179,7 +178,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
var completion = (float)numHits / HitObject.RequiredHits;
expandingRing
.FadeTo(expandingRing.Alpha + MathHelper.Clamp(completion / 16, 0.1f, 0.6f), 50)
.FadeTo(expandingRing.Alpha + Math.Clamp(completion / 16, 0.1f, 0.6f), 50)
.Then()
.FadeTo(completion / 8, 2000, Easing.OutQuint);

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Graphics;
using osu.Game.Rulesets.UI;
using osuTK;
@ -22,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{
base.Update();
float aspectAdjust = MathHelper.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
float aspectAdjust = Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
Size = new Vector2(1, default_relative_height * aspectAdjust);
}
}

View File

@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
@ -13,7 +14,9 @@ namespace osu.Game.Tests.Visual.Components
{
public class TestScenePreviewTrackManager : OsuTestScene, IPreviewTrackOwner
{
private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager();
private readonly TestPreviewTrackManager trackManager = new TestPreviewTrackManager();
private AudioManager audio;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
@ -24,8 +27,10 @@ namespace osu.Game.Tests.Visual.Components
}
[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audio)
{
this.audio = audio;
Add(trackManager);
}
@ -108,6 +113,60 @@ namespace osu.Game.Tests.Visual.Components
AddAssert("track stopped", () => !track.IsRunning);
}
/// <summary>
/// Ensures that <see cref="PreviewTrackManager.CurrentTrack"/> changes correctly.
/// </summary>
[Test]
public void TestCurrentTrackChanges()
{
PreviewTrack track = null;
TestTrackOwner owner = null;
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start track", () => track.Start());
AddAssert("current is track", () => trackManager.CurrentTrack == track);
AddStep("pause manager updates", () => trackManager.AllowUpdate = false);
AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
AddAssert("current not changed", () => trackManager.CurrentTrack == track);
AddStep("resume manager updates", () => trackManager.AllowUpdate = true);
AddAssert("current is null", () => trackManager.CurrentTrack == null);
}
/// <summary>
/// Ensures that <see cref="PreviewTrackManager"/> mutes game-wide audio tracks correctly.
/// </summary>
[TestCase(false)]
[TestCase(true)]
public void TestEnsureMutingCorrectly(bool stopAnyPlaying)
{
PreviewTrack track = null;
TestTrackOwner owner = null;
AddStep("ensure volume not zero", () =>
{
if (audio.Volume.Value == 0)
audio.Volume.Value = 1;
if (audio.VolumeTrack.Value == 0)
audio.VolumeTrack.Value = 1;
});
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start track", () => track.Start());
AddAssert("game is muted", () => audio.Tracks.AggregateVolume.Value == 0);
if (stopAnyPlaying)
AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
else
AddStep("stop track", () => track.Stop());
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
}
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
private TestPreviewTrack getOwnedTrack()
@ -144,8 +203,20 @@ namespace osu.Game.Tests.Visual.Components
public class TestPreviewTrackManager : PreviewTrackManager
{
public bool AllowUpdate = true;
public new PreviewTrack CurrentTrack => base.CurrentTrack;
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
public override bool UpdateSubTree()
{
if (!AllowUpdate)
return true;
return base.UpdateSubTree();
}
public class TestPreviewTrack : TrackManagerPreviewTrack
{
private readonly ITrackStore trackManager;

View File

@ -0,0 +1,23 @@
// 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.Game.Overlays;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneNewsOverlay : OsuTestScene
{
private NewsOverlay news;
protected override void LoadComplete()
{
base.LoadComplete();
Add(news = new NewsOverlay());
AddStep(@"Show", news.Show);
AddStep(@"Hide", news.Hide);
AddStep(@"Show front page", () => news.ShowFrontPage());
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
}
}
}

View File

@ -0,0 +1,36 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Overlays.Comments;
using osu.Framework.MathUtils;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneTotalCommentsCounter : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TotalCommentsCounter),
};
public TestSceneTotalCommentsCounter()
{
var count = new BindableInt();
Add(new TotalCommentsCounter
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = { BindTarget = count }
});
AddStep(@"Set 100", () => count.Value = 100);
AddStep(@"Set 0", () => count.Value = 0);
AddStep(@"Set random", () => count.Value = RNG.Next(0, int.MaxValue));
}
}
}

View File

@ -57,23 +57,6 @@ namespace osu.Game.Tests.Visual.SongSelect
typeof(DrawableCarouselBeatmapSet),
};
private class TestSongSelect : PlaySongSelect
{
public Action StartRequested;
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
public new BeatmapCarousel Carousel => base.Carousel;
protected override bool OnStart()
{
StartRequested?.Invoke();
return base.OnStart();
}
}
private TestSongSelect songSelect;
[BackgroundDependencyLoader]
@ -101,6 +84,17 @@ namespace osu.Game.Tests.Visual.SongSelect
manager?.Delete(manager.GetAllUsableBeatmapSets());
});
[Test]
public void TestSingleFilterOnEnter()
{
addRulesetImportStep(0);
addRulesetImportStep(0);
createSongSelect();
AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
}
[Test]
public void TestAudioResuming()
{
@ -373,5 +367,30 @@ namespace osu.Game.Tests.Visual.SongSelect
base.Dispose(isDisposing);
rulesets?.Dispose();
}
private class TestSongSelect : PlaySongSelect
{
public Action StartRequested;
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
public new BeatmapCarousel Carousel => base.Carousel;
protected override bool OnStart()
{
StartRequested?.Invoke();
return base.OnStart();
}
public int FilterCount;
protected override void ApplyFilterToCarousel(FilterCriteria criteria)
{
FilterCount++;
base.ApplyFilterToCarousel(criteria);
}
}
}
}

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
private IReadOnlyList<Type> requiredGameDependencies => new[]
{
typeof(OsuGame),
typeof(RavenLogger),
typeof(SentryLogger),
typeof(OsuLogo),
typeof(IdleTracker),
typeof(OnScreenDisplay),

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@ -32,7 +33,7 @@ namespace osu.Game.Tournament.Screens.Ladder
protected override bool OnScroll(ScrollEvent e)
{
var newScale = MathHelper.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
var newScale = Math.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
this.MoveTo(target -= e.MousePosition * (newScale - scale), 2000, Easing.OutQuint);
this.ScaleTo(scale = newScale, 2000, Easing.OutQuint);

View File

@ -22,7 +22,7 @@ namespace osu.Game.Audio
private AudioManager audio;
private PreviewTrackStore trackStore;
private TrackManagerPreviewTrack current;
protected TrackManagerPreviewTrack CurrentTrack;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
@ -48,17 +48,17 @@ namespace osu.Game.Audio
track.Started += () => Schedule(() =>
{
current?.Stop();
current = track;
CurrentTrack?.Stop();
CurrentTrack = track;
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
});
track.Stopped += () => Schedule(() =>
{
if (current != track)
if (CurrentTrack != track)
return;
current = null;
CurrentTrack = null;
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
});
@ -76,11 +76,11 @@ namespace osu.Game.Audio
/// <param name="source">The <see cref="IPreviewTrackOwner"/> which may be the owner of the <see cref="PreviewTrack"/>.</param>
public void StopAnyPlaying(IPreviewTrackOwner source)
{
if (current == null || current.Owner != source)
if (CurrentTrack == null || CurrentTrack.Owner != source)
return;
current.Stop();
current = null;
CurrentTrack.Stop();
// CurrentTrack should not be set to null here as it will result in incorrect handling in the track.Stopped callback above.
}
/// <summary>

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Input;
@ -48,7 +49,7 @@ namespace osu.Game.Graphics.Containers
if (!parallaxEnabled.Value)
{
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint);
content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount));
content.Scale = new Vector2(1 + Math.Abs(ParallaxAmount));
}
};
}
@ -71,10 +72,10 @@ namespace osu.Game.Graphics.Containers
const float parallax_duration = 100;
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, parallax_duration);
double elapsed = Math.Clamp(Clock.ElapsedFrameTime, 0, parallax_duration);
content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, parallax_duration, Easing.OutQuint);
content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint);
content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint);
}
firstUpdate = false;

View File

@ -1,12 +1,12 @@
// 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 osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using System;
namespace osu.Game.Graphics.UserInterface
{
@ -29,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface
get => length;
set
{
length = MathHelper.Clamp(value, 0, 1);
length = Math.Clamp(value, 0, 1);
updateBarLength();
}
}

View File

@ -175,9 +175,9 @@ namespace osu.Game.Graphics.UserInterface
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
leftBox.Scale = new Vector2(MathHelper.Clamp(
leftBox.Scale = new Vector2(Math.Clamp(
Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
rightBox.Scale = new Vector2(MathHelper.Clamp(
rightBox.Scale = new Vector2(Math.Clamp(
DrawWidth - Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
}

View File

@ -99,7 +99,7 @@ namespace osu.Game.Graphics.UserInterface
// dont bother calculating if the strip is invisible
if (strip.Colour.MaxAlpha > 0)
strip.Width = Interpolation.ValueAt(MathHelper.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

@ -227,7 +227,7 @@ namespace osu.Game.Online.API
{
try
{
return JObject.Parse(req.ResponseString).SelectToken("form_error", true).ToObject<RegistrationRequest.RegistrationRequestErrors>();
return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).ToObject<RegistrationRequest.RegistrationRequestErrors>();
}
catch
{

View File

@ -113,7 +113,7 @@ namespace osu.Game.Online.API
cancelled = true;
WebRequest?.Abort();
string responseString = WebRequest?.ResponseString;
string responseString = WebRequest?.GetResponseString();
if (!string.IsNullOrEmpty(responseString))
{

View File

@ -71,7 +71,7 @@ namespace osu.Game
[Cached]
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
protected RavenLogger RavenLogger;
protected SentryLogger SentryLogger;
public virtual Storage GetStorageForStableInstall() => null;
@ -110,7 +110,7 @@ namespace osu.Game
forwardLoggedErrorsToNotifications();
RavenLogger = new RavenLogger(this);
SentryLogger = new SentryLogger(this);
}
private void updateBlockingOverlayFade() =>
@ -166,7 +166,7 @@ namespace osu.Game
dependencies.CacheAs(this);
dependencies.Cache(RavenLogger);
dependencies.Cache(SentryLogger);
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
@ -486,7 +486,7 @@ namespace osu.Game
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
RavenLogger.Dispose();
SentryLogger.Dispose();
}
protected override void LoadComplete()

View File

@ -99,7 +99,7 @@ namespace osu.Game.Overlays.Chat.Tabs
private void tabCloseRequested(TabItem<Channel> tab)
{
int totalTabs = TabContainer.Count - 1; // account for selectorTab
int currentIndex = MathHelper.Clamp(TabContainer.IndexOf(tab), 1, totalTabs);
int currentIndex = Math.Clamp(TabContainer.IndexOf(tab), 1, totalTabs);
if (tab == SelectedTab && totalTabs > 1)
// Select the tab after tab-to-be-removed's index, or the tab before if current == last

View File

@ -0,0 +1,80 @@
// 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.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
namespace osu.Game.Overlays.Comments
{
public class TotalCommentsCounter : CompositeDrawable
{
public readonly BindableInt Current = new BindableInt();
private readonly SpriteText counter;
public TotalCommentsCounter()
{
RelativeSizeAxes = Axes.X;
Height = 50;
AddInternal(new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Left = 50 },
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 20, italics: true),
Text = @"Comments"
},
new CircularContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.05f)
},
counter = new SpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)
}
},
}
}
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
counter.Colour = colours.BlueLighter;
}
protected override void LoadComplete()
{
Current.BindValueChanged(value => counter.Text = value.NewValue.ToString("N0"), true);
base.LoadComplete();
}
}
}

View File

@ -241,7 +241,7 @@ namespace osu.Game.Overlays.Dialog
protected override void PopOut()
{
if (!actionInvoked)
if (!actionInvoked && content.IsPresent)
// In the case a user did not choose an action before a hide was triggered, press the last button.
// This is presumed to always be a sane default "cancel" action.
buttonsContainer.Last().Click();

View File

@ -217,7 +217,7 @@ namespace osu.Game.Overlays.Music
break;
}
dstIndex = MathHelper.Clamp(dstIndex, 0, items.Count - 1);
dstIndex = Math.Clamp(dstIndex, 0, items.Count - 1);
if (srcIndex == dstIndex)
return;

View File

@ -0,0 +1,19 @@
// 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.Containers;
namespace osu.Game.Overlays.News
{
public abstract class NewsContent : FillFlowContainer
{
protected NewsContent()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Bottom = 100, Top = 20, Horizontal = 50 };
}
}
}

View File

@ -0,0 +1,109 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using System;
namespace osu.Game.Overlays.News
{
public class NewsHeader : OverlayHeader
{
private const string front_page_string = "Front Page";
private NewsHeaderTitle title;
public readonly Bindable<string> Current = new Bindable<string>(null);
public Action ShowFrontPage;
public NewsHeader()
{
TabControl.AddItem(front_page_string);
TabControl.Current.ValueChanged += e =>
{
if (e.NewValue == front_page_string)
ShowFrontPage?.Invoke();
};
Current.ValueChanged += showArticle;
}
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
TabControl.AccentColour = colour.Violet;
}
private void showArticle(ValueChangedEvent<string> e)
{
if (e.OldValue != null)
TabControl.RemoveItem(e.OldValue);
if (e.NewValue != null)
{
TabControl.AddItem(e.NewValue);
TabControl.Current.Value = e.NewValue;
title.IsReadingArticle = true;
}
else
{
TabControl.Current.Value = front_page_string;
title.IsReadingArticle = false;
}
}
protected override Drawable CreateBackground() => new NewsHeaderBackground();
protected override Drawable CreateContent() => new Container();
protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle();
private class NewsHeaderBackground : Sprite
{
public NewsHeaderBackground()
{
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/news");
}
}
private class NewsHeaderTitle : ScreenTitle
{
private const string article_string = "Article";
public bool IsReadingArticle
{
set => Section = value ? article_string : front_page_string;
}
public NewsHeaderTitle()
{
Title = "News";
IsReadingArticle = false;
}
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news");
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.Violet;
}
}
}
}

View File

@ -0,0 +1,68 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.News;
namespace osu.Game.Overlays
{
public class NewsOverlay : FullscreenOverlay
{
private NewsHeader header;
//ReSharper disable NotAccessedField.Local
private Container<NewsContent> content;
public readonly Bindable<string> Current = new Bindable<string>(null);
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.PurpleDarkAlternative
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new NewsHeader
{
ShowFrontPage = ShowFrontPage
},
content = new Container<NewsContent>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
},
},
},
};
header.Current.BindTo(Current);
Current.TriggerChange();
}
public void ShowFrontPage()
{
Current.Value = null;
Show();
}
}
}

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -8,7 +9,6 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osuTK;
namespace osu.Game.Overlays.Profile.Header.Components
{
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
set
{
int count = MathHelper.Clamp(value, 0, 3);
int count = Math.Clamp(value, 0, 3);
if (count == 0)
{

View File

@ -60,7 +60,10 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
Children = new Drawable[]
{
dropdown = new AudioDeviceSettingsDropdown()
dropdown = new AudioDeviceSettingsDropdown
{
Keywords = new[] { "speaker", "headphone", "output" }
}
};
updateItems();

View File

@ -1,6 +1,8 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Settings.Sections.Audio;
@ -10,6 +12,9 @@ namespace osu.Game.Overlays.Settings.Sections
public class AudioSection : SettingsSection
{
public override string Header => "Audio";
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(new[] { "sound" });
public override IconUsage Icon => FontAwesome.Solid.VolumeUp;
public AudioSection()

View File

@ -38,6 +38,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
LabelText = "Show health display even when you can't fail",
Bindable = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
Keywords = new[] { "hp", "bar" }
},
new SettingsCheckbox
{

View File

@ -1,6 +1,8 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Game.Configuration;
@ -10,6 +12,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
protected override string Header => "Mods";
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(new[] { "mod" });
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
@ -18,7 +22,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
new SettingsCheckbox
{
LabelText = "Increase visibility of first object when visual impairment mods are enabled",
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility)
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility),
},
};
}

View File

@ -31,13 +31,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
LabelText = "Display beatmaps from",
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
KeyboardStep = 0.1f
KeyboardStep = 0.1f,
Keywords = new[] { "star", "difficulty" }
},
new SettingsSlider<double, StarSlider>
{
LabelText = "up to",
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
KeyboardStep = 0.1f
KeyboardStep = 0.1f,
Keywords = new[] { "star", "difficulty" }
},
new SettingsEnumDropdown<RandomSelectAlgorithm>
{

View File

@ -75,12 +75,14 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
LabelText = "UI Scaling",
TransferValueOnCommit = true,
Bindable = osuConfig.GetBindable<float>(OsuSetting.UIScale),
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
Keywords = new[] { "scale", "letterbox" },
},
new SettingsEnumDropdown<ScalingMode>
{
LabelText = "Screen Scaling",
Bindable = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling),
Keywords = new[] { "scale", "letterbox" },
},
scalingSettings = new FillFlowContainer<SettingsSlider<float>>
{

View File

@ -76,7 +76,9 @@ namespace osu.Game.Overlays.Settings
}
}
public virtual IEnumerable<string> FilterTerms => new[] { LabelText };
public virtual IEnumerable<string> FilterTerms => Keywords == null ? new[] { LabelText } : new List<string>(Keywords) { LabelText }.ToArray();
public IEnumerable<string> Keywords { get; set; }
public bool MatchingFilter
{

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings
public abstract string Header { get; }
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
public IEnumerable<string> FilterTerms => new[] { Header };
public virtual IEnumerable<string> FilterTerms => new[] { Header };
private const int header_size = 26;
private const int header_margin = 25;

View File

@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings
protected abstract string Header { get; }
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
public IEnumerable<string> FilterTerms => new[] { Header };
public virtual IEnumerable<string> FilterTerms => new[] { Header };
public bool MatchingFilter
{

View File

@ -9,7 +9,6 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Mods
{
@ -59,7 +58,7 @@ namespace osu.Game.Rulesets.Mods
/// <param name="amount">The amount of adjustment to apply (from 0..1).</param>
private void applyAdjustment(double amount)
{
double adjust = 1 + (Math.Sign(FinalRateAdjustment) * MathHelper.Clamp(amount, 0, 1) * Math.Abs(FinalRateAdjustment));
double adjust = 1 + (Math.Sign(FinalRateAdjustment) * Math.Clamp(amount, 0, 1) * Math.Abs(FinalRateAdjustment));
switch (clock)
{

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osuTK;
namespace osu.Game.Rulesets.Objects
{
@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Objects
const double max_length = 100000;
var length = Math.Min(max_length, totalDistance);
tickDistance = MathHelper.Clamp(tickDistance, 0, length);
tickDistance = Math.Clamp(tickDistance, 0, length);
var minDistanceFromEnd = velocity * 10;

View File

@ -246,7 +246,7 @@ namespace osu.Game.Rulesets.Objects
private double progressToDistance(double progress)
{
return MathHelper.Clamp(progress, 0, 1) * Distance;
return Math.Clamp(progress, 0, 1) * Distance;
}
private Vector2 interpolateVertices(int i, double d)

View File

@ -7,7 +7,6 @@ using JetBrains.Annotations;
using osu.Framework.Input.StateChanges;
using osu.Game.Input.Handlers;
using osu.Game.Replays;
using osuTK;
namespace osu.Game.Rulesets.Replays
{
@ -52,7 +51,7 @@ namespace osu.Game.Rulesets.Replays
private int? currentFrameIndex;
private int nextFrameIndex => currentFrameIndex.HasValue ? MathHelper.Clamp(currentFrameIndex.Value + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1) : 0;
private int nextFrameIndex => currentFrameIndex.HasValue ? Math.Clamp(currentFrameIndex.Value + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1) : 0;
protected FramedReplayInputHandler(Replay replay)
{

View File

@ -517,6 +517,12 @@ namespace osu.Game.Rulesets.UI
public BindableDouble Frequency => throw new NotImplementedException();
public IBindable<double> AggregateVolume => throw new NotImplementedException();
public IBindable<double> AggregateBalance => throw new NotImplementedException();
public IBindable<double> AggregateFrequency => throw new NotImplementedException();
public int PlaybackConcurrency
{
get => throw new NotImplementedException();

View File

@ -1,9 +1,9 @@
// 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 osu.Framework.Lists;
using osu.Game.Rulesets.Timing;
using osuTK;
namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
{
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
}
}
i = MathHelper.Clamp(i, 0, controlPoints.Count - 1);
i = Math.Clamp(i, 0, controlPoints.Count - 1);
return controlPoints[i].StartTime + (position - pos) * timeRange / controlPoints[i].Multiplier / scrollLength;
}

View File

@ -1,6 +1,7 @@
// 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 osuTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -59,7 +60,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
if (Beatmap.Value == null)
return;
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
float markerPos = Math.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
});
}

View File

@ -313,14 +313,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Attempts to select any hovered blueprints.
/// </summary>
/// <param name="e">The input event that triggered this selection.</param>
private void beginClickSelection(UIEvent e)
private void beginClickSelection(MouseButtonEvent e)
{
Debug.Assert(!clickSelectionBegan);
// If a select blueprint is already hovered, disallow changes in selection.
// Exception is made when holding control, as deselection should still be allowed.
if (!e.CurrentState.Keyboard.ControlPressed &&
selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
// Deselections are only allowed for control + left clicks
bool allowDeselection = e.ControlPressed && e.Button == MouseButton.Left;
// Todo: This is probably incorrectly disallowing multiple selections on stacked objects
if (!allowDeselection && selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
return;
foreach (SelectionBlueprint blueprint in selectionBlueprints.AliveBlueprints)

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
float distance = direction.Length;
float radius = DistanceSpacing;
int radialCount = MathHelper.Clamp((int)Math.Round(distance / radius), 1, MaxIntervals);
int radialCount = Math.Clamp((int)Math.Round(distance / radius), 1, MaxIntervals);
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
Vector2 snappedPosition = CentrePosition + normalisedDirection * radialCount * radius;

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
get => zoomTarget;
set
{
value = MathHelper.Clamp(value, MinZoom, MaxZoom);
value = Math.Clamp(value, MinZoom, MaxZoom);
if (IsLoaded)
setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
@ -117,7 +117,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private void setZoomTarget(float newZoom, float focusPoint)
{
zoomTarget = MathHelper.Clamp(newZoom, MinZoom, MaxZoom);
zoomTarget = Math.Clamp(newZoom, MinZoom, MaxZoom);
transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
}

View File

@ -7,7 +7,6 @@ using osu.Framework.MathUtils;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osuTK;
namespace osu.Game.Screens.Edit
{
@ -125,7 +124,7 @@ namespace osu.Game.Screens.Edit
seekTime = nextTimingPoint.Time;
// Ensure the sought point is within the boundaries
seekTime = MathHelper.Clamp(seekTime, 0, TrackLength);
seekTime = Math.Clamp(seekTime, 0, TrackLength);
Seek(seekTime);
}
}

View File

@ -236,7 +236,7 @@ namespace osu.Game.Screens.Menu
protected override void Update()
{
iconText.Alpha = MathHelper.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
iconText.Alpha = Math.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
base.Update();
}

View File

@ -74,7 +74,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
set
{
matchingFilter = value;
this.FadeTo(MatchingFilter ? 1 : 0, 200);
if (IsLoaded)
this.FadeTo(MatchingFilter ? 1 : 0, 200);
}
}
@ -203,7 +205,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components
protected override void LoadComplete()
{
base.LoadComplete();
this.FadeInFromZero(transition_duration);
if (matchingFilter)
this.FadeInFromZero(transition_duration);
else
Alpha = 0;
}
private class RoomName : OsuSpriteText

View File

@ -4,6 +4,7 @@
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Overlays.SearchableList;
using osuTK.Graphics;
@ -37,12 +38,22 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{
base.LoadComplete();
Search.Current.BindValueChanged(_ => updateFilter());
Search.Current.BindValueChanged(_ => scheduleUpdateFilter());
Tabs.Current.BindValueChanged(_ => updateFilter(), true);
}
private ScheduledDelegate scheduledFilterUpdate;
private void scheduleUpdateFilter()
{
scheduledFilterUpdate?.Cancel();
scheduledFilterUpdate = Scheduler.AddDelayed(updateFilter, 200);
}
private void updateFilter()
{
scheduledFilterUpdate?.Cancel();
filter.Value = new FilterCriteria
{
SearchString = Search.Current.Value ?? string.Empty,

View File

@ -24,6 +24,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private readonly FillFlowContainer<DrawableRoom> roomFlow;
public IReadOnlyList<DrawableRoom> Rooms => roomFlow;
[Resolved(CanBeNull = true)]
private Bindable<FilterCriteria> filter { get; set; }
[Resolved]
private Bindable<Room> currentRoom { get; set; }
@ -57,7 +60,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
addRooms(rooms);
}
private FilterCriteria currentFilter;
protected override void LoadComplete()
{
filter?.BindValueChanged(f => Filter(f.NewValue), true);
}
public void Filter(FilterCriteria criteria)
{
@ -74,15 +80,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{
default:
case SecondaryFilter.Public:
r.MatchingFilter = r.Room.Availability.Value == RoomAvailability.Public;
matchingFilter &= r.Room.Availability.Value == RoomAvailability.Public;
break;
}
r.MatchingFilter = matchingFilter;
}
});
currentFilter = criteria;
}
private void addRooms(IEnumerable<Room> rooms)
@ -90,7 +94,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
foreach (var r in rooms)
roomFlow.Add(new DrawableRoom(r) { Action = () => selectRoom(r) });
Filter(currentFilter);
if (filter != null)
Filter(filter.Value);
}
private void removeRooms(IEnumerable<Room> rooms)

View File

@ -102,8 +102,8 @@ namespace osu.Game.Screens.Play.HUD
else
{
Alpha = Interpolation.ValueAt(
MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 200),
Alpha, MathHelper.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint);
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
Alpha, Math.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint);
}
}

View File

@ -116,7 +116,7 @@ namespace osu.Game.Screens.Play
{
base.Update();
float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, MathHelper.Clamp(Time.Elapsed / 40, 0, 1));
float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, Math.Clamp(Time.Elapsed / 40, 0, 1));
fill.Width = newX;
handleBase.X = newX;

View File

@ -256,7 +256,7 @@ namespace osu.Game.Screens.Play
{
Color4 colour = State == ColumnState.Lit ? LitColour : DimmedColour;
int countFilled = (int)MathHelper.Clamp(filled * drawableRows.Count, 0, drawableRows.Count);
int countFilled = (int)Math.Clamp(filled * drawableRows.Count, 0, drawableRows.Count);
for (int i = 0; i < drawableRows.Count; i++)
drawableRows[i].Colour = i < countFilled ? colour : EmptyColour;

View File

@ -87,9 +87,9 @@ namespace osu.Game.Screens
private static Color4 getColourFor(object type)
{
int hash = type.GetHashCode();
byte r = (byte)MathHelper.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255);
byte g = (byte)MathHelper.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255);
byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
byte r = (byte)Math.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255);
byte g = (byte)Math.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255);
byte b = (byte)Math.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
return new Color4(r, g, b, 255);
}

View File

@ -452,9 +452,6 @@ namespace osu.Game.Screens.Select
if (!itemsCache.IsValid)
updateItems();
if (!scrollPositionCache.IsValid)
updateScrollPosition();
// Remove all items that should no longer be on-screen
scrollableContent.RemoveAll(p => p.Y < visibleUpperBound - p.DrawHeight || p.Y > visibleBottomBound || !p.IsPresent);
@ -519,6 +516,14 @@ namespace osu.Game.Screens.Select
updateItem(p);
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
if (!scrollPositionCache.IsValid)
updateScrollPosition();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@ -637,8 +642,11 @@ namespace osu.Game.Screens.Select
private void updateScrollPosition()
{
if (scrollTarget != null) scroll.ScrollTo(scrollTarget.Value);
scrollPositionCache.Validate();
if (scrollTarget != null)
{
scroll.ScrollTo(scrollTarget.Value);
scrollPositionCache.Validate();
}
}
/// <summary>
@ -677,7 +685,7 @@ namespace osu.Game.Screens.Select
// We are applying a multiplicative alpha (which is internally done by nesting an
// additional container and setting that container's alpha) such that we can
// layer transformations on top, with a similar reasoning to the previous comment.
p.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
p.SetMultiplicativeAlpha(Math.Clamp(1.75f - 1.5f * dist, 0, 1));
}
private class CarouselRoot : CarouselGroupEagerSelect

View File

@ -1,7 +1,7 @@
// 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;
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select.Details
retryGraph.MaxValue = maxValue;
failGraph.Values = fails.Select(f => (float)f);
retryGraph.Values = retries.Zip(fails, (retry, fail) => retry + MathHelper.Clamp(fail, 0, maxValue));
retryGraph.Values = retries.Zip(fails, (retry, fail) => retry + Math.Clamp(fail, 0, maxValue));
}
}

View File

@ -46,48 +46,54 @@ namespace osu.Game.Screens.Select
protected const float BACKGROUND_BLUR = 20;
private const float left_area_padding = 20;
public readonly FilterControl FilterControl;
public FilterControl FilterControl { get; private set; }
protected virtual bool ShowFooter => true;
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.
/// </summary>
protected readonly BeatmapOptionsOverlay BeatmapOptions;
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; }
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.
/// </summary>
protected readonly Footer Footer;
protected Footer Footer { get; private set; }
/// <summary>
/// Contains any panel which is triggered by a footer button.
/// Helps keep them located beneath the footer itself.
/// </summary>
protected readonly Container FooterPanels;
protected Container FooterPanels { get; private set; }
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge;
protected BeatmapCarousel Carousel { get; private set; }
private BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps;
protected readonly ModSelectOverlay ModSelect;
protected ModSelectOverlay ModSelect { get; private set; }
protected SampleChannel SampleConfirm { get; private set; }
protected SampleChannel SampleConfirm;
private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap;
protected readonly BeatmapDetailArea BeatmapDetails;
protected BeatmapDetailArea BeatmapDetails { get; private set; }
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
[Resolved(canBeNull: true)]
private MusicController music { get; set; }
protected SongSelect()
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
{
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
transferRulesetValue();
AddRangeInternal(new Drawable[]
{
new ParallaxContainer
@ -161,7 +167,7 @@ namespace osu.Game.Screens.Select
{
RelativeSizeAxes = Axes.X,
Height = FilterControl.HEIGHT,
FilterChanged = c => Carousel.Filter(c),
FilterChanged = ApplyFilterToCarousel,
Background = { Width = 2 },
},
}
@ -211,11 +217,7 @@ namespace osu.Game.Screens.Select
}
BeatmapDetails.Leaderboard.ScoreSelected += score => this.Push(new SoloResults(score));
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
{
if (Footer != null)
{
Footer.AddButton(new FooterButtonMods { Current = Mods }, ModSelect);
@ -258,6 +260,12 @@ namespace osu.Game.Screens.Select
}
}
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
{
if (this.IsCurrentScreen())
Carousel.Filter(criteria);
}
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -429,6 +437,8 @@ namespace osu.Game.Screens.Select
{
base.OnEntering(last);
Carousel.Filter(FilterControl.CreateCriteria(), false);
this.FadeInFromZero(250);
FilterControl.Activate();
}
@ -624,7 +634,7 @@ namespace osu.Game.Screens.Select
return;
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value;
transferRulesetValue();
Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue);
decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue;
@ -636,6 +646,11 @@ namespace osu.Game.Screens.Select
boundLocalBindables = true;
}
private void transferRulesetValue()
{
rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value;
}
private void delete(BeatmapSetInfo beatmap)
{
if (beatmap == null || beatmap.ID <= 0) return;

View File

@ -22,7 +22,6 @@ using osu.Game.Online.API;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual
{
@ -250,7 +249,7 @@ namespace osu.Game.Tests.Visual
public override bool Seek(double seek)
{
offset = MathHelper.Clamp(seek, 0, Length);
offset = Math.Clamp(seek, 0, Length);
lastReferenceTime = null;
return offset == seek;

View File

@ -2,31 +2,34 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using osu.Framework.Logging;
using SharpRaven;
using SharpRaven.Data;
using Sentry;
namespace osu.Game.Utils
{
/// <summary>
/// Report errors to sentry.
/// </summary>
public class RavenLogger : IDisposable
public class SentryLogger : IDisposable
{
private readonly RavenClient raven = new RavenClient("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255");
private SentryClient sentry;
private Scope sentryScope;
private readonly List<Task> tasks = new List<Task>();
public RavenLogger(OsuGame game)
public SentryLogger(OsuGame game)
{
raven.Release = game.Version;
if (!game.IsDeployedBuild) return;
var options = new SentryOptions
{
Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
Release = game.Version
};
sentry = new SentryClient(options);
sentryScope = new Scope(options);
Exception lastException = null;
Logger.NewEntry += entry =>
@ -46,10 +49,10 @@ namespace osu.Game.Utils
return;
lastException = exception;
queuePendingTask(raven.CaptureAsync(new SentryEvent(exception) { Message = entry.Message }));
sentry.CaptureEvent(new SentryEvent(exception) { Message = entry.Message }, sentryScope);
}
else
raven.AddTrail(new Breadcrumb(entry.Target.ToString(), BreadcrumbType.Navigation) { Message = entry.Message });
sentryScope.AddBreadcrumb(DateTimeOffset.Now, entry.Message, entry.Target.ToString(), "navigation");
};
}
@ -81,19 +84,9 @@ namespace osu.Game.Utils
return true;
}
private void queuePendingTask(Task<string> task)
{
lock (tasks) tasks.Add(task);
task.ContinueWith(_ =>
{
lock (tasks)
tasks.Remove(task);
});
}
#region Disposal
~RavenLogger()
~SentryLogger()
{
Dispose(false);
}
@ -112,7 +105,9 @@ namespace osu.Game.Utils
return;
isDisposed = true;
lock (tasks) Task.WaitAll(tasks.ToArray(), 5000);
sentry?.Dispose();
sentry = null;
sentryScope = null;
}
#endregion

View File

@ -21,10 +21,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1112.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1121.0" />
<PackageReference Include="Sentry" Version="1.2.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
</ItemGroup>
</Project>

View File

@ -74,7 +74,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1112.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1121.0" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies">