mirror of
https://github.com/ppy/osu.git
synced 2026-05-19 12:40:50 +08:00
Compare commits
21 Commits
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RiderProjectSettingsUpdater">
|
||||
<option name="vcsConfiguration" value="2" />
|
||||
<option name="vcsConfiguration" value="3" />
|
||||
</component>
|
||||
</project>
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.618.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.625.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
// i dunno this looks about right??
|
||||
// the guard against zero draw height is intended for zero-length hold notes. yes, such cases have been spotted in the wild.
|
||||
if (sprite.DrawHeight > 0)
|
||||
bodySprite.Scale = new Vector2(1, MathF.Max(1, scaleDirection * 32800 / sprite.DrawHeight));
|
||||
bodySprite.Scale = new Vector2(1, scaleDirection * MathF.Max(1, 32800 / sprite.DrawHeight));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -53,9 +53,11 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Begin()
|
||||
{
|
||||
if (objectsInRotation != null)
|
||||
if (OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Begin)} a rotate operation while another is in progress!");
|
||||
|
||||
base.Begin();
|
||||
|
||||
changeHandler?.BeginChange();
|
||||
|
||||
objectsInRotation = selectedMovableObjects.ToArray();
|
||||
@@ -68,10 +70,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Update(float rotation, Vector2? origin = null)
|
||||
{
|
||||
if (objectsInRotation == null)
|
||||
if (!OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Update)} a rotate operation without calling {nameof(Begin)} first!");
|
||||
|
||||
Debug.Assert(originalPositions != null && originalPathControlPointPositions != null && defaultOrigin != null);
|
||||
Debug.Assert(objectsInRotation != null && originalPositions != null && originalPathControlPointPositions != null && defaultOrigin != null);
|
||||
|
||||
Vector2 actualOrigin = origin ?? defaultOrigin.Value;
|
||||
|
||||
@@ -91,11 +93,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Commit()
|
||||
{
|
||||
if (objectsInRotation == null)
|
||||
if (!OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Commit)} a rotate operation without calling {nameof(Begin)} first!");
|
||||
|
||||
changeHandler?.EndChange();
|
||||
|
||||
base.Commit();
|
||||
|
||||
objectsInRotation = null;
|
||||
originalPositions = null;
|
||||
originalPathControlPointPositions = null;
|
||||
|
||||
@@ -72,9 +72,11 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Begin()
|
||||
{
|
||||
if (objectsInScale != null)
|
||||
if (OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Begin)} a scale operation while another is in progress!");
|
||||
|
||||
base.Begin();
|
||||
|
||||
changeHandler?.BeginChange();
|
||||
|
||||
objectsInScale = selectedMovableObjects.ToDictionary(ho => ho, ho => new OriginalHitObjectState(ho));
|
||||
@@ -86,10 +88,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
if (objectsInScale == null)
|
||||
if (!OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Update)} a scale operation without calling {nameof(Begin)} first!");
|
||||
|
||||
Debug.Assert(defaultOrigin != null && OriginalSurroundingQuad != null);
|
||||
Debug.Assert(objectsInScale != null && defaultOrigin != null && OriginalSurroundingQuad != null);
|
||||
|
||||
Vector2 actualOrigin = origin ?? defaultOrigin.Value;
|
||||
|
||||
@@ -117,11 +119,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
public override void Commit()
|
||||
{
|
||||
if (objectsInScale == null)
|
||||
if (!OperationInProgress.Value)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Commit)} a rotate operation without calling {nameof(Begin)} first!");
|
||||
|
||||
changeHandler?.EndChange();
|
||||
|
||||
base.Commit();
|
||||
|
||||
objectsInScale = null;
|
||||
OriginalSurroundingQuad = null;
|
||||
defaultOrigin = null;
|
||||
|
||||
@@ -77,13 +77,15 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
case GlobalAction.EditorToggleRotateControl:
|
||||
{
|
||||
rotateButton.TriggerClick();
|
||||
if (!RotationHandler.OperationInProgress.Value || rotateButton.Selected.Value)
|
||||
rotateButton.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
case GlobalAction.EditorToggleScaleControl:
|
||||
{
|
||||
scaleButton.TriggerClick();
|
||||
if (!ScaleHandler.OperationInProgress.Value || scaleButton.Selected.Value)
|
||||
scaleButton.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
if (!positionTransferred && JudgedObject is DrawableOsuHitObject osuObject && JudgedObject.IsInUse)
|
||||
{
|
||||
Position = osuObject.ToSpaceOfOtherDrawable(osuObject.OriginPosition, Parent!);
|
||||
Scale = new Vector2(osuObject.HitObject.Scale);
|
||||
switch (osuObject)
|
||||
{
|
||||
case DrawableSlider slider:
|
||||
Position = slider.TailCircle.ToSpaceOfOtherDrawable(slider.TailCircle.OriginPosition, Parent!);
|
||||
break;
|
||||
|
||||
default:
|
||||
Position = osuObject.ToSpaceOfOtherDrawable(osuObject.OriginPosition, Parent!);
|
||||
break;
|
||||
}
|
||||
|
||||
positionTransferred = true;
|
||||
|
||||
Scale = new Vector2(osuObject.HitObject.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,5 +296,109 @@ namespace osu.Game.Tests.Editing
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(8800));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreaksAtEndOfBeatmapAreRemoved()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 2000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(10000, 15000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualBreaksAtEndOfBeatmapAreRemoved()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 2000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new ManualBreakPeriod(10000, 15000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreaksAtStartOfBeatmapAreRemoved()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 10000 },
|
||||
new HitCircle { StartTime = 11000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(0, 9000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualBreaksAtStartOfBeatmapAreRemoved()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 10000 },
|
||||
new HitCircle { StartTime = 11000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new ManualBreakPeriod(0, 9000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.DailyChallenge
|
||||
{
|
||||
public partial class TestSceneDailyChallengeScoreBreakdown : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
||||
|
||||
[Test]
|
||||
public void TestBasicAppearance()
|
||||
{
|
||||
DailyChallengeScoreBreakdown breakdown = null!;
|
||||
|
||||
AddStep("create content", () => Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4,
|
||||
},
|
||||
breakdown = new DailyChallengeScoreBreakdown
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
});
|
||||
AddSliderStep("adjust width", 0.1f, 1, 1, width =>
|
||||
{
|
||||
if (breakdown.IsNotNull())
|
||||
breakdown.Width = width;
|
||||
});
|
||||
AddSliderStep("adjust height", 0.1f, 1, 1, height =>
|
||||
{
|
||||
if (breakdown.IsNotNull())
|
||||
breakdown.Height = height;
|
||||
});
|
||||
|
||||
AddStep("set initial data", () => breakdown.SetInitialCounts([1, 4, 9, 16, 25, 36, 49, 36, 25, 16, 9, 4, 1]));
|
||||
AddStep("add new score", () =>
|
||||
{
|
||||
var testScore = TestResources.CreateTestScoreInfo();
|
||||
testScore.TotalScore = RNG.Next(1_000_000);
|
||||
|
||||
breakdown.AddNewScore(testScore);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
targetContainer = getTargetContainer();
|
||||
initialRotation = targetContainer!.Rotation;
|
||||
|
||||
base.Begin();
|
||||
}
|
||||
|
||||
public override void Update(float rotation, Vector2? origin = null)
|
||||
@@ -102,6 +104,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
targetContainer = null;
|
||||
initialRotation = null;
|
||||
|
||||
base.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Online.Rooms
|
||||
@@ -42,14 +43,14 @@ namespace osu.Game.Online.Rooms
|
||||
/// <summary>
|
||||
/// Returns the total duration from the <see cref="PlaylistItem"/> in playlist order from the supplied <paramref name="playlist"/>,
|
||||
/// </summary>
|
||||
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist) =>
|
||||
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist, RulesetStore rulesetStore) =>
|
||||
playlist.Select(p =>
|
||||
{
|
||||
double rate = 1;
|
||||
|
||||
if (p.RequiredMods.Length > 0)
|
||||
{
|
||||
var ruleset = p.Beatmap.Ruleset.CreateInstance();
|
||||
var ruleset = rulesetStore.GetRuleset(p.RulesetID)!.CreateInstance();
|
||||
rate = ModUtils.CalculateRateWithMods(p.RequiredMods.Select(mod => mod.ToMod(ruleset)));
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
originalRotations = objectsInRotation.ToDictionary(d => d, d => d.Rotation);
|
||||
originalPositions = objectsInRotation.ToDictionary(d => d, d => d.ToScreenSpace(d.OriginPosition));
|
||||
defaultOrigin = GeometryUtils.GetSurroundingQuad(objectsInRotation.SelectMany(d => d.ScreenSpaceDrawQuad.GetVertices().ToArray())).Centre;
|
||||
|
||||
base.Begin();
|
||||
}
|
||||
|
||||
public override void Update(float rotation, Vector2? origin = null)
|
||||
@@ -99,6 +101,8 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
originalPositions = null;
|
||||
originalRotations = null;
|
||||
defaultOrigin = null;
|
||||
|
||||
base.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,9 +381,12 @@ namespace osu.Game.Rulesets.Scoring
|
||||
if (rank.Value == ScoreRank.F)
|
||||
return;
|
||||
|
||||
rank.Value = RankFromScore(Accuracy.Value, ScoreResultCounts);
|
||||
ScoreRank newRank = RankFromScore(Accuracy.Value, ScoreResultCounts);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
rank.Value = mod.AdjustRank(Rank.Value, Accuracy.Value);
|
||||
newRank = mod.AdjustRank(newRank, Accuracy.Value);
|
||||
|
||||
rank.Value = newRank;
|
||||
}
|
||||
|
||||
protected virtual double ComputeTotalScore(double comboProgress, double accuracyProgress, double bonusPortion)
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
if (rotationHandler == null) return false;
|
||||
|
||||
if (rotationHandler.OperationInProgress.Value)
|
||||
return false;
|
||||
|
||||
rotationHandler.Begin();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
if (scaleHandler == null) return false;
|
||||
|
||||
if (scaleHandler.OperationInProgress.Value)
|
||||
return false;
|
||||
|
||||
originalAnchor = Anchor;
|
||||
|
||||
scaleHandler.Begin();
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
public partial class SelectionRotationHandler : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether there is any ongoing scale operation right now.
|
||||
/// </summary>
|
||||
public Bindable<bool> OperationInProgress { get; private set; } = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Whether rotation anchored by the selection origin can currently be performed.
|
||||
/// </summary>
|
||||
@@ -50,6 +55,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </remarks>
|
||||
public virtual void Begin()
|
||||
{
|
||||
OperationInProgress.Value = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,6 +91,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </remarks>
|
||||
public virtual void Commit()
|
||||
{
|
||||
OperationInProgress.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
public partial class SelectionScaleHandler : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether there is any ongoing scale operation right now.
|
||||
/// </summary>
|
||||
public Bindable<bool> OperationInProgress { get; private set; } = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Whether horizontal scaling (from the left or right edge) support should be enabled.
|
||||
/// </summary>
|
||||
@@ -63,6 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </remarks>
|
||||
public virtual void Begin()
|
||||
{
|
||||
OperationInProgress.Value = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,6 +105,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </remarks>
|
||||
public virtual void Commit()
|
||||
{
|
||||
OperationInProgress.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
changeHandler?.BeginChange();
|
||||
updateState();
|
||||
|
||||
double min = beatmap.HitObjects.Last(ho => ho.GetEndTime() <= Break.Value.StartTime).GetEndTime();
|
||||
double max = beatmap.HitObjects.First(ho => ho.StartTime >= Break.Value.EndTime).StartTime;
|
||||
double min = beatmap.HitObjects.LastOrDefault(ho => ho.GetEndTime() <= Break.Value.StartTime)?.GetEndTime() ?? double.NegativeInfinity;
|
||||
double max = beatmap.HitObjects.FirstOrDefault(ho => ho.StartTime >= Break.Value.EndTime)?.StartTime ?? double.PositiveInfinity;
|
||||
|
||||
if (isStartHandle)
|
||||
max = Math.Min(max, Break.Value.EndTime - BreakPeriod.MIN_BREAK_DURATION);
|
||||
|
||||
@@ -40,8 +40,12 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
foreach (var manualBreak in Beatmap.Breaks.ToList())
|
||||
{
|
||||
if (Beatmap.HitObjects.Any(ho => ho.StartTime <= manualBreak.EndTime && ho.GetEndTime() >= manualBreak.StartTime))
|
||||
if (manualBreak.EndTime <= Beatmap.HitObjects.FirstOrDefault()?.StartTime
|
||||
|| manualBreak.StartTime >= Beatmap.HitObjects.LastOrDefault()?.GetEndTime()
|
||||
|| Beatmap.HitObjects.Any(ho => ho.StartTime <= manualBreak.EndTime && ho.GetEndTime() >= manualBreak.StartTime))
|
||||
{
|
||||
Beatmap.Breaks.Remove(manualBreak);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < Beatmap.HitObjects.Count; ++i)
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
// 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.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public partial class OverlinedPlaylistHeader : OverlinedHeader
|
||||
{
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; } = null!;
|
||||
|
||||
public OverlinedPlaylistHeader()
|
||||
: base("Playlist")
|
||||
{
|
||||
@@ -16,7 +21,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Playlist.BindCollectionChanged((_, _) => Details.Value = Playlist.GetTotalDuration(), true);
|
||||
Playlist.BindCollectionChanged((_, _) => Details.Value = Playlist.GetTotalDuration(rulesets), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
{
|
||||
public partial class DailyChallengeScoreBreakdown : CompositeDrawable
|
||||
{
|
||||
private FillFlowContainer<Bar> barsContainer = null!;
|
||||
|
||||
private const int bin_count = 13;
|
||||
private long[] bins = new long[bin_count];
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new SectionHeader("Score breakdown"),
|
||||
barsContainer = new FillFlowContainer<Bar>
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.9f,
|
||||
Padding = new MarginPadding { Top = 35 },
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < bin_count; ++i)
|
||||
{
|
||||
LocalisableString? label = null;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
label = @$"{100 * i}k";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
label = @"1M";
|
||||
break;
|
||||
}
|
||||
|
||||
barsContainer.Add(new Bar(label)
|
||||
{
|
||||
Width = 1f / bin_count,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void AddNewScore(IScoreInfo scoreInfo)
|
||||
{
|
||||
int targetBin = (int)Math.Clamp(Math.Floor((float)scoreInfo.TotalScore / 100000), 0, bin_count - 1);
|
||||
bins[targetBin] += 1;
|
||||
updateCounts();
|
||||
|
||||
var text = new OsuSpriteText
|
||||
{
|
||||
Text = scoreInfo.TotalScore.ToString(@"N0"),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Font = OsuFont.Default.With(size: 30),
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = (targetBin + 0.5f) / bin_count - 0.5f,
|
||||
Alpha = 0,
|
||||
};
|
||||
AddInternal(text);
|
||||
|
||||
Scheduler.AddDelayed(() =>
|
||||
{
|
||||
float startY = ToLocalSpace(barsContainer[targetBin].CircularBar.ScreenSpaceDrawQuad.TopLeft).Y;
|
||||
text.FadeInFromZero()
|
||||
.ScaleTo(new Vector2(0.8f), 500, Easing.OutElasticHalf)
|
||||
.MoveToY(startY)
|
||||
.MoveToOffset(new Vector2(0, -50), 2500, Easing.OutQuint)
|
||||
.FadeOut(2500, Easing.OutQuint)
|
||||
.Expire();
|
||||
}, 150);
|
||||
}
|
||||
|
||||
public void SetInitialCounts(long[] counts)
|
||||
{
|
||||
if (counts.Length != bin_count)
|
||||
throw new ArgumentException(@"Incorrect number of bins.", nameof(counts));
|
||||
|
||||
bins = counts;
|
||||
updateCounts();
|
||||
}
|
||||
|
||||
private void updateCounts()
|
||||
{
|
||||
long max = bins.Max();
|
||||
for (int i = 0; i < bin_count; ++i)
|
||||
barsContainer[i].UpdateCounts(bins[i], max);
|
||||
}
|
||||
|
||||
private partial class Bar : CompositeDrawable
|
||||
{
|
||||
private readonly LocalisableString? label;
|
||||
|
||||
private long count;
|
||||
private long max;
|
||||
|
||||
public Container CircularBar { get; private set; } = null!;
|
||||
|
||||
public Bar(LocalisableString? label = null)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
AddInternal(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Bottom = 20,
|
||||
Horizontal = 3,
|
||||
},
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Masking = true,
|
||||
Child = CircularBar = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Height = 0.01f,
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
Colour = colourProvider.Highlight1,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (label != null)
|
||||
{
|
||||
AddInternal(new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Text = label.Value,
|
||||
Colour = colourProvider.Content2,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
CircularBar.CornerRadius = Math.Min(CircularBar.DrawHeight / 2, CircularBar.DrawWidth / 4);
|
||||
}
|
||||
|
||||
public void UpdateCounts(long newCount, long newMax)
|
||||
{
|
||||
bool isIncrement = newCount > count;
|
||||
|
||||
count = newCount;
|
||||
max = newMax;
|
||||
|
||||
CircularBar.ResizeHeightTo(0.01f + 0.99f * count / max, 300, Easing.OutQuint);
|
||||
if (isIncrement)
|
||||
CircularBar.FlashColour(Colour4.White, 600, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osuTK;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
@@ -78,6 +79,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; } = null!;
|
||||
|
||||
private IBindable<APIUser> localUser = null!;
|
||||
|
||||
private readonly Room room;
|
||||
@@ -366,7 +370,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
public void SelectBeatmap() => editPlaylistButton.TriggerClick();
|
||||
|
||||
private void onPlaylistChanged(object? sender, NotifyCollectionChangedEventArgs e) =>
|
||||
playlistLength.Text = $"Length: {Playlist.GetTotalDuration()}";
|
||||
playlistLength.Text = $"Length: {Playlist.GetTotalDuration(rulesets)}";
|
||||
|
||||
private bool hasValidSettings => RoomID.Value == null && NameField.Text.Length > 0 && Playlist.Count > 0
|
||||
&& hasValidDuration;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.618.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.625.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.622.0" />
|
||||
<PackageReference Include="Sentry" Version="4.3.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@
|
||||
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.618.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.625.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user