コード例 #1
0
        public static void RenderSprite(Sprite sprite, int leftPixel, int topPixel, int pixelWidth, int pixelHeight, ImageData imageData)
        {
            if (sprite.Texture == null || sprite.BlendOperation != BlendOperation.Regular)
            {
                // for now throw an exception, later we may want to handle pure color rendering and stuff like that
                throw new NotImplementedException();
            }

            ImageData spriteTextureImageData = ImageData.FromTexture2D(sprite.Texture);

#if FRB_MDX
            ColorOperation colorOperation = GraphicalEnumerations.TranslateTextureOperationToColorOperation(sprite.ColorOperation);
#else
            ColorOperation colorOperation = sprite.ColorOperation;
#endif

            spriteTextureImageData.ApplyColorOperation(colorOperation, sprite.Red, sprite.Green, sprite.Blue, sprite.Alpha);


            int rightBound  = System.Math.Min(imageData.Width, leftPixel + pixelWidth);
            int bottomBound = System.Math.Min(imageData.Height, topPixel + pixelHeight);

            int actualWidth  = rightBound - leftPixel;
            int actualHeight = bottomBound - topPixel;



            for (int destinationX = leftPixel; destinationX < rightBound; destinationX++)
            {
                for (int destinationY = topPixel; destinationY < bottomBound; destinationY++)
                {
                    int sourcePixelX = spriteTextureImageData.Width * (destinationX - leftPixel) / pixelWidth;
                    int sourcePixelY = spriteTextureImageData.Height * (destinationY - topPixel) / pixelHeight;

                    Color sourcePixel = spriteTextureImageData.GetPixelColor(sourcePixelX, sourcePixelY);

                    if (sourcePixel.A != 255)
                    {
                        Color destinationPixel = imageData.GetPixelColor(destinationX, destinationY);
#if FRB_MDX
                        sourcePixel = Color.FromArgb(
                            System.Math.Max(sourcePixel.A, destinationPixel.A),
                            (byte)(destinationPixel.R * (255 - sourcePixel.A) / 255.0f + sourcePixel.R * (sourcePixel.A) / 255.0f),
                            (byte)(destinationPixel.G * (255 - sourcePixel.A) / 255.0f + sourcePixel.G * (sourcePixel.A) / 255.0f),
                            (byte)(destinationPixel.B * (255 - sourcePixel.A) / 255.0f + sourcePixel.B * (sourcePixel.A) / 255.0f));

                        // This is probably not accurate, but will work currently.  Eventually we may want to look at how blending is actually performed
#else
                        sourcePixel.R = (byte)(destinationPixel.R * (255 - sourcePixel.A) / 255.0f + sourcePixel.R * (sourcePixel.A) / 255.0f);
                        sourcePixel.G = (byte)(destinationPixel.G * (255 - sourcePixel.A) / 255.0f + sourcePixel.G * (sourcePixel.A) / 255.0f);
                        sourcePixel.B = (byte)(destinationPixel.B * (255 - sourcePixel.A) / 255.0f + sourcePixel.B * (sourcePixel.A) / 255.0f);

                        // This is probably not accurate, but will work currently.  Eventually we may want to look at how blending is actually performed
                        sourcePixel.A = System.Math.Max(sourcePixel.A, destinationPixel.A);
#endif
                    }
                    imageData.SetPixel(destinationX, destinationY, sourcePixel);
                }
            }
        }
コード例 #2
0
        public RenderBreak(int itemNumber, Texture2D texture,
                           ColorOperation colorOperation,
                           BlendOperation blendOperation, TextureAddressMode textureAddressMode)
        {
#if DEBUG
            ObjectCausingBreak = null;
#endif
            LayerName = Renderer.CurrentLayerName;


            PrimitiveType = PrimitiveType.TriangleList;
            ItemNumber    = itemNumber;

            if (texture != null && texture.IsDisposed)
            {
                throw new ObjectDisposedException("Cannot create render break with disposed Texture2D");
            }

            mTexture               = texture;
            ColorOperation         = colorOperation;
            BlendOperation         = blendOperation;
            TextureAddressMode     = textureAddressMode;
            TextureFilter          = FlatRedBallServices.GraphicsOptions.TextureFilter;
            _originalTextureFilter = TextureFilter.Linear;

#if MONOGAME
            Red   = 0;
            Green = 0;
            Blue  = 0;
#endif
        }
コード例 #3
0
        private void PlatformSpecificInitialization()
        {
            mColorOperation = ColorOperation.Texture;
            mBlendOperation = BlendOperation.Regular;


            // This is needed because SpriteChains may
            // use particle Sprites which can screw up
            mVertices[0].TextureCoordinate.X = 0;
            mVertices[0].TextureCoordinate.Y = 0;
            mVertices[0].Scale = new Vector2(-1, 1);

            mVertices[1].TextureCoordinate.X = 1;
            mVertices[1].TextureCoordinate.Y = 0;
            mVertices[1].Scale = new Vector2(1, 1);

            mVertices[2].TextureCoordinate.X = 1;
            mVertices[2].TextureCoordinate.Y = 1;
            mVertices[2].Scale = new Vector2(1, -1);

            mVertices[3].TextureCoordinate.X = 0;
            mVertices[3].TextureCoordinate.Y = 1;
            mVertices[3].Scale = new Vector2(-1, -1);

            CustomBehavior = null;
        }
コード例 #4
0
        public void SetStates()
        {
            //if (Renderer.RendererDiagnosticSettings.RenderBreaksPerformStateChanges)
            {
                if (ColorOperation != Graphics.ColorOperation.Color)
                {
                    Renderer.Texture = Texture;
                }

                if (Texture == null && ColorOperation == ColorOperation.Texture)
                {
                    ColorOperation = ColorOperation.Color;
                }

                Renderer.ColorOperation     = ColorOperation;
                Renderer.BlendOperation     = BlendOperation;
                Renderer.TextureAddressMode = TextureAddressMode;
                _originalTextureFilter      = FlatRedBallServices.GraphicsOptions.TextureFilter;
                //if (TextureFilter != FlatRedBallServices.GraphicsOptions.TextureFilter)
                FlatRedBallServices.GraphicsOptions.TextureFilter = TextureFilter;

#if !USE_CUSTOM_SHADER
                if (ColorOperation == Graphics.ColorOperation.ColorTextureAlpha)
                {
                    Renderer.SetFogForColorOperation(Red, Green, Blue);
                }
#endif
            }
        }
コード例 #5
0
        public RenderBreak(int itemNumber, Sprite sprite)
        {
#if DEBUG
            ObjectCausingBreak = sprite;
#endif
            LayerName              = Renderer.CurrentLayerName;
            ItemNumber             = itemNumber;
            PrimitiveType          = PrimitiveType.TriangleList;
            _originalTextureFilter = TextureFilter.Linear;

            if (sprite != null)
            {
                if (sprite.Texture != null && sprite.Texture.IsDisposed)
                {
                    throw new ObjectDisposedException("The Sprite with the name \"" + sprite.Name +
                                                      "\" references a disposed texture of the name " + sprite.Texture.Name +
                                                      ".  If you're using Screens you may have forgotten to remove a Sprite that was " +
                                                      "added in the Screen.");
                }

                mTexture = sprite.Texture;

                ColorOperation = sprite.ColorOperation;
                BlendOperation = sprite.BlendOperation;
                TextureFilter  = sprite.TextureFilter.HasValue ? sprite.TextureFilter.Value : FlatRedBallServices.GraphicsOptions.TextureFilter;

                if (sprite.Texture == null)
                {
                    // requirement for reach profile - this shouldn't impact anything
                    TextureAddressMode = Microsoft.Xna.Framework.Graphics.TextureAddressMode.Clamp;
                }
                else
                {
                    TextureAddressMode = sprite.TextureAddressMode;
                }


                Red   = sprite.Red;
                Green = sprite.Green;
                Blue  = sprite.Blue;
            }
            else
            {
                Red   = 0;
                Green = 0;
                Blue  = 0;

                mTexture = null;

                ColorOperation = ColorOperation.Texture;

                BlendOperation     = BlendOperation.Regular;
                TextureAddressMode = TextureAddressMode.Clamp;
                TextureFilter      = FlatRedBallServices.GraphicsOptions.TextureFilter;
            }
        }
コード例 #6
0
        public static string ColorOperationToFlatRedBallMdxString(ColorOperation op)
        {
            switch (op)
            {
            case FlatRedBall.Graphics.ColorOperation.Add:
                return("Add");

            //break;
            case ColorOperation.InverseTexture:
                return("InverseTexture");

            //break;
            case ColorOperation.InterpolateColor:
                return("InterpolateColor");

            //break;
            case FlatRedBall.Graphics.ColorOperation.Modulate:
                return("Modulate");

            //break;
            case FlatRedBall.Graphics.ColorOperation.Texture:
            case ColorOperation.None:
                return("SelectArg1");

            //break;
            case ColorOperation.Color:
            case FlatRedBall.Graphics.ColorOperation.ColorTextureAlpha:
                return("SelectArg2");

            //break;
            case FlatRedBall.Graphics.ColorOperation.Subtract:
                return("Subtract");

            //break;
            case FlatRedBall.Graphics.ColorOperation.Modulate2X:
                return("Modulate2X");

            // break;
            case FlatRedBall.Graphics.ColorOperation.Modulate4X:
                return("Modulate4X");

            // break;
            default:
                throw new System.NotImplementedException(
                          op + " is currently not supported in FlatRedBall XNA");
                //break;
            }
        }
コード例 #7
0
        public RenderBreak(int itemNumber, Text text, int textureIndex)
        {
#if DEBUG
            ObjectCausingBreak = text;
#endif
            LayerName = Renderer.CurrentLayerName;


            Red   = 1;
            Green = 1;
            Blue  = 1;
#if !USE_CUSTOM_SHADER
            if (text.ColorOperation != Graphics.ColorOperation.Texture)
            {
                Red   = text.Red;
                Green = text.Green;
                Blue  = text.Blue;
            }
#endif

            ItemNumber = itemNumber;

            PrimitiveType          = PrimitiveType.TriangleList;
            TextureFilter          = FlatRedBallServices.GraphicsOptions.TextureFilter;
            _originalTextureFilter = TextureFilter.Linear;

            if (text != null)
            {
                if (text.Font.Texture != null && text.Font.Texture.IsDisposed)
                {
                    throw new ObjectDisposedException("Cannot create render break with disposed Texture2D");
                }

                mTexture = text.Font.Textures[textureIndex];

                ColorOperation     = text.ColorOperation;
                BlendOperation     = text.BlendOperation;
                TextureAddressMode = TextureAddressMode.Clamp;
            }
            else
            {
                mTexture           = null;
                ColorOperation     = ColorOperation.Texture;
                BlendOperation     = BlendOperation.Regular;
                TextureAddressMode = TextureAddressMode.Clamp;
            }
        }
コード例 #8
0
ファイル: ImageData.cs プロジェクト: profexorgeek/FlatRedBall
        public void ApplyColorOperation(ColorOperation colorOperation, float red, float green, float blue, float alpha)
        {
            Color appliedColor;

#if FRB_MDX
            // passed values from MDX will be 0-255 instead of 0-1 so we simply cast into a byte (Justin 5/15/2012)
            appliedColor = Color.FromArgb(
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(alpha),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(red),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(green),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(blue)
                );
#else
            // passed values from XNA will be 0-1, use the float constructor to create a color object (Justin 5/15/2012)
            appliedColor = new Color(red, green, blue, alpha);
#endif
            ApplyColorOperation(colorOperation, appliedColor);
        }
コード例 #9
0
    void InitColorList()
    {
        colorListInfo.Clear();
        colorCount = 0;
        string line;

        string       dataPath = Application.dataPath.Replace('/', '\\');
        StreamReader file     = new StreamReader(dataPath + @"\Editor Default Resources\UIColorList.txt");

        while ((line = file.ReadLine()) != null)
        {
            if (line != "" && !line.StartsWith("//"))
            {
                colorListInfo.Add(line);
                colorCount++;
            }
        }
        file.Close();
        file = null;

        colorBtnsTxt = new string[colorCount / 2];
        colors       = new Color[colorBtnsTxt.Length];

        for (int i = 0; i < colorCount; i++)
        {
            if ((i & 1) == 0)
            {
                int index = i / 2;
                colorBtnsTxt[index] = colorListInfo[i].ToString();
            }
            else
            {
                int      index     = (i - 1) / 2;
                string[] colorInfo = colorListInfo[i].ToString().Split(' ');
                float    alpha     = int.Parse(colorInfo[1]) / 100f;
                colors[index] = ColorOperation.GetColorFromStr(colorInfo[0], alpha);
            }
        }
    }
コード例 #10
0
ファイル: ImageData.cs プロジェクト: vchelaru/FlatRedBall
        public void ApplyColorOperation(ColorOperation colorOperation, Color appliedColor)
        {

            Color baseColor;

            switch (colorOperation)
            {

                case ColorOperation.Add:
                    for (int x = 0; x < Width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            baseColor = GetPixelColor(x, y);
#if FRB_MDX
                            // System.Drawing.Color doesn't have setters for A, R, G, B
                            // so we have to do it a more inefficient way in FRB MDX
                            Color combinedColor = Color.FromArgb(
                                baseColor.A,
                                (byte)System.Math.Min((baseColor.R + appliedColor.R), 255),
                                (byte)System.Math.Min((baseColor.G + appliedColor.G), 255),
                                (byte)System.Math.Min((baseColor.B + appliedColor.B), 255));
                            baseColor = combinedColor;
#elif XNA4
                            baseColor.R = (byte)(System.Math.Min((baseColor.R + appliedColor.R), 255) * baseColor.A / 255);
                            baseColor.G = (byte)(System.Math.Min((baseColor.G + appliedColor.G), 255) * baseColor.A / 255);
                            baseColor.B = (byte)(System.Math.Min((baseColor.B + appliedColor.B), 255) * baseColor.A / 255);
#else
                            baseColor.R = (byte)System.Math.Min((baseColor.R + appliedColor.R), 255);
                            baseColor.G = (byte)System.Math.Min((baseColor.G + appliedColor.G), 255);
                            baseColor.B = (byte)System.Math.Min((baseColor.B + appliedColor.B), 255);
#endif
                            SetPixel(x, y, baseColor);
                        }
                    }
                    break;

                case ColorOperation.Modulate:

                    // Justin Johnson - May 15, 2012 - pre-multiply so we don't calculate every iteration (Justin 5/15/2012)
                    float red = appliedColor.R / 255f;
                    float green = appliedColor.G / 255f;
                    float blue = appliedColor.B / 255f;

                    for (int x = 0; x < Width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            baseColor = GetPixelColor(x, y);
#if FRB_MDX
                            // System.Drawing.Color doesn't have setters for A, R, G, B
                            // so we have to do it a more inefficient way in FRB MDX
                            Color combinedColor = Color.FromArgb(
                                baseColor.A,
                                (byte)(baseColor.R * red),
                                (byte)(baseColor.G * green),
                                (byte)(baseColor.B * blue));
                            baseColor = combinedColor;
#else
                            baseColor.R = (byte)(baseColor.R * red);
                            baseColor.G = (byte)(baseColor.G * green);
                            baseColor.B = (byte)(baseColor.B * blue);
#endif
                            SetPixel(x, y, baseColor);
                        }
                    }
                    break;

                case ColorOperation.Texture:
                    // no-op
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
コード例 #11
0
ファイル: ImageData.cs プロジェクト: vchelaru/FlatRedBall
        public void ApplyColorOperation(ColorOperation colorOperation, float red, float green, float blue, float alpha)
        {
            Color appliedColor;
#if FRB_MDX
            // passed values from MDX will be 0-255 instead of 0-1 so we simply cast into a byte (Justin 5/15/2012)
            appliedColor = Color.FromArgb(
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(alpha),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(red),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(green),
                (byte)FlatRedBall.Math.MathFunctions.RoundToInt(blue)
            );
#else
            // passed values from XNA will be 0-1, use the float constructor to create a color object (Justin 5/15/2012)
            appliedColor = new Color(red, green, blue, alpha);
#endif
            ApplyColorOperation(colorOperation, appliedColor);
        }
コード例 #12
0
 public Image <Gray, Byte> RangeImage(Image <Bgr, Byte> src)
 {
     return(BaseImage(src).InRange(ColorOperation.Sub(HaloColor, BaseTolerance), ColorOperation.Sum(HaloColor, BaseTolerance)));
 }
コード例 #13
0
ファイル: ImageData.cs プロジェクト: profexorgeek/FlatRedBall
        public void ApplyColorOperation(ColorOperation colorOperation, Color appliedColor)
        {
            Color baseColor;

            switch (colorOperation)
            {
            case ColorOperation.Add:
                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        baseColor = GetPixelColor(x, y);
#if FRB_MDX
                        // System.Drawing.Color doesn't have setters for A, R, G, B
                        // so we have to do it a more inefficient way in FRB MDX
                        Color combinedColor = Color.FromArgb(
                            baseColor.A,
                            (byte)System.Math.Min((baseColor.R + appliedColor.R), 255),
                            (byte)System.Math.Min((baseColor.G + appliedColor.G), 255),
                            (byte)System.Math.Min((baseColor.B + appliedColor.B), 255));
                        baseColor = combinedColor;
#elif XNA4
                        baseColor.R = (byte)(System.Math.Min((baseColor.R + appliedColor.R), 255) * baseColor.A / 255);
                        baseColor.G = (byte)(System.Math.Min((baseColor.G + appliedColor.G), 255) * baseColor.A / 255);
                        baseColor.B = (byte)(System.Math.Min((baseColor.B + appliedColor.B), 255) * baseColor.A / 255);
#else
                        baseColor.R = (byte)System.Math.Min((baseColor.R + appliedColor.R), 255);
                        baseColor.G = (byte)System.Math.Min((baseColor.G + appliedColor.G), 255);
                        baseColor.B = (byte)System.Math.Min((baseColor.B + appliedColor.B), 255);
#endif
                        SetPixel(x, y, baseColor);
                    }
                }
                break;

            case ColorOperation.Modulate:

                // Justin Johnson - May 15, 2012 - pre-multiply so we don't calculate every iteration (Justin 5/15/2012)
                float red   = appliedColor.R / 255f;
                float green = appliedColor.G / 255f;
                float blue  = appliedColor.B / 255f;

                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        baseColor = GetPixelColor(x, y);
#if FRB_MDX
                        // System.Drawing.Color doesn't have setters for A, R, G, B
                        // so we have to do it a more inefficient way in FRB MDX
                        Color combinedColor = Color.FromArgb(
                            baseColor.A,
                            (byte)(baseColor.R * red),
                            (byte)(baseColor.G * green),
                            (byte)(baseColor.B * blue));
                        baseColor = combinedColor;
#else
                        baseColor.R = (byte)(baseColor.R * red);
                        baseColor.G = (byte)(baseColor.G * green);
                        baseColor.B = (byte)(baseColor.B * blue);
#endif
                        SetPixel(x, y, baseColor);
                    }
                }
                break;

            case ColorOperation.Texture:
                // no-op
                break;

            default:
                throw new NotImplementedException();
            }
        }
コード例 #14
0
        public static Microsoft.DirectX.Direct3D.TextureOperation TranslateColorOperation(ColorOperation op)
        {
            switch (op)
            {
            case ColorOperation.Add:
                return(Microsoft.DirectX.Direct3D.TextureOperation.Add);

            //break;

            case ColorOperation.Modulate:
                return(Microsoft.DirectX.Direct3D.TextureOperation.Modulate);

            //break;
            case ColorOperation.Color:
                return(Microsoft.DirectX.Direct3D.TextureOperation.SelectArg1);

            //break;
            case ColorOperation.Texture:
                return(Microsoft.DirectX.Direct3D.TextureOperation.SelectArg2);

            //break;
            case ColorOperation.Subtract:
                return(Microsoft.DirectX.Direct3D.TextureOperation.Subtract);

            //break;
            case ColorOperation.Modulate2X:
                return(Microsoft.DirectX.Direct3D.TextureOperation.Modulate2X);

            //break;
            case ColorOperation.Modulate4X:
                return(Microsoft.DirectX.Direct3D.TextureOperation.Modulate4X);

            //break;

            default:
                throw new System.NotImplementedException(
                          op + " is currently not supported in FlatRedBall MDX");
                //break;
            }
        }
コード例 #15
0
 public static string ColorOperationToFlatRedBallMdxString(ColorOperation op)
 {
     switch (op)
     {
         case FlatRedBall.Graphics.ColorOperation.Add:
             return "Add";
         //break;
         case ColorOperation.InverseTexture:
             return "InverseTexture";
             //break;
         case ColorOperation.InterpolateColor:
             return "InterpolateColor";
             //break;
         case FlatRedBall.Graphics.ColorOperation.Modulate:
             return "Modulate";
         //break;
         case FlatRedBall.Graphics.ColorOperation.Texture:
         case ColorOperation.None:
             return "SelectArg1";
         //break;
         case ColorOperation.Color:
         case FlatRedBall.Graphics.ColorOperation.ColorTextureAlpha:
             return "SelectArg2";
         //break;
         case FlatRedBall.Graphics.ColorOperation.Subtract:
             return "Subtract";
         //break;
         case FlatRedBall.Graphics.ColorOperation.Modulate2X:
             return "Modulate2X";
         // break;
         case FlatRedBall.Graphics.ColorOperation.Modulate4X:
             return "Modulate4X";
         // break;
         default:
             throw new System.NotImplementedException(
                 op + " is currently not supported in FlatRedBall XNA");
         //break;
     }
 }
コード例 #16
0
        public static Microsoft.DirectX.Direct3D.TextureOperation TranslateColorOperation(ColorOperation op)
        {
            switch (op)
            {
                case ColorOperation.Add:
                    return Microsoft.DirectX.Direct3D.TextureOperation.Add;
                //break;

                case ColorOperation.Modulate:
                    return Microsoft.DirectX.Direct3D.TextureOperation.Modulate;
                //break;
                case ColorOperation.Color:
                    return Microsoft.DirectX.Direct3D.TextureOperation.SelectArg1;
                //break;
                case ColorOperation.Texture:
                    return Microsoft.DirectX.Direct3D.TextureOperation.SelectArg2;
                //break;
                case ColorOperation.Subtract:
                    return Microsoft.DirectX.Direct3D.TextureOperation.Subtract;
                //break;
                case ColorOperation.Modulate2X:
                    return Microsoft.DirectX.Direct3D.TextureOperation.Modulate2X;
                //break;
                case ColorOperation.Modulate4X:
                    return Microsoft.DirectX.Direct3D.TextureOperation.Modulate4X;
                //break;

                default:
                    throw new System.NotImplementedException(
                        op + " is currently not supported in FlatRedBall MDX");
                //break;
            }
        }
コード例 #17
0
ファイル: Sprite.cs プロジェクト: GorillaOne/FlatRedBall
        private void PlatformSpecificInitialization()
        {

            mColorOperation = ColorOperation.Texture;
            mBlendOperation = BlendOperation.Regular;


            // This is needed because SpriteChains may
            // use particle Sprites which can screw up 
            mVertices[0].TextureCoordinate.X = 0;
            mVertices[0].TextureCoordinate.Y = 0;
            mVertices[0].Scale = new Vector2(-1, 1);

            mVertices[1].TextureCoordinate.X = 1;
            mVertices[1].TextureCoordinate.Y = 0;
            mVertices[1].Scale = new Vector2(1, 1);

            mVertices[2].TextureCoordinate.X = 1;
            mVertices[2].TextureCoordinate.Y = 1;
            mVertices[2].Scale = new Vector2(1, -1);

            mVertices[3].TextureCoordinate.X = 0;
            mVertices[3].TextureCoordinate.Y = 1;
            mVertices[3].Scale = new Vector2(-1, -1);

            CustomBehavior = null;
        }
コード例 #18
0
    override protected bool OnDrawProperties()
    {
        mLabel = mWidget as UILabel;
        if (GUILayout.Button("Font", GUILayout.Width(76f)))
        {
            ComponentSelectorNew.Show <Font>(OnSelectFont);
        }

        int fontSize = EditorGUILayout.IntField("FontSize:", mLabel.FontSize);

        if (fontSize != mLabel.FontSize)
        {
            RegisterUndo(); mLabel.FontSize = fontSize;
        }

        Font font = EditorGUILayout.ObjectField("", mLabel.TrueTypeFont, typeof(Font), false) as Font;

        if (font != mLabel.TrueTypeFont)
        {
            mLabel.TrueTypeFont = font;
        }

        EditorGUILayout.ObjectField("Material", mLabel.material, typeof(Material), false);

        if (mLabel.font == null)
        {
            return(false);
        }

        string text = EditorGUILayout.TextArea(mLabel.text, GUILayout.Height(100f));

        if (!text.Equals(mLabel.text))
        {
            RegisterUndo(); mLabel.text = text;
        }

        GUILayout.BeginHorizontal();
        {
            int len = EditorGUILayout.IntField("Line Width", mLabel.lineWidth, GUILayout.Width(120f));
            if (len != mLabel.lineWidth)
            {
                RegisterUndo(); mLabel.lineWidth = len;
            }

            bool multi = EditorGUILayout.Toggle("Multi-line", mLabel.multiLine, GUILayout.Width(100f));
            if (multi != mLabel.multiLine)
            {
                RegisterUndo(); mLabel.multiLine = multi;
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            int len = EditorGUILayout.IntField("Fixed Chinese", mLabel.FixedWidthForChinese, GUILayout.Width(120f));
            if (len != mLabel.FixedWidthForChinese)
            {
                RegisterUndo(); mLabel.FixedWidthForChinese = len;
            }
        }
        GUILayout.EndHorizontal();

        int spaceingY = EditorGUILayout.IntField("LineSpacingY", mLabel.lineSpacingY);

        if (spaceingY != mLabel.lineSpacingY)
        {
            RegisterUndo(); mLabel.lineSpacingY = spaceingY;
        }

        int spaceingX = EditorGUILayout.IntField("FontSpacingX", mLabel.FontSpacingX);

        if (spaceingX != mLabel.FontSpacingX)
        {
            RegisterUndo(); mLabel.FontSpacingX = spaceingX;
        }

        GUILayout.BeginHorizontal();
        {
            bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(120f));
            if (password != mLabel.password)
            {
                RegisterUndo(); mLabel.password = password;
            }

            bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f));
            if (encoding != mLabel.supportEncoding)
            {
                RegisterUndo(); mLabel.supportEncoding = encoding;
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f));
            if (effect != mLabel.effectStyle)
            {
                RegisterUndo(); mLabel.effectStyle = effect;
            }

            if (effect != UILabel.Effect.None)
            {
                Color c = EditorGUILayout.ColorField(mLabel.effectColor);
                if (mLabel.effectColor != c)
                {
                    RegisterUndo(); mLabel.effectColor = c;
                }
            }
        }
        GUILayout.EndHorizontal();
        FontStyle style = (FontStyle)EditorGUILayout.EnumPopup("FontStyle:", mLabel.FontStyle, GUILayout.Width(200f));

        if (style != mLabel.FontStyle)
        {
            RegisterUndo();
            mLabel.FontStyle = style;
        }

        GUILayout.BeginHorizontal();
        Color color = EditorGUILayout.ColorField("Top Color", mLabel.TopColor);

        uint colorIntValue = (uint)NGUIMath.ColorToInt(color);

        colorIntValue &= 0xFFFFFFFF;
        string colorRGBA  = colorIntValue.ToString("X8");
        string ncolorRGBA = EditorGUILayout.TextField("RGBA:", colorRGBA);

        if (ncolorRGBA != colorRGBA)
        {
            color = ColorOperation.GetColorFromRGBAStr(ncolorRGBA);
        }

        if (mLabel.TopColor != color)
        {
            NGUIEditorTools.RegisterUndo("Color Change", mLabel);
            mLabel.TopColor = color;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        color = EditorGUILayout.ColorField("Bottom Color", mLabel.BottomColor);

        colorIntValue  = (uint)NGUIMath.ColorToInt(color);
        colorIntValue &= 0xFFFFFFFF;
        colorRGBA      = colorIntValue.ToString("X8");
        ncolorRGBA     = EditorGUILayout.TextField("RGBA:", colorRGBA);
        if (ncolorRGBA != colorRGBA)
        {
            color = ColorOperation.GetColorFromRGBAStr(ncolorRGBA);
        }

        if (mLabel.BottomColor != color)
        {
            NGUIEditorTools.RegisterUndo("Color Change", mLabel);
            mLabel.BottomColor = color;
        }
        GUILayout.EndHorizontal();

        return(true);
    }