1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 23:36:10 +08:00

Initialise all file lists at construction time (and remove setter)

This commit is contained in:
Dean Herbert 2021-11-24 13:42:07 +09:00
parent 049f25a133
commit 99a139dc98
7 changed files with 10 additions and 9 deletions

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
@ -34,8 +33,7 @@ namespace osu.Game.Beatmaps
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;
[NotNull] public List<BeatmapSetFileInfo> Files { get; } = new List<BeatmapSetFileInfo>();
public List<BeatmapSetFileInfo> Files { get; set; } = new List<BeatmapSetFileInfo>();
/// <summary> /// <summary>
/// The maximum star difficulty of all beatmaps in this set. /// The maximum star difficulty of all beatmaps in this set.

View File

@ -392,7 +392,8 @@ namespace osu.Game.Database
{ {
LogForModel(item, @"Beginning import..."); 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); item.Hash = ComputeHash(item);
await Populate(item, archive, cancellationToken).ConfigureAwait(false); await Populate(item, archive, cancellationToken).ConfigureAwait(false);

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations;
namespace osu.Game.Database namespace osu.Game.Database
{ {
@ -12,7 +13,8 @@ namespace osu.Game.Database
public interface IHasFiles<TFile> public interface IHasFiles<TFile>
where TFile : INamedFileInfo where TFile : INamedFileInfo
{ {
List<TFile> Files { get; set; } [NotNull]
List<TFile> Files { get; }
string Hash { get; set; } string Hash { get; set; }
} }

View File

@ -394,7 +394,7 @@ namespace osu.Game.Online.Leaderboards
if (Score.Mods.Length > 0 && modsContainer.Any(s => s.IsHovered) && songSelect != null) 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)); 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))); items.Add(new OsuMenuItem("Export", MenuItemType.Standard, () => scoreManager.Export(Score)));
if (Score.ID != 0) if (Score.ID != 0)

View File

@ -160,7 +160,7 @@ namespace osu.Game.Scoring
[NotMapped] [NotMapped]
public List<HitEvent> HitEvents { get; set; } 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; } public string Hash { get; set; }

View File

@ -59,7 +59,7 @@ namespace osu.Game.Skinning
string filename = $"{skinnableTarget}.json"; string filename = $"{skinnableTarget}.json";
// skininfo files may be null for default skin. // 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) if (fileInfo == null)
continue; continue;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Skinning
return (Skin)Activator.CreateInstance(type, this, resources); 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; } public bool DeletePending { get; set; }