From 21ddbf698b89cfc4ed449623dfc27a76a708986c Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 28 Sep 2020 09:42:18 -0400 Subject: [PATCH] Add info for common unsupported audio types --- Pixi/Audio/AudioFakeImporter.cs | 37 ++++++++++++++++++++++++++++++++ Pixi/Common/ColorSpaceUtility.cs | 1 + Pixi/Common/CommandRoot.cs | 2 +- Pixi/PixiPlugin.cs | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Pixi/Audio/AudioFakeImporter.cs diff --git a/Pixi/Audio/AudioFakeImporter.cs b/Pixi/Audio/AudioFakeImporter.cs new file mode 100644 index 0000000..dcca578 --- /dev/null +++ b/Pixi/Audio/AudioFakeImporter.cs @@ -0,0 +1,37 @@ +using System; +using GamecraftModdingAPI; +using GamecraftModdingAPI.Utility; +using Pixi.Common; + +namespace Pixi.Audio +{ + public class AudioFakeImporter : Importer + { + public int Priority { get; } = 0; + public bool Optimisable { get; } = false; + public string Name { get; } = "AudioWarning~Spell"; + public BlueprintProvider BlueprintProvider { get; } = null; + public bool Qualifies(string name) + { + return name.EndsWith(".flac", StringComparison.InvariantCultureIgnoreCase) + || name.EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase) + || name.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase) + || name.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase) + || name.EndsWith(".aac", StringComparison.InvariantCultureIgnoreCase); + } + + public BlockJsonInfo[] Import(string name) + { + Logging.CommandLogWarning($"Audio importing only works with MIDI (.mid) files, which '{name}' is not.\nThere are many converters online, but for best quality use a MIDI file made from a music transcription.\nFor example, musescore.com has lots of good transcriptions and they offer a 30-day free trial."); + return null; + } + + public void PreProcess(string name, ref ProcessedVoxelObjectNotation[] blocks) + { + } + + public void PostProcess(string name, ref Block[] blocks) + { + } + } +} \ No newline at end of file diff --git a/Pixi/Common/ColorSpaceUtility.cs b/Pixi/Common/ColorSpaceUtility.cs index b2d68c9..2b087a6 100644 --- a/Pixi/Common/ColorSpaceUtility.cs +++ b/Pixi/Common/ColorSpaceUtility.cs @@ -314,6 +314,7 @@ namespace Pixi.Common count++; } } + yield return asyncHandle.Continue(); } } } diff --git a/Pixi/Common/CommandRoot.cs b/Pixi/Common/CommandRoot.cs index f0b3c14..9ff6804 100644 --- a/Pixi/Common/CommandRoot.cs +++ b/Pixi/Common/CommandRoot.cs @@ -157,7 +157,7 @@ namespace Pixi.Common #endif // import blocks BlockJsonInfo[] blocksInfo = magicImporter.Import(name); - if (blocksInfo.Length == 0) + if (blocksInfo == null || blocksInfo.Length == 0) { #if DEBUG Logging.CommandLogError($"Importer {magicImporter.Name} didn't provide any blocks to import. Mission Aborted!"); diff --git a/Pixi/PixiPlugin.cs b/Pixi/PixiPlugin.cs index 78e73d4..1716a17 100644 --- a/Pixi/PixiPlugin.cs +++ b/Pixi/PixiPlugin.cs @@ -57,6 +57,7 @@ namespace Pixi #endif // Audio functionality root.Inject(new MidiImporter()); + root.Inject(new AudioFakeImporter()); } } } \ No newline at end of file