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

Merge branch 'master' into skin-editor-null-ref-on-game-exit

This commit is contained in:
Bartłomiej Dach 2022-06-06 21:49:13 +02:00 committed by GitHub
commit f7ae156bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 240 additions and 173 deletions

View File

@ -59,12 +59,14 @@ namespace osu.Game.Tests.Gameplay
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new TestJudgement(HitResult.Great)) { Type = HitResult.Great });
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(1_000_000));
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
Assert.That(scoreProcessor.Combo.Value, Is.EqualTo(1));
// No header shouldn't cause any change
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame());
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(1_000_000));
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
Assert.That(scoreProcessor.Combo.Value, Is.EqualTo(1));
// Reset with a miss instead.
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame
@ -74,6 +76,7 @@ namespace osu.Game.Tests.Gameplay
Assert.That(scoreProcessor.TotalScore.Value, Is.Zero);
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
Assert.That(scoreProcessor.Combo.Value, Is.EqualTo(0));
// Reset with no judged hit.
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame
@ -83,6 +86,7 @@ namespace osu.Game.Tests.Gameplay
Assert.That(scoreProcessor.TotalScore.Value, Is.Zero);
Assert.That(scoreProcessor.JudgedHits, Is.Zero);
Assert.That(scoreProcessor.Combo.Value, Is.EqualTo(0));
}
private class TestJudgement : Judgement

View File

@ -128,11 +128,11 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("Ensure no adjacent day separators", () =>
{
var indices = chatDisplay.FillFlow.OfType<DrawableChannel.DaySeparator>().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
var indices = chatDisplay.FillFlow.OfType<DaySeparator>().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
foreach (int i in indices)
{
if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DrawableChannel.DaySeparator)
if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DaySeparator)
return false;
}

View File

@ -319,6 +319,15 @@ namespace osu.Game.Beatmaps
});
}
public void DeleteAllVideos()
{
realm.Write(r =>
{
var items = r.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected);
beatmapModelManager.DeleteVideos(items.ToList());
});
}
public void UndeleteAll()
{
realm.Run(r => beatmapModelManager.Undelete(r.All<BeatmapSetInfo>().Where(s => s.DeletePending).ToList()));

View File

@ -16,6 +16,7 @@ using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Skinning;
using osu.Game.Stores;
using osu.Game.Overlays.Notifications;
#nullable enable
@ -33,6 +34,8 @@ namespace osu.Game.Beatmaps
protected override string[] HashableFileTypes => new[] { ".osu" };
public static readonly string[] VIDEO_EXTENSIONS = { ".mp4", ".mov", ".avi", ".flv" };
public BeatmapModelManager(RealmAccess realm, Storage storage, BeatmapOnlineLookupQueue? onlineLookupQueue = null)
: base(realm, storage, onlineLookupQueue)
{
@ -114,5 +117,50 @@ namespace osu.Game.Beatmaps
item.CopyChangesToRealm(existing);
});
}
/// <summary>
/// Delete videos from a list of beatmaps.
/// This will post notifications tracking progress.
/// </summary>
public void DeleteVideos(List<BeatmapSetInfo> items, bool silent = false)
{
if (items.Count == 0) return;
var notification = new ProgressNotification
{
Progress = 0,
Text = $"Preparing to delete all {HumanisedModelName} videos...",
CompletionText = "No videos found to delete!",
State = ProgressNotificationState.Active,
};
if (!silent)
PostNotification?.Invoke(notification);
int i = 0;
int deleted = 0;
foreach (var b in items)
{
if (notification.State == ProgressNotificationState.Cancelled)
// user requested abort
return;
var video = b.Files.FirstOrDefault(f => VIDEO_EXTENSIONS.Any(ex => f.Filename.EndsWith(ex, StringComparison.Ordinal)));
if (video != null)
{
DeleteFile(b, video);
deleted++;
notification.CompletionText = $"Deleted {deleted} {HumanisedModelName} video(s)!";
}
notification.Text = $"Deleting videos from {HumanisedModelName}s ({deleted} deleted)";
notification.Progress = (float)++i / items.Count;
}
notification.State = ProgressNotificationState.Completed;
}
}
}

View File

@ -2,11 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using System.IO;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -65,6 +67,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
{
get
{
if (BeatmapModelManager.VIDEO_EXTENSIONS.Contains(File.Extension))
return FontAwesome.Regular.FileVideo;
switch (File.Extension)
{
case @".ogg":
@ -77,12 +82,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
case @".png":
return FontAwesome.Regular.FileImage;
case @".mp4":
case @".avi":
case @".mov":
case @".flv":
return FontAwesome.Regular.FileVideo;
default:
return FontAwesome.Regular.File;
}

View File

@ -29,6 +29,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString DeleteAllBeatmaps => new TranslatableString(getKey(@"delete_all_beatmaps"), @"Delete ALL beatmaps");
/// <summary>
/// "Delete ALL beatmap videos"
/// </summary>
public static LocalisableString DeleteAllBeatmapVideos => new TranslatableString(getKey(@"delete_all_beatmap_videos"), @"Delete ALL beatmap videos");
/// <summary>
/// "Import scores from stable"
/// </summary>

View File

@ -155,9 +155,6 @@ namespace osu.Game.Online.Chat
{
public Func<Message, ChatLine> CreateChatLineAction;
[Resolved]
private OsuColour colours { get; set; }
public StandAloneDrawableChannel(Channel channel)
: base(channel)
{
@ -166,25 +163,40 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader]
private void load()
{
// TODO: Remove once DrawableChannel & ChatLine padding is fixed
ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 };
}
protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m);
protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time)
protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new StandAloneDaySeparator(time);
}
protected class StandAloneDaySeparator : DaySeparator
{
protected override float TextSize => 14;
protected override float LineHeight => 1;
protected override float Spacing => 10;
protected override float DateAlign => 120;
public StandAloneDaySeparator(DateTimeOffset time)
: base(time)
{
TextSize = 14,
Colour = colours.Yellow,
LineHeight = 1,
Padding = new MarginPadding { Horizontal = 10 },
Margin = new MarginPadding { Vertical = 5 },
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Height = 25;
Colour = colours.Yellow;
// TODO: Remove once DrawableChannel & ChatLine padding is fixed
Padding = new MarginPadding { Horizontal = 10 };
}
}
protected class StandAloneMessage : ChatLine
{
protected override float TextSize => 15;
protected override float HorizontalPadding => 10;
protected override float MessagePadding => 120;
protected override float TimestampPadding => 50;

View File

@ -6,10 +6,6 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
namespace osu.Game.Overlays.Chat
@ -24,85 +20,19 @@ namespace osu.Game.Overlays.Chat
[BackgroundDependencyLoader]
private void load()
{
// TODO: Remove once DrawableChannel & ChatLine padding is fixed
ChatLineFlow.Padding = new MarginPadding(0);
}
protected override Drawable CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time);
protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time);
private class ChatOverlayDaySeparator : Container
private class ChatOverlayDaySeparator : DaySeparator
{
private readonly DateTimeOffset time;
public ChatOverlayDaySeparator(DateTimeOffset time)
: base(time)
{
this.time = time;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = 15, Vertical = 20 };
Child = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, 200),
new Dimension(GridSizeMode.Absolute, 15),
new Dimension(),
},
Content = new[]
{
new[]
{
new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 15),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new[]
{
new Circle
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Colour = colourProvider.Background5,
RelativeSizeAxes = Axes.X,
Height = 2,
},
Drawable.Empty(),
new OsuSpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(),
Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold),
Colour = colourProvider.Content1,
},
},
},
},
Drawable.Empty(),
new Circle
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Colour = colourProvider.Background5,
RelativeSizeAxes = Axes.X,
Height = 2,
},
},
},
};
// TODO: Remove once DrawableChannel & ChatLine padding is fixed
Padding = new MarginPadding { Horizontal = 15 };
}
}
}

View File

@ -0,0 +1,105 @@
// 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 enable
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Chat
{
public class DaySeparator : Container
{
protected virtual float TextSize => 15;
protected virtual float LineHeight => 2;
protected virtual float DateAlign => 200;
protected virtual float Spacing => 15;
private readonly DateTimeOffset time;
[Resolved(CanBeNull = true)]
private OverlayColourProvider? colourProvider { get; set; }
public DaySeparator(DateTimeOffset time)
{
this.time = time;
Height = 40;
}
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.X;
Child = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RowDimensions = new[] { new Dimension() },
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, DateAlign),
new Dimension(GridSizeMode.Absolute, Spacing),
new Dimension(),
},
Content = new[]
{
new[]
{
new GridContainer
{
RelativeSizeAxes = Axes.Both,
RowDimensions = new[] { new Dimension() },
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, Spacing),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new[]
{
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = LineHeight,
Colour = colourProvider?.Background5 ?? Colour4.White,
},
Drawable.Empty(),
new OsuSpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(),
Font = OsuFont.Torus.With(size: TextSize, weight: FontWeight.SemiBold),
Colour = colourProvider?.Content1 ?? Colour4.White,
},
}
},
},
Drawable.Empty(),
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = LineHeight,
Colour = colourProvider?.Background5 ?? Colour4.White,
},
}
}
};
}
}
}

View File

@ -7,14 +7,9 @@ using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osuTK.Graphics;
@ -40,9 +35,6 @@ namespace osu.Game.Overlays.Chat
}
}
[Resolved]
private OsuColour colours { get; set; }
public DrawableChannel(Channel channel)
{
Channel = channel;
@ -67,7 +59,7 @@ namespace osu.Game.Overlays.Chat
Padding = new MarginPadding { Bottom = 5 },
Child = ChatLineFlow = new FillFlowContainer
{
Padding = new MarginPadding { Left = 20, Right = 20 },
Padding = new MarginPadding { Horizontal = 15 },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
@ -121,11 +113,7 @@ namespace osu.Game.Overlays.Chat
protected virtual ChatLine CreateChatLine(Message m) => new ChatLine(m);
protected virtual Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time)
{
Colour = colours.ChatBlue.Lighten(0.7f),
Margin = new MarginPadding { Vertical = 10 },
};
protected virtual DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time);
private void newMessagesArrived(IEnumerable<Message> newMessages) => Schedule(() =>
{
@ -203,69 +191,5 @@ namespace osu.Game.Overlays.Chat
});
private IEnumerable<ChatLine> chatLines => ChatLineFlow.Children.OfType<ChatLine>();
public class DaySeparator : Container
{
public float TextSize
{
get => text.Font.Size;
set => text.Font = text.Font.With(size: value);
}
private float lineHeight = 2;
public float LineHeight
{
get => lineHeight;
set => lineHeight = leftBox.Height = rightBox.Height = value;
}
private readonly SpriteText text;
private readonly Box leftBox;
private readonly Box rightBox;
public DaySeparator(DateTimeOffset time)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Child = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
},
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize), },
Content = new[]
{
new Drawable[]
{
leftBox = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = lineHeight,
},
text = new OsuSpriteText
{
Margin = new MarginPadding { Horizontal = 10 },
Text = time.ToLocalTime().ToString("dd MMM yyyy"),
},
rightBox = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Height = lineHeight,
},
}
}
};
}
}
}
}

View File

@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private SettingsButton deleteSkinsButton;
private SettingsButton restoreButton;
private SettingsButton undeleteButton;
private SettingsButton deleteBeatmapVideosButton;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, [CanBeNull] CollectionManager collectionManager, [CanBeNull] LegacyImportManager legacyImportManager, IDialogOverlay dialogOverlay)
@ -58,6 +59,19 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
}
});
Add(deleteBeatmapVideosButton = new DangerousSettingsButton
{
Text = MaintenanceSettingsStrings.DeleteAllBeatmapVideos,
Action = () =>
{
dialogOverlay?.Push(new MassVideoDeleteConfirmationDialog(() =>
{
deleteBeatmapVideosButton.Enabled.Value = false;
Task.Run(beatmaps.DeleteAllVideos).ContinueWith(t => Schedule(() => deleteBeatmapVideosButton.Enabled.Value = true));
}));
}
});
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importScoresButton = new SettingsButton

View File

@ -0,0 +1,16 @@
// 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;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class MassVideoDeleteConfirmationDialog : MassDeleteConfirmationDialog
{
public MassVideoDeleteConfirmationDialog(Action deleteAction)
: base(deleteAction)
{
BodyText = "All beatmap videos? This cannot be undone!";
}
}
}

View File

@ -460,6 +460,7 @@ namespace osu.Game.Rulesets.Scoring
currentMaximumScoringValues.BaseScore = maximum.BaseScore;
currentMaximumScoringValues.MaxCombo = maximum.MaxCombo;
Combo.Value = frame.Header.Combo;
HighestCombo.Value = frame.Header.MaxCombo;
scoreResultCounts.Clear();