/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/Texture.cs
ViewVC logotype

Diff of /trunk/gr2lib/core/coretypes/implementation/Texture.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 181 by william, Fri Jul 23 19:53:10 2010 UTC revision 191 by william, Sat Jul 24 06:31:50 2010 UTC
# Line 14  using System.Drawing.Design; Line 14  using System.Drawing.Design;
14    
15  namespace gr2lib.core.coretypes.implementation  namespace gr2lib.core.coretypes.implementation
16  {  {
17        /// <summary>
18        /// Represents a Granny_Texture
19        /// </summary>
20      public class Texture : ITexture      public class Texture : ITexture
21      {      {
22          private GrannyRigResource _rigResource;          private GrannyRigResource _rigResource;
# Line 27  namespace gr2lib.core.coretypes.implemen Line 30  namespace gr2lib.core.coretypes.implemen
30          private Layout _Layout;          private Layout _Layout;
31          private List<Image> _Images;          private List<Image> _Images;
32    
33            /// <summary>
34            /// Gets the string representation of this instance
35            /// </summary>
36            /// <returns></returns>
37          public override string ToString()          public override string ToString()
38          {          {
39              return this.FromFileName.Name;              return this.FromFileName.Name;
40          }          }
41    
42          //private string _ParentResourceName;          //private string _ParentResourceName;
43            /// <summary>
44            /// Get's the parent resource name
45            /// </summary>
46          protected internal string ParentResourceName { get { return "Textures"; } }          protected internal string ParentResourceName { get { return "Textures"; } }
47    
48            /// <summary>
49            /// default constructor
50            /// </summary>
51          public Texture()// : base("Textures")          public Texture()// : base("Textures")
52          {          {
53              this.FromFileName = "";              this.FromFileName = "";
54              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
55              this.Width = 0;              this.Width = 0;
56              this.Height = 0;              this.Height = 0;
57              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
58              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);
59              this.Layout = new Layout();              this.Layout = new Layout();
60              this.Images = new List<Image>();              this.Images = new List<Image>();
61              //this.ExtendedData = new IntPtr();              //this.ExtendedData = new IntPtr();
62              //this.NativePointer = IntPtr.Zero;              //this.NativePointer = IntPtr.Zero;
63              this._rigResource = new GrannyRigResource();              this._rigResource = new GrannyRigResource();
64          }          }
65            /// <summary>
66            /// default constructor (specifying index)
67            /// </summary>
68            /// <param name="index">the texture's index</param>
69          public Texture(int index)          public Texture(int index)
70          {          {
71              this.FromFileName = "";              this.FromFileName = "";
72              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
73              this.Width = 0;              this.Width = 0;
74              this.Height = 0;              this.Height = 0;
75              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
76              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);
77              this.Layout = new Layout();              this.Layout = new Layout();
78              this.Images = new List<Image>();              this.Images = new List<Image>();
79              //this.ExtendedData = new IntPtr();              //this.ExtendedData = new IntPtr();
# Line 109  namespace gr2lib.core.coretypes.implemen Line 125  namespace gr2lib.core.coretypes.implemen
125              {              {
126                  Texture managed = new Texture();                  Texture managed = new Texture();
127                  managed.FromFileName = native.FromFileName;                  managed.FromFileName = native.FromFileName;
128                  managed.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>((granny_texture_type)native.TextureType), (granny_texture_type)native.TextureType);                  managed.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_type>((granny_texture_type)native.TextureType), (granny_texture_type)native.TextureType);
129                  managed.Width = native.Width;                  managed.Width = native.Width;
130                  managed.Height = native.Height;                  managed.Height = native.Height;
131                  managed.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>((granny_texture_encoding)native.Encoding), (granny_texture_encoding)native.Encoding);                  managed.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_texture_encoding>((granny_texture_encoding)native.Encoding), (granny_texture_encoding)native.Encoding);
132                  managed.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>((granny_pixel_layout)native.SubFormat), (granny_pixel_layout)native.SubFormat);                  managed.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.EnumToStringSupport.GetGrannyEnumTypeString<granny_pixel_layout>((granny_pixel_layout)native.SubFormat), (granny_pixel_layout)native.SubFormat);
133                  managed.Layout = Layout.ReadFromNative(native.Layout);                  managed.Layout = Layout.ReadFromNative(native.Layout);
134                  IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);                  IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);
135                  int length = images.Length;                  int length = images.Length;
# Line 155  namespace gr2lib.core.coretypes.implemen Line 171  namespace gr2lib.core.coretypes.implemen
171          }          }
172    
173          #region ITexture Members          #region ITexture Members
174            /// <summary>
175          //[RefreshPropertiesAttribute(RefreshProperties.All)]          /// Get's the texture's name
176          //public string TextureTypeFormat          /// </summary>
         //{  
         //    get  
         //    {  
         //        string texture_type = "Unknown Texture Type";  
   
         //        foreach (int val in Enum.GetValues(typeof(granny_texture_type)))  
         //        {  
         //            if (val == this.TextureType)  
         //            {  
         //                texture_type = Enum.GetName(typeof(granny_texture_type),val);  
         //                break;  
         //            }  
         //        }  
         //        return texture_type;  
         //    }  
         //}  
         //[RefreshPropertiesAttribute(RefreshProperties.All)]  
         //public string EncodingFormat  
         //{  
         //    get  
         //    {  
         //        string encodingformat = "Unknown Encoding Format";  
   
         //        foreach (int val in Enum.GetValues(typeof(granny_texture_encoding)))  
         //        {  
         //            if (val == this.Encoding)  
         //            {  
         //                encodingformat = Enum.GetName(typeof(granny_texture_encoding), val);  
         //                break;  
         //            }  
         //        }  
         //        return encodingformat;  
         //    }  
         //}  
   
177          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
178          public FilePath FromFileName { get { return _FromFileName; } set { _FromFileName = value; } }          public FilePath FromFileName { get { return _FromFileName; } set { _FromFileName = value; } }
179            /// <summary>
180            /// Get's the texture's type
181            /// </summary>
182          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
183          [Editor(typeof(UIComboValueSelector<granny_texture_type, int>), typeof(UITypeEditor))]          [Editor(typeof(UIComboValueSelector<granny_texture_type, int>), typeof(UITypeEditor))]
184          public NameValuePair<string, granny_texture_type> TextureType { get { return _TextureType; } set { _TextureType = value; } }          public NameValuePair<string, granny_texture_type> TextureType { get { return _TextureType; } set { _TextureType = value; } }
185            /// <summary>
186            /// Get's the texture's widh
187            /// </summary>
188          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
189          public int Width { get { return _Width; } set { _Width = value; } }          public int Width { get { return _Width; } set { _Width = value; } }
190            /// <summary>
191            /// Get's the texture's height
192            /// </summary>
193          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
194          public int Height { get { return _Height; } set { _Height = value; } }          public int Height { get { return _Height; } set { _Height = value; } }
195            /// <summary>
196            /// Get's the texture's encoding
197            /// </summary>
198          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
199          [Editor(typeof(UIComboValueSelector<granny_texture_encoding, int>), typeof(UITypeEditor))]          [Editor(typeof(UIComboValueSelector<granny_texture_encoding, int>), typeof(UITypeEditor))]
200          public NameValuePair<string, granny_texture_encoding> Encoding { get { return _Encoding; } set { _Encoding = value; } }          public NameValuePair<string, granny_texture_encoding> Encoding { get { return _Encoding; } set { _Encoding = value; } }
201            /// <summary>
202            /// Get's the texture's subformat
203            /// </summary>
204          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
205          [Editor(typeof(UIComboValueSelector<granny_pixel_layout, int>), typeof(UITypeEditor))]          [Editor(typeof(UIComboValueSelector<granny_pixel_layout, int>), typeof(UITypeEditor))]
206          public NameValuePair<string, granny_pixel_layout> SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }          public NameValuePair<string, granny_pixel_layout> SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }
207            /// <summary>
208            /// Get's the texture's Pixel Layout
209            /// </summary>
210          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
211          [Browsable(true)]          [Browsable(true)]
212          public Layout Layout { get { return _Layout; } set { _Layout = value; } }          public Layout Layout { get { return _Layout; } set { _Layout = value; } }
213            /// <summary>
214            /// Get a List of Images associated with this texture
215            /// </summary>
216          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
217          public List<Image> Images { get { return _Images; } set { _Images = value; } }          public List<Image> Images { get { return _Images; } set { _Images = value; } }
218          #endregion          #endregion

Legend:
Removed from v.181  
changed lines
  Added in v.191

  ViewVC Help
Powered by ViewVC 1.1.22