EncodeColor() static public méthode

The reverse of ParseColor -- encodes a color in RrGgBb format.
static public EncodeColor ( Color c ) : string
c Color
Résultat string
Exemple #1
0
 static public int EncodeColor_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.Color a1;
             checkType(l, 1, out a1);
             var ret = NGUIText.EncodeColor(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 2)
         {
             System.String a1;
             checkType(l, 1, out a1);
             UnityEngine.Color a2;
             checkType(l, 2, out a2);
             var ret = NGUIText.EncodeColor(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #2
0
    private static int EncodeColor(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 1 && TypeChecker.CheckTypes(L, 1, typeof(Color)))
            {
                Color  c   = ToLua.ToColor(L, 1);
                string str = NGUIText.EncodeColor(c);
                LuaDLL.lua_pushstring(L, str);
                result = 1;
            }
            else if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(Color)))
            {
                string text = ToLua.ToString(L, 1);
                Color  c2   = ToLua.ToColor(L, 2);
                string str2 = NGUIText.EncodeColor(text, c2);
                LuaDLL.lua_pushstring(L, str2);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: NGUIText.EncodeColor");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    // Token: 0x060000DF RID: 223 RVA: 0x00011944 File Offset: 0x0000FB44
    private void OnTooltip(bool show)
    {
        InvGameItem invGameItem = show ? this.mItem : null;

        if (invGameItem != null)
        {
            InvBaseItem baseItem = invGameItem.baseItem;
            if (baseItem != null)
            {
                string text = string.Concat(new string[]
                {
                    "[",
                    NGUIText.EncodeColor(invGameItem.color),
                    "]",
                    invGameItem.name,
                    "[-]\n"
                });
                text = string.Concat(new object[]
                {
                    text,
                    "[AFAFAF]Level ",
                    invGameItem.itemLevel,
                    " ",
                    baseItem.slot
                });
                List <InvStat> list  = invGameItem.CalculateStats();
                int            i     = 0;
                int            count = list.Count;
                while (i < count)
                {
                    InvStat invStat = list[i];
                    if (invStat.amount != 0)
                    {
                        if (invStat.amount < 0)
                        {
                            text = text + "\n[FF0000]" + invStat.amount;
                        }
                        else
                        {
                            text = text + "\n[00FF00]+" + invStat.amount;
                        }
                        if (invStat.modifier == InvStat.Modifier.Percent)
                        {
                            text += "%";
                        }
                        text  = text + " " + invStat.id;
                        text += "[-]";
                    }
                    i++;
                }
                if (!string.IsNullOrEmpty(baseItem.description))
                {
                    text = text + "\n[FF9900]" + baseItem.description;
                }
                UITooltip.Show(text);
                return;
            }
        }
        UITooltip.Hide();
    }
Exemple #4
0
    static int EncodeColor(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Color)))
            {
                UnityEngine.Color arg0 = ToLua.ToColor(L, 1);
                string            o    = NGUIText.EncodeColor(arg0);
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(UnityEngine.Color)))
            {
                string            arg0 = ToLua.ToString(L, 1);
                UnityEngine.Color arg1 = ToLua.ToColor(L, 2);
                string            o    = NGUIText.EncodeColor(arg0, arg1);
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: NGUIText.EncodeColor"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int EncodeColor(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            Color  arg0 = LuaScriptMgr.GetColor(L, 1);
            string o    = NGUIText.EncodeColor(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2)
        {
            string arg0 = LuaScriptMgr.GetLuaString(L, 1);
            Color  arg1 = LuaScriptMgr.GetColor(L, 2);
            string o    = NGUIText.EncodeColor(arg0, arg1);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: NGUIText.EncodeColor");
        }

        return(0);
    }
Exemple #6
0
 // Token: 0x060019CF RID: 6607 RVA: 0x0017EBDC File Offset: 0x0017CDDC
 private void RestoreSetting()
 {
     this.label.text = NGUIText.EncodeColor(this.label.text, Singleton <HUDMessage> .Instance.restoreColor);
     this.tweenPosition.animationCurve = Singleton <HUDMessage> .Instance.restoreTweenCurve;
     this.tweenPosition.to             = HUDMessage.RecoverTargetPosition;
     this.EnableTween(true);
 }
Exemple #7
0
    /// <summary>
    /// Updates the points label.
    /// </summary>
    public void UpdatePointsLabel()
    {
        if (this.pointsLabel == null)
        {
            return;
        }

        // Set the points string on the label
        this.pointsLabel.text = "";

        // No points assigned
        if (this.currentPoints == 0)
        {
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelMinColor) + "]" + this.currentPoints.ToString() + "[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelMaxColor) + "]/[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelMaxColor) + "]" + this.talentInfo.maxPoints.ToString() + "[-]";
        }
        // Assigned but not maxec
        else if (this.currentPoints > 0 && this.currentPoints < this.talentInfo.maxPoints)
        {
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelActiveColor) + "]" + this.currentPoints.ToString() + "[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelMaxColor) + "]/[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelMaxColor) + "]" + this.talentInfo.maxPoints.ToString() + "[-]";
        }
        // Maxed
        else
        {
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelActiveColor) + "]" + this.currentPoints.ToString() + "[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelActiveColor) + "]/[-]";
            this.pointsLabel.text += "[" + NGUIText.EncodeColor(this.pointLabelActiveColor) + "]" + this.talentInfo.maxPoints.ToString() + "[-]";
        }
    }
 public override void OnUpdate()
 {
     if (_lastColor != color.Value)
     {
         _lastColor        = color.Value;
         colorString.Value = NGUIText.EncodeColor(_lastColor);
     }
 }
Exemple #9
0
    static int EncodeColor(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        Color  arg0 = LuaScriptMgr.GetColor(L, 1);
        string o    = NGUIText.EncodeColor(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
        public override void OnEnter()
        {
            _lastColor        = color.Value;
            colorString.Value = NGUIText.EncodeColor(_lastColor);

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemple #11
0
    private void _AddAttribute(string value, string text, bool singleColumnRow, RectOffset margin)
    {
        // Create new attribute info
        AttributeInfo info = new AttributeInfo();

        info.value           = "[" + NGUIText.EncodeColor(this.attrValueColor) + "]" + value + "[-]";
        info.text            = "[" + NGUIText.EncodeColor(this.attrTextColor) + "]" + text + "[-]";
        info.singleColumnRow = singleColumnRow;
        info.margin          = margin;

        // Add it to the attribute list
        this.mAttributes.Add(info);
    }
Exemple #12
0
    public override void FillItem(IList datas, int index)
    {
        base.FillItem(datas, index);
        ChatData data = (ChatData)datas[datas.Count - 1 - index];
        Vector3  pos  = _preChannelPos;

        _labelChannel.text = NGUIText.EncodeColor(data.chatTypeName, data.chatTypeColor);
        string text   = String.Format("[00ff00]    [{0}][-]:{1}", data.playName, data.text);
        float  height = _emoji.SetChatData(data, text);

        pos.y -= height;
        _channelPanle.localPosition = pos;
    }
Exemple #13
0
    /// <summary>
    /// Show a tooltip for the item.
    /// </summary>

    void OnTooltip(bool show)
    {
        InvGameItem item = show ? mItem : null;

        if (item != null)
        {
            InvBaseItem bi = item.baseItem;

            if (bi != null)
            {
                string t = "[" + NGUIText.EncodeColor(item.color) + "]" + item.name + "[-]\n";

                t += "[AFAFAF]Level " + item.itemLevel + " " + bi.slot;

                List <InvStat> stats = item.CalculateStats();

                for (int i = 0, imax = stats.Count; i < imax; ++i)
                {
                    InvStat stat = stats[i];
                    if (stat.amount == 0)
                    {
                        continue;
                    }

                    if (stat.amount < 0)
                    {
                        t += "\n[FF0000]" + stat.amount;
                    }
                    else
                    {
                        t += "\n[00FF00]+" + stat.amount;
                    }

                    if (stat.modifier == InvStat.Modifier.Percent)
                    {
                        t += "%";
                    }
                    t += " " + stat.id;
                    t += "[-]";
                }

                if (!string.IsNullOrEmpty(bi.description))
                {
                    t += "\n[FF9900]" + bi.description;
                }
                UITooltip.Show(t);
                return;
            }
        }
        UITooltip.Hide();
    }
Exemple #14
0
    public float SetText(string text)
    {
        if (_microPhoneInput == null)
        {
            _microPhoneInput = NGUITools.FindInParents <MicroPhoneInput>(gameObject);
            emojiContainer   = transform.Find("emojis");
            faceTemplate     = transform.Find("Sprite").gameObject;
            faceTemplate.SetActive(false);
            _lblChatInfo = transform.GetComponent <UILabelCustom>();
            if (!isColorSet)
            {
                curColor   = _lblChatInfo.color;
                isColorSet = true;
            }
            if (_lblChatInfo.gameObject.GetComponent <BoxCollider>() == null)
            {
                _lblChatInfo.gameObject.AddComponent <BoxCollider>();
            }
        }

        emojiContainer.DestroyChildren();

        _lblChatInfo.color = Color.white;
        text = NGUIText.EncodeColor(text, curColor);
        _lblChatInfo.ProcessText();
        _lblChatInfo.UpdateNGUIText();
        cellLength = _lblChatInfo.fontSize + _lblChatInfo.floatSpacingY;

        _lblChatInfo.text = SetEmoji(text, (faceName) => {
            AnimationVO aniConfig;
            aniConfig = GameConst.GetAnimationConfigByIndex(faceName);
            //根据文本算出表情的初步坐标(如果后面添加了更高的表情需要重新调整位置)
            GameObject sprite = ReplaceEmojiWithPicture(faceName);
            Vector3 temPos;
            sprites.Add(sprite);

            //对齐同一行的表情
            float vetY = sprite.transform.localPosition.y - cellLength * (aniConfig.rowNum - 1);
            for (int i = 0; i < sprites.Count; i++)
            {
                aniConfig = GameConst.GetAnimationConfigByIndex(sprites[i].name);
                temPos    = sprites[i].transform.localPosition;
                temPos.y  = vetY + (aniConfig.rowNum - 1) * cellLength;
                sprites[i].transform.localPosition = temPos;
            }
        });
        _lblChatInfo.ResizeCollider();
        isUseUrl = _isUseUrl;
        return(rowDict[rowList[0]] * cellLength);
    }
Exemple #15
0
 static public int EncodeColor_s(IntPtr l)
 {
     try {
         UnityEngine.Color a1;
         checkType(l, 1, out a1);
         var ret = NGUIText.EncodeColor(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    public string Setup()
    {
        if (bundleInfo.bundleItem == null)
        {
            return("Hello");
        }

        string formated = "[" + NGUIText.EncodeColor(ItemQuailityColorSelector.GetColorQuality(bundleInfo.bundleItem.Quality)) + "]" + bundleInfo.bundleItem.Name;

        foreach (BundleItemDetails detail in bundleInfo.bundleItem.bundleItemDetails)
        {
            formated = string.Format("{0}\n [" + NGUIText.EncodeColor(Color.white) + "]{1}: {2}", formated, detail.BundleDetailName, detail.Value);
        }
        return(formated);
    }
        public void SetInventory(Inventory inventory)
        {
            //first clean up previous objects from our view
            for (var i = 0; i < itemsUI.Count; ++i)
            {
                itemsUI[i].SetInactive();
                itemsUI[i].ResetItem();
            }

            //now fill in the new inventory
            for (var i = 0; i < inventory.items.Count; ++i)
            {
                Item itemInventory = inventory.items[i];

                //do not exceed our pool range..
                if (i >= itemsUI.Count)
                {
                    break;
                }

                ItemUI item = itemsUI[i];

                var quality = itemInventory.quality == GameEnums.Quality.NORMAL
                    ? ""
                    : "[" + itemInventory.quality + "]";

                var title = "[" + NGUIText.EncodeColor(_itemsCreator.GetColor(itemInventory.quality)) + "]" +
                            quality +
                            "[-]" + " Item " + i;

                var description = itemInventory.GetType().Name;

                item.Init(
                    itemInventory.objectId,
                    title,
                    description,
                    itemInventory.price.ToString() + "$",
                    itemInventory.data.amount.ToString(),
                    "NGUI");

                item.SetActive();
            }

            Invoke("RepositionGrid", 0.1f);
        }
Exemple #18
0
    private void OnTooltip(bool show)
    {
        InvGameItem invGameItem = (show ? mItem : null);

        if (invGameItem != null)
        {
            InvBaseItem baseItem = invGameItem.baseItem;
            if (baseItem != null)
            {
                string text = "[" + NGUIText.EncodeColor(invGameItem.color) + "]" + invGameItem.name + "[-]\n";
                object obj  = text;
                text = string.Concat(obj, "[AFAFAF]Level ", invGameItem.itemLevel, " ", baseItem.slot);
                List <InvStat> list = invGameItem.CalculateStats();
                int            i    = 0;
                for (int count = list.Count; i < count; i++)
                {
                    InvStat invStat = list[i];
                    if (invStat.amount != 0)
                    {
                        text = ((invStat.amount >= 0) ? (text + "\n[00FF00]+" + invStat.amount) : (text + "\n[FF0000]" + invStat.amount));
                        if (invStat.modifier == InvStat.Modifier.Percent)
                        {
                            text += "%";
                        }
                        text  = text + " " + invStat.id;
                        text += "[-]";
                    }
                }
                if (!string.IsNullOrEmpty(baseItem.description))
                {
                    text = text + "\n[FF9900]" + baseItem.description;
                }
                UITooltip.ShowText(text);
                return;
            }
        }
        UITooltip.ShowText(null);
    }
Exemple #19
0
 static public string EncodeColor(Color c)
 {
     return(NGUIText.EncodeColor(c));
 }
Exemple #20
0
    static public bool WrapText(string text, out string finalText, bool keepCharCount, bool wrapLineColors, bool eastern)
    {
        if (NGUIText.regionWidth < 1 || NGUIText.regionHeight < 1 || NGUIText.finalLineHeight < 1f)
        {
            finalText = "";
            return(false);
        }

        float height       = (NGUIText.maxLines > 0) ? Mathf.Min(NGUIText.regionHeight, NGUIText.finalLineHeight * NGUIText.maxLines) : NGUIText.regionHeight;
        int   maxLineCount = (NGUIText.maxLines > 0) ? NGUIText.maxLines : 1000000;

        maxLineCount = Mathf.FloorToInt(Mathf.Min(maxLineCount, height / NGUIText.finalLineHeight) + 0.01f);

        if (maxLineCount == 0)
        {
            finalText = "";
            return(false);
        }

        if (string.IsNullOrEmpty(text))
        {
            text = " ";
        }
        NGUIText.Prepare(text);

        StringBuilder sb = new StringBuilder();
        int           textLength = text.Length;
        float         remainingWidth = NGUIText.regionWidth;
        int           start = 0, offset = 0, lineCount = 1, prev = 0;
        bool          lineIsEmpty = true;
        bool          fits        = true;

        Color c             = NGUIText.tint;
        int   subscriptMode = 0;        // 0 = normal, 1 = subscript, 2 = superscript
        bool  bold          = false;
        bool  italic        = false;
        bool  underline     = false;
        bool  strikethrough = false;
        bool  ignoreColor   = false;

        if (!NGUIText.useSymbols)
        {
            wrapLineColors = false;
        }
        if (wrapLineColors)
        {
            NGUIText.mColors.Add(c);
        }

        // Run through all characters
        for (; offset < textLength; ++offset)
        {
            char ch = text[offset];

            // New line character -- start a new line
            if (ch == '\n')
            {
                if (lineCount == maxLineCount)
                {
                    break;
                }
                remainingWidth = NGUIText.regionWidth;

                // Add the previous word to the final string
                if (start < offset)
                {
                    sb.Append(text.Substring(start, offset - start + 1));
                }
                else
                {
                    sb.Append(ch);
                }

                if (wrapLineColors)
                {
                    for (int i = 0; i < NGUIText.mColors.size; ++i)
                    {
                        sb.Insert(sb.Length - 1, "[-]");
                    }

                    for (int i = 0; i < NGUIText.mColors.size; ++i)
                    {
                        sb.Append("[");
                        sb.Append(NGUIText.EncodeColor(NGUIText.mColors[i]));
                        sb.Append("]");
                    }
                }

                lineIsEmpty = true;
                ++lineCount;
                start = offset + 1;
                prev  = 0;
                continue;
            }
            // When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
            if (NGUIText.encoding)
            {
                if (!wrapLineColors)
                {
                    if (NGUIText.ParseSymbol(text, ref offset))
                    {
                        --offset;
                        continue;
                    }
                }
                else if (NGUIText.ParseSymbol(text, ref offset, NGUIText.mColors, NGUIText.premultiply, ref subscriptMode, ref bold,
                                              ref italic, ref underline, ref strikethrough, ref ignoreColor))
                {
                    if (ignoreColor)
                    {
                        c    = NGUIText.mColors[NGUIText.mColors.size - 1];
                        c.a *= NGUIText.mAlpha * NGUIText.tint.a;
                    }
                    else
                    {
                        c    = NGUIText.tint * NGUIText.mColors[NGUIText.mColors.size - 1];
                        c.a *= NGUIText.mAlpha;
                    }

                    for (int b = 0, bmax = NGUIText.mColors.size - 2; b < bmax; ++b)
                    {
                        c.a *= NGUIText.mColors[b].a;
                    }

                    --offset;
                    continue;
                }
            }

            // See if there is a symbol matching this text
            BMSymbol symbol = NGUIText.useSymbols ? NGUIText.GetSymbol(text, offset, textLength) : null;

            // Calculate how wide this symbol or character is going to be
            float glyphWidth;

            if (symbol == null)
            {
                // Find the glyph for this character
                float w = NGUIText.GetGlyphWidth(ch, prev);
                if (w == 0f)
                {
                    continue;
                }
                glyphWidth = NGUIText.finalSpacingX + w;
            }
            else
            {
                glyphWidth = NGUIText.finalSpacingX + symbol.advance * NGUIText.fontScale;
            }

            // Reduce the width
            remainingWidth -= glyphWidth;

            // If this marks the end of a word, add it to the final string.
            if (NGUIText.IsSpace(ch) && !eastern && start < offset)
            {
                int end = offset - start + 1;

                // Last word on the last line should not include an invisible character
                if (lineCount == maxLineCount && remainingWidth <= 0f && offset < textLength)
                {
                    char cho = text[offset];
                    if (cho < ' ' || NGUIText.IsSpace(cho))
                    {
                        --end;
                    }
                }

                sb.Append(text.Substring(start, end));
                lineIsEmpty = false;
                start       = offset + 1;
                prev        = ch;
            }

            // Doesn't fit?
            if (Mathf.RoundToInt(remainingWidth) < 0)
            {
                // Can't start a new line
                if (lineIsEmpty || lineCount == maxLineCount)
                {
                    // This is the first word on the line -- add it up to the character that fits
                    sb.Append(text.Substring(start, Mathf.Max(0, offset - start)));
                    bool space = NGUIText.IsSpace(ch);
                    if (!space && !eastern)
                    {
                        fits = false;
                    }

                    if (wrapLineColors && NGUIText.mColors.size > 0)
                    {
                        sb.Append("[-]");
                    }

                    if (lineCount++ == maxLineCount)
                    {
                        start = offset;
                        break;
                    }

                    if (keepCharCount)
                    {
                        NGUIText.ReplaceSpaceWithNewline(ref sb);
                    }
                    else
                    {
                        NGUIText.EndLine(ref sb);
                    }

                    if (wrapLineColors)
                    {
                        for (int i = 0; i < NGUIText.mColors.size; ++i)
                        {
                            sb.Insert(sb.Length - 1, "[-]");
                        }

                        for (int i = 0; i < NGUIText.mColors.size; ++i)
                        {
                            sb.Append("[");
                            sb.Append(NGUIText.EncodeColor(NGUIText.mColors[i]));
                            sb.Append("]");
                        }
                    }

                    // Start a brand-new line
                    lineIsEmpty = true;

                    start          = offset;
                    remainingWidth = NGUIText.regionWidth - glyphWidth;

                    prev = 0;
                }
                else
                {
                    // Revert the position to the beginning of the word and reset the line
                    lineIsEmpty    = true;
                    remainingWidth = NGUIText.regionWidth;
                    offset         = start - 1;
                    prev           = 0;

                    if (lineCount++ == maxLineCount)
                    {
                        break;
                    }
                    if (keepCharCount)
                    {
                        NGUIText.ReplaceSpaceWithNewline(ref sb);
                    }
                    else
                    {
                        NGUIText.EndLine(ref sb);
                    }

                    if (wrapLineColors)
                    {
                        for (int i = 0; i < NGUIText.mColors.size; ++i)
                        {
                            sb.Insert(sb.Length - 1, "[-]");
                        }

                        for (int i = 0; i < NGUIText.mColors.size; ++i)
                        {
                            sb.Append("[");
                            sb.Append(NGUIText.EncodeColor(NGUIText.mColors[i]));
                            sb.Append("]");
                        }
                    }
                    continue;
                }
            }
            else
            {
                prev = ch;
            }

            // Advance the offset past the symbol
            if (symbol != null)
            {
                offset += symbol.length - 1;
                prev    = 0;
            }
        }

        if (start < offset)
        {
            sb.Append(text.Substring(start, offset - start));
        }
        if (wrapLineColors && NGUIText.mColors.size > 0)
        {
            sb.Append("[-]");
        }
        finalText = sb.ToString();
        NGUIText.mColors.Clear();
        return(fits && ((offset == textLength) || (lineCount <= Mathf.Min(NGUIText.maxLines, maxLineCount))));
    }
Exemple #21
0
 public static String ColorToHex(Color c)
 {
     return(NGUIText.EncodeColor(c));
 }