mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Initial commit
This commit is contained in:
parent
d8ffc00f75
commit
78692dc684
@ -26,6 +26,7 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Skinning;
|
||||
using Decoder = osu.Game.Beatmaps.Formats.Decoder;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
@ -201,7 +202,10 @@ namespace osu.Game.Beatmaps
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
|
||||
new LegacyBeatmapEncoder(beatmapContent).Encode(sw);
|
||||
{
|
||||
var skin = new LegacyBeatmapSkin(info, Files.Store, audioManager);
|
||||
new LegacyBeatmapEncoder(beatmapContent, skin).Encode(sw);
|
||||
}
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
@ -22,10 +23,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
public const int LATEST_VERSION = 128;
|
||||
|
||||
private readonly IBeatmap beatmap;
|
||||
private readonly LegacyBeatmapSkin beatmapSkin;
|
||||
|
||||
public LegacyBeatmapEncoder(IBeatmap beatmap)
|
||||
public LegacyBeatmapEncoder(IBeatmap beatmap, LegacyBeatmapSkin beatmapSkin = null)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.beatmapSkin = beatmapSkin;
|
||||
|
||||
if (beatmap.BeatmapInfo.RulesetID < 0 || beatmap.BeatmapInfo.RulesetID > 3)
|
||||
throw new ArgumentException("Only beatmaps in the osu, taiko, catch, or mania rulesets can be encoded to the legacy beatmap format.", nameof(beatmap));
|
||||
@ -53,6 +56,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
writer.WriteLine();
|
||||
handleControlPoints(writer);
|
||||
|
||||
writer.WriteLine();
|
||||
handleComboColours(writer);
|
||||
|
||||
writer.WriteLine();
|
||||
handleHitObjects(writer);
|
||||
}
|
||||
@ -196,6 +202,31 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
private void handleComboColours(TextWriter writer)
|
||||
{
|
||||
if (beatmapSkin == null)
|
||||
return;
|
||||
|
||||
var colours = beatmapSkin.Configuration.ComboColours;
|
||||
|
||||
if (colours.Count == 0)
|
||||
return;
|
||||
|
||||
writer.WriteLine("[Colours]");
|
||||
|
||||
for (var i = 0; i < colours.Count; i++)
|
||||
{
|
||||
var comboColour = colours[i];
|
||||
|
||||
var r = (byte)(comboColour.R * byte.MaxValue);
|
||||
var g = (byte)(comboColour.G * byte.MaxValue);
|
||||
var b = (byte)(comboColour.B * byte.MaxValue);
|
||||
var a = (byte)(comboColour.A * byte.MaxValue);
|
||||
|
||||
writer.WriteLine($"Combo{i}: {r},{g},{b},{a}");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleHitObjects(TextWriter writer)
|
||||
{
|
||||
if (beatmap.HitObjects.Count == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user