widget/options methods moved from ArchiveFormat to IResource.

any resource could have options and corresponding widget.
This commit is contained in:
morkt 2015-08-12 01:31:03 +04:00
parent 142f7e1cdf
commit 5bf2493044
2 changed files with 40 additions and 40 deletions

View File

@ -101,6 +101,44 @@ namespace GameRes
Extensions = new string[] { Tag.ToLowerInvariant() }; Extensions = new string[] { Tag.ToLowerInvariant() };
Signatures = new uint[] { this.Signature }; 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<OptType> (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<OptType> (string notice) where OptType : ResourceOptions
{
var args = new ParametersRequestEventArgs { Notice = notice };
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
return GetOptions<OptType> (args.Options);
}
} }
public class ResourceOptions public class ResourceOptions
@ -197,44 +235,6 @@ namespace GameRes
throw new NotImplementedException ("ArchiveFormat.Create is not implemented"); 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<OptType> (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<OptType> (string notice) where OptType : ResourceOptions
{
var args = new ParametersRequestEventArgs { Notice = notice };
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
return GetOptions<OptType> (args.Options);
}
protected static bool IsSaneCount (int count) protected static bool IsSaneCount (int count)
{ {
return count > 0 && count < 0x20000; return count > 0 && count < 0x20000;

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.1.3.8")] [assembly: AssemblyVersion ("1.1.4.8")]
[assembly: AssemblyFileVersion ("1.1.3.8")] [assembly: AssemblyFileVersion ("1.1.4.8")]