mirror of
https://github.com/ppy/osu
synced 2025-01-04 21:30:08 +00:00
Use @strings where appropriate
This commit is contained in:
parent
dd86e75ea7
commit
deff5ad61e
@ -25,9 +25,9 @@ namespace osu.Desktop.Beatmaps.IO
|
|||||||
public LegacyFilesystemReader(string path)
|
public LegacyFilesystemReader(string path)
|
||||||
{
|
{
|
||||||
basePath = path;
|
basePath = path;
|
||||||
beatmaps = Directory.GetFiles(basePath, "*.osu").Select(f => Path.GetFileName(f)).ToArray();
|
beatmaps = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray();
|
||||||
if (beatmaps.Length == 0)
|
if (beatmaps.Length == 0)
|
||||||
throw new FileNotFoundException("This directory contains no beatmaps");
|
throw new FileNotFoundException(@"This directory contains no beatmaps");
|
||||||
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
||||||
{
|
{
|
||||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var line = stream.ReadLine().Trim();
|
var line = stream.ReadLine().Trim();
|
||||||
if (!decoders.ContainsKey(line))
|
if (!decoders.ContainsKey(line))
|
||||||
throw new IOException("Unknown file format");
|
throw new IOException(@"Unknown file format");
|
||||||
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]);
|
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]);
|
||||||
}
|
}
|
||||||
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
|
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
|
||||||
|
@ -15,11 +15,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
public static void Register()
|
public static void Register()
|
||||||
{
|
{
|
||||||
AddDecoder<OsuLegacyDecoder>("osu file format v14");
|
AddDecoder<OsuLegacyDecoder>(@"osu file format v14");
|
||||||
AddDecoder<OsuLegacyDecoder>("osu file format v13");
|
AddDecoder<OsuLegacyDecoder>(@"osu file format v13");
|
||||||
AddDecoder<OsuLegacyDecoder>("osu file format v12");
|
AddDecoder<OsuLegacyDecoder>(@"osu file format v12");
|
||||||
AddDecoder<OsuLegacyDecoder>("osu file format v11");
|
AddDecoder<OsuLegacyDecoder>(@"osu file format v11");
|
||||||
AddDecoder<OsuLegacyDecoder>("osu file format v10");
|
AddDecoder<OsuLegacyDecoder>(@"osu file format v10");
|
||||||
// TODO: Not sure how far back to go, or differences between versions
|
// TODO: Not sure how far back to go, or differences between versions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,34 +40,34 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case "AudioFilename":
|
case @"AudioFilename":
|
||||||
beatmap.Metadata.AudioFile = val;
|
beatmap.Metadata.AudioFile = val;
|
||||||
break;
|
break;
|
||||||
case "AudioLeadIn":
|
case @"AudioLeadIn":
|
||||||
beatmap.AudioLeadIn = int.Parse(val);
|
beatmap.AudioLeadIn = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "PreviewTime":
|
case @"PreviewTime":
|
||||||
beatmap.Metadata.PreviewTime = int.Parse(val);
|
beatmap.Metadata.PreviewTime = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "Countdown":
|
case @"Countdown":
|
||||||
beatmap.Countdown = int.Parse(val) == 1;
|
beatmap.Countdown = int.Parse(val) == 1;
|
||||||
break;
|
break;
|
||||||
case "SampleSet":
|
case @"SampleSet":
|
||||||
beatmap.SampleSet = (SampleSet)Enum.Parse(typeof(SampleSet), val);
|
beatmap.SampleSet = (SampleSet)Enum.Parse(typeof(SampleSet), val);
|
||||||
break;
|
break;
|
||||||
case "StackLeniency":
|
case @"StackLeniency":
|
||||||
beatmap.StackLeniency = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.StackLeniency = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "Mode":
|
case @"Mode":
|
||||||
beatmap.Mode = (PlayMode)int.Parse(val);
|
beatmap.Mode = (PlayMode)int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "LetterboxInBreaks":
|
case @"LetterboxInBreaks":
|
||||||
beatmap.LetterboxInBreaks = int.Parse(val) == 1;
|
beatmap.LetterboxInBreaks = int.Parse(val) == 1;
|
||||||
break;
|
break;
|
||||||
case "SpecialStyle":
|
case @"SpecialStyle":
|
||||||
beatmap.SpecialStyle = int.Parse(val) == 1;
|
beatmap.SpecialStyle = int.Parse(val) == 1;
|
||||||
break;
|
break;
|
||||||
case "WidescreenStoryboard":
|
case @"WidescreenStoryboard":
|
||||||
beatmap.WidescreenStoryboard = int.Parse(val) == 1;
|
beatmap.WidescreenStoryboard = int.Parse(val) == 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -77,19 +77,19 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case "Bookmarks":
|
case @"Bookmarks":
|
||||||
beatmap.StoredBookmarks = val;
|
beatmap.StoredBookmarks = val;
|
||||||
break;
|
break;
|
||||||
case "DistanceSpacing":
|
case @"DistanceSpacing":
|
||||||
beatmap.DistanceSpacing = double.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.DistanceSpacing = double.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "BeatDivisor":
|
case @"BeatDivisor":
|
||||||
beatmap.BeatDivisor = int.Parse(val);
|
beatmap.BeatDivisor = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "GridSize":
|
case @"GridSize":
|
||||||
beatmap.GridSize = int.Parse(val);
|
beatmap.GridSize = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "TimelineZoom":
|
case @"TimelineZoom":
|
||||||
beatmap.TimelineZoom = double.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.TimelineZoom = double.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -99,34 +99,34 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case "Title":
|
case @"Title":
|
||||||
beatmap.Metadata.Title = val;
|
beatmap.Metadata.Title = val;
|
||||||
break;
|
break;
|
||||||
case "TitleUnicode":
|
case @"TitleUnicode":
|
||||||
beatmap.Metadata.TitleUnicode = val;
|
beatmap.Metadata.TitleUnicode = val;
|
||||||
break;
|
break;
|
||||||
case "Artist":
|
case @"Artist":
|
||||||
beatmap.Metadata.Artist = val;
|
beatmap.Metadata.Artist = val;
|
||||||
break;
|
break;
|
||||||
case "ArtistUnicode":
|
case @"ArtistUnicode":
|
||||||
beatmap.Metadata.ArtistUnicode = val;
|
beatmap.Metadata.ArtistUnicode = val;
|
||||||
break;
|
break;
|
||||||
case "Creator":
|
case @"Creator":
|
||||||
beatmap.Metadata.Author = val;
|
beatmap.Metadata.Author = val;
|
||||||
break;
|
break;
|
||||||
case "Version":
|
case @"Version":
|
||||||
beatmap.Version = val;
|
beatmap.Version = val;
|
||||||
break;
|
break;
|
||||||
case "Source":
|
case @"Source":
|
||||||
beatmap.Metadata.Source = val;
|
beatmap.Metadata.Source = val;
|
||||||
break;
|
break;
|
||||||
case "Tags":
|
case @"Tags":
|
||||||
beatmap.Metadata.Tags = val;
|
beatmap.Metadata.Tags = val;
|
||||||
break;
|
break;
|
||||||
case "BeatmapID":
|
case @"BeatmapID":
|
||||||
beatmap.BeatmapID = int.Parse(val);
|
beatmap.BeatmapID = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
case "BeatmapSetID":
|
case @"BeatmapSetID":
|
||||||
beatmap.BeatmapSetID = int.Parse(val);
|
beatmap.BeatmapSetID = int.Parse(val);
|
||||||
beatmap.Metadata.BeatmapSetID = int.Parse(val);
|
beatmap.Metadata.BeatmapSetID = int.Parse(val);
|
||||||
break;
|
break;
|
||||||
@ -137,22 +137,22 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case "HPDrainRate":
|
case @"HPDrainRate":
|
||||||
beatmap.BaseDifficulty.DrainRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.DrainRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "CircleSize":
|
case @"CircleSize":
|
||||||
beatmap.BaseDifficulty.CircleSize = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.CircleSize = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "OverallDifficulty":
|
case @"OverallDifficulty":
|
||||||
beatmap.BaseDifficulty.OverallDifficulty = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.OverallDifficulty = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "ApproachRate":
|
case @"ApproachRate":
|
||||||
beatmap.BaseDifficulty.ApproachRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.ApproachRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "SliderMultiplier":
|
case @"SliderMultiplier":
|
||||||
beatmap.BaseDifficulty.SliderMultiplier = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.SliderMultiplier = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
case "SliderTickRate":
|
case @"SliderTickRate":
|
||||||
beatmap.BaseDifficulty.SliderTickRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BaseDifficulty.SliderTickRate = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -160,9 +160,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleEvents(Beatmap beatmap, string val)
|
private void handleEvents(Beatmap beatmap, string val)
|
||||||
{
|
{
|
||||||
if (val.StartsWith("//"))
|
if (val.StartsWith(@"//"))
|
||||||
return;
|
return;
|
||||||
if (val.StartsWith(" "))
|
if (val.StartsWith(@" "))
|
||||||
return; // TODO
|
return; // TODO
|
||||||
string[] split = val.Split(',');
|
string[] split = val.Split(',');
|
||||||
EventType type;
|
EventType type;
|
||||||
@ -222,10 +222,10 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
line = line.Trim();
|
line = line.Trim();
|
||||||
if (string.IsNullOrEmpty(line))
|
if (string.IsNullOrEmpty(line))
|
||||||
continue;
|
continue;
|
||||||
if (line.StartsWith("osu file format v"))
|
if (line.StartsWith(@"osu file format v"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (line.StartsWith("[") && line.EndsWith("]"))
|
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
|
||||||
{
|
{
|
||||||
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
||||||
throw new InvalidDataException($@"Unknown osu section {line}");
|
throw new InvalidDataException($@"Unknown osu section {line}");
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
if (reader.Test(storage, path))
|
if (reader.Test(storage, path))
|
||||||
return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
|
return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
|
||||||
}
|
}
|
||||||
throw new IOException("Unknown file format");
|
throw new IOException(@"Unknown file format");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void AddReader<T>(Func<BasicStorage, string, bool> test) where T : ArchiveReader
|
protected static void AddReader<T>(Func<BasicStorage, string, bool> test) where T : ArchiveReader
|
||||||
|
@ -25,10 +25,10 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
public OszArchiveReader(Stream archiveStream)
|
public OszArchiveReader(Stream archiveStream)
|
||||||
{
|
{
|
||||||
archive = ZipFile.Read(archiveStream);
|
archive = ZipFile.Read(archiveStream);
|
||||||
beatmaps = archive.Entries.Where(e => e.FileName.EndsWith(".osu"))
|
beatmaps = archive.Entries.Where(e => e.FileName.EndsWith(@".osu"))
|
||||||
.Select(e => e.FileName).ToArray();
|
.Select(e => e.FileName).ToArray();
|
||||||
if (beatmaps.Length == 0)
|
if (beatmaps.Length == 0)
|
||||||
throw new FileNotFoundException("This directory contains no beatmaps");
|
throw new FileNotFoundException(@"This directory contains no beatmaps");
|
||||||
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
||||||
{
|
{
|
||||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
|
Loading…
Reference in New Issue
Block a user