/[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

--- trunk/gr2lib/core/coretypes/implementation/Texture.cs	2010/07/22 09:06:33	159
+++ trunk/gr2lib/core/coretypes/implementation/Texture.cs	2010/07/22 10:20:55	160
@@ -9,6 +9,8 @@
 using gr2lib.core.ui.helpers;
 using System.ComponentModel;
 using gr2lib.core.typedefs;
+using gr2lib.core.ui.typeeditors;
+using System.Drawing.Design;
 
 namespace gr2lib.core.coretypes.implementation
 {
@@ -17,10 +19,10 @@
         private GrannyRigResource _rigResource;
 
         private FilePath _FromFileName;
-        private int _TextureType;
+        private NameValuePair<string, granny_texture_type> _TextureType;
         private int _Width;
         private int _Height;
-        private int _Encoding;
+        private NameValuePair<string, granny_texture_encoding> _Encoding;
         private int _SubFormat;
         private Layout _Layout;
         private List<Image> _Images;
@@ -37,10 +39,10 @@
         public Texture()// : base("Textures")
         {
             this.FromFileName = "";
-            this.TextureType = 0;
+            this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyTextureTypeString(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
             this.Width = 0;
             this.Height = 0;
-            this.Encoding = 0;
+            this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyTextureEncodingString(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
             this.SubFormat = 0;
             this.Layout = new Layout();
             this.Images = new List<Image>();
@@ -51,10 +53,10 @@
         public Texture(int index)
         {
             this.FromFileName = "";
-            this.TextureType = 0;
+            this.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyTextureTypeString(granny_texture_type.GrannyColorMapTextureType), granny_texture_type.GrannyColorMapTextureType);
             this.Width = 0;
             this.Height = 0;
-            this.Encoding = 0;
+            this.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyTextureEncodingString(granny_texture_encoding.GrannyBinkTextureEncoding), granny_texture_encoding.GrannyBinkTextureEncoding);
             this.SubFormat = 0;
             this.Layout = new Layout();
             this.Images = new List<Image>();
@@ -107,10 +109,10 @@
             {
                 Texture managed = new Texture();
                 managed.FromFileName = native.FromFileName;
-                managed.TextureType = native.TextureType;
+                managed.TextureType = new NameValuePair<string, granny_texture_type>(coreapi.GetGrannyTextureTypeString((granny_texture_type)native.TextureType), (granny_texture_type)native.TextureType);
                 managed.Width = native.Width;
                 managed.Height = native.Height;
-                managed.Encoding = native.Encoding;
+                managed.Encoding = new NameValuePair<string, granny_texture_encoding>(coreapi.GetGrannyTextureEncodingString((granny_texture_encoding)native.Encoding), (granny_texture_encoding)native.Encoding);
                 managed.SubFormat = native.SubFormat;
                 managed.Layout = Layout.ReadFromNative(native.Layout);
                 IntPtr[] images = Helpers.ReadPtrArrayFromMemory<native.Image>(native.Images);
@@ -154,53 +156,55 @@
 
         #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;
-            }
-        }
+        //[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;
+        //    }
+        //}
 
         [RefreshPropertiesAttribute(RefreshProperties.All)]
         public FilePath FromFileName { get { return _FromFileName; } set { _FromFileName = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]
-        public int TextureType { get { return _TextureType; } set { _TextureType = value; } }
+        [Editor(typeof(UIComboValueSelector<granny_texture_type, int>), typeof(UITypeEditor))]
+        public NameValuePair<string, granny_texture_type> TextureType { get { return _TextureType; } set { _TextureType = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]
         public int Width { get { return _Width; } set { _Width = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]
         public int Height { get { return _Height; } set { _Height = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]
-        public int Encoding { get { return _Encoding; } set { _Encoding = value; } }
+        [Editor(typeof(UIComboValueSelector<granny_texture_encoding, int>), typeof(UITypeEditor))]
+        public NameValuePair<string, granny_texture_encoding> Encoding { get { return _Encoding; } set { _Encoding = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]
         public int SubFormat { get { return _SubFormat; } set { _SubFormat = value; } }
         [RefreshPropertiesAttribute(RefreshProperties.All)]

 

  ViewVC Help
Powered by ViewVC 1.1.22