public void TestParseMapAudio(string mapSoundsFilePath) { using var original = FileProvider.GetFile(mapSoundsFilePath); using var recreated = new MemoryStream(); MapSounds.Parse(original, true).SerializeTo(recreated, true); StreamAssert.AreEqual(original, recreated, true); }
public static GamePatch GetMinimumPatch(this MapSounds mapSounds) { return(mapSounds.FormatVersion switch { MapSoundsFormatVersion.Normal => GamePatch.v1_00, MapSoundsFormatVersion.Reforged => GamePatch.v1_32_0, MapSoundsFormatVersion.ReforgedV3 => GamePatch.v1_32_6, // todo; verify correctness });
public FunctionBuilderData(MapInfo mapInfo, MapDoodads mapDoodads, MapUnits mapUnits, MapRegions mapRegions, MapSounds mapSounds, string?lobbyMusic, bool csharp) { _mapInfo = mapInfo; _mapDoodads = mapDoodads; _mapUnits = mapUnits; _mapRegions = mapRegions; _mapSounds = mapSounds; _lobbyMusic = lobbyMusic; _csharp = csharp; }
public static bool TryDowngrade(this MapSounds mapSounds, GamePatch targetPatch) { try { while (mapSounds.GetMinimumPatch() > targetPatch) { mapSounds.DowngradeOnce(); } return(true); } catch (NotSupportedException) { return(false); } catch { throw; } }
public static void DowngradeOnce(this MapSounds mapSounds) { switch (mapSounds.FormatVersion) { case MapSoundsFormatVersion.ReforgedV3: mapSounds.FormatVersion = MapSoundsFormatVersion.Reforged; break; case MapSoundsFormatVersion.Reforged: foreach (var sound in mapSounds.Sounds) { // TODO: warn/error if it's a .flac file sound.SoundName = null; } mapSounds.FormatVersion = MapSoundsFormatVersion.Normal; break; default: break; } }
private static bool WantGenerateSoundsHelperFunction(MapSounds mapSounds) { return((mapSounds?.Count ?? 0) > 0); }
public static void Write(this BinaryWriter writer, MapSounds mapSounds) => mapSounds.WriteTo(writer);