From 5bf249304485b37d154659daf0a30560147f3be9 Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 12 Aug 2015 01:31:03 +0400 Subject: [PATCH] widget/options methods moved from ArchiveFormat to IResource. any resource could have options and corresponding widget. --- GameRes/GameRes.cs | 76 +++++++++++++++--------------- GameRes/Properties/AssemblyInfo.cs | 4 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/GameRes/GameRes.cs b/GameRes/GameRes.cs index ee6b7f1c..7440e896 100644 --- a/GameRes/GameRes.cs +++ b/GameRes/GameRes.cs @@ -101,6 +101,44 @@ namespace GameRes Extensions = new string[] { Tag.ToLowerInvariant() }; Signatures = new uint[] { this.Signature }; } + + public virtual ResourceOptions GetDefaultOptions () + { + return null; + } + + public virtual ResourceOptions GetOptions (object widget) + { + return GetDefaultOptions(); + } + + public virtual object GetCreationWidget () + { + return null; + } + + public virtual object GetAccessWidget () + { + return null; + } + + protected OptType GetOptions (ResourceOptions res_options) where OptType : ResourceOptions + { + var options = res_options as OptType; + if (null == options) + options = this.GetDefaultOptions() as OptType; + return options; + } + + protected OptType Query (string notice) where OptType : ResourceOptions + { + var args = new ParametersRequestEventArgs { Notice = notice }; + FormatCatalog.Instance.InvokeParametersRequest (this, args); + if (!args.InputResult) + throw new OperationCanceledException(); + + return GetOptions (args.Options); + } } public class ResourceOptions @@ -197,44 +235,6 @@ namespace GameRes throw new NotImplementedException ("ArchiveFormat.Create is not implemented"); } - public virtual ResourceOptions GetDefaultOptions () - { - return null; - } - - public virtual ResourceOptions GetOptions (object widget) - { - return GetDefaultOptions(); - } - - public virtual object GetCreationWidget () - { - return null; - } - - public virtual object GetAccessWidget () - { - return null; - } - - protected OptType GetOptions (ResourceOptions res_options) where OptType : ResourceOptions - { - var options = res_options as OptType; - if (null == options) - options = this.GetDefaultOptions() as OptType; - return options; - } - - protected OptType Query (string notice) where OptType : ResourceOptions - { - var args = new ParametersRequestEventArgs { Notice = notice }; - FormatCatalog.Instance.InvokeParametersRequest (this, args); - if (!args.InputResult) - throw new OperationCanceledException(); - - return GetOptions (args.Options); - } - protected static bool IsSaneCount (int count) { return count > 0 && count < 0x20000; diff --git a/GameRes/Properties/AssemblyInfo.cs b/GameRes/Properties/AssemblyInfo.cs index 0aee44a1..1ad17f04 100644 --- a/GameRes/Properties/AssemblyInfo.cs +++ b/GameRes/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.1.3.8")] -[assembly: AssemblyFileVersion ("1.1.3.8")] +[assembly: AssemblyVersion ("1.1.4.8")] +[assembly: AssemblyFileVersion ("1.1.4.8")]