mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge branch 'master' into fix-mp-resuming
This commit is contained in:
commit
20f71da2c4
@ -1,7 +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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
@ -13,7 +12,6 @@ using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -33,14 +31,10 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
Files =
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.mp4",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
}
|
||||
})
|
||||
CheckTestHelpers.CreateMockFile("mp4"),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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 System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
@ -12,7 +12,6 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -25,25 +24,17 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var file = CheckTestHelpers.CreateMockFile("jpg");
|
||||
|
||||
check = new CheckBackgroundQuality();
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
||||
Metadata = new BeatmapMetadata { BackgroundFile = file.Filename },
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo
|
||||
{
|
||||
Hash = "abcdef"
|
||||
}
|
||||
}
|
||||
})
|
||||
Files = { file }
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -54,7 +45,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
// While this is a problem, it is out of scope for this check and is caught by a different one.
|
||||
beatmap.Metadata.BackgroundFile = string.Empty;
|
||||
var context = getContext(null, new MemoryStream(System.Array.Empty<byte>()));
|
||||
var context = getContext(null, new MemoryStream(Array.Empty<byte>()));
|
||||
|
||||
Assert.That(check.Run(context), Is.Empty);
|
||||
}
|
||||
|
@ -1,11 +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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -22,22 +20,17 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var file = CheckTestHelpers.CreateMockFile("jpg");
|
||||
|
||||
check = new CheckBackgroundPresence();
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata { BackgroundFile = "abc123.jpg" },
|
||||
Metadata = new BeatmapMetadata { BackgroundFile = file.Filename },
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
}
|
||||
})
|
||||
Files = { file }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
18
osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
Normal file
18
osu.Game.Tests/Editing/Checks/CheckTestHelpers.cs
Normal 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 osu.Game.Beatmaps;
|
||||
using osu.Game.IO;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
public static class CheckTestHelpers
|
||||
{
|
||||
public static BeatmapSetFileInfo CreateMockFile(string extension) =>
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = $"abc123.{extension}",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
};
|
||||
}
|
||||
}
|
@ -1,7 +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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ManagedBass;
|
||||
@ -14,7 +13,6 @@ using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Audio;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -34,14 +32,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.wav",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
}
|
||||
})
|
||||
Files = { CheckTestHelpers.CreateMockFile("wav") }
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -55,11 +46,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
public void TestDifferentExtension()
|
||||
{
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Add(new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
});
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Add(CheckTestHelpers.CreateMockFile("jpg"));
|
||||
|
||||
// Should fail to load, but not produce an error due to the extension not being expected to load.
|
||||
Assert.IsEmpty(check.Run(getContext(null, allowMissing: true)));
|
||||
|
@ -1,7 +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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
@ -10,7 +9,6 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Checks;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using FileInfo = osu.Game.IO.FileInfo;
|
||||
|
||||
namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
@ -30,14 +28,10 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Files = new List<BeatmapSetFileInfo>(new[]
|
||||
Files =
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = "abc123.jpg",
|
||||
FileInfo = new FileInfo { Hash = "abcdef" }
|
||||
}
|
||||
})
|
||||
CheckTestHelpers.CreateMockFile("jpg"),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -36,8 +36,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None;
|
||||
|
||||
[NotNull]
|
||||
public List<BeatmapSetFileInfo> Files { get; set; } = new List<BeatmapSetFileInfo>();
|
||||
public List<BeatmapSetFileInfo> Files { get; } = new List<BeatmapSetFileInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The maximum star difficulty of all beatmaps in this set.
|
||||
|
@ -392,7 +392,8 @@ namespace osu.Game.Database
|
||||
{
|
||||
LogForModel(item, @"Beginning import...");
|
||||
|
||||
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
|
||||
if (archive != null)
|
||||
item.Files.AddRange(createFileInfos(archive, Files));
|
||||
item.Hash = ComputeHash(item);
|
||||
|
||||
await Populate(item, archive, cancellationToken).ConfigureAwait(false);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
@ -12,7 +13,8 @@ namespace osu.Game.Database
|
||||
public interface IHasFiles<TFile>
|
||||
where TFile : INamedFileInfo
|
||||
{
|
||||
List<TFile> Files { get; set; }
|
||||
[NotNull]
|
||||
List<TFile> Files { get; }
|
||||
|
||||
string Hash { get; set; }
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ namespace osu.Game.Database
|
||||
/// 9 2021-11-04 Converted BeatmapMetadata.Author from string to RealmUser.
|
||||
/// 10 2021-11-22 Use ShortName instead of RulesetID for ruleset settings.
|
||||
/// 11 2021-11-22 Use ShortName instead of RulesetID for ruleset key bindings.
|
||||
/// 12 2021-11-24 Add Status to RealmBeatmapSet.
|
||||
/// </summary>
|
||||
private const int schema_version = 11;
|
||||
private const int schema_version = 12;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking context creation during blocking periods.
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Models
|
||||
}
|
||||
|
||||
[MapTo(nameof(Status))]
|
||||
public int StatusInt { get; set; }
|
||||
public int StatusInt { get; set; } = (int)BeatmapOnlineStatus.None;
|
||||
|
||||
[Indexed]
|
||||
public int OnlineID { get; set; } = -1;
|
||||
|
@ -32,6 +32,15 @@ namespace osu.Game.Models
|
||||
|
||||
public IList<RealmNamedFileUsage> Files { get; } = null!;
|
||||
|
||||
public BeatmapOnlineStatus Status
|
||||
{
|
||||
get => (BeatmapOnlineStatus)StatusInt;
|
||||
set => StatusInt = (int)value;
|
||||
}
|
||||
|
||||
[MapTo(nameof(Status))]
|
||||
public int StatusInt { get; set; } = (int)BeatmapOnlineStatus.None;
|
||||
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
|
@ -394,7 +394,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
if (Score.Mods.Length > 0 && modsContainer.Any(s => s.IsHovered) && songSelect != null)
|
||||
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = Score.Mods));
|
||||
|
||||
if (Score.Files?.Count > 0)
|
||||
if (Score.Files.Count > 0)
|
||||
items.Add(new OsuMenuItem("Export", MenuItemType.Standard, () => scoreManager.Export(Score)));
|
||||
|
||||
if (Score.ID != 0)
|
||||
|
@ -160,7 +160,7 @@ namespace osu.Game.Scoring
|
||||
[NotMapped]
|
||||
public List<HitEvent> HitEvents { get; set; }
|
||||
|
||||
public List<ScoreFileInfo> Files { get; set; }
|
||||
public List<ScoreFileInfo> Files { get; } = new List<ScoreFileInfo>();
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
||||
|
@ -24,9 +24,6 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected override IEnumerable<string> GetFilenames(string name)
|
||||
{
|
||||
if (source.Files == null)
|
||||
yield break;
|
||||
|
||||
foreach (string filename in base.GetFilenames(name))
|
||||
{
|
||||
string path = getPathForFile(filename.ToStandardisedPath());
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Skinning
|
||||
string filename = $"{skinnableTarget}.json";
|
||||
|
||||
// skininfo files may be null for default skin.
|
||||
var fileInfo = SkinInfo.Files?.FirstOrDefault(f => f.Filename == filename);
|
||||
var fileInfo = SkinInfo.Files.FirstOrDefault(f => f.Filename == filename);
|
||||
|
||||
if (fileInfo == null)
|
||||
continue;
|
||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Skinning
|
||||
return (Skin)Activator.CreateInstance(type, this, resources);
|
||||
}
|
||||
|
||||
public List<SkinFileInfo> Files { get; set; } = new List<SkinFileInfo>();
|
||||
public List<SkinFileInfo> Files { get; } = new List<SkinFileInfo>();
|
||||
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
|
@ -87,23 +87,19 @@ namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
AddStep("setup skins", () =>
|
||||
{
|
||||
userSkinInfo.Files = new List<SkinFileInfo>
|
||||
userSkinInfo.Files.Clear();
|
||||
userSkinInfo.Files.Add(new SkinFileInfo
|
||||
{
|
||||
new SkinFileInfo
|
||||
{
|
||||
Filename = userFile,
|
||||
FileInfo = new IO.FileInfo { Hash = userFile }
|
||||
}
|
||||
};
|
||||
Filename = userFile,
|
||||
FileInfo = new IO.FileInfo { Hash = userFile }
|
||||
});
|
||||
|
||||
beatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>
|
||||
beatmapInfo.BeatmapSet.Files.Clear();
|
||||
beatmapInfo.BeatmapSet.Files.Add(new BeatmapSetFileInfo
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = beatmapFile,
|
||||
FileInfo = new IO.FileInfo { Hash = beatmapFile }
|
||||
}
|
||||
};
|
||||
Filename = beatmapFile,
|
||||
FileInfo = new IO.FileInfo { Hash = beatmapFile }
|
||||
});
|
||||
|
||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
||||
dependencies.SkinSource = new SkinProvidingContainer(Skin = new LegacySkin(userSkinInfo, this));
|
||||
|
Loading…
Reference in New Issue
Block a user