mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 06:12:54 +08:00
Allow for variables in storyboards
This commit is contained in:
parent
e67a00f1f6
commit
0b770d1225
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -31,6 +32,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private ConvertHitObjectParser parser;
|
private ConvertHitObjectParser parser;
|
||||||
|
|
||||||
|
private Dictionary<string, string> variables = new Dictionary<string, string>();
|
||||||
|
|
||||||
private LegacySampleBank defaultSampleBank;
|
private LegacySampleBank defaultSampleBank;
|
||||||
private int defaultSampleVolume = 100;
|
private int defaultSampleVolume = 100;
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
TimingPoints,
|
TimingPoints,
|
||||||
Colours,
|
Colours,
|
||||||
HitObjects,
|
HitObjects,
|
||||||
|
Variables,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleGeneral(Beatmap beatmap, string key, string val)
|
private void handleGeneral(Beatmap beatmap, string key, string val)
|
||||||
@ -391,7 +395,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
|
|
||||||
string val = line, key = null;
|
string val = line, key = null;
|
||||||
if (section != Section.Events && section != Section.TimingPoints && section != Section.HitObjects)
|
if (section != Section.Events && section != Section.TimingPoints && section != Section.HitObjects && section != Section.Variables)
|
||||||
{
|
{
|
||||||
key = val.Remove(val.IndexOf(':')).Trim();
|
key = val.Remove(val.IndexOf(':')).Trim();
|
||||||
val = val.Substring(val.IndexOf(':') + 1).Trim();
|
val = val.Substring(val.IndexOf(':') + 1).Trim();
|
||||||
@ -411,6 +415,13 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
handleDifficulty(beatmap, key, val);
|
handleDifficulty(beatmap, key, val);
|
||||||
break;
|
break;
|
||||||
case Section.Events:
|
case Section.Events:
|
||||||
|
string[] valSplit = val.Split(',');
|
||||||
|
for (int i = 0; i < valSplit.Length; i++)
|
||||||
|
{
|
||||||
|
if (valSplit[i][0] == '$' && variables.ContainsKey(valSplit[i]))
|
||||||
|
valSplit[i] = variables[valSplit[i]];
|
||||||
|
}
|
||||||
|
val = string.Join(",", valSplit);
|
||||||
handleEvents(beatmap, val);
|
handleEvents(beatmap, val);
|
||||||
break;
|
break;
|
||||||
case Section.TimingPoints:
|
case Section.TimingPoints:
|
||||||
@ -426,6 +437,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
beatmap.HitObjects.Add(obj);
|
beatmap.HitObjects.Add(obj);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case Section.Variables:
|
||||||
|
key = val.Remove(val.IndexOf('=')).Trim();
|
||||||
|
val = val.Substring(val.IndexOf('=') + 1).Trim();
|
||||||
|
variables[key] = val;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user