2017-12-02 00:43:33 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-12-02 05:05:01 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Formats
|
|
|
|
|
{
|
|
|
|
|
public class LegacyBeatmapDecoder : LegacyDecoder
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
private Beatmap beatmap;
|
|
|
|
|
|
2017-12-02 00:58:11 +08:00
|
|
|
|
private bool hasCustomColours;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
private ConvertHitObjectParser parser;
|
|
|
|
|
|
|
|
|
|
private LegacySampleBank defaultSampleBank;
|
|
|
|
|
private int defaultSampleVolume = 100;
|
|
|
|
|
|
2017-12-02 02:11:52 +08:00
|
|
|
|
public LegacyBeatmapDecoder()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LegacyBeatmapDecoder(string header)
|
|
|
|
|
{
|
|
|
|
|
BeatmapVersion = int.Parse(header.Substring(17));
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
if (stream == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(stream));
|
|
|
|
|
if (beatmap == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(beatmap));
|
|
|
|
|
|
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
this.beatmap.BeatmapInfo.BeatmapVersion = BeatmapVersion;
|
|
|
|
|
|
|
|
|
|
ParseContent(stream);
|
|
|
|
|
|
|
|
|
|
foreach (var hitObject in this.beatmap.HitObjects)
|
|
|
|
|
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 23:05:39 +08:00
|
|
|
|
protected override bool ShouldSkipLine(string line)
|
|
|
|
|
{
|
|
|
|
|
if (base.ShouldSkipLine(line) || line.StartsWith(" ") || line.StartsWith("_"))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 00:58:11 +08:00
|
|
|
|
protected override void ProcessSection(Section section, string line)
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
switch (section)
|
|
|
|
|
{
|
|
|
|
|
case Section.General:
|
|
|
|
|
handleGeneral(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Editor:
|
|
|
|
|
handleEditor(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Metadata:
|
|
|
|
|
handleMetadata(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Difficulty:
|
|
|
|
|
handleDifficulty(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Events:
|
|
|
|
|
handleEvents(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.TimingPoints:
|
|
|
|
|
handleTimingPoints(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Colours:
|
|
|
|
|
handleColours(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.HitObjects:
|
|
|
|
|
handleHitObjects(line);
|
|
|
|
|
break;
|
|
|
|
|
case Section.Variables:
|
|
|
|
|
handleVariables(line);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleGeneral(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, ':');
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
var metadata = beatmap.BeatmapInfo.Metadata;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case @"AudioFilename":
|
|
|
|
|
metadata.AudioFile = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"AudioLeadIn":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.AudioLeadIn = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"PreviewTime":
|
|
|
|
|
metadata.PreviewTime = int.Parse(pair.Value);
|
|
|
|
|
break;
|
|
|
|
|
case @"Countdown":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.Countdown = int.Parse(pair.Value) == 1;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"SampleSet":
|
|
|
|
|
defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), pair.Value);
|
|
|
|
|
break;
|
|
|
|
|
case @"SampleVolume":
|
|
|
|
|
defaultSampleVolume = int.Parse(pair.Value);
|
|
|
|
|
break;
|
|
|
|
|
case @"StackLeniency":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.StackLeniency = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"Mode":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.RulesetID = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
switch (beatmap.BeatmapInfo.RulesetID)
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
parser = new Rulesets.Objects.Legacy.Taiko.ConvertHitObjectParser();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
parser = new Rulesets.Objects.Legacy.Catch.ConvertHitObjectParser();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
parser = new Rulesets.Objects.Legacy.Mania.ConvertHitObjectParser();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case @"LetterboxInBreaks":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.LetterboxInBreaks = int.Parse(pair.Value) == 1;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"SpecialStyle":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.SpecialStyle = int.Parse(pair.Value) == 1;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"WidescreenStoryboard":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.WidescreenStoryboard = int.Parse(pair.Value) == 1;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleEditor(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, ':');
|
|
|
|
|
|
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case @"Bookmarks":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.StoredBookmarks = pair.Value;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"DistanceSpacing":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.DistanceSpacing = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"BeatDivisor":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.BeatDivisor = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"GridSize":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.GridSize = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"TimelineZoom":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.TimelineZoom = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleMetadata(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, ':');
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
var metadata = beatmap.BeatmapInfo.Metadata;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case @"Title":
|
|
|
|
|
metadata.Title = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"TitleUnicode":
|
|
|
|
|
metadata.TitleUnicode = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"Artist":
|
|
|
|
|
metadata.Artist = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"ArtistUnicode":
|
|
|
|
|
metadata.ArtistUnicode = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"Creator":
|
|
|
|
|
metadata.AuthorString = pair.Value;
|
|
|
|
|
break;
|
|
|
|
|
case @"Version":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.Version = pair.Value;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"Source":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.Metadata.Source = pair.Value;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"Tags":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.Metadata.Tags = pair.Value;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"BeatmapID":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.OnlineBeatmapID = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case @"BeatmapSetID":
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.OnlineBeatmapSetID = int.Parse(pair.Value);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
metadata.OnlineBeatmapSetID = int.Parse(pair.Value);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleDifficulty(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, ':');
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case @"HPDrainRate":
|
|
|
|
|
difficulty.DrainRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
case @"CircleSize":
|
|
|
|
|
difficulty.CircleSize = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
case @"OverallDifficulty":
|
|
|
|
|
difficulty.OverallDifficulty = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
case @"ApproachRate":
|
|
|
|
|
difficulty.ApproachRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
case @"SliderMultiplier":
|
|
|
|
|
difficulty.SliderMultiplier = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
case @"SliderTickRate":
|
|
|
|
|
difficulty.SliderTickRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleEvents(string line)
|
|
|
|
|
{
|
2017-12-02 00:58:11 +08:00
|
|
|
|
DecodeVariables(ref line);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
|
|
|
|
|
string[] split = line.Split(',');
|
|
|
|
|
|
|
|
|
|
EventType type;
|
|
|
|
|
if (!Enum.TryParse(split[0], out type))
|
|
|
|
|
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case EventType.Background:
|
|
|
|
|
string filename = split[2].Trim('"');
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.BeatmapInfo.Metadata.BackgroundFile = filename;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
case EventType.Break:
|
|
|
|
|
var breakEvent = new BreakPeriod
|
|
|
|
|
{
|
|
|
|
|
StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo),
|
|
|
|
|
EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!breakEvent.HasEffect)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.Breaks.Add(breakEvent);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleTimingPoints(string line)
|
|
|
|
|
{
|
|
|
|
|
string[] split = line.Split(',');
|
|
|
|
|
|
|
|
|
|
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
|
|
|
|
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
|
|
|
|
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
|
|
|
|
|
|
|
|
|
TimeSignatures timeSignature = TimeSignatures.SimpleQuadruple;
|
|
|
|
|
if (split.Length >= 3)
|
|
|
|
|
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
|
|
|
|
|
|
|
|
|
|
LegacySampleBank sampleSet = defaultSampleBank;
|
|
|
|
|
if (split.Length >= 4)
|
|
|
|
|
sampleSet = (LegacySampleBank)int.Parse(split[3]);
|
|
|
|
|
|
|
|
|
|
//SampleBank sampleBank = SampleBank.Default;
|
|
|
|
|
//if (split.Length >= 5)
|
|
|
|
|
// sampleBank = (SampleBank)int.Parse(split[4]);
|
|
|
|
|
|
|
|
|
|
int sampleVolume = defaultSampleVolume;
|
|
|
|
|
if (split.Length >= 6)
|
|
|
|
|
sampleVolume = int.Parse(split[5]);
|
|
|
|
|
|
|
|
|
|
bool timingChange = true;
|
|
|
|
|
if (split.Length >= 7)
|
|
|
|
|
timingChange = split[6][0] == '1';
|
|
|
|
|
|
|
|
|
|
bool kiaiMode = false;
|
|
|
|
|
bool omitFirstBarSignature = false;
|
|
|
|
|
if (split.Length >= 8)
|
|
|
|
|
{
|
|
|
|
|
int effectFlags = int.Parse(split[7]);
|
|
|
|
|
kiaiMode = (effectFlags & 1) > 0;
|
|
|
|
|
omitFirstBarSignature = (effectFlags & 8) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string stringSampleSet = sampleSet.ToString().ToLower();
|
|
|
|
|
if (stringSampleSet == @"none")
|
|
|
|
|
stringSampleSet = @"normal";
|
|
|
|
|
|
2017-12-02 05:05:01 +08:00
|
|
|
|
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
|
2017-12-23 15:31:45 +08:00
|
|
|
|
SampleControlPoint samplePoint = beatmap.ControlPointInfo.SamplePointAt(time);
|
2017-12-02 05:05:01 +08:00
|
|
|
|
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
|
|
|
|
|
if (timingChange)
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
Time = time,
|
|
|
|
|
BeatLength = beatLength,
|
|
|
|
|
TimeSignature = timeSignature
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (speedMultiplier != difficultyPoint.SpeedMultiplier)
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.ControlPointInfo.DifficultyPoints.RemoveAll(x => x.Time == time);
|
|
|
|
|
beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
Time = time,
|
|
|
|
|
SpeedMultiplier = speedMultiplier
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-23 15:31:45 +08:00
|
|
|
|
if (stringSampleSet != samplePoint.SampleBank || sampleVolume != samplePoint.SampleVolume)
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
2017-12-23 15:31:45 +08:00
|
|
|
|
beatmap.ControlPointInfo.SamplePoints.Add(new SampleControlPoint
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
Time = time,
|
|
|
|
|
SampleBank = stringSampleSet,
|
|
|
|
|
SampleVolume = sampleVolume
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (kiaiMode != effectPoint.KiaiMode || omitFirstBarSignature != effectPoint.OmitFirstBarLine)
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.ControlPointInfo.EffectPoints.Add(new EffectControlPoint
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
Time = time,
|
|
|
|
|
KiaiMode = kiaiMode,
|
|
|
|
|
OmitFirstBarLine = omitFirstBarSignature
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleColours(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, ':');
|
|
|
|
|
|
|
|
|
|
string[] split = pair.Value.Split(',');
|
|
|
|
|
|
|
|
|
|
if (split.Length != 3)
|
|
|
|
|
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
|
|
|
|
|
|
|
|
|
|
byte r, g, b;
|
|
|
|
|
if (!byte.TryParse(split[0], out r) || !byte.TryParse(split[1], out g) || !byte.TryParse(split[2], out b))
|
|
|
|
|
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
|
|
|
|
|
|
|
|
|
if (!hasCustomColours)
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.ComboColors.Clear();
|
2017-12-02 00:43:33 +08:00
|
|
|
|
hasCustomColours = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Note: the combo index specified in the beatmap is discarded
|
|
|
|
|
if (pair.Key.StartsWith(@"Combo"))
|
|
|
|
|
{
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.ComboColors.Add(new Color4
|
2017-12-02 00:43:33 +08:00
|
|
|
|
{
|
|
|
|
|
R = r / 255f,
|
|
|
|
|
G = g / 255f,
|
|
|
|
|
B = b / 255f,
|
|
|
|
|
A = 1f,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleHitObjects(string line)
|
|
|
|
|
{
|
|
|
|
|
// If the ruleset wasn't specified, assume the osu!standard ruleset.
|
|
|
|
|
if (parser == null)
|
|
|
|
|
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
|
|
|
|
|
|
|
|
|
var obj = parser.Parse(line);
|
|
|
|
|
|
|
|
|
|
if (obj != null)
|
2017-12-02 05:05:01 +08:00
|
|
|
|
beatmap.HitObjects.Add(obj);
|
2017-12-02 00:43:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleVariables(string line)
|
|
|
|
|
{
|
|
|
|
|
var pair = splitKeyVal(line, '=');
|
2017-12-02 00:58:11 +08:00
|
|
|
|
Variables[pair.Key] = pair.Value;
|
2017-12-02 00:43:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private KeyValuePair<string, string> splitKeyVal(string line, char separator)
|
|
|
|
|
{
|
|
|
|
|
var split = line.Trim().Split(new[] { separator }, 2);
|
|
|
|
|
|
|
|
|
|
return new KeyValuePair<string, string>
|
|
|
|
|
(
|
|
|
|
|
split[0].Trim(),
|
|
|
|
|
split.Length > 1 ? split[1].Trim() : string.Empty
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|