2023-12-06 08:09:12 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
2023-12-06 08:11:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2023-12-06 08:09:12 +00:00
|
|
|
|
using NUnit.Framework;
|
2023-12-06 08:11:28 +00:00
|
|
|
|
using osu.Framework.Extensions;
|
2023-12-06 08:09:12 +00:00
|
|
|
|
using osu.Framework.Utils;
|
2023-12-06 08:16:20 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2023-12-06 08:09:12 +00:00
|
|
|
|
using osu.Game.Tests.Visual;
|
2023-12-06 08:11:28 +00:00
|
|
|
|
using SharpCompress.Archives.Zip;
|
2023-12-06 08:09:12 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests.Editor
|
|
|
|
|
{
|
|
|
|
|
public partial class TestSceneTaikoEditorSaving : EditorSavingTestScene
|
|
|
|
|
{
|
|
|
|
|
protected override Ruleset CreateRuleset() => new TaikoRuleset();
|
|
|
|
|
|
2023-12-06 08:16:20 +00:00
|
|
|
|
[TestCase(null)]
|
|
|
|
|
[TestCase(1f)]
|
|
|
|
|
[TestCase(2f)]
|
|
|
|
|
[TestCase(2.4f)]
|
|
|
|
|
public void TestTaikoSliderMultiplierInExport(float? multiplier)
|
2023-12-06 08:11:28 +00:00
|
|
|
|
{
|
2023-12-06 08:16:20 +00:00
|
|
|
|
if (multiplier.HasValue)
|
|
|
|
|
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.SliderMultiplier = multiplier.Value);
|
2023-12-06 08:11:28 +00:00
|
|
|
|
|
|
|
|
|
SaveEditor();
|
|
|
|
|
AddStep("export beatmap", () => Game.BeatmapManager.Export(EditorBeatmap.BeatmapInfo.BeatmapSet!).WaitSafely());
|
|
|
|
|
|
|
|
|
|
AddAssert("check slider multiplier correct in file", () =>
|
|
|
|
|
{
|
|
|
|
|
string export = LocalStorage.GetFiles("exports").First();
|
|
|
|
|
|
|
|
|
|
using (var stream = LocalStorage.GetStream(export))
|
|
|
|
|
using (var zip = ZipArchive.Open(stream))
|
|
|
|
|
{
|
|
|
|
|
using (var osuStream = zip.Entries.First().OpenEntryStream())
|
|
|
|
|
using (var reader = new StreamReader(osuStream))
|
|
|
|
|
{
|
|
|
|
|
string? line;
|
|
|
|
|
|
|
|
|
|
while ((line = reader.ReadLine()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (line.StartsWith("SliderMultiplier", StringComparison.Ordinal))
|
|
|
|
|
{
|
|
|
|
|
return float.Parse(line.Split(':', StringSplitOptions.TrimEntries).Last(), provider: CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2023-12-06 08:16:20 +00:00
|
|
|
|
}, () => Is.EqualTo(multiplier ?? new BeatmapDifficulty().SliderMultiplier).Within(Precision.FLOAT_EPSILON));
|
2023-12-06 08:11:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-06 08:09:12 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestTaikoSliderMultiplier()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.SliderMultiplier = 2);
|
|
|
|
|
|
|
|
|
|
SaveEditor();
|
|
|
|
|
|
|
|
|
|
AddAssert("Beatmap has correct slider multiplier", assertTaikoSliderMulitplier);
|
|
|
|
|
|
|
|
|
|
ReloadEditorToSameBeatmap();
|
|
|
|
|
|
|
|
|
|
AddAssert("Beatmap still has correct slider multiplier", assertTaikoSliderMulitplier);
|
|
|
|
|
|
|
|
|
|
bool assertTaikoSliderMulitplier()
|
|
|
|
|
{
|
|
|
|
|
return Precision.AlmostEquals(EditorBeatmap.Difficulty.SliderMultiplier, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|