(GameRes): persistent resource settings infrastructure.

This commit is contained in:
morkt
2018-01-08 19:55:28 +04:00
parent 444a15b94a
commit a3ce27da5f
10 changed files with 203 additions and 4 deletions

View File

@@ -46,24 +46,33 @@ namespace GameRes
}
[Export(typeof(ImageFormat))]
public class BmpFormat : ImageFormat
public sealed class BmpFormat : ImageFormat
{
public override string Tag { get { return "BMP"; } }
public override string Description { get { return "Windows device independent bitmap"; } }
public override uint Signature { get { return 0; } }
public override bool CanWrite { get { return true; } }
public BmpFormat ()
{
Settings = new[] { EnableExtensions };
}
#pragma warning disable 649
[ImportMany(typeof(IBmpExtension))]
private IEnumerable<IBmpExtension> m_extensions;
#pragma warning restore 649
bool EnableExtensions = true;
LocalResourceSetting EnableExtensions = new LocalResourceSetting {
Name = "BMPEnableExtensions",
Text = "Enable BMP format extensions",
Description = "Enables various extensions, such as transparency support.",
};
public override ImageData Read (IBinaryStream file, ImageMetaData info)
{
var bmp_info = info as BmpMetaData;
if (bmp_info != null && EnableExtensions && file.AsStream.CanSeek)
if (bmp_info != null && EnableExtensions.Get<bool>() && file.AsStream.CanSeek)
{
foreach (var ext in m_extensions)
{