Ejemplo n.º 1
0
    private static int ParseAlpha(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            string text  = ToLua.CheckString(L, 1);
            int    index = (int)LuaDLL.luaL_checknumber(L, 2);
            float  num   = NGUIText.ParseAlpha(text, index);
            LuaDLL.lua_pushnumber(L, (double)num);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 2
0
    public void OnSubmit()
    {
        if (textList != null)
        {
            string _text = NGUIText.StripSymbols(m_Input.value);

            if (!string.IsNullOrEmpty(_text))
            {
                textList.Add(_text);
                m_Input.value      = "";
                m_Input.isSelected = false;

                if (isNetworkEnabled)
                {
                    networkView.RPC("UIChatInput_OnSubmit", RPCMode.Others, Network.player, _text);
                }
            }
        }
    }
Ejemplo n.º 3
0
 static public int Print_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         BetterList <UnityEngine.Vector3> a2;
         checkType(l, 2, out a2);
         BetterList <UnityEngine.Vector2> a3;
         checkType(l, 3, out a3);
         BetterList <UnityEngine.Color32> a4;
         checkType(l, 4, out a4);
         NGUIText.Print(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 4
0
    private static int GetGlyphWidth(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            int   ch         = (int)LuaDLL.luaL_checknumber(L, 1);
            int   prev       = (int)LuaDLL.luaL_checknumber(L, 2);
            float glyphWidth = NGUIText.GetGlyphWidth(ch, prev);
            LuaDLL.lua_pushnumber(L, (double)glyphWidth);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 5
0
    private static int GetGlyph(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            int ch   = (int)LuaDLL.luaL_checknumber(L, 1);
            int prev = (int)LuaDLL.luaL_checknumber(L, 2);
            NGUIText.GlyphInfo glyph = NGUIText.GetGlyph(ch, prev);
            ToLua.PushObject(L, glyph);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Retrieve the word right under the specified character index.
    /// </summary>

    public string GetWordAtCharacterIndex(int characterIndex)
    {
        if (characterIndex != -1 && characterIndex < mText.Length)
        {
            int linkStart = mText.LastIndexOf(' ', characterIndex) + 1;
            int linkEnd   = mText.IndexOf(' ', characterIndex);
            if (linkEnd == -1)
            {
                linkEnd = mText.Length;
            }

            if (linkStart != linkEnd)
            {
                string word = mText.Substring(linkStart, linkEnd - linkStart);
                return(NGUIText.StripSymbols(word));
            }
        }
        return(null);
    }
Ejemplo n.º 7
0
    static int ParseSymbol(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            string arg0 = LuaScriptMgr.GetLuaString(L, 1);
            int    arg1 = (int)LuaScriptMgr.GetNetObject(L, 2, typeof(int));
            bool   o    = NGUIText.ParseSymbol(arg0, ref arg1);
            LuaScriptMgr.Push(L, o);
            LuaScriptMgr.Push(L, arg1);
            return(2);
        }
        else if (count == 10)
        {
            string             arg0 = LuaScriptMgr.GetLuaString(L, 1);
            int                arg1 = (int)LuaScriptMgr.GetNetObject(L, 2, typeof(int));
            BetterList <Color> arg2 = (BetterList <Color>)LuaScriptMgr.GetNetObject(L, 3, typeof(BetterList <Color>));
            bool               arg3 = LuaScriptMgr.GetBoolean(L, 4);
            int                arg4 = (int)LuaScriptMgr.GetNetObject(L, 5, typeof(int));
            bool               arg5 = (bool)LuaScriptMgr.GetNetObject(L, 6, typeof(bool));
            bool               arg6 = (bool)LuaScriptMgr.GetNetObject(L, 7, typeof(bool));
            bool               arg7 = (bool)LuaScriptMgr.GetNetObject(L, 8, typeof(bool));
            bool               arg8 = (bool)LuaScriptMgr.GetNetObject(L, 9, typeof(bool));
            bool               arg9 = (bool)LuaScriptMgr.GetNetObject(L, 10, typeof(bool));
            bool               o    = NGUIText.ParseSymbol(arg0, ref arg1, arg2, arg3, ref arg4, ref arg5, ref arg6, ref arg7, ref arg8, ref arg9);
            LuaScriptMgr.Push(L, o);
            LuaScriptMgr.Push(L, arg1);
            LuaScriptMgr.Push(L, arg4);
            LuaScriptMgr.Push(L, arg5);
            LuaScriptMgr.Push(L, arg6);
            LuaScriptMgr.Push(L, arg7);
            LuaScriptMgr.Push(L, arg8);
            LuaScriptMgr.Push(L, arg9);
            return(8);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: NGUIText.ParseSymbol");
        }

        return(0);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Request the needed characters in the texture.
    /// </summary>

    void ProcessAndRequest()
    {
#if UNITY_EDITOR
        if (!mAllowProcessing)
        {
            return;
        }
#endif
        if (ambigiousFont != null)
        {
            ProcessText();
#if DYNAMIC_FONT
            if (mActiveTTF != null)
            {
                NGUIText.RequestCharactersInTexture(mActiveTTF, mText);
            }
#endif
        }
    }
Ejemplo n.º 9
0
    private static int ParseColor32(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            string text   = ToLua.CheckString(L, 1);
            int    offset = (int)LuaDLL.luaL_checknumber(L, 2);
            Color  clr    = NGUIText.ParseColor32(text, offset);
            ToLua.Push(L, clr);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 10
0
    public override void OnFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols)
    {
        if (!isValid)
        {
            return;
        }
        int   size  = verts.size;
        Color color = base.color;

        color.a = finalAlpha;
        if (mFont != null && mFont.premultipliedAlphaShader)
        {
            color = NGUITools.ApplyPMA(color);
        }
        string text  = processedText;
        int    size2 = verts.size;

        UpdateNGUIText();
        NGUIText.tint = color;
        NGUIText.Print(text, verts, uvs, cols);
        Vector2 vector = ApplyOffset(verts, size2);

        if ((!(mFont != null) || !mFont.packedFontShader) && effectStyle != 0)
        {
            int size3 = verts.size;
            vector.x = mEffectDistance.x;
            vector.y = mEffectDistance.y;
            ApplyShadow(verts, uvs, cols, size, size3, vector.x, 0f - vector.y);
            if (effectStyle == Effect.Outline)
            {
                size  = size3;
                size3 = verts.size;
                ApplyShadow(verts, uvs, cols, size, size3, 0f - vector.x, vector.y);
                size  = size3;
                size3 = verts.size;
                ApplyShadow(verts, uvs, cols, size, size3, vector.x, vector.y);
                size  = size3;
                size3 = verts.size;
                ApplyShadow(verts, uvs, cols, size, size3, 0f - vector.x, 0f - vector.y);
            }
        }
    }
Ejemplo n.º 11
0
    // Use this for initialization
    public virtual void Start()
    {
        //m_nHp = m_nFullHp = 100;
        //preValue = value = 1;
        GameObject child = NGUITools.AddChild(WndManager.GetWndRoot(), prefab);

        mText = child.GetComponentInChildren <HUDText>();

        if (null == forceTex)
        {
            forceTex = hp4;
        }

        //forceGrond.GetComponent<SpriteRenderer>().sprite.border
        // Make the UI follow the target
        child.AddComponent <UIFollowTarget>().target             = target;
        child.GetComponent <UIFollowTarget>().disableIfInvisible = false;

        if (mBaojiText != null)
        {
            child      = NGUITools.AddChild(WndManager.GetWndRoot(), mBaojiText.gameObject);
            mBaojiText = child.GetComponentInChildren <HUDText>();
            child.AddComponent <UIFollowTarget>().target             = target;
            child.GetComponent <UIFollowTarget>().disableIfInvisible = false;
        }
        if (mAngerText != null)
        {
            child      = NGUITools.AddChild(WndManager.GetWndRoot(), mAngerText.gameObject);
            mAngerText = child.GetComponentInChildren <HUDText>();
            child.AddComponent <UIFollowTarget>().target             = target;
            child.GetComponent <UIFollowTarget>().disableIfInvisible = false;
        }
        if (BuffText != null)
        {
            child    = NGUITools.AddChild(WndManager.GetWndRoot(), BuffText.gameObject);
            BuffText = child.GetComponentInChildren <HUDText>();
            child.AddComponent <UIFollowTarget>().target             = target;
            child.GetComponent <UIFollowTarget>().disableIfInvisible = false;
        }
        mColorBuff   = NGUIText.ParseColor("d3fe78", 0);
        mColorDebuff = NGUIText.ParseColor("ff5163", 0);
    }
Ejemplo n.º 12
0
    public void onTextChanged(GameObject go)
    {
        if (!isFinishInit)
        {
            isFinishInit = true;
            init();
        }

        clean();
        mTempVerts.Clear();
        mTempIndices.Clear();
        string str = findFace();

        label.text = str;
        string text = label.processedText;

        label.UpdateNGUIText();
        NGUIText.PrintExactCharacterPositions(label.text, mTempVerts, mTempIndices);
        //		for (int i=0; i < mTempVerts.size; i++) {
        //			Debug.Log (mTempVerts [i]);
        //		}
        ArrayList keyList = new ArrayList();

        keyList.AddRange(facesMap.Keys);
        int     count    = keyList.Count;
        int     index    = 0;
        string  faceName = "";
        Vector3 pos      = Vector3.zero;

        for (int i = 0; i < count; i++)
        {
            index    = (int)(keyList [i]);
            faceName = facesMap [index].ToString();
            //			Debug.Log ("index==" + index);
            //			Debug.Log("faceName==" + faceName);
            pos = calculatePos(mTempVerts [index * 2], mTempVerts [index * 2 + 1]);
            showFace(faceName, pos);
        }
        keyList.Clear();
        mTempVerts.Clear();
        mTempIndices.Clear();
    }
Ejemplo n.º 13
0
 static public int WrapText_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.String  a2;
             System.Boolean a3;
             checkType(l, 3, out a3);
             var ret = NGUIText.WrapText(a1, out a2, a3);
             pushValue(l, true);
             pushValue(l, ret);
             pushValue(l, a2);
             return(3);
         }
         else if (argc == 5)
         {
             System.String a1;
             checkType(l, 1, out a1);
             System.String  a2;
             System.Boolean a3;
             checkType(l, 3, out a3);
             System.Boolean a4;
             checkType(l, 4, out a4);
             System.Boolean a5;
             checkType(l, 5, out a5);
             var ret = NGUIText.WrapText(a1, out a2, a3, a4, a5);
             pushValue(l, true);
             pushValue(l, ret);
             pushValue(l, a2);
             return(3);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 14
0
    /// <summary>
    /// 测量给定<see cref="UILabel"/>的宽度能容纳的字符串长度
    /// </summary>
    /// <param name="label"></param>
    /// <param name="text">要测量的字符串,为null则采用<c>label.text</c></param>
    /// <param name="startIndex">起始下标</param>
    /// <returns>满足<paramref name="label"/>一行宽度的字符串末尾下标,其他则返回<paramref name="startIndex"/></returns>
    /// <remarks>该函数不会改变<paramref name="label"/>的状态,但会污染<see cref="NGUIText"/>的状态</remarks>
    public static int WrapLine(this UILabel label, string text = null, int startIndex = 0)
    {
        if (label == null)
        {
            return(startIndex);
        }
        if (text == null)
        {
            text = label.text;
        }
        if (startIndex < 0 || startIndex >= text.Length)
        {
            return(startIndex);
        }

        label.UpdateNGUIText();         // 更新 NGUIText 的状态
        if (NGUIText.rectWidth < 1 || NGUIText.rectHeight < 1 || NGUIText.finalLineHeight < 1f)
        {
            return(startIndex);
        }
        NGUIText.Prepare(text);         // 准备字体以备测量

        var cur_extent = 0f;
        var prev       = 0;

        for (var c = startIndex; c < text.Length; ++c)
        {
            var ch = text[c];
            var w  = NGUIText.GetGlyphWidth(ch, prev);
            if (w == 0f)
            {
                continue;
            }
            cur_extent += w + NGUIText.finalSpacingX;
            if (NGUIText.rectWidth < cur_extent)
            {
                return(c);
            }
        }

        return(text.Length);
    }
Ejemplo n.º 15
0
    private static int Print(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 4);
            string text = ToLua.CheckString(L, 1);
            BetterList <Vector3> verts = (BetterList <Vector3>)ToLua.CheckObject(L, 2, typeof(BetterList <Vector3>));
            BetterList <Vector2> uvs   = (BetterList <Vector2>)ToLua.CheckObject(L, 3, typeof(BetterList <Vector2>));
            BetterList <Color32> cols  = (BetterList <Color32>)ToLua.CheckObject(L, 4, typeof(BetterList <Color32>));
            NGUIText.Print(text, verts, uvs, cols);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 16
0
    private static int GetApproximateCharacterIndex(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 3);
            BetterList <Vector3> verts   = (BetterList <Vector3>)ToLua.CheckObject(L, 1, typeof(BetterList <Vector3>));
            BetterList <int>     indices = (BetterList <int>)ToLua.CheckObject(L, 2, typeof(BetterList <int>));
            Vector2 pos = ToLua.ToVector2(L, 3);
            int     approximateCharacterIndex = NGUIText.GetApproximateCharacterIndex(verts, indices, pos);
            LuaDLL.lua_pushinteger(L, approximateCharacterIndex);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 17
0
 static public int ReplaceLink_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         System.String a3;
         checkType(l, 3, out a3);
         var ret = NGUIText.ReplaceLink(ref a1, ref a2, a3);
         pushValue(l, true);
         pushValue(l, ret);
         pushValue(l, a1);
         pushValue(l, a2);
         return(4);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 18
0
    private static int GetSymbol(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 3);
            string   text       = ToLua.CheckString(L, 1);
            int      index      = (int)LuaDLL.luaL_checknumber(L, 2);
            int      textLength = (int)LuaDLL.luaL_checknumber(L, 3);
            BMSymbol symbol     = NGUIText.GetSymbol(text, index, textLength);
            ToLua.PushObject(L, symbol);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 19
0
        public static ClientPlayerInfo clientFromName(string name)
        {
            foreach (ClientPlayerInfo current in G.Sys.PlayerManager_.PlayerList_)
            {
                if (current.Username_ == name)
                {
                    return(current);
                }
            }
            var noFormatClientname = NGUIText.StripSymbols(name);

            foreach (ClientPlayerInfo current in G.Sys.PlayerManager_.PlayerList_)
            {
                if (NGUIText.StripSymbols(current.Username_) == noFormatClientname)
                {
                    return(current);
                }
            }
            return(null);
        }
Ejemplo n.º 20
0
 public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor)
 {
     caret?.Clear();
     highlight?.Clear();
     if (isValid)
     {
         string processedText = this.processedText;
         UpdateNGUIText();
         int     size       = caret.verts.size;
         Vector2 item       = new Vector2(0.5f, 0.5f);
         float   finalAlpha = base.finalAlpha;
         if (highlight != null && start != end)
         {
             int size2 = highlight.verts.size;
             NGUIText.PrintCaretAndSelection(processedText, start, end, caret.verts, highlight.verts);
             if (highlight.verts.size > size2)
             {
                 ApplyOffset(highlight.verts, size2);
                 Color32 item2 = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * finalAlpha);
                 for (int i = size2; i < highlight.verts.size; i++)
                 {
                     highlight.uvs.Add(item);
                     highlight.cols.Add(item2);
                 }
             }
         }
         else
         {
             NGUIText.PrintCaretAndSelection(processedText, start, end, caret.verts, null);
         }
         ApplyOffset(caret.verts, size);
         Color32 item3 = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * finalAlpha);
         for (int j = size; j < caret.verts.size; j++)
         {
             caret.uvs.Add(item);
             caret.cols.Add(item3);
         }
         NGUIText.bitmapFont  = null;
         NGUIText.dynamicFont = null;
     }
 }
    /// <summary>
    /// Rebuild the visible text.
    /// </summary>

    protected void Rebuild()
    {
        if (isValid)
        {
            // Although we could simply use UILabel.Wrap, it would mean setting the same data
            // over and over every paragraph, which is not ideal. It's faster to only do it once
            // and then do wrapping ourselves in the 'for' loop below.
            textLabel.UpdateNGUIText();
            NGUIText.rectHeight = 1000000;
            mTotalLines         = 0;

            for (int i = 0; i < mParagraphs.size; ++i)
            {
                string    final;
                Paragraph p = mParagraphs.buffer[i];
                NGUIText.WrapText(p.text, out final);
                p.lines      = final.Split('\n');
                mTotalLines += p.lines.Length;
            }

            // Recalculate the total number of lines
            mTotalLines = 0;
            for (int i = 0, imax = mParagraphs.size; i < imax; ++i)
            {
                mTotalLines += mParagraphs.buffer[i].lines.Length;
            }

            // Update the bar's size
            if (scrollBar != null)
            {
                UIScrollBar sb = scrollBar as UIScrollBar;
                if (sb != null)
                {
                    sb.barSize = (mTotalLines == 0) ? 1f : 1f - (float)scrollHeight / mTotalLines;
                }
            }

            // Update the visible text
            UpdateVisibleText();
        }
    }
Ejemplo n.º 22
0
 static public int PrintCaretAndSelection_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         System.Int32 a3;
         checkType(l, 3, out a3);
         BetterList <UnityEngine.Vector3> a4;
         checkType(l, 4, out a4);
         BetterList <UnityEngine.Vector3> a5;
         checkType(l, 5, out a5);
         NGUIText.PrintCaretAndSelection(a1, a2, a3, a4, a5);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 23
0
    private static int PrintCaretAndSelection(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 5);
            string text  = ToLua.CheckString(L, 1);
            int    start = (int)LuaDLL.luaL_checknumber(L, 2);
            int    end   = (int)LuaDLL.luaL_checknumber(L, 3);
            BetterList <Vector3> caret     = (BetterList <Vector3>)ToLua.CheckObject(L, 4, typeof(BetterList <Vector3>));
            BetterList <Vector3> highlight = (BetterList <Vector3>)ToLua.CheckObject(L, 5, typeof(BetterList <Vector3>));
            NGUIText.PrintCaretAndSelection(text, start, end, caret, highlight);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 24
0
        private void UpdateNoticeRequest(string notice)
        {
            float screenHalfSize = 512f;
            float moveSpeed      = 100f;

            labNotice.text = notice;

            Vector3 from = labNotice.transform.localPosition;

            from.x = screenHalfSize;

            Vector3 to = from;

            to.x = -NGUIText.CalculatePrintedSize(labNotice.text).x - screenHalfSize;

            noticeObj.SetActive(true);
            float moveTime = (from.x - to.x) / moveSpeed;

            ShowNoticeMoveEffect(labNotice, from, to, moveTime);
            vp_Timer.In(moveTime, FinishNoticeMove, 1, 0);
        }
Ejemplo n.º 25
0
 // Token: 0x06000910 RID: 2320 RVA: 0x00047F5C File Offset: 0x0004615C
 protected void Rebuild()
 {
     if (this.isValid)
     {
         this.mLastWidth  = this.textLabel.width;
         this.mLastHeight = this.textLabel.height;
         this.textLabel.UpdateNGUIText();
         NGUIText.rectHeight   = 1000000;
         NGUIText.regionHeight = 1000000;
         this.mTotalLines      = 0;
         for (int i = 0; i < this.paragraphs.size; i++)
         {
             UITextList.Paragraph paragraph = this.mParagraphs.buffer[i];
             string text;
             NGUIText.WrapText(paragraph.text, out text, false, true, false);
             paragraph.lines = text.Split(new char[]
             {
                 '\n'
             });
             this.mTotalLines += paragraph.lines.Length;
         }
         this.mTotalLines = 0;
         int j    = 0;
         int size = this.mParagraphs.size;
         while (j < size)
         {
             this.mTotalLines += this.mParagraphs.buffer[j].lines.Length;
             j++;
         }
         if (this.scrollBar != null)
         {
             UIScrollBar uiscrollBar = this.scrollBar as UIScrollBar;
             if (uiscrollBar != null)
             {
                 uiscrollBar.barSize = ((this.mTotalLines == 0) ? 1f : (1f - (float)this.scrollHeight / (float)this.mTotalLines));
             }
         }
         this.UpdateVisibleText();
     }
 }
Ejemplo n.º 26
0
 protected void Rebuild()
 {
     if (this.isValid)
     {
         this.mLastWidth  = this.textLabel.width;
         this.mLastHeight = this.textLabel.height;
         this.textLabel.UpdateNGUIText();
         NGUIText.rectHeight   = 1000000;
         NGUIText.regionHeight = 1000000;
         this.mTotalLines      = 0;
         for (Int32 i = 0; i < this.paragraphs.size; i++)
         {
             UITextList.Paragraph paragraph = this.mParagraphs.buffer[i];
             String text;
             NGUIText.WrapText(paragraph.text, out text, false, true);
             paragraph.lines = text.Split(new Char[]
             {
                 '\n'
             });
             this.mTotalLines += (Int32)paragraph.lines.Length;
         }
         this.mTotalLines = 0;
         Int32 j    = 0;
         Int32 size = this.mParagraphs.size;
         while (j < size)
         {
             this.mTotalLines += (Int32)this.mParagraphs.buffer[j].lines.Length;
             j++;
         }
         if (this.scrollBar != (UnityEngine.Object)null)
         {
             UIScrollBar uiscrollBar = this.scrollBar as UIScrollBar;
             if (uiscrollBar != (UnityEngine.Object)null)
             {
                 uiscrollBar.barSize = ((this.mTotalLines != 0) ? (1f - (Single)this.scrollHeight / (Single)this.mTotalLines) : 1f);
             }
         }
         this.UpdateVisibleText();
     }
 }
Ejemplo n.º 27
0
    public static void GenerateEmotion(UILabel chatContent, UIAtlas atlas, Transform emojiHitch)
    {
        BetterList <Vector3> betterList = new BetterList <Vector3>();
        BetterList <int>     indices    = new BetterList <int>();
        List <GameObject>    list       = new List <GameObject>();

        chatContent.pivot = UIWidget.Pivot.Left;
        chatContent.UpdateNGUIText();
        NGUIText.PrintCharacterPositions(chatContent.text, betterList, indices);
        int num = 0;

        for (int num2 = 0; num2 != Tools_StringCheck.listEmotionData.Count; num2++)
        {
            GameObject gameObject = new GameObject();
            UISprite   uISprite   = gameObject.AddComponent <UISprite>();
            if (null != emojiHitch)
            {
                uISprite.transform.parent = emojiHitch;
            }
            uISprite.depth = chatContent.depth + 1;
            uISprite.transform.localScale = new Vector3(1f, 1f, 1f);
            uISprite.name       = "emotion" + num2;
            uISprite.atlas      = atlas;
            uISprite.spriteName = Tools_StringCheck.listEmotionData[num2].serialNumber;
            uISprite.SetDimensions(38, 38);
            if (Tools_StringCheck.listEmotionData != null && Tools_StringCheck.listEmotionData.Count > 1)
            {
                if (Tools_StringCheck.listEmotionData[0].position == 0 && num2 != 0)
                {
                    num = -8;
                }
                else
                {
                    num = 0;
                }
            }
            int i = (2 * Tools_StringCheck.listEmotionData[num2].position != 0) ? (2 * Tools_StringCheck.listEmotionData[num2].position - 1) : 0;
            uISprite.transform.localPosition = new Vector3(chatContent.transform.localPosition.x, 0f, chatContent.transform.localPosition.z) + betterList[i] + new Vector3((float)(uISprite.width / 2 + -(float)chatContent.spacingX + num), (float)(-(float)chatContent.spacingY / 2 + 21), 0f);
        }
    }
Ejemplo n.º 28
0
    public void ShowBubble(string msg)
    {
        this.bubbleTween.gameObject.SetActive(true);
        this.bubbleTween.Play(true);
        this.bubbleMsgLab.text = msg;
        this.bubbleMsgLab.UpdateNGUIText();
        msg = this.ReplaceFace(msg);
        this.bubbleMsgLab.text = msg;
        int num = Mathf.RoundToInt(NGUIText.CalculatePrintedSize(msg, 330).x);

        if (num < 58)
        {
            num = 58;
        }
        this.bubbleMsgLab.width  = Mathf.RoundToInt(NGUIText.CalculatePrintedSize(msg, 330).x);
        this.bubbleMsgLab.height = Mathf.RoundToInt(NGUIText.CalculatePrintedSize(msg, 330).y);
        this.bubbleBg.width      = num + 68;
        this.bubbleBg.height     = Mathf.RoundToInt(NGUIText.CalculatePrintedSize(msg, 330).y) + 64;
        this.DrawFace();
        this.bubbleMsgLab.transform.localPosition = new Vector3(0f, 6.6f, 0f);
        base.Invoke("DelayHideBubble", 2f);
    }
Ejemplo n.º 29
0
    /// <summary>
    /// Submit notification is sent by UIInput when 'enter' is pressed or iOS/Android keyboard finalizes input.
    /// </summary>

    public void OnSubmit()
    {
        if (textList != null)
        {
            // It's a good idea to strip out all symbols as we don't want user input to alter colors, add new lines, etc
            string text = NGUIText.StripSymbols(mInput.value);

            if (!string.IsNullOrEmpty(text))
            {
                //Debug.Log(mInput.value);

                ///ChatManager.Instance.SendChatToAllContent(mInput.value);

                //textList.Add("Amera: "+"[99ff00]"+text+"[-]");
                //textList.Add("[99ff00]"+KiiUser.CurrentUser.Displayname+": "+text+"[-]");
                //timeList.Add(System.DateTime.Now.ToString());

                mInput.value      = "";
                mInput.isSelected = false;
            }
        }
    }
Ejemplo n.º 30
0
 public string GetWordAtCharacterIndex(int characterIndex)
 {
     if (characterIndex != -1 && characterIndex < mText.Length)
     {
         int num  = mText.LastIndexOf(' ', characterIndex) + 1;
         int num2 = mText.IndexOf(' ', characterIndex);
         if (num2 == -1)
         {
             num2 = mText.Length;
         }
         if (num != num2)
         {
             int num3 = num2 - num;
             if (num3 > 0)
             {
                 string text = mText.Substring(num, num3);
                 return(NGUIText.StripSymbols(text));
             }
         }
     }
     return(null);
 }