(GalFormat): use string representation of keys instead of numeric.

This commit is contained in:
morkt
2016-06-10 06:27:21 +04:00
parent cb04b322f2
commit dd9ed869c5
11 changed files with 25 additions and 92 deletions

View File

@@ -57,7 +57,7 @@ namespace GameRes.Formats.LiveMaker
[Serializable]
public class GalScheme : ResourceScheme
{
public Dictionary<string, uint> KnownKeys;
public Dictionary<string, string> KnownKeys;
}
[Export(typeof(ImageFormat))]
@@ -67,7 +67,7 @@ namespace GameRes.Formats.LiveMaker
public override string Description { get { return "LiveMaker image format"; } }
public override uint Signature { get { return 0x656C6147; } } // 'Gale'
public static Dictionary<string, uint> KnownKeys = new Dictionary<string, uint>();
public static Dictionary<string, string> KnownKeys = new Dictionary<string, string>();
public override ResourceScheme Scheme
{
@@ -145,7 +145,7 @@ namespace GameRes.Formats.LiveMaker
public override ResourceOptions GetDefaultOptions ()
{
return new GalOptions { Key = Settings.Default.GALKey };
return new GalOptions { Key = KeyFromString (Settings.Default.GALKey) };
}
public override object GetAccessWidget ()
@@ -160,6 +160,13 @@ namespace GameRes.Formats.LiveMaker
var options = Query<GalOptions> (arcStrings.ArcImageEncrypted);
return options.Key;
}
public static uint KeyFromString (string key)
{
if (string.IsNullOrWhiteSpace (key) || key.Length < 4)
return 0;
return (uint)(key[0] | key[1] << 8 | key[2] << 16 | key[3] << 24);
}
}
internal sealed class GalReader : IDisposable