HexToDecimal() private method

private HexToDecimal ( char ch ) : int
ch char
return int
Exemplo n.º 1
0
 static public int HexToDecimal_s(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         System.Char a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.HexToDecimal(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemplo n.º 2
0
	/// <summary>
	/// Parse a RrGgBb color encoded in the string.
	/// </summary>

	static public Color ParseColor (string text, int offset)
	{
		int r = (NGUIMath.HexToDecimal(text[offset])	 << 4) | NGUIMath.HexToDecimal(text[offset + 1]);
		int g = (NGUIMath.HexToDecimal(text[offset + 2]) << 4) | NGUIMath.HexToDecimal(text[offset + 3]);
		int b = (NGUIMath.HexToDecimal(text[offset + 4]) << 4) | NGUIMath.HexToDecimal(text[offset + 5]);
		float f = 1f / 255f;
		return new Color(f * r, f * g, f * b);
	}
Exemplo n.º 3
0
    public static Color32 ParseColor32(String text, Int32 offset)
    {
        Byte r = (Byte)(NGUIMath.HexToDecimal(text[offset]) << 4 | NGUIMath.HexToDecimal(text[offset + 1]));
        Byte g = (Byte)(NGUIMath.HexToDecimal(text[offset + 2]) << 4 | NGUIMath.HexToDecimal(text[offset + 3]));
        Byte b = (Byte)(NGUIMath.HexToDecimal(text[offset + 4]) << 4 | NGUIMath.HexToDecimal(text[offset + 5]));

        return(new Color32(r, g, b, Byte.MaxValue));
    }
Exemplo n.º 4
0
    public static Color ParseColor(String text, Int32 offset)
    {
        Int32 num  = NGUIMath.HexToDecimal(text[offset]) << 4 | NGUIMath.HexToDecimal(text[offset + 1]);
        Int32 num2 = NGUIMath.HexToDecimal(text[offset + 2]) << 4 | NGUIMath.HexToDecimal(text[offset + 3]);
        Int32 num3 = NGUIMath.HexToDecimal(text[offset + 4]) << 4 | NGUIMath.HexToDecimal(text[offset + 5]);

        return(new Color(0.003921569f * num, 0.003921569f * num2, 0.003921569f * num3));
    }
Exemplo n.º 5
0
    public static Color ParseColor(string text, int offset)
    {
        int   num  = (NGUIMath.HexToDecimal(text[offset]) << 4) | NGUIMath.HexToDecimal(text[offset + 1]);
        int   num2 = (NGUIMath.HexToDecimal(text[offset + 2]) << 4) | NGUIMath.HexToDecimal(text[offset + 3]);
        int   num3 = (NGUIMath.HexToDecimal(text[offset + 4]) << 4) | NGUIMath.HexToDecimal(text[offset + 5]);
        float num4 = 0.003921569f;

        return(new Color(num4 * num, num4 * num2, num4 * num3));
    }
Exemplo n.º 6
0
    public static Color ParseColor(string text, int offset)
    {
        int   num    = NGUIMath.HexToDecimal(text[offset]) << 4 | NGUIMath.HexToDecimal(text[offset + 1]);
        int   num1   = NGUIMath.HexToDecimal(text[offset + 2]) << 4 | NGUIMath.HexToDecimal(text[offset + 3]);
        int   num2   = NGUIMath.HexToDecimal(text[offset + 4]) << 4 | NGUIMath.HexToDecimal(text[offset + 5]);
        float single = 0.003921569f;

        return(new Color(single * (float)num, single * (float)num1, single * (float)num2));
    }
Exemplo n.º 7
0
 static public int HexToDecimal_s(IntPtr l)
 {
     try {
         System.Char a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.HexToDecimal(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 8
0
 static public int HexToDecimal_s(IntPtr l)
 {
     try {
         System.Char a1;
         checkType(l, 1, out a1);
         var ret = NGUIMath.HexToDecimal(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 9
0
        public static Boolean ParseSymbol(String text, ref Int32 index, BetterList <Color> colors, Boolean premultiply, ref Int32 sub, ref Boolean bold, ref Boolean italic, ref Boolean underline, ref Boolean strike, ref Boolean ignoreColor, ref Boolean highShadow, ref Boolean center, ref Boolean justified, ref Int32 ff9Signal, ref Vector3 extraOffset, ref Single tabX, ref Dialog.DialogImage insertImage)
        {
            Int32 length = text.Length;

            if (IsMemoriaTag(text, index))
            {
                Char[] chars = text.ToCharArray();
                if (DialogBoxRenderer.ProcessMemoriaTag(chars, ref index, colors, ref highShadow, ref center, ref justified, ref ff9Signal, ref extraOffset, ref tabX, ref insertImage))
                {
                    return(true);
                }

                return(false);
            }

            if (!IsOriginalTag(text, index))
            {
                return(false);
            }

            if (text[index + 2] == ']')
            {
                if (text[index + 1] == '-')
                {
                    if (colors != null && colors.size > 1)
                    {
                        colors.RemoveAt(colors.size - 1);
                    }
                    index += 3;
                    return(true);
                }
                String text2 = text.Substring(index, 3);
                String text3 = text2;
                switch (text3)
                {
                case "[b]":
                    bold   = true;
                    index += 3;
                    return(true);

                case "[i]":
                    italic = true;
                    index += 3;
                    return(true);

                case "[u]":
                    underline = true;
                    index    += 3;
                    return(true);

                case "[s]":
                    strike = true;
                    index += 3;
                    return(true);

                case "[c]":
                    ignoreColor = true;
                    index      += 3;
                    return(true);
                }
            }
            if (index + 4 > length)
            {
                return(false);
            }
            if (text[index + 3] == ']')
            {
                String text4 = text.Substring(index, 4);
                String text3 = text4;
                switch (text3)
                {
                case "[/b]":
                    bold   = false;
                    index += 4;
                    return(true);

                case "[/i]":
                    italic = false;
                    index += 4;
                    return(true);

                case "[/u]":
                    underline = false;
                    index    += 4;
                    return(true);

                case "[/s]":
                    strike = false;
                    index += 4;
                    return(true);

                case "[/c]":
                    ignoreColor = false;
                    index      += 4;
                    return(true);
                }
                Char ch  = text[index + 1];
                Char ch2 = text[index + 2];
                if (NGUIText.IsHex(ch) && NGUIText.IsHex(ch2))
                {
                    Int32 num2 = NGUIMath.HexToDecimal(ch) << 4 | NGUIMath.HexToDecimal(ch2);
                    NGUIText.mAlpha = (Single)num2 / 255f;
                    index          += 4;
                    return(true);
                }
            }
            if (index + 5 > length)
            {
                return(false);
            }
            if (text[index + 4] == ']')
            {
                String text5 = text.Substring(index, 5);
                switch (text5)
                {
                case "[sub]":
                    sub    = 1;
                    index += 5;
                    return(true);

                case "[sup]":
                    sub    = 2;
                    index += 5;
                    return(true);
                }
            }
            if (index + 6 > length)
            {
                return(false);
            }
            if (DialogBoxRenderer.ProcessOriginalTag(text.ToCharArray(), ref index, ref highShadow, ref center, ref ff9Signal, ref extraOffset, ref tabX, ref insertImage))
            {
                return(true);
            }
            if (text[index + 5] == ']')
            {
                String text6 = text.Substring(index, 6);
                String text3 = text6;
                switch (text3)
                {
                case "[/sub]":
                    sub    = 0;
                    index += 6;
                    return(true);

                case "[/sup]":
                    sub    = 0;
                    index += 6;
                    return(true);

                case "[/url]":
                    index += 6;
                    return(true);
                }
            }
            if (text[index + 1] == 'u' && text[index + 2] == 'r' && text[index + 3] == 'l' && text[index + 4] == '=')
            {
                Int32 num3 = text.IndexOf(']', index + 4);
                if (num3 != -1)
                {
                    index  = num3 + 1;
                    center = true;
                    return(true);
                }
                index  = text.Length;
                center = false;
                return(true);
            }
            if (index + 8 > length)
            {
                return(false);
            }
            if (text[index + 7] == ']')
            {
                Color color = NGUIText.ParseColor24(text, index + 1);
                if (NGUIText.EncodeColor24(color) != text.Substring(index + 1, 6).ToUpper())
                {
                    return(false);
                }
                if (colors != null)
                {
                    color.a = colors[colors.size - 1].a;
                    if (premultiply && color.a != 1f)
                    {
                        color = Color.Lerp(NGUIText.mInvisible, color, color.a);
                    }
                    colors.Add(color);
                }
                index += 8;
                return(true);
            }

            if (index + 10 > length)
            {
                return(false);
            }
            if (text[index + 9] != ']')
            {
                return(false);
            }
            Color color2 = NGUIText.ParseColor32(text, index + 1);

            if (NGUIText.EncodeColor32(color2) != text.Substring(index + 1, 8).ToUpper())
            {
                return(false);
            }
            if (colors != null)
            {
                if (premultiply && color2.a != 1f)
                {
                    color2 = Color.Lerp(NGUIText.mInvisible, color2, color2.a);
                }
                colors.Add(color2);
            }
            index += 10;
            return(true);
        }