1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 23:42:55 +08:00

Merge branch 'master' into taiko-geki-katu

This commit is contained in:
Dean Herbert 2022-09-07 16:22:47 +09:00 committed by GitHub
commit 5b758afd09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 387 additions and 108 deletions

View File

@ -117,6 +117,26 @@ namespace osu.Game.Tests.Beatmaps.Formats
}
}
[Test]
public void TestEarliestStartTimeWithLoopAlphas()
{
var decoder = new LegacyStoryboardDecoder();
using (var resStream = TestResources.OpenResource("loop-containing-earlier-non-zero-fade.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var storyboard = decoder.Decode(stream);
StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3);
Assert.AreEqual(2, background.Elements.Count);
Assert.AreEqual(1000, background.Elements[0].StartTime);
Assert.AreEqual(1000, background.Elements[1].StartTime);
Assert.AreEqual(1000, storyboard.EarliestEventTime);
}
}
[Test]
public void TestDecodeVariableWithSuffix()
{

View File

@ -0,0 +1,14 @@
osu file format v14
[Events]
//Storyboard Layer 0 (Background)
Sprite,Background,TopCentre,"img.jpg",320,240
L,1000,1
F,0,0,,1 // fade inside a loop with non-zero alpha and an earlier start time should be the true start time..
F,0,2000,,0 // ..not a zero alpha fade with a later start time
Sprite,Background,TopCentre,"img.jpg",320,240
L,2000,1
F,0,0,24,0 // fade inside a loop with zero alpha but later start time than the top-level zero alpha start time.
F,0,24,48,1
F,0,1000,,1 // ..so this should be the true start time

View File

@ -0,0 +1,85 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Storyboards;
using osu.Game.Tests.Beatmaps.IO;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneDifficultyDelete : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
protected override bool IsolateSavingFromDatabase => false;
[Resolved]
private OsuGameBase game { get; set; } = null!;
[Resolved]
private BeatmapManager beatmaps { get; set; } = null!;
private BeatmapSetInfo importedBeatmapSet = null!;
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null!)
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
public override void SetUpSteps()
{
AddStep("import test beatmap", () => importedBeatmapSet = BeatmapImportHelper.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely());
base.SetUpSteps();
}
[Test]
public void TestDeleteDifficulties()
{
Guid deletedDifficultyID = Guid.Empty;
int countBeforeDeletion = 0;
string beatmapSetHashBefore = string.Empty;
for (int i = 0; i < 12; i++)
{
// Will be reloaded after each deletion.
AddUntilStep("wait for editor to load", () => Editor?.ReadyForUse == true);
AddStep("store selected difficulty", () =>
{
deletedDifficultyID = EditorBeatmap.BeatmapInfo.ID;
countBeforeDeletion = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count;
beatmapSetHashBefore = Beatmap.Value.BeatmapSetInfo.Hash;
});
AddStep("click File", () => this.ChildrenOfType<DrawableOsuMenuItem>().First().TriggerClick());
if (i == 11)
{
// last difficulty shouldn't be able to be deleted.
AddAssert("Delete menu item disabled", () => getDeleteMenuItem().Item.Action.Disabled);
}
else
{
AddStep("click delete", () => getDeleteMenuItem().TriggerClick());
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog != null);
AddStep("confirm", () => InputManager.Key(Key.Number1));
AddAssert($"difficulty {i} is deleted", () => Beatmap.Value.BeatmapSetInfo.Beatmaps.Select(b => b.ID), () => Does.Not.Contain(deletedDifficultyID));
AddAssert("count decreased by one", () => Beatmap.Value.BeatmapSetInfo.Beatmaps.Count, () => Is.EqualTo(countBeforeDeletion - 1));
AddAssert("set hash changed", () => Beatmap.Value.BeatmapSetInfo.Hash, () => Is.Not.EqualTo(beatmapSetHashBefore));
}
}
}
private DrawableOsuMenuItem getDeleteMenuItem() => this.ChildrenOfType<DrawableOsuMenuItem>()
.Single(item => item.ChildrenOfType<SpriteText>().Any(text => text.Text.ToString().StartsWith("Delete", StringComparison.Ordinal)));
}
}

View File

@ -66,18 +66,20 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestCase(-10000, -10000, true)]
public void TestStoryboardProducesCorrectStartTimeFadeInAfterOtherEvents(double firstStoryboardEvent, double expectedStartTime, bool addEventToLoop)
{
const double loop_start_time = -20000;
var storyboard = new Storyboard();
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
// these should be ignored as we have an alpha visibility blocker proceeding this command.
sprite.TimelineGroup.Scale.Add(Easing.None, -20000, -18000, 0, 1);
var loopGroup = sprite.AddLoop(-20000, 50);
loopGroup.Scale.Add(Easing.None, -20000, -18000, 0, 1);
sprite.TimelineGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
var loopGroup = sprite.AddLoop(loop_start_time, 50);
loopGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
var target = addEventToLoop ? loopGroup : sprite.TimelineGroup;
double targetTime = addEventToLoop ? 20000 : 0;
target.Alpha.Add(Easing.None, targetTime + firstStoryboardEvent, targetTime + firstStoryboardEvent + 500, 0, 1);
double loopRelativeOffset = addEventToLoop ? -loop_start_time : 0;
target.Alpha.Add(Easing.None, loopRelativeOffset + firstStoryboardEvent, loopRelativeOffset + firstStoryboardEvent + 500, 0, 1);
// these should be ignored due to being in the future.
sprite.TimelineGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1);

View File

@ -301,7 +301,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(1));
clickNotificationIfAny();
clickNotification();
AddAssert("check " + volumeName, assert);
@ -370,8 +370,12 @@ namespace osu.Game.Tests.Visual.Gameplay
batteryInfo.SetChargeLevel(chargeLevel);
}));
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
AddAssert($"notification {(shouldWarn ? "triggered" : "not triggered")}", () => notificationOverlay.UnreadCount.Value == (shouldWarn ? 1 : 0));
clickNotificationIfAny();
if (shouldWarn)
clickNotification();
else
AddAssert("notification not triggered", () => notificationOverlay.UnreadCount.Value == 0);
AddUntilStep("wait for player load", () => player.IsLoaded);
}
@ -436,9 +440,13 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
}
private void clickNotificationIfAny()
private void clickNotification()
{
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()?.TriggerClick());
Notification notification = null;
AddUntilStep("wait for notification", () => (notification = notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()) != null);
AddStep("open notification overlay", () => notificationOverlay.Show());
AddStep("click notification", () => notification.TriggerClick());
}
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
@ -13,7 +11,7 @@ namespace osu.Game.Tests.Visual.Navigation
{
public class TestSceneStartupImport : OsuGameTestScene
{
private string importFilename;
private string? importFilename;
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
@ -23,9 +24,12 @@ namespace osu.Game.Tests.Visual.UserInterface
private SpriteText displayedCount = null!;
public double TimeToCompleteProgress { get; set; } = 2000;
[SetUp]
public void SetUp() => Schedule(() =>
{
TimeToCompleteProgress = 2000;
progressingNotifications.Clear();
Content.Children = new Drawable[]
@ -41,10 +45,36 @@ namespace osu.Game.Tests.Visual.UserInterface
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
});
[Test]
public void TestPresence()
{
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
AddStep(@"post notification", sendBackgroundNotification);
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
}
[Test]
public void TestPresenceWithManualDismiss()
{
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
AddStep(@"post notification", sendBackgroundNotification);
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().Single().TriggerClick());
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
}
[Test]
public void TestCompleteProgress()
{
ProgressNotification notification = null!;
AddStep("add progress notification", () =>
{
notification = new ProgressNotification
@ -57,6 +87,31 @@ namespace osu.Game.Tests.Visual.UserInterface
});
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
AddUntilStep("wait forwarded", () => notificationOverlay.ToastCount == 0);
}
[Test]
public void TestCompleteProgressSlow()
{
ProgressNotification notification = null!;
AddStep("Set progress slow", () => TimeToCompleteProgress *= 2);
AddStep("add progress notification", () =>
{
notification = new ProgressNotification
{
Text = @"Uploading to BSS...",
CompletionText = "Uploaded to BSS!",
};
notificationOverlay.Post(notification);
progressingNotifications.Add(notification);
});
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
}
[Test]
@ -177,7 +232,7 @@ namespace osu.Game.Tests.Visual.UserInterface
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
{
if (n.Progress < 1)
n.Progress += (float)(Time.Elapsed / 2000);
n.Progress += (float)(Time.Elapsed / TimeToCompleteProgress);
else
n.State = ProgressNotificationState.Completed;
}

View File

@ -25,6 +25,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
public bool ShowScore
{
get => teamDisplay.ShowScore;
set => teamDisplay.ShowScore = value;
}
@ -92,10 +93,14 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
private void teamChanged(ValueChangedEvent<TournamentTeam> team)
{
bool wasShowingScores = teamDisplay?.ShowScore ?? false;
InternalChildren = new Drawable[]
{
teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0),
};
teamDisplay.ShowScore = wasShowingScores;
}
}
}

View File

@ -280,7 +280,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
protected override bool OnClick(ClickEvent e)
{
if (editorInfo == null || Match is ConditionalTournamentMatch)
if (editorInfo == null || Match is ConditionalTournamentMatch || e.Button != MouseButton.Left)
return false;
Selected = true;

View File

@ -46,7 +46,10 @@ namespace osu.Game.Tournament.Screens.MapPool
Loop = true,
RelativeSizeAxes = Axes.Both,
},
new MatchHeader(),
new MatchHeader
{
ShowScores = true,
},
mapFlows = new FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>>
{
Y = 160,

View File

@ -319,8 +319,7 @@ namespace osu.Game.Beatmaps
AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo));
setInfo.Hash = beatmapImporter.ComputeHash(setInfo);
setInfo.Status = BeatmapOnlineStatus.LocallyModified;
updateHashAndMarkDirty(setInfo);
Realm.Write(r =>
{
@ -363,6 +362,33 @@ namespace osu.Game.Beatmaps
});
}
/// <summary>
/// Delete a beatmap difficulty immediately.
/// </summary>
/// <remarks>
/// There's no undoing this operation, as we don't have a soft-deletion flag on <see cref="BeatmapInfo"/>.
/// This may be a future consideration if there's a user requirement for undeleting support.
/// </remarks>
public void DeleteDifficultyImmediately(BeatmapInfo beatmapInfo)
{
Realm.Write(r =>
{
if (!beatmapInfo.IsManaged)
beatmapInfo = r.Find<BeatmapInfo>(beatmapInfo.ID);
Debug.Assert(beatmapInfo.BeatmapSet != null);
Debug.Assert(beatmapInfo.File != null);
var setInfo = beatmapInfo.BeatmapSet;
DeleteFile(setInfo, beatmapInfo.File);
setInfo.Beatmaps.Remove(beatmapInfo);
updateHashAndMarkDirty(setInfo);
workingBeatmapCache.Invalidate(setInfo);
});
}
/// <summary>
/// Delete videos from a list of beatmaps.
/// This will post notifications tracking progress.
@ -416,6 +442,12 @@ namespace osu.Game.Beatmaps
public Task<Live<BeatmapSetInfo>?> ImportAsUpdate(ProgressNotification notification, ImportTask importTask, BeatmapSetInfo original) =>
beatmapImporter.ImportAsUpdate(notification, importTask, original);
private void updateHashAndMarkDirty(BeatmapSetInfo setInfo)
{
setInfo.Hash = beatmapImporter.ComputeHash(setInfo);
setInfo.Status = BeatmapOnlineStatus.LocallyModified;
}
#region Implementation of ICanAcceptFiles
public Task Import(params string[] paths) => beatmapImporter.Import(paths);

View File

@ -88,6 +88,7 @@ namespace osu.Game.Graphics.UserInterface
if (Text.Length > 0)
{
Text = string.Empty;
PlayFeedbackSample(FeedbackSampleType.TextRemove);
return true;
}
}

View File

@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
private bool selectionStarted;
private double sampleLastPlaybackTime;
private enum FeedbackSampleType
protected enum FeedbackSampleType
{
TextAdd,
TextAddCaps,
@ -117,30 +117,30 @@ namespace osu.Game.Graphics.UserInterface
return;
if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples)
playSample(FeedbackSampleType.TextAddCaps);
PlayFeedbackSample(FeedbackSampleType.TextAddCaps);
else
playSample(FeedbackSampleType.TextAdd);
PlayFeedbackSample(FeedbackSampleType.TextAdd);
}
protected override void OnUserTextRemoved(string removed)
{
base.OnUserTextRemoved(removed);
playSample(FeedbackSampleType.TextRemove);
PlayFeedbackSample(FeedbackSampleType.TextRemove);
}
protected override void NotifyInputError()
{
base.NotifyInputError();
playSample(FeedbackSampleType.TextInvalid);
PlayFeedbackSample(FeedbackSampleType.TextInvalid);
}
protected override void OnTextCommitted(bool textChanged)
{
base.OnTextCommitted(textChanged);
playSample(FeedbackSampleType.TextConfirm);
PlayFeedbackSample(FeedbackSampleType.TextConfirm);
}
protected override void OnCaretMoved(bool selecting)
@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface
base.OnCaretMoved(selecting);
if (!selecting)
playSample(FeedbackSampleType.CaretMove);
PlayFeedbackSample(FeedbackSampleType.CaretMove);
}
protected override void OnTextSelectionChanged(TextSelectionType selectionType)
@ -158,15 +158,15 @@ namespace osu.Game.Graphics.UserInterface
switch (selectionType)
{
case TextSelectionType.Character:
playSample(FeedbackSampleType.SelectCharacter);
PlayFeedbackSample(FeedbackSampleType.SelectCharacter);
break;
case TextSelectionType.Word:
playSample(selectionStarted ? FeedbackSampleType.SelectCharacter : FeedbackSampleType.SelectWord);
PlayFeedbackSample(selectionStarted ? FeedbackSampleType.SelectCharacter : FeedbackSampleType.SelectWord);
break;
case TextSelectionType.All:
playSample(FeedbackSampleType.SelectAll);
PlayFeedbackSample(FeedbackSampleType.SelectAll);
break;
}
@ -179,7 +179,7 @@ namespace osu.Game.Graphics.UserInterface
if (!selectionStarted) return;
playSample(FeedbackSampleType.Deselect);
PlayFeedbackSample(FeedbackSampleType.Deselect);
selectionStarted = false;
}
@ -198,13 +198,13 @@ namespace osu.Game.Graphics.UserInterface
case 1:
// composition probably ended by pressing backspace, or was cancelled.
playSample(FeedbackSampleType.TextRemove);
PlayFeedbackSample(FeedbackSampleType.TextRemove);
return;
default:
// longer text removed, composition ended because it was cancelled.
// could be a different sample if desired.
playSample(FeedbackSampleType.TextRemove);
PlayFeedbackSample(FeedbackSampleType.TextRemove);
return;
}
}
@ -212,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface
if (addedTextLength > 0)
{
// some text was added, probably due to typing new text or by changing the candidate.
playSample(FeedbackSampleType.TextAdd);
PlayFeedbackSample(FeedbackSampleType.TextAdd);
return;
}
@ -220,14 +220,14 @@ namespace osu.Game.Graphics.UserInterface
{
// text was probably removed by backspacing.
// it's also possible that a candidate that only removed text was changed to.
playSample(FeedbackSampleType.TextRemove);
PlayFeedbackSample(FeedbackSampleType.TextRemove);
return;
}
if (caretMoved)
{
// only the caret/selection was moved.
playSample(FeedbackSampleType.CaretMove);
PlayFeedbackSample(FeedbackSampleType.CaretMove);
}
}
@ -238,13 +238,13 @@ namespace osu.Game.Graphics.UserInterface
if (successful)
{
// composition was successfully completed, usually by pressing the enter key.
playSample(FeedbackSampleType.TextConfirm);
PlayFeedbackSample(FeedbackSampleType.TextConfirm);
}
else
{
// composition was prematurely ended, eg. by clicking inside the textbox.
// could be a different sample if desired.
playSample(FeedbackSampleType.TextConfirm);
PlayFeedbackSample(FeedbackSampleType.TextConfirm);
}
}
@ -283,7 +283,7 @@ namespace osu.Game.Graphics.UserInterface
return samples[RNG.Next(0, samples.Length)]?.GetChannel();
}
private void playSample(FeedbackSampleType feedbackSample) => Schedule(() =>
protected void PlayFeedbackSample(FeedbackSampleType feedbackSample) => Schedule(() =>
{
if (Time.Current < sampleLastPlaybackTime + 15) return;

View File

@ -71,7 +71,6 @@ namespace osu.Game.Overlays
},
mainContent = new Container
{
AlwaysPresent = true,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
@ -137,7 +136,9 @@ namespace osu.Game.Overlays
private readonly Scheduler postScheduler = new Scheduler();
public override bool IsPresent => base.IsPresent || postScheduler.HasPendingTasks;
public override bool IsPresent =>
// Delegate presence as we need to consider the toast tray in addition to the main overlay.
State.Value == Visibility.Visible || mainContent.IsPresent || toastTray.IsPresent || postScheduler.HasPendingTasks;
private bool processingPosts = true;

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
@ -23,6 +24,8 @@ namespace osu.Game.Overlays
/// </summary>
public class NotificationOverlayToastTray : CompositeDrawable
{
public override bool IsPresent => toastContentBackground.Height > 0 || toastFlow.Count > 0;
public bool IsDisplayingToasts => toastFlow.Count > 0;
private FillFlowContainer<Notification> toastFlow = null!;
@ -33,8 +36,12 @@ namespace osu.Game.Overlays
public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }
public int UnreadCount => toastFlow.Count(n => !n.WasClosed && !n.Read)
+ InternalChildren.OfType<Notification>().Count(n => !n.WasClosed && !n.Read);
public int UnreadCount => allDisplayedNotifications.Count(n => !n.WasClosed && !n.Read);
/// <summary>
/// Notifications contained in the toast flow, or in a detached state while they animate during forwarding to the main overlay.
/// </summary>
private IEnumerable<Notification> allDisplayedNotifications => toastFlow.Concat(InternalChildren.OfType<Notification>());
private int runningDepth;
@ -55,6 +62,7 @@ namespace osu.Game.Overlays
colourProvider.Background6.Opacity(0.7f),
colourProvider.Background6.Opacity(0.5f)),
RelativeSizeAxes = Axes.Both,
Height = 0,
}.WithEffect(new BlurEffect
{
PadExtent = true,
@ -66,7 +74,7 @@ namespace osu.Game.Overlays
postEffectDrawable.AutoSizeAxes = Axes.None;
postEffectDrawable.RelativeSizeAxes = Axes.X;
})),
toastFlow = new AlwaysUpdateFillFlowContainer<Notification>
toastFlow = new FillFlowContainer<Notification>
{
LayoutDuration = 150,
LayoutEasing = Easing.OutQuart,
@ -143,8 +151,8 @@ namespace osu.Game.Overlays
{
base.Update();
float height = toastFlow.DrawHeight + 120;
float alpha = IsDisplayingToasts ? MathHelper.Clamp(toastFlow.DrawHeight / 40, 0, 1) * toastFlow.Children.Max(n => n.Alpha) : 0;
float height = toastFlow.Count > 0 ? toastFlow.DrawHeight + 120 : 0;
float alpha = toastFlow.Count > 0 ? MathHelper.Clamp(toastFlow.DrawHeight / 41, 0, 1) * toastFlow.Children.Max(n => n.Alpha) : 0;
toastContentBackground.Height = (float)Interpolation.DampContinuously(toastContentBackground.Height, height, 10, Clock.ElapsedFrameTime);
toastContentBackground.Alpha = (float)Interpolation.DampContinuously(toastContentBackground.Alpha, alpha, 10, Clock.ElapsedFrameTime);

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Framework.Graphics.Colour;

View File

@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Notifications
base.LoadComplete();
// we may have received changes before we were displayed.
updateState();
Scheduler.AddOnce(updateState);
}
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
@ -87,8 +87,8 @@ namespace osu.Game.Overlays.Notifications
state = value;
if (IsLoaded)
Schedule(updateState);
Scheduler.AddOnce(updateState);
attemptPostCompletion();
}
}
@ -141,11 +141,33 @@ namespace osu.Game.Overlays.Notifications
case ProgressNotificationState.Completed:
loadingSpinner.Hide();
Completed();
attemptPostCompletion();
base.Close();
break;
}
}
private bool completionSent;
/// <summary>
/// Attempt to post a completion notification.
/// </summary>
private void attemptPostCompletion()
{
if (state != ProgressNotificationState.Completed) return;
// This notification may not have been posted yet (and thus may not have a target to post the completion to).
// Completion posting will be re-attempted in a scheduled invocation.
if (CompletionTarget == null)
return;
if (completionSent)
return;
CompletionTarget.Invoke(CreateCompletionNotification());
completionSent = true;
}
private ProgressNotificationState state;
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
@ -154,14 +176,10 @@ namespace osu.Game.Overlays.Notifications
Text = CompletionText
};
protected void Completed()
{
CompletionTarget?.Invoke(CreateCompletionNotification());
base.Close();
}
public override bool DisplayOnTop => false;
public override bool IsImportant => false;
private readonly ProgressBar progressBar;
private Color4 colourQueued;
private Color4 colourActive;

View File

@ -0,0 +1,18 @@
// 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.Game.Beatmaps;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Edit
{
public class DeleteDifficultyConfirmationDialog : DeleteConfirmationDialog
{
public DeleteDifficultyConfirmationDialog(BeatmapInfo beatmapInfo, Action deleteAction)
{
BodyText = $"\"{beatmapInfo.DifficultyName}\" difficulty";
DeleteAction = deleteAction;
}
}
}

View File

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework;
@ -879,35 +878,61 @@ namespace osu.Game.Screens.Edit
clock.SeekForward(!trackPlaying, amount);
}
private void updateLastSavedHash()
{
lastSavedHash = changeHandler?.CurrentStateHash;
}
private List<MenuItem> createFileMenuItems() => new List<MenuItem>
{
new EditorMenuItem("Save", MenuItemType.Standard, () => Save()),
new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap) { Action = { Disabled = !RuntimeInfo.IsDesktop } },
new EditorMenuItemSpacer(),
createDifficultyCreationMenu(),
createDifficultySwitchMenu(),
new EditorMenuItemSpacer(),
new EditorMenuItem("Delete difficulty", MenuItemType.Standard, deleteDifficulty) { Action = { Disabled = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count < 2 } },
new EditorMenuItemSpacer(),
new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit)
};
private void exportBeatmap()
{
Save();
new LegacyBeatmapExporter(storage).Export(Beatmap.Value.BeatmapSetInfo);
}
private void updateLastSavedHash()
/// <summary>
/// Beatmaps of the currently edited set, grouped by ruleset and ordered by difficulty.
/// </summary>
private IOrderedEnumerable<IGrouping<RulesetInfo, BeatmapInfo>> groupedOrderedBeatmaps => Beatmap.Value.BeatmapSetInfo.Beatmaps
.OrderBy(b => b.StarRating)
.GroupBy(b => b.Ruleset)
.OrderBy(group => group.Key);
private void deleteDifficulty()
{
lastSavedHash = changeHandler?.CurrentStateHash;
if (dialogOverlay == null)
delete();
else
dialogOverlay.Push(new DeleteDifficultyConfirmationDialog(Beatmap.Value.BeatmapInfo, delete));
void delete()
{
BeatmapInfo difficultyToDelete = playableBeatmap.BeatmapInfo;
var difficultiesBeforeDeletion = groupedOrderedBeatmaps.SelectMany(g => g).ToList();
beatmapManager.DeleteDifficultyImmediately(difficultyToDelete);
int deletedIndex = difficultiesBeforeDeletion.IndexOf(difficultyToDelete);
// of note, we're still working with the cloned version, so indices are all prior to deletion.
BeatmapInfo nextToShow = difficultiesBeforeDeletion[deletedIndex == 0 ? 1 : deletedIndex - 1];
Beatmap.Value = beatmapManager.GetWorkingBeatmap(nextToShow);
SwitchToDifficulty(nextToShow);
}
private List<MenuItem> createFileMenuItems()
{
var fileMenuItems = new List<MenuItem>
{
new EditorMenuItem("Save", MenuItemType.Standard, () => Save())
};
if (RuntimeInfo.IsDesktop)
fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
fileMenuItems.Add(new EditorMenuItemSpacer());
fileMenuItems.Add(createDifficultyCreationMenu());
fileMenuItems.Add(createDifficultySwitchMenu());
fileMenuItems.Add(new EditorMenuItemSpacer());
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
return fileMenuItems;
}
private EditorMenuItem createDifficultyCreationMenu()
@ -939,18 +964,14 @@ namespace osu.Game.Screens.Edit
private EditorMenuItem createDifficultySwitchMenu()
{
var beatmapSet = playableBeatmap.BeatmapInfo.BeatmapSet;
Debug.Assert(beatmapSet != null);
var difficultyItems = new List<MenuItem>();
foreach (var rulesetBeatmaps in beatmapSet.Beatmaps.GroupBy(b => b.Ruleset).OrderBy(group => group.Key))
foreach (var rulesetBeatmaps in groupedOrderedBeatmaps)
{
if (difficultyItems.Count > 0)
difficultyItems.Add(new EditorMenuItemSpacer());
foreach (var beatmap in rulesetBeatmaps.OrderBy(b => b.StarRating))
foreach (var beatmap in rulesetBeatmaps)
{
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmap);
difficultyItems.Add(new DifficultyMenuItem(beatmap, isCurrentDifficulty, SwitchToDifficulty));

View File

@ -47,30 +47,11 @@ namespace osu.Game.Storyboards
};
}
/// <summary>
/// Returns the earliest visible time. Will be null unless this group's first <see cref="Alpha"/> command has a start value of zero.
/// </summary>
public double? EarliestDisplayedTime
{
get
{
var first = Alpha.Commands.FirstOrDefault();
return first?.StartValue == 0 ? first.StartTime : null;
}
}
[JsonIgnore]
public double CommandsStartTime
{
get
{
// if the first alpha command starts at zero it should be given priority over anything else.
// this is due to it creating a state where the target is not present before that time, causing any other events to not be visible.
double? earliestDisplay = EarliestDisplayedTime;
if (earliestDisplay != null)
return earliestDisplay.Value;
double min = double.MaxValue;
for (int i = 0; i < timelines.Length; i++)

View File

@ -30,24 +30,35 @@ namespace osu.Game.Storyboards
{
get
{
// check for presence affecting commands as an initial pass.
double earliestStartTime = TimelineGroup.EarliestDisplayedTime ?? double.MaxValue;
// To get the initial start time, we need to check whether the first alpha command to exist (across all loops) has a StartValue of zero.
// A StartValue of zero governs, above all else, the first valid display time of a sprite.
//
// You can imagine that the first command of each type decides that type's start value, so if the initial alpha is zero,
// anything before that point can be ignored (the sprite is not visible after all).
var alphaCommands = new List<(double startTime, bool isZeroStartValue)>();
foreach (var l in loops)
var command = TimelineGroup.Alpha.Commands.FirstOrDefault();
if (command != null) alphaCommands.Add((command.StartTime, command.StartValue == 0));
foreach (var loop in loops)
{
if (l.EarliestDisplayedTime is double loopEarliestDisplayTime)
earliestStartTime = Math.Min(earliestStartTime, l.LoopStartTime + loopEarliestDisplayTime);
command = loop.Alpha.Commands.FirstOrDefault();
if (command != null) alphaCommands.Add((command.StartTime + loop.LoopStartTime, command.StartValue == 0));
}
if (earliestStartTime < double.MaxValue)
return earliestStartTime;
if (alphaCommands.Count > 0)
{
var firstAlpha = alphaCommands.OrderBy(t => t.startTime).First();
// if an alpha-affecting command was not found, use the earliest of any command.
earliestStartTime = TimelineGroup.StartTime;
if (firstAlpha.isZeroStartValue)
return firstAlpha.startTime;
}
// If we got to this point, either no alpha commands were present, or the earliest had a non-zero start value.
// The sprite's StartTime will be determined by the earliest command, regardless of type.
double earliestStartTime = TimelineGroup.StartTime;
foreach (var l in loops)
earliestStartTime = Math.Min(earliestStartTime, l.StartTime);
return earliestStartTime;
}
}