StripSymbols() static public méthode

Runs through the specified string and removes all color-encoding symbols.
static public StripSymbols ( string text ) : string
text string
Résultat string
Exemple #1
0
 public string GetWordAtCharacterIndex(int characterIndex)
 {
     if (characterIndex != -1 && characterIndex < mText.Length)
     {
         int num = mText.LastIndexOfAny(new char[2]
         {
             ' ',
             '\n'
         }, characterIndex) + 1;
         int num2 = mText.IndexOfAny(new char[4]
         {
             ' ',
             '\n',
             ',',
             '.'
         }, 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);
 }
Exemple #2
0
    private int GetPictureIndex(string text, int index)
    {
        string tempText = text.Substring(0, index + 1);

        tempText = NGUIText.StripSymbols(tempText).Replace("\n", "");
        return(tempText.Length - 1);
    }
Exemple #3
0
    void onLogin(GameObject target)
    {
        SetResolution();

        Environment.Operation = 0;

        string username = NGUIText.StripSymbols(mUserName.value);
        string passwd   = NGUIText.StripSymbols(mPasswd.value);

        if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(passwd))
        {
            mMessage.text = "[ff0000]用户名或密码不可为空";
            return;
        }

        Environment.SeverAddress      = mServerList.value;
        Environment.ChatServerAddress = GameConfig.ChatServerAddress;

        LoginEvent e = new LoginEvent(LoginEvent.LOGIN_EVENT_LOGIN);

        e.TencentLogin = false;
        e.UserName     = username;
        e.PassWord     = passwd;

        EventSystem.Instance.PushEvent(e);

        PlayerPrefs.SetString("username", username);
        PlayerPrefs.SetString("passwd", passwd);
        PlayerPrefs.SetString("ip", Environment.SeverAddress);
    }
Exemple #4
0
    /// <summary>
    /// Submit notification is sent by UIInput when 'enter' is pressed or iOS/Android keyboard finalizes input.
    /// </summary>
    ///
    void Submit()
    {
        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))
            {
                SendChatToServer(text);

                if (GameManager.CurrentScene == ESceneName.GameplayChan)
                {
                    text = string.Format("{0}" + GameManager.Instance.mInfo.username.ToUpper() + ":[-] " + text + "\n", GameModelChan.ListWaitingPlayer.Find(plc => plc.username == GameManager.Instance.mInfo.username) != null ? "[FFCC00]" : "[FF6600]");
                }
                else
                {
                    text = string.Format("[FF6600]" + GameManager.Instance.mInfo.username.ToUpper() + ":[-] " + text + "\n");
                }

                textList.Add(text);
                Utility.AutoScrollChat(textList);

                mInput.value      = "";
                mInput.isSelected = false;
            }
        }
        mIgnoreNextEnter = true;
    }
Exemple #5
0
            static bool Prefix(ClientLogic __instance, ChatSubmitMessage.Data data)
            {
                if (data.message_.StartsWith("!") || data.message_.StartsWith("%") || data.message_.StartsWith("/"))
                {
                    return(true);
                }

                var chatName = __instance.GetType().GetMethod("GetClientChatName", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { }) as string;

                if (configs.colorizeName)
                {
                    chatName = colorizeText(NGUIText.StripSymbols(chatName));
                }
                if (data.message_ == "/colorizer")
                {
                    configs.colorizeMessage = !configs.colorizeMessage;
                    return(false);
                }
                if (data.message_ == "/coloriname")
                {
                    configs.colorizeName = !configs.colorizeName;
                    return(false);
                }

                if (!configs.colorizeMessage)
                {
                    Message.SendMessage(chatName + ": " + data.message_);
                }
                else
                {
                    Message.SendMessage(chatName + ": " + colorizeText(data.message_, false));
                }

                return(false);
            }
Exemple #6
0
    void onLoginButtonClickOK(GameObject target)
    {
        Environment.Operation = 0;

        string username = NGUIText.StripSymbols(mUserName.value);

        if (string.IsNullOrEmpty(username))
        {
            mMessage.text = "[ff0000]用户名不可为空";
            return;
        }
        if (StrFilterManager.Instance.CheckBlacklist(username) == true)
        {
            mMessage.text = "[ff0000]您的用户名包含敏感字";
            return;
        }
        CreateRoleModule module = ModuleManager.Instance.FindModule <CreateRoleModule>();
        uint             Roleid = module.GetRoleID();

        if (Roleid != 1 && Roleid != 2)
        {
            mMessage.text = "[ff0000]请返回重新选择人物角色";
            return;
        }
        NGUITools.SetActive(IconEffects.gameObject, true);
        CreateRoleEvent e = new CreateRoleEvent(CreateRoleEvent.LOGIN_EVENT_CREATE_ROLE);

        e.UserName = username;
        e.id       = Roleid;

        EventSystem.Instance.PushEvent(e);
    }
Exemple #7
0
        // Send按钮单击事件
        public void SendBtnClick(GameObject btnObj)
        {
            // 获取内容
            if (mInput)
            {
                string strText = NGUIText.StripSymbols(mInput.text);
                if (!string.IsNullOrEmpty(strText))
                {
                    LogMgr.UnityLog("input: " + strText);

                    LogToBuff(DEBUG_TYPE.DEBUG_GM, LOG_TYPE.LOG_NULL, strText);

                    string[] cmdstr = strText.Split("\r\n".ToCharArray());
                    for (int i = 0; i < cmdstr.Length; ++i)
                    {
                        string cmd = cmdstr[i].Trim();
                        if (!string.IsNullOrEmpty(cmd))
                        {
                            mGmMgr.GmReq(cmd);
                        }
                    }
                    mInput.text = "";
                }
            }
        }
Exemple #8
0
 public void AddLine(NetworkId?playerId, string message, bool system)
 {
     this.CheckInit();
     if ((playerId != null && this._players.ContainsKey(playerId.Value)) || system)
     {
         ChatMessageRow chatMessageRow = UnityEngine.Object.Instantiate <ChatMessageRow>(this._messageRowPrefab);
         if (system)
         {
             chatMessageRow._name.text  = message;
             chatMessageRow._name.color = Color.white;
         }
         else
         {
             chatMessageRow._name.text  = this._players[playerId.Value]._name + " : ";
             chatMessageRow._name.color = this._players[playerId.Value]._color;
         }
         chatMessageRow._message.text = NGUIText.StripSymbols(message);
         chatMessageRow.name          = this._lastMessageId++ + chatMessageRow.name;
         chatMessageRow.gameObject.SetActive(true);
         chatMessageRow.transform.parent        = this._grid.transform;
         chatMessageRow.transform.localPosition = Vector3.zero;
         chatMessageRow.transform.localScale    = Vector3.one;
         this._messageRows.Enqueue(chatMessageRow);
         if (this._messageRows.Count > this._historySize)
         {
             UnityEngine.Object.Destroy(this._messageRows.Dequeue().gameObject);
         }
         this._grid.repositionNow = true;
         this._grid.gameObject.SetActive(true);
         this._lastInteractionTime = Time.time;
     }
 }
Exemple #9
0
    /// <summary>
    /// Get the printed size of the specified string. The returned value is in pixels.
    /// </summary>

    static public Vector2 CalculatePrintedSize(string text, Font font, int size, FontStyle style, bool encoding)
    {
        Vector2 v = Vector2.zero;

        if (font != null && !string.IsNullOrEmpty(text))
        {
            // When calculating printed size, get rid of all symbols first since they are invisible anyway
            if (encoding)
            {
                text = NGUIText.StripSymbols(text);
            }

            // Ensure we have characters to work with
            font.RequestCharactersInTexture(text, size, style);

            float x    = 0f;
            float y    = 0;
            float fs   = size;
            float maxX = 0f;

            for (int i = 0, imax = text.Length; i < imax; ++i)
            {
                char c = text[i];

                // Start a new line
                if (c == '\n')
                {
                    if (x > maxX)
                    {
                        maxX = x;
                    }
                    x  = 0f;
                    y += fs;
                    continue;
                }

                // Skip invalid characters
                if (c < ' ')
                {
                    continue;
                }

                if (font.GetCharacterInfo(c, out mTempChar, size, style))
                {
                    x += mTempChar.width;
                    //Luzexi 修改:动态字体粗体间隔额外加2
                    if (style == FontStyle.Bold)
                    {
                        x += 2;
                    }
                }

                // Convert from pixel coordinates to local coordinates
                v.x = ((x > maxX) ? x : maxX);
                v.y = (y + fs);
            }
        }
        return(v);
    }
Exemple #10
0
 private static CommonChatUserCmd_CS CreateCommonChat(string message)
 {
     return(new CommonChatUserCmd_CS()
     {
         chatpos = CommonChatUserCmd_CS.ChatPos.ChatPos_Normal,
         info = NGUIText.StripSymbols(message),
     });
 }
    static int StripSymbols(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        string arg0 = LuaScriptMgr.GetLuaString(L, 1);
        string o    = NGUIText.StripSymbols(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Exemple #12
0
    private void RefreshSymbolList()
    {
        if (m_realMatchs == null)
        {
            return;
        }

        m_realMatchs.Clear();

        string mProcessedText = m_TextLabel.processedText;

        if (overflowMethod == UILabel.Overflow.ResizeHeight)
        {
            mProcessedText = m_Text;
        }
        else
        {
            NGUIText.WrapText(m_Text, out mProcessedText);
        }

        StringBuilder sString = new StringBuilder();
        const string  pattern = @"\#\w\w";

        m_realText = NGUIText.StripSymbols(mProcessedText);
        m_matchs   = Regex.Matches(m_realText, pattern);

        const string pat = "\\s";

        m_spaceMatchs = Regex.Matches(m_realText, pat);

        if (m_matchs.Count > 0)
        {
            Match item;
            for (int i = 0; i < m_matchs.Count; i++)
            {
                item = m_matchs[i];
                string name     = item.Value.Substring(1, 2);
                string realname = "{" + name + "}";
                if (m_Symbols.IndexOf(realname) > -1)
                {
                    m_realMatchs.Add(item);
                    sString.Append(realname);
                }
            }
        }

        m_TextLabel.text   = m_Text;
        m_SymbolLabel.text = sString.ToString();

        m_SymbolLabel.width  = m_TextLabel.width;
        m_SymbolLabel.height = m_TextLabel.height;

        m_SymbolLabel.MarkAsChanged();
    }
Exemple #13
0
    /// <summary>
    /// Send a chat message to everyone.
    /// </summary>

    void OnSubmitInternal()
    {
        string text = UIInput.current.value;

        if (!string.IsNullOrEmpty(text))
        {
            text        = NGUIText.StripSymbols(text);
            input.value = "";
            OnSubmit(text);
        }
        mIgnoreNextEnter = true;
    }
Exemple #14
0
    public void OnClickSendMessage()
    {
        string text = NGUIText.StripSymbols(ChattingBarInput.value);

        if (string.IsNullOrEmpty(text) && !Localization.Get("InputMessage").Equals(text))
        {
            return;
        }

        ChattingMain.Instance.ConnectCheck();

        if (text.Length > GameConfig.Get <int>("line_max_char"))
        {
            text = text.Remove(GameConfig.Get <int>("line_max_char"));
        }

        switch (m_selectedType)
        {
        case pe_MsgType.Normal:
        case pe_MsgType.Guild:
            switch (text)
            {
            case "@crash":
                throw new System.Exception("CrashTest");

            case "@cheat":
                if (Network.PlayerInfo.can_cheat == true)
                {
                    Popup.Instance.Show(ePopupMode.Cheat);
                }
                return;
            }
            if (m_selectedType == pe_MsgType.Guild && GuildManager.Instance.GuildInfo == null)
            {
                return;
            }
            Network.ChatServer.SendChat(text, m_selectedType);
            break;

        case pe_MsgType.SendWhisper:
            Network.ChatServer.SendWhisper(text, WhisperTargetInput.value);
            break;

        case pe_MsgType.Yell:
            Network.ChatServer.SendYell(text);
            break;
        }

        ChattingBarInput.value = string.Empty;

        OnDragFinished(DraggedScrollView);
    }
Exemple #15
0
    public void OnSubmit()
    {
        mInput.RemoveFocus();

        string text = NGUIText.StripSymbols(mInput.value);

        if (!string.IsNullOrEmpty(text))
        {
            ChatModule module = ModuleManager.Instance.FindModule <ChatModule>();
            module.SendText(mCurChannel, text);
            mInput.value = "";
        }
    }
Exemple #16
0
 public void OnSubmit()
 {
     if (this.textList != null)
     {
         string text = NGUIText.StripSymbols(this.mInput.value);
         if (!string.IsNullOrEmpty(text))
         {
             this.textList.Add(text);
             this.mInput.value      = string.Empty;
             this.mInput.isSelected = false;
         }
     }
 }
Exemple #17
0
    public void OnSubmit()
    {
        string text = NGUIText.StripSymbols(input.mInput.value);

        Debug.Log(text);


        //input.textList.Add (text);
        string json = string.Format("[\"{0}\"]", text);

        Debug.Log(json);
        send(json);
        input.mInput.value = "";
    }
Exemple #18
0
    private void InputTextChange()
    {
        string text = _inputBox.value;

        if (!string.IsNullOrEmpty(_inputText))
        {
            string stripText = NGUIText.StripSymbols(_inputText);
            if (text.Contains(stripText))
            {
                text = text.Replace(stripText, _inputText);
            }
        }
        _inputText = text;
    }
Exemple #19
0
    void Send()
    {
        mInput.isSelected = false;
        string text = NGUIText.StripSymbols(mInput.value);

        mInput.value = "";
        if (!string.IsNullOrEmpty(text))
        {
            JObject json = new JObject();
            json["type"]    = NetworkProtocol.Chat;
            json["message"] = text;
            NetworkMain.SendMessage(json);
        }
    }
Exemple #20
0
 static public int StripSymbols_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         var ret = NGUIText.StripSymbols(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #21
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))
            {
                textList.Add("[FF0000]" + player.Handle + ": " + "[000000]" + text);
                photonView.RPC("recieveMessage", PhotonTargets.OthersBuffered, "[0000FF]" + player.Handle + ": " + "[000000]" + text);
                mInput.value = "";
            }
        }
    }
Exemple #22
0
 static int StripSymbols(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         string o    = NGUIText.StripSymbols(arg0);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #23
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))
            {
                textList.Add(text);
                mInput.value      = "";
                mInput.isSelected = false;
            }
        }
    }
    public void OnSubmit()
    {
        if (textList != null)
        {
            string text = NGUIText.StripSymbols(mInput.value);

            if (!string.IsNullOrEmpty(text))
            {
                SocketManager.Socket.Emit("chat message", text);
                //textList.Add(text); // 이거 떔에 그래 서버에 보내면 알아서 받아서 뿌리는데 또찍으니까 2번임.
                mInput.value      = "";
                mInput.isSelected = false;
                text = null;
            }
        }
    }
Exemple #25
0
    /// <summary>
    /// 添加文本
    /// </summary>
    /// <param name="text">要添加的文本。'\n'表示换行,'\t'将被替换为"    "</param>
    /// <param name="paragraph">本次添加生成的所有<see cref="UILabel"/></param>
    public void AddText(string text, ICollection <UIWidget> paragraph = null)
    {
        if (string.IsNullOrEmpty(text))
        {
            return;
        }
        text = NGUIText.StripSymbols(text);
        var lines = text.Split(new char[] { '\n' });

        for (var i = 0; i < lines.Length - 1; i++)
        {
            AddRawText(lines[i], paragraph);
            AddNewLine();
        }
        AddRawText(lines.Last(), paragraph);
    }
Exemple #26
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
            int    index = Random.Range(0, 3);
            string text  = nameArr[index] + ": " + NGUIText.StripSymbols(mInput.value);

            if (!string.IsNullOrEmpty(text))
            {
                textList.Add(text);
                mInput.value = "";
                //mInput.isSelected = false;
            }
        }
    }
    public void OnSubmit()
    {
        string currentRoomNo = AppManager.Instance.currentRoomNo;
        string userId        = AppManager.Instance.user.UserId;
        string userName      = AppManager.Instance.user.DisplayName;
        // 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 (!AppManager.Instance.GetUserType(currentRoomNo))
        {
            return;
        }

        if (!string.IsNullOrEmpty(text))
        {
            mInput.value = "";
            // mInput.isSelected = false;

            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

            if (editChatKey != null)
            {
                reference.Child("Messages").Child(currentRoomNo).Child(editChatKey).Child("Editing").RemoveValueAsync();
                if (!editChatTextBefore.Equals(text))
                {
                    DatabaseReference existChatRef = reference.Child("Messages").Child(currentRoomNo).Child(editChatKey);
                    existChatRef.Child(editChatUser).SetValueAsync(text);
                    existChatRef.Child("Edited").SetValueAsync(AppManager.Instance.user.DisplayName);
                    existChatRef.Child("EditTime").SetValueAsync(ServerValue.Timestamp);

                    DatabaseReference chatHistoryRef = existChatRef.Child("EditHistory").Push();
                    chatHistoryRef.Child(userName).SetValueAsync(text);
                    chatHistoryRef.Child("EditTime").SetValueAsync(ServerValue.Timestamp);
                }

                editChatTextBefore = null;
                editChatKey        = null;
                editChatUser       = null;
            }
            else
            {
                DatabaseReference newChatRef = reference.Child("Messages").Child(currentRoomNo).Push();
                newChatRef.Child(userName).SetValueAsync(text);
                newChatRef.Child("SendTime").SetValueAsync(ServerValue.Timestamp);
            }
        }
    }
    public void OnSubmit()
    {
        if (textList != null)
        {
            string text = NGUIText.StripSymbols(_Input.value);

            if (!string.IsNullOrEmpty(text))
            {
                string s = string.Format("[FFFF00][{0}][-]: {1}", GameManager.GameUser.Base.NickName, text);

                manager.SendChat(s);

                _Input.value      = "";
                _Input.isSelected = false;
            }
        }
    }
Exemple #29
0
    private static int StripSymbols(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            string text = ToLua.CheckString(L, 1);
            string str  = NGUIText.StripSymbols(text);
            LuaDLL.lua_pushstring(L, str);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemple #30
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))
            {
                //textList.Add(text);
                mInput.value      = "";
                mInput.isSelected = false;

                // SendPacket
                GameObject.Find("SimpleClient").GetComponent <SimpleClient>().SendPacket_AckChat(text);
            }
        }
    }