mirror of https://github.com/ppy/osu
Fix CI reported warnings
This commit is contained in:
parent
08da948afc
commit
51251e3204
|
@ -174,7 +174,7 @@ private void load()
|
|||
|
||||
pointGrid.Content = points;
|
||||
|
||||
if (score.HitEvents == null || score.HitEvents.Count == 0)
|
||||
if (score.HitEvents.Count == 0)
|
||||
return;
|
||||
|
||||
// Todo: This should probably not be done like this.
|
||||
|
|
|
@ -31,7 +31,7 @@ public void TestDecodeMetadata()
|
|||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
var meta = beatmap.BeatmapInfo.Metadata;
|
||||
Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet.OnlineID);
|
||||
Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID);
|
||||
Assert.AreEqual("Soleily", meta.Artist);
|
||||
Assert.AreEqual("Soleily", meta.ArtistUnicode);
|
||||
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
||||
|
|
|
@ -56,7 +56,7 @@ public void TestReadMetadata()
|
|||
|
||||
var meta = beatmap.Metadata;
|
||||
|
||||
Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet.OnlineID);
|
||||
Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID);
|
||||
Assert.AreEqual("Soleily", meta.Artist);
|
||||
Assert.AreEqual("Soleily", meta.ArtistUnicode);
|
||||
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
|
@ -30,7 +31,13 @@ public void TestHitObjectAddEvent()
|
|||
|
||||
AddStep("add beatmap", () =>
|
||||
{
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
});
|
||||
editorBeatmap.HitObjectAdded += h => addedObject = h;
|
||||
});
|
||||
|
||||
|
@ -49,7 +56,14 @@ public void HitObjectRemoveEvent()
|
|||
EditorBeatmap editorBeatmap = null;
|
||||
AddStep("add beatmap", () =>
|
||||
{
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects = { hitCircle }
|
||||
});
|
||||
editorBeatmap.HitObjectRemoved += h => removedObject = h;
|
||||
});
|
||||
AddStep("remove hitobject", () => editorBeatmap.Remove(editorBeatmap.HitObjects.First()));
|
||||
|
@ -71,7 +85,14 @@ public void TestInitialHitObjectStartTimeChangeEvent()
|
|||
{
|
||||
EditorBeatmap editorBeatmap;
|
||||
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects = { hitCircle }
|
||||
});
|
||||
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||
});
|
||||
|
||||
|
@ -91,7 +112,13 @@ public void TestAddedHitObjectStartTimeChangeEvent()
|
|||
|
||||
AddStep("add beatmap", () =>
|
||||
{
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
});
|
||||
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||
});
|
||||
|
||||
|
@ -111,7 +138,14 @@ public void TestAddedHitObjectStartTimeChangeEvent()
|
|||
public void TestRemovedHitObjectStartTimeChangeEvent()
|
||||
{
|
||||
var hitCircle = new HitCircle();
|
||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects = { hitCircle }
|
||||
});
|
||||
|
||||
HitObject changedObject = null;
|
||||
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||
|
@ -131,6 +165,10 @@ public void TestAddHitObjectInMiddle()
|
|||
{
|
||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle(),
|
||||
|
@ -156,6 +194,10 @@ public void TestResortWhenStartTimeChanged()
|
|||
|
||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle(),
|
||||
|
@ -185,7 +227,13 @@ public void TestMultipleHitObjectUpdate()
|
|||
{
|
||||
updatedObjects.Clear();
|
||||
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
});
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
|
@ -220,7 +268,13 @@ public void TestDebouncedUpdate()
|
|||
{
|
||||
updatedObjects.Clear();
|
||||
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
});
|
||||
editorBeatmap.Add(new HitCircle());
|
||||
});
|
||||
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
@ -151,12 +149,8 @@ public async Task TestOnlineScoreIsAvailableLocally()
|
|||
|
||||
public static async Task<ScoreInfo> LoadScoreIntoOsu(OsuGameBase osu, ScoreInfo score, ArchiveReader archive = null)
|
||||
{
|
||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
// clone to avoid attaching the input score to realm.
|
||||
score = score.DeepClone();
|
||||
score.BeatmapInfo ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||
score.Ruleset ??= new OsuRuleset().RulesetInfo;
|
||||
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
await scoreManager.Import(score, archive);
|
||||
|
|
|
@ -70,7 +70,7 @@ private void load(GameHost host, AudioManager audio)
|
|||
|
||||
var beatmap = new BeatmapInfo
|
||||
{
|
||||
Ruleset = rulesets.GetRuleset(i % 4),
|
||||
Ruleset = rulesets.GetRuleset(i % 4) ?? throw new InvalidOperationException(),
|
||||
OnlineID = beatmapId,
|
||||
Length = length,
|
||||
BPM = bpm,
|
||||
|
|
|
@ -67,7 +67,7 @@ public void TestManiaFirstBarText()
|
|||
{
|
||||
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Ruleset = rulesets.GetRuleset(3),
|
||||
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException(),
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 5,
|
||||
|
|
|
@ -81,7 +81,7 @@ private void readBracket()
|
|||
|
||||
ladder ??= new LadderInfo();
|
||||
|
||||
ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
|
||||
ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value.ShortName)
|
||||
?? RulesetStore.AvailableRulesets.First();
|
||||
|
||||
bool addedInfo = false;
|
||||
|
|
|
@ -86,7 +86,7 @@ public APIBeatmapSet BeatmapSet
|
|||
/// <returns></returns>
|
||||
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
|
||||
{
|
||||
var ruleset = rulesets.GetRuleset(RulesetID);
|
||||
var ruleset = rulesets.GetRuleset(RulesetID) ?? throw new InvalidOperationException();
|
||||
|
||||
var rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
|
@ -99,7 +99,7 @@ public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = nu
|
|||
{
|
||||
TotalScore = TotalScore,
|
||||
MaxCombo = MaxCombo,
|
||||
BeatmapInfo = beatmap,
|
||||
BeatmapInfo = beatmap ?? new BeatmapInfo(),
|
||||
User = User,
|
||||
Accuracy = Accuracy,
|
||||
OnlineID = OnlineID,
|
||||
|
|
|
@ -73,7 +73,7 @@ public ScoreInfo CreateScoreInfo(RulesetStore rulesets, PlaylistItem playlistIte
|
|||
TotalScore = TotalScore,
|
||||
MaxCombo = MaxCombo,
|
||||
BeatmapInfo = beatmap,
|
||||
Ruleset = rulesets.GetRuleset(playlistItem.RulesetID),
|
||||
Ruleset = rulesets.GetRuleset(playlistItem.RulesetID) ?? throw new InvalidOperationException(),
|
||||
Statistics = Statistics,
|
||||
User = User,
|
||||
Accuracy = Accuracy,
|
||||
|
|
|
@ -1,6 +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;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
|
@ -131,9 +132,14 @@ private void load(RulesetStore rulesets)
|
|||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(2),
|
||||
Children = Score.Mods.Select(mod => new ModIcon(rulesets.GetRuleset(Score.RulesetID).CreateInstance().CreateModFromAcronym(mod.Acronym))
|
||||
Children = Score.Mods.Select(mod =>
|
||||
{
|
||||
var ruleset = rulesets.GetRuleset(Score.RulesetID) ?? throw new InvalidOperationException();
|
||||
|
||||
return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym))
|
||||
{
|
||||
Scale = new Vector2(0.35f)
|
||||
};
|
||||
}).ToList(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
else if (texture.Width < low_width || texture.Height < low_height)
|
||||
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height);
|
||||
|
||||
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet?.GetPathForFile(backgroundFile);
|
||||
|
||||
using (Stream stream = context.WorkingBeatmap.GetStream(storagePath))
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
}
|
||||
|
||||
// If the file is set, also make sure it still exists.
|
||||
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet?.GetPathForFile(filename);
|
||||
if (storagePath != null)
|
||||
yield break;
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
{
|
||||
var beatmapSet = context.Beatmap.BeatmapInfo.BeatmapSet;
|
||||
|
||||
if (beatmapSet != null)
|
||||
{
|
||||
foreach (var file in beatmapSet.Files)
|
||||
{
|
||||
using (Stream data = context.WorkingBeatmap.GetStream(file.File.GetStoragePath()))
|
||||
|
@ -59,6 +61,7 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool hasAudioExtension(string filename) => audioExtensions.Any(filename.ToLower().EndsWith);
|
||||
private bool probablyHasAudioData(Stream data) => data.Length > min_bytes_threshold;
|
||||
|
|
|
@ -21,6 +21,8 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
{
|
||||
var beatmapSet = context.Beatmap.BeatmapInfo.BeatmapSet;
|
||||
|
||||
if (beatmapSet != null)
|
||||
{
|
||||
foreach (var file in beatmapSet.Files)
|
||||
{
|
||||
using (Stream data = context.WorkingBeatmap.GetStream(file.File.GetStoragePath()))
|
||||
|
@ -30,6 +32,7 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class IssueTemplateZeroBytes : IssueTemplate
|
||||
{
|
||||
|
|
|
@ -76,9 +76,6 @@ private void updateCurrentFromSlider()
|
|||
|
||||
var difficulty = beatmap.Value.BeatmapInfo.BaseDifficulty;
|
||||
|
||||
if (difficulty == null)
|
||||
return;
|
||||
|
||||
// generally should always be implemented, else the slider will have a zero default.
|
||||
if (difficultyBindable.ReadCurrentFromDifficulty == null)
|
||||
return;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class DifficultyMenuItem : StatefulMenuItem<bool>
|
|||
public BeatmapInfo BeatmapInfo { get; }
|
||||
|
||||
public DifficultyMenuItem(BeatmapInfo beatmapInfo, bool selected, Action<BeatmapInfo> difficultyChangeFunc)
|
||||
: base(beatmapInfo.DifficultyName ?? "(unnamed)", null)
|
||||
: base(string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? "(unnamed)" : beatmapInfo.DifficultyName, null)
|
||||
{
|
||||
BeatmapInfo = beatmapInfo;
|
||||
State.Value = selected;
|
||||
|
|
|
@ -40,7 +40,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
|
|||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
ruleset = parent.Get<IBindable<WorkingBeatmap>>().Value.BeatmapInfo.Ruleset?.CreateInstance();
|
||||
ruleset = parent.Get<IBindable<WorkingBeatmap>>().Value.BeatmapInfo.Ruleset.CreateInstance();
|
||||
composer = ruleset?.CreateHitObjectComposer();
|
||||
|
||||
// make the composer available to the timeline and other components in this screen.
|
||||
|
|
|
@ -599,6 +599,7 @@ private void confirmExit()
|
|||
if (isNewBeatmap)
|
||||
{
|
||||
// confirming exit without save means we should delete the new beatmap completely.
|
||||
if (playableBeatmap.BeatmapInfo.BeatmapSet != null)
|
||||
beatmapManager.Delete(playableBeatmap.BeatmapInfo.BeatmapSet);
|
||||
|
||||
// eagerly clear contents before restoring default beatmap to prevent value change callbacks from firing.
|
||||
|
|
|
@ -102,7 +102,7 @@ public EditorBeatmap(IBeatmap playableBeatmap, ISkin beatmapSkin = null, Beatmap
|
|||
if (beatmapSkin is Skin skin)
|
||||
BeatmapSkin = new EditorBeatmapSkin(skin);
|
||||
|
||||
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
|
||||
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
|
||||
|
||||
foreach (var obj in HitObjects)
|
||||
trackStartTime(obj);
|
||||
|
|
|
@ -33,7 +33,7 @@ private void load(EditorBeatmap beatmap)
|
|||
new DesignSection(),
|
||||
};
|
||||
|
||||
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateEditorSetupSection();
|
||||
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset.CreateInstance().CreateEditorSetupSection();
|
||||
if (rulesetSpecificSection != null)
|
||||
sectionsEnumerable.Add(rulesetSpecificSection);
|
||||
|
||||
|
|
|
@ -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;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -13,7 +12,6 @@
|
|||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Placeholders;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
|
||||
|
@ -76,7 +74,7 @@ private void populateStatistics(ValueChangedEvent<ScoreInfo> score)
|
|||
if (newScore == null)
|
||||
return;
|
||||
|
||||
if (newScore.HitEvents == null || newScore.HitEvents.Count == 0)
|
||||
if (newScore.HitEvents.Count == 0)
|
||||
{
|
||||
content.Add(new FillFlowContainer
|
||||
{
|
||||
|
@ -104,7 +102,7 @@ private void populateStatistics(ValueChangedEvent<ScoreInfo> score)
|
|||
// Todo: The placement of this is temporary. Eventually we'll both generate the playable beatmap _and_ run through it in a background task to generate the hit events.
|
||||
Task.Run(() =>
|
||||
{
|
||||
playableBeatmap = beatmapManager.GetWorkingBeatmap(newScore.BeatmapInfo).GetPlayableBeatmap(newScore.Ruleset, newScore.Mods ?? Array.Empty<Mod>());
|
||||
playableBeatmap = beatmapManager.GetWorkingBeatmap(newScore.BeatmapInfo).GetPlayableBeatmap(newScore.Ruleset, newScore.Mods);
|
||||
}, loadCancellation.Token).ContinueWith(t => Schedule(() =>
|
||||
{
|
||||
var rows = new FillFlowContainer
|
||||
|
|
|
@ -324,7 +324,7 @@ private void load(OsuColour colours, LocalisationManager localisation, BeatmapDi
|
|||
});
|
||||
|
||||
// no difficulty means it can't have a status to show
|
||||
if (beatmapInfo.DifficultyName == null)
|
||||
if (string.IsNullOrEmpty(beatmapInfo.DifficultyName))
|
||||
StatusPill.Hide();
|
||||
|
||||
addInfoLabels();
|
||||
|
|
|
@ -53,7 +53,7 @@ public FilterCriteria CreateCriteria()
|
|||
if (!maximumStars.IsDefault)
|
||||
criteria.UserStarDifficulty.Max = maximumStars.Value;
|
||||
|
||||
criteria.RulesetCriteria = ruleset.Value.CreateInstance()?.CreateRulesetFilterCriteria();
|
||||
criteria.RulesetCriteria = ruleset.Value.CreateInstance().CreateRulesetFilterCriteria();
|
||||
|
||||
FilterQueryParser.ApplyQueries(criteria, query);
|
||||
return criteria;
|
||||
|
|
|
@ -98,6 +98,8 @@ protected void SetupSkins(string beatmapFile, string userFile)
|
|||
userSkinInfo.Files.Clear();
|
||||
userSkinInfo.Files.Add(new RealmNamedFileUsage(new RealmFile { Hash = userFile }, userFile));
|
||||
|
||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||
|
||||
beatmapInfo.BeatmapSet.Files.Clear();
|
||||
beatmapInfo.BeatmapSet.Files.Add(new RealmNamedFileUsage(new RealmFile { Hash = beatmapFile }, beatmapFile));
|
||||
|
||||
|
|
Loading…
Reference in New Issue