/[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 142 by william, Mon Jul 19 09:17:53 2010 UTC revision 183 by william, Fri Jul 23 21:08:46 2010 UTC
# Line 9  using gr2lib.core.exceptions; Line 9  using gr2lib.core.exceptions;
9  using gr2lib.core.ui.helpers;  using gr2lib.core.ui.helpers;
10  using System.ComponentModel;  using System.ComponentModel;
11  using gr2lib.core.typedefs;  using gr2lib.core.typedefs;
12    using gr2lib.core.ui.typeeditors;
13    using System.Drawing.Design;
14    
15  namespace gr2lib.core.coretypes.implementation  namespace gr2lib.core.coretypes.implementation
16  {  {
# Line 17  namespace gr2lib.core.coretypes.implemen Line 19  namespace gr2lib.core.coretypes.implemen
19          private GrannyRigResource _rigResource;          private GrannyRigResource _rigResource;
20    
21          private FilePath _FromFileName;          private FilePath _FromFileName;
22          private int _TextureType;          private NameValuePair<string, granny_texture_type> _TextureType;
23          private int _Width;          private int _Width;
24          private int _Height;          private int _Height;
25          private int _Encoding;          private NameValuePair<string, granny_texture_encoding> _Encoding;
26          private int _SubFormat;          private NameValuePair<string, granny_pixel_layout> _SubFormat;
27          private Layout _Layout;          private Layout _Layout;
28          private List<Image> _Images;          private List<Image> _Images;
29    
# Line 31  namespace gr2lib.core.coretypes.implemen Line 33  namespace gr2lib.core.coretypes.implemen
33              return this.FromFileName.Name;              return this.FromFileName.Name;
34          }          }
35    
36          private string _ParentResourceName;          //private string _ParentResourceName;
37          protected internal string ParentResourceName { get { return "Textures"; } }          protected internal string ParentResourceName { get { return "Textures"; } }
38    
39          public Texture()// : base("Textures")          public Texture()// : base("Textures")
40          {          {
41              this.FromFileName = "";              this.FromFileName = "";
42              this.TextureType = 0;              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
43              this.Width = 0;              this.Width = 0;
44              this.Height = 0;              this.Height = 0;
45              this.Encoding = 0;              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
46              this.SubFormat = 0;              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);
47              this.Layout = new Layout();              this.Layout = new Layout();
48              this.Images = new List<Image>();              this.Images = new List<Image>();
49              //this.ExtendedData = new IntPtr();              //this.ExtendedData = new IntPtr();
# Line 51  namespace gr2lib.core.coretypes.implemen Line 53  namespace gr2lib.core.coretypes.implemen
53          public Texture(int index)          public Texture(int index)
54          {          {
55              this.FromFileName = "";              this.FromFileName = "";
56              this.TextureType = 0;              this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
57              this.Width = 0;              this.Width = 0;
58              this.Height = 0;              this.Height = 0;
59              this.Encoding = 0;              this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
60              this.SubFormat = 0;              this.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>(granny_pixel_layout.GrannyBGRA8888PixelFormat), granny_pixel_layout.GrannyBGRA8888PixelFormat);
61              this.Layout = new Layout();              this.Layout = new Layout();
62              this.Images = new List<Image>();              this.Images = new List<Image>();
63              //this.ExtendedData = new IntPtr();              //this.ExtendedData = new IntPtr();
# Line 68  namespace gr2lib.core.coretypes.implemen Line 70  namespace gr2lib.core.coretypes.implemen
70          {          {
71              native.Texture _texture_struct = new gr2lib.core.coretypes.native.Texture();              native.Texture _texture_struct = new gr2lib.core.coretypes.native.Texture();
72    
73              _texture_struct.Encoding = texture.Encoding;              //_texture_struct.Encoding = texture.Encoding;
74              _texture_struct.ExtendedData = texture.ExtendedData;              //_texture_struct.ExtendedData = texture.ExtendedData;
75              _texture_struct.FromFileName = texture.FromFileName.FullPath;              //_texture_struct.FromFileName = texture.FromFileName.FullPath;
76              _texture_struct.Height = texture.Height;              //_texture_struct.Height = texture.Height;
77              //_texture_struct.Images = texture.Images;              ////_texture_struct.Images = texture.Images;
78              _texture_struct.Layout = Layout.AssignToStructure(texture.Layout);              //_texture_struct.Layout = Layout.AssignToStructure(texture.Layout);
79              _texture_struct.SubFormat = texture.SubFormat;              //_texture_struct.SubFormat = texture.SubFormat;
80              _texture_struct.TextureType = texture.TextureType;              //_texture_struct.TextureType = texture.TextureType;
81              _texture_struct.Width = texture.Width;              //_texture_struct.Width = texture.Width;
82    
83              return _texture_struct;              return _texture_struct;
84          }          }
# Line 107  namespace gr2lib.core.coretypes.implemen Line 109  namespace gr2lib.core.coretypes.implemen
109              {              {
110                  Texture managed = new Texture();                  Texture managed = new Texture();
111                  managed.FromFileName = native.FromFileName;                  managed.FromFileName = native.FromFileName;
112                  managed.TextureType = native.TextureType;                  managed.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyEnumTypeString<granny_texture_type>((granny_texture_type)native.TextureType), (granny_texture_type)native.TextureType);
113                  managed.Width = native.Width;                  managed.Width = native.Width;
114                  managed.Height = native.Height;                  managed.Height = native.Height;
115                  managed.Encoding = native.Encoding;                  managed.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyEnumTypeString<granny_texture_encoding>((granny_texture_encoding)native.Encoding), (granny_texture_encoding)native.Encoding);
116                  managed.SubFormat = native.SubFormat;                  managed.SubFormat = new NameValuePair<string, granny_pixel_layout>(coreapi.GetGrannyEnumTypeString<granny_pixel_layout>((granny_pixel_layout)native.SubFormat), (granny_pixel_layout)native.SubFormat);
117                  managed.Layout = Layout.ReadFromNative(native.Layout);                  managed.Layout = Layout.ReadFromNative(native.Layout);
118                  IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);                  IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);
119                  int length = images.Length;                  int length = images.Length;
# Line 153  namespace gr2lib.core.coretypes.implemen Line 155  namespace gr2lib.core.coretypes.implemen
155          }          }
156    
157          #region ITexture Members          #region ITexture Members
   
         [RefreshPropertiesAttribute(RefreshProperties.All)]  
         public string TextureTypeFormat  
         {  
             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;  
             }  
         }  
   
158          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
159          public FilePath FromFileName { get { return _FromFileName; } set { _FromFileName = value; } }          public FilePath FromFileName { get { return _FromFileName; } set { _FromFileName = value; } }
160          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
161          public int TextureType { get { return _TextureType; } set { _TextureType = value; } }          [Editor(typeof(UIComboValueSelector<granny_texture_type, int>), typeof(UITypeEditor))]
162            public NameValuePair<string, granny_texture_type> TextureType { get { return _TextureType; } set { _TextureType = value; } }
163          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
164          public int Width { get { return _Width; } set { _Width = value; } }          public int Width { get { return _Width; } set { _Width = value; } }
165          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
166          public int Height { get { return _Height; } set { _Height = value; } }          public int Height { get { return _Height; } set { _Height = value; } }
167          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
168          public int Encoding { get { return _Encoding; } set { _Encoding = value; } }          [Editor(typeof(UIComboValueSelector<granny_texture_encoding, int>), typeof(UITypeEditor))]
169            public NameValuePair<string, granny_texture_encoding> Encoding { get { return _Encoding; } set { _Encoding = value; } }
170          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
171          public int SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }          [Editor(typeof(UIComboValueSelector<granny_pixel_layout, int>), typeof(UITypeEditor))]
172            public NameValuePair<string, granny_pixel_layout> SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }
173          [RefreshPropertiesAttribute(RefreshProperties.All)]          [RefreshPropertiesAttribute(RefreshProperties.All)]
174          [Browsable(true)]          [Browsable(true)]
175          public Layout Layout { get { return _Layout; } set { _Layout = value; } }          public Layout Layout { get { return _Layout; } set { _Layout = value; } }
# Line 212  namespace gr2lib.core.coretypes.implemen Line 179  namespace gr2lib.core.coretypes.implemen
179    
180          #region INativePointer Members          #region INativePointer Members
181          private IntPtr _NativePointer;          private IntPtr _NativePointer;
182            /// <summary>
183            /// When used in a derived class, gets the native pointer for this instance
184            /// </summary>
185          public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }          public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
186          #endregion          #endregion
187    
188          #region IExtendedData Members          #region IExtendedData Members
189          private IntPtr _ExtendedData;          private IntPtr _ExtendedData;
190            /// <summary>
191            /// When used in a derived class, gets the ExtendedData pointer for this instance
192            /// </summary>
193          public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }          public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
194          #endregion          #endregion
195    

Legend:
Removed from v.142  
changed lines
  Added in v.183

  ViewVC Help
Powered by ViewVC 1.1.22