Add info for common unsupported audio types

This commit is contained in:
NGnius (Graham) 2020-09-28 09:42:18 -04:00
parent 3c9c60b679
commit 85c1342313
4 changed files with 40 additions and 1 deletions

View file

@ -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)
{
}
}
}

View file

@ -314,6 +314,7 @@ namespace Pixi.Common
count++;
}
}
yield return asyncHandle.Continue();
}
}
}

View file

@ -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!");

View file

@ -57,6 +57,7 @@ namespace Pixi
#endif
// Audio functionality
root.Inject(new MidiImporter());
root.Inject(new AudioFakeImporter());
}
}
}