2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2020-11-12 16:03:42 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-03-08 13:32:03 +08:00
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using osu.Game.IO;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Storyboards;
|
2020-03-08 13:32:03 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Formats
|
|
|
|
|
{
|
|
|
|
|
public class LegacyStoryboardDecoder : LegacyDecoder<Storyboard>
|
|
|
|
|
{
|
|
|
|
|
private StoryboardSprite storyboardSprite;
|
|
|
|
|
private CommandTimelineGroup timelineGroup;
|
|
|
|
|
|
|
|
|
|
private Storyboard storyboard;
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<string, string> variables = new Dictionary<string, string>();
|
|
|
|
|
|
2020-11-12 16:03:42 +08:00
|
|
|
|
public LegacyStoryboardDecoder(int version = LATEST_VERSION)
|
|
|
|
|
: base(version)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Register()
|
|
|
|
|
{
|
|
|
|
|
// note that this isn't completely correct
|
2020-11-12 16:03:42 +08:00
|
|
|
|
AddDecoder<Storyboard>(@"osu file format v", m => new LegacyStoryboardDecoder(Parsing.ParseInt(m.Split('v').Last())));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
AddDecoder<Storyboard>(@"[Events]", m => new LegacyStoryboardDecoder());
|
2019-09-11 04:06:10 +08:00
|
|
|
|
SetFallbackDecoder<Storyboard>(() => new LegacyStoryboardDecoder());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 06:43:30 +08:00
|
|
|
|
protected override void ParseStreamInto(LineBufferedReader stream, Storyboard storyboard)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.storyboard = storyboard;
|
|
|
|
|
base.ParseStreamInto(stream, storyboard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
|
|
|
|
{
|
|
|
|
|
switch (section)
|
|
|
|
|
{
|
2020-10-20 05:32:04 +08:00
|
|
|
|
case Section.General:
|
|
|
|
|
handleGeneral(storyboard, line);
|
|
|
|
|
return;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case Section.Events:
|
|
|
|
|
handleEvents(line);
|
|
|
|
|
return;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case Section.Variables:
|
|
|
|
|
handleVariables(line);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.ParseLine(storyboard, section, line);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 05:32:04 +08:00
|
|
|
|
private void handleGeneral(Storyboard storyboard, string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = SplitKeyVal(line);
|
|
|
|
|
|
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case "UseSkinSprites":
|
|
|
|
|
storyboard.UseSkinSprites = pair.Value == "1";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private void handleEvents(string line)
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
int depth = 0;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2020-02-09 01:05:27 +08:00
|
|
|
|
foreach (char c in line)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-02-09 01:05:27 +08:00
|
|
|
|
if (c == ' ' || c == '_')
|
|
|
|
|
depth++;
|
|
|
|
|
else
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2020-01-25 00:05:27 +08:00
|
|
|
|
|
2020-02-09 01:05:27 +08:00
|
|
|
|
line = line.Substring(depth);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
decodeVariables(ref line);
|
|
|
|
|
|
|
|
|
|
string[] split = line.Split(',');
|
|
|
|
|
|
|
|
|
|
if (depth == 0)
|
|
|
|
|
{
|
|
|
|
|
storyboardSprite = null;
|
|
|
|
|
|
2019-12-10 19:23:15 +08:00
|
|
|
|
if (!Enum.TryParse(split[0], out LegacyEventType type))
|
2019-08-08 13:44:04 +08:00
|
|
|
|
throw new InvalidDataException($@"Unknown event type: {split[0]}");
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
2020-03-08 13:32:03 +08:00
|
|
|
|
case LegacyEventType.Video:
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
int offset = Parsing.ParseInt(split[1]);
|
|
|
|
|
string path = CleanFilename(split[2]);
|
2020-03-08 13:32:03 +08:00
|
|
|
|
|
2020-03-25 11:04:09 +08:00
|
|
|
|
storyboard.GetLayer("Video").Add(new StoryboardVideo(path, offset));
|
2020-03-08 13:32:03 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 19:23:15 +08:00
|
|
|
|
case LegacyEventType.Sprite:
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string layer = parseLayer(split[1]);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var origin = parseOrigin(split[2]);
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string path = CleanFilename(split[3]);
|
|
|
|
|
float x = Parsing.ParseFloat(split[4], Parsing.MAX_COORDINATE_VALUE);
|
|
|
|
|
float y = Parsing.ParseFloat(split[5], Parsing.MAX_COORDINATE_VALUE);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
|
|
|
|
|
storyboard.GetLayer(layer).Add(storyboardSprite);
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 19:23:15 +08:00
|
|
|
|
case LegacyEventType.Animation:
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string layer = parseLayer(split[1]);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var origin = parseOrigin(split[2]);
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string path = CleanFilename(split[3]);
|
|
|
|
|
float x = Parsing.ParseFloat(split[4], Parsing.MAX_COORDINATE_VALUE);
|
|
|
|
|
float y = Parsing.ParseFloat(split[5], Parsing.MAX_COORDINATE_VALUE);
|
|
|
|
|
int frameCount = Parsing.ParseInt(split[6]);
|
|
|
|
|
double frameDelay = Parsing.ParseDouble(split[7]);
|
2020-11-12 16:03:42 +08:00
|
|
|
|
|
|
|
|
|
if (FormatVersion < 6)
|
|
|
|
|
// this is random as hell but taken straight from osu-stable.
|
|
|
|
|
frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f);
|
|
|
|
|
|
2021-01-31 22:33:07 +08:00
|
|
|
|
var loopType = split.Length > 8 ? parseAnimationLoopType(split[8]) : AnimationLoopType.LoopForever;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
|
|
|
|
|
storyboard.GetLayer(layer).Add(storyboardSprite);
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 19:23:15 +08:00
|
|
|
|
case LegacyEventType.Sample:
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
double time = Parsing.ParseDouble(split[1]);
|
|
|
|
|
string layer = parseLayer(split[2]);
|
|
|
|
|
string path = CleanFilename(split[3]);
|
|
|
|
|
float volume = split.Length > 4 ? Parsing.ParseFloat(split[4]) : 100;
|
2019-08-23 19:54:39 +08:00
|
|
|
|
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (depth < 2)
|
|
|
|
|
timelineGroup = storyboardSprite?.TimelineGroup;
|
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string commandType = split[0];
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
switch (commandType)
|
|
|
|
|
{
|
|
|
|
|
case "T":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string triggerName = split[1];
|
|
|
|
|
double startTime = split.Length > 2 ? Parsing.ParseDouble(split[2]) : double.MinValue;
|
|
|
|
|
double endTime = split.Length > 3 ? Parsing.ParseDouble(split[3]) : double.MaxValue;
|
|
|
|
|
int groupNumber = split.Length > 4 ? Parsing.ParseInt(split[4]) : 0;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup = storyboardSprite?.AddTrigger(triggerName, startTime, endTime, groupNumber);
|
|
|
|
|
break;
|
2019-11-11 19:53:22 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "L":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
double startTime = Parsing.ParseDouble(split[1]);
|
|
|
|
|
int repeatCount = Parsing.ParseInt(split[2]);
|
2021-10-01 18:05:08 +08:00
|
|
|
|
timelineGroup = storyboardSprite?.AddLoop(startTime, Math.Max(0, repeatCount - 1));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
2019-11-11 19:53:22 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(split[3]))
|
|
|
|
|
split[3] = split[2];
|
|
|
|
|
|
2020-03-10 10:58:33 +08:00
|
|
|
|
var easing = (Easing)Parsing.ParseInt(split[1]);
|
2021-10-27 12:04:41 +08:00
|
|
|
|
double startTime = Parsing.ParseDouble(split[2]);
|
|
|
|
|
double endTime = Parsing.ParseDouble(split[3]);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
switch (commandType)
|
|
|
|
|
{
|
|
|
|
|
case "F":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startValue = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup?.Alpha.Add(easing, startTime, endTime, startValue, endValue);
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "S":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startValue = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
2019-12-18 16:21:38 +08:00
|
|
|
|
timelineGroup?.Scale.Add(easing, startTime, endTime, startValue, endValue);
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "V":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startX = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float startY = Parsing.ParseFloat(split[5]);
|
|
|
|
|
float endX = split.Length > 6 ? Parsing.ParseFloat(split[6]) : startX;
|
|
|
|
|
float endY = split.Length > 7 ? Parsing.ParseFloat(split[7]) : startY;
|
2019-12-18 16:21:38 +08:00
|
|
|
|
timelineGroup?.VectorScale.Add(easing, startTime, endTime, new Vector2(startX, startY), new Vector2(endX, endY));
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "R":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startValue = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
2020-01-09 03:21:13 +08:00
|
|
|
|
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathUtils.RadiansToDegrees(startValue), MathUtils.RadiansToDegrees(endValue));
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "M":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startX = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float startY = Parsing.ParseFloat(split[5]);
|
|
|
|
|
float endX = split.Length > 6 ? Parsing.ParseFloat(split[6]) : startX;
|
|
|
|
|
float endY = split.Length > 7 ? Parsing.ParseFloat(split[7]) : startY;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup?.X.Add(easing, startTime, endTime, startX, endX);
|
|
|
|
|
timelineGroup?.Y.Add(easing, startTime, endTime, startY, endY);
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "MX":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startValue = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup?.X.Add(easing, startTime, endTime, startValue, endValue);
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "MY":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startValue = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup?.Y.Add(easing, startTime, endTime, startValue, endValue);
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "C":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float startRed = Parsing.ParseFloat(split[4]);
|
|
|
|
|
float startGreen = Parsing.ParseFloat(split[5]);
|
|
|
|
|
float startBlue = Parsing.ParseFloat(split[6]);
|
|
|
|
|
float endRed = split.Length > 7 ? Parsing.ParseFloat(split[7]) : startRed;
|
|
|
|
|
float endGreen = split.Length > 8 ? Parsing.ParseFloat(split[8]) : startGreen;
|
|
|
|
|
float endBlue = split.Length > 9 ? Parsing.ParseFloat(split[9]) : startBlue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
timelineGroup?.Colour.Add(easing, startTime, endTime,
|
|
|
|
|
new Color4(startRed / 255f, startGreen / 255f, startBlue / 255f, 1),
|
|
|
|
|
new Color4(endRed / 255f, endGreen / 255f, endBlue / 255f, 1));
|
2019-11-11 20:05:36 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "P":
|
|
|
|
|
{
|
2021-10-27 12:04:41 +08:00
|
|
|
|
string type = split[4];
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case "A":
|
2019-08-21 12:29:50 +08:00
|
|
|
|
timelineGroup?.BlendingParameters.Add(easing, startTime, endTime, BlendingParameters.Additive, startTime == endTime ? BlendingParameters.Additive : BlendingParameters.Inherit);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "H":
|
|
|
|
|
timelineGroup?.FlipH.Add(easing, startTime, endTime, true, startTime == endTime);
|
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case "V":
|
|
|
|
|
timelineGroup?.FlipV.Add(easing, startTime, endTime, true, startTime == endTime);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-11 20:05:36 +08:00
|
|
|
|
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
default:
|
|
|
|
|
throw new InvalidDataException($@"Unknown command type: {commandType}");
|
|
|
|
|
}
|
2019-11-11 20:05:36 +08:00
|
|
|
|
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 19:23:15 +08:00
|
|
|
|
private string parseLayer(string value) => Enum.Parse(typeof(LegacyStoryLayer), value).ToString();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private Anchor parseOrigin(string value)
|
|
|
|
|
{
|
|
|
|
|
var origin = (LegacyOrigins)Enum.Parse(typeof(LegacyOrigins), value);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
switch (origin)
|
|
|
|
|
{
|
|
|
|
|
case LegacyOrigins.TopLeft:
|
|
|
|
|
return Anchor.TopLeft;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.TopCentre:
|
|
|
|
|
return Anchor.TopCentre;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.TopRight:
|
|
|
|
|
return Anchor.TopRight;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.CentreLeft:
|
|
|
|
|
return Anchor.CentreLeft;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.Centre:
|
|
|
|
|
return Anchor.Centre;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.CentreRight:
|
|
|
|
|
return Anchor.CentreRight;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.BottomLeft:
|
|
|
|
|
return Anchor.BottomLeft;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.BottomCentre:
|
|
|
|
|
return Anchor.BottomCentre;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case LegacyOrigins.BottomRight:
|
|
|
|
|
return Anchor.BottomRight;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-08-22 13:50:03 +08:00
|
|
|
|
default:
|
|
|
|
|
return Anchor.TopLeft;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-31 22:33:07 +08:00
|
|
|
|
private AnimationLoopType parseAnimationLoopType(string value)
|
|
|
|
|
{
|
|
|
|
|
var parsed = (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), value);
|
|
|
|
|
return Enum.IsDefined(typeof(AnimationLoopType), parsed) ? parsed : AnimationLoopType.LoopForever;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private void handleVariables(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = SplitKeyVal(line, '=');
|
|
|
|
|
variables[pair.Key] = pair.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Decodes any beatmap variables present in a line into their real values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="line">The line which may contains variables.</param>
|
|
|
|
|
private void decodeVariables(ref string line)
|
|
|
|
|
{
|
2020-11-02 01:54:44 +08:00
|
|
|
|
while (line.Contains('$'))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
string origLine = line;
|
|
|
|
|
|
2018-08-14 17:15:09 +08:00
|
|
|
|
foreach (var v in variables)
|
|
|
|
|
line = line.Replace(v.Key, v.Value);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
if (line == origLine)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|