1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 06:23:20 +08:00

Merge pull request #10801 from peppy/fix-legacy-legacy-storyboard-frame-delays

Fix storyboard animations of very old beatmaps playing too slow
This commit is contained in:
Dan Balasescu 2020-11-12 19:06:57 +09:00 committed by GitHub
commit e804fe5458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -16,8 +16,6 @@ namespace osu.Game.Beatmaps.Formats
{
public class LegacyBeatmapDecoder : LegacyDecoder<Beatmap>
{
public const int LATEST_VERSION = 14;
private Beatmap beatmap;
private ConvertHitObjectParser parser;

View File

@ -16,6 +16,8 @@ namespace osu.Game.Beatmaps.Formats
public abstract class LegacyDecoder<T> : Decoder<T>
where T : new()
{
public const int LATEST_VERSION = 14;
protected readonly int FormatVersion;
protected LegacyDecoder(int version)

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Beatmaps.Legacy;
@ -23,15 +24,15 @@ namespace osu.Game.Beatmaps.Formats
private readonly Dictionary<string, string> variables = new Dictionary<string, string>();
public LegacyStoryboardDecoder()
: base(0)
public LegacyStoryboardDecoder(int version = LATEST_VERSION)
: base(version)
{
}
public static void Register()
{
// note that this isn't completely correct
AddDecoder<Storyboard>(@"osu file format v", m => new LegacyStoryboardDecoder());
AddDecoder<Storyboard>(@"osu file format v", m => new LegacyStoryboardDecoder(Parsing.ParseInt(m.Split('v').Last())));
AddDecoder<Storyboard>(@"[Events]", m => new LegacyStoryboardDecoder());
SetFallbackDecoder<Storyboard>(() => new LegacyStoryboardDecoder());
}
@ -133,6 +134,11 @@ namespace osu.Game.Beatmaps.Formats
var y = Parsing.ParseFloat(split[5], Parsing.MAX_COORDINATE_VALUE);
var frameCount = Parsing.ParseInt(split[6]);
var frameDelay = Parsing.ParseDouble(split[7]);
if (FormatVersion < 6)
// this is random as hell but taken straight from osu-stable.
frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f);
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever;
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
storyboard.GetLayer(layer).Add(storyboardSprite);