public void registerButtonCallback() { string userName = loginPanel.loginInput.text; if (userName != "") { if (!BWFManager.Contains(userName) && userName != "Rookie") { loginPanel.ErrorString = ""; loginPanel.loginStarted(); Debug.Log("Updating Player..."); // new GameSparks.Api.Requests.RegistrationRequest() // .SetDisplayName(userName) // .SetUserName(SystemInfo.deviceUniqueIdentifier) // .SetPassword("") // .Send(RegisterGameSparksResponse); newName = userName; new GameSparks.Api.Requests.ChangeUserDetailsRequest() .SetDisplayName(userName) .Send(ChangeDisplayNameResponse); } else { loginPanel.ErrorString = socialErrorManager.GetErrorMessage("BAD_WORD"); } } else { loginPanel.ErrorString = socialErrorManager.GetErrorMessage("EMPTY_INPUT_LOGIN"); } }
private IEnumerator multiTreaded() { Debug.Log("Starting..."); while (!Manager.BadWordManager.isReady) { yield return(null); } //System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.ContainsMT(out containsUnwantedWords, DirtyText)); System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.GetAllMT(out unwantedWords, DirtyText)); //System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.ReplaceAllMT(out cleanText, DirtyText)); //System.Threading.Thread worker = new System.Threading.Thread(() => BadWordManager.ReplaceAllMT(out CleanText, DirtyText)); worker.Start(); Debug.Log("Checking..."); do { yield return(null); } while (worker.IsAlive); Debug.Log("Finished: " + System.Environment.NewLine + unwantedWords.CTDump()); }
////获取文本框中的文字 //public void GetChatData(string str) //{ // m_chatText = ""; // m_chatText = str; //} //发送聊天文字 public void SendChatData(string chatText) { if (BWFManager.isReady && BWFManager.Contains(chatText)) { chatText = BWFManager.ReplaceAll(chatText); } if (chatText.Length > LobbyChatDataLenght) { GameSceneUIHandler.ShowLog("文字长度过长,请重新输入!"); } else if (chatText.Length == 0) { GameSceneUIHandler.ShowLog("输入信息不能为空!"); } else { //var kernel = (GameScene)CServerItem.get().GetClientKernelSink(); //if (kernel == null) { return; } //Buffer.BlockCopy(temp, 0, data, 0, temp.Length); //kernel.SendChatData(data); CGPLobbyMission kGPLobbyMission = CGPLobbyMission.GetInstance(); if (kGPLobbyMission != null) { if (!kGPLobbyMission.isLobbyChatSystemSetted()) { kGPLobbyMission.setLobbyChatSystem(this); } kGPLobbyMission.SendChatData(chatText); } } //m_chatText = ""; }
//发送聊天文字 public void SendChatData(string str) { if (BWFManager.isReady && BWFManager.Contains(str)) { str = BWFManager.ReplaceAll(str); } if (str.Length > ChatDataLenght) { GameSceneUIHandler.ShowLog("文字长度过长,请重新输入!"); } else if (str.Length == 0) { GameSceneUIHandler.ShowLog("输入信息不能为空!"); } else { var temp = Encoding.GetEncoding(936).GetBytes(str); //byte[] data = new byte[40]; //Array.Clear(data, 0, 40); var kernel = (GameScene)CServerItem.get().GetClientKernelSink(); if (kernel == null) { return; } //Buffer.BlockCopy(temp, 0, data, 0, temp.Length); kernel.SendChatData(temp); } chat = ""; }
public void Replace() { tested = true; Text.text = BWFManager.ReplaceAll(Text.text, BadwordManager | DomManager | CapsManager | PuncManager, Sources.ToArray()); badWords.Clear(); }
private void showTestDrive() { if (Util.Helper.isEditorMode) { if (BWFManager.isReady) { scrollPosTD = EditorGUILayout.BeginScrollView(scrollPosTD, false, false); { GUILayout.Label("Test-Drive", EditorStyles.boldLabel); inputText = EditorGUILayout.TextField(new GUIContent("Input Text", "Text to check."), inputText); EditorHelper.ReadOnlyTextField("Output Text", outputText); } EditorGUILayout.EndScrollView(); EditorHelper.SeparatorUI(); GUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent(" Contains", EditorHelper.Icon_Contains, "Contains any bad words?"))) { BWFManager.Load(); outputText = BWFManager.Contains(inputText).ToString(); } if (GUILayout.Button(new GUIContent(" Get", EditorHelper.Icon_Get, "Get all bad words."))) { BWFManager.Load(); outputText = string.Join(", ", BWFManager.GetAll(inputText).ToArray()); } if (GUILayout.Button(new GUIContent(" Replace", EditorHelper.Icon_Replace, "Check and replace all bad words."))) { BWFManager.Load(); outputText = BWFManager.ReplaceAll(inputText); } if (GUILayout.Button(new GUIContent(" Mark", EditorHelper.Icon_Mark, "Mark all bad words."))) { BWFManager.Load(); outputText = BWFManager.Mark(inputText, BWFManager.GetAll(inputText)); } } GUILayout.EndHorizontal(); } else { EditorHelper.BWFUnavailable(); } } else { EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info); } }
public void SetNickNameForRegister(string str) { if (!BWFManager.Contains(str)) { CustomNameWindow.transform.Find("UserName").GetComponent <InputField>().text = str; LoginScene.m_kNickName = str; } else { GameSceneUIHandler.ShowLog("该昵称包含敏感词汇,无法使用"); CustomNameWindow.transform.Find("UserName").GetComponent <InputField>().text = LoginScene.m_kNickName; } }
protected override void speedTest(Model.ManagerMask mask) { stopWatch.Reset(); stopWatch.Start(); for (int ii = 0; ii < Iterations; ii++) { BWFManager.Contains(createRandomString(TextStartLength + (TextGrowPerIteration * ii)), mask, TestSources); } stopWatch.Stop(); Debug.Log("## " + mask + ": " + stopWatch.ElapsedMilliseconds + ";" + ((float)stopWatch.ElapsedMilliseconds / Iterations) + " ##"); }
public void SendMessageToChat() { string messageToSend = BWFManager.ReplaceAll(messageArea.text); if (messageToSend != "") { new SendTeamChatMessageRequest() .SetMessage(messageToSend) //Player data Team ID .SetTeamId(GameSparksPlayerData.playerTeam) //Player data Team Type .SetTeamType(teamType) .Send(SendMessageToChatCallback); } }
protected override void speedTest(Model.ManagerMask mask) { System.Collections.Generic.List <string> badWords = new System.Collections.Generic.List <string>(); badWords.Add(badword); stopWatch.Reset(); stopWatch.Start(); for (int ii = 0; ii < Iterations; ii++) { BWFManager.Replace(createRandomString(TextStartLength + (TextGrowPerIteration * ii)), badWords, mask); } stopWatch.Stop(); //Debug.Log(totalTime + ";" + totalTime/Iterations); Debug.Log("## " + mask + ": " + stopWatch.ElapsedMilliseconds + ";" + ((float)stopWatch.ElapsedMilliseconds / Iterations) + " ##"); }
// Token: 0x06002364 RID: 9060 RVA: 0x000E7EBC File Offset: 0x000E60BC public bool CheckName() { if (this.MBPHKDQMJJH.BGBMIEJJQKC.Length < 3) { this.QHNLDODGGQB.PIDLOFMIEFQ = "Username is too short"; this.QHNLDODGGQB.gameObject.SetActive(true); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = true; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(false); } int num = 0; for (int i = 0; i < this.MBPHKDQMJJH.BGBMIEJJQKC.Length; i++) { if (char.IsUpper(this.MBPHKDQMJJH.BGBMIEJJQKC[i])) { num++; } } if (num > 3) { this.QHNLDODGGQB.PIDLOFMIEFQ = "Username can only contain 3 capitals"; this.QHNLDODGGQB.gameObject.SetActive(true); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = true; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(false); } if (BWFManager.Contains(this.MBPHKDQMJJH.BGBMIEJJQKC, ManagerMask.BadWord, Array.Empty <string>())) { this.QHNLDODGGQB.PIDLOFMIEFQ = "You can not use this username"; this.QHNLDODGGQB.gameObject.SetActive(true); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = true; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(false); } this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = false; this.QHNLDODGGQB.gameObject.SetActive(false); return(true); }
// Token: 0x06002359 RID: 9049 RVA: 0x000E777C File Offset: 0x000E597C public bool MJBMBBFOQPF() { if (this.MBPHKDQMJJH.BGBMIEJJQKC.Length < 3) { this.QHNLDODGGQB.LKPOBCBOFIC(" days ago"); this.QHNLDODGGQB.gameObject.SetActive(false); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = false; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(true); } int num = 0; for (int i = 1; i < this.MBPHKDQMJJH.BGBMIEJJQKC.Length; i += 0) { if (char.IsUpper(this.MBPHKDQMJJH.HJMJDJKOILH()[i])) { num++; } } if (num > 0) { this.QHNLDODGGQB.PIDLOFMIEFQ = "50/50"; this.QHNLDODGGQB.gameObject.SetActive(false); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = false; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(false); } if (BWFManager.Contains(this.MBPHKDQMJJH.HJMJDJKOILH(), ManagerMask.None, Array.Empty <string>())) { this.QHNLDODGGQB.PIDLOFMIEFQ = "a"; this.QHNLDODGGQB.gameObject.SetActive(true); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().ResetToBeginning(); this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = false; this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().PlayForward(); return(false); } this.QHNLDODGGQB.GetComponent <EPIJJNOIKEK>().enabled = false; this.QHNLDODGGQB.gameObject.SetActive(false); return(false); }
private IEnumerator buildLanguageList() { if (ItemPrefab != null && Scroll != null) { while (!BWFManager.isReady) { yield return(null); } RectTransform rowRectTransform = ItemPrefab.GetComponent <RectTransform>(); RectTransform containerRectTransform = Target.GetComponent <RectTransform>(); for (var i = Target.transform.childCount - 1; i >= 0; i--) { Transform child = Target.transform.GetChild(i); child.SetParent(null); Destroy(child.gameObject); // Optionally destroy the objectA if not longer needed } System.Collections.Generic.List <Source> items = BWFManager.Sources(ManagerMask.BadWord); //Debug.Log("ITEMS: " + items.Count); //calculate the width and height of each child item. float width = containerRectTransform.rect.width / ColumnCount - (SpaceWidth.x + SpaceWidth.y) * ColumnCount; //float ratio = width / rowRectTransform.rect.width; //float height = rowRectTransform.rect.height * ratio; float height = rowRectTransform.rect.height - (SpaceHeight.x + SpaceHeight.y); int rowCount = items.Count / ColumnCount; if (rowCount > 0 && items.Count % rowCount > 0) { rowCount++; } //adjust the height of the container so that it will just barely fit all its children float scrollHeight = height * rowCount; containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -scrollHeight / 2); containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, scrollHeight / 2); int j = 0; for (int ii = 0; ii < items.Count; ii++) { //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns if (ii % ColumnCount == 0) { j++; } //create a new item, name it, and set the parent GameObject newItem = Instantiate(ItemPrefab) as GameObject; newItem.name = Target.name + " item at (" + ii + "," + j + ")"; newItem.transform.SetParent(Target.transform); newItem.transform.localScale = Vector3.one; //newItem.GetComponent<Image>().color = ii%2 == 0 ? evenColor : oddColor; //newItem.GetComponent<Image>().sprite = ; newItem.GetComponent <SourceEntry>().Source = items[ii]; newItem.GetComponent <SourceEntry>().GuiMain = GuiMain; //move and size the new item RectTransform rectTransform = newItem.GetComponent <RectTransform>(); float x = -containerRectTransform.rect.width / 2 + (width + SpaceWidth.x) * (ii % ColumnCount) + SpaceWidth.x * ColumnCount; //float y = containerRectTransform.rect.height / 2 - height * j; float y = containerRectTransform.rect.height / 2 - (height + SpaceHeight.y) * j; //NEW rectTransform.offsetMin = new Vector2(x, y); x = rectTransform.offsetMin.x + width; y = rectTransform.offsetMin.y + height; rectTransform.offsetMax = new Vector2(x, y); } Scroll.value = 1f; } }
public void Test() { tested = true; badWords = BWFManager.GetAll(Text.text, BadwordManager | DomManager | CapsManager | PuncManager, Sources.ToArray()); }
public void Update() { elapsedTimeCheck += Time.deltaTime; elapsedTimeReplace += Time.deltaTime; if (AutoTest && !AutoReplace && elapsedTimeCheck > IntervalCheck) { Test(); elapsedTimeCheck = 0f; } if (AutoReplace && elapsedTimeReplace > IntervalReplace) { Replace(); elapsedTimeReplace = 0f; } if (BadwordReplaceChars != null) { BadWordManager.ReplaceCharacters = BadwordReplaceChars.text; } if (DomainReplaceChars != null) { DomainManager.ReplaceCharacters = DomainReplaceChars.text; } int number; bool res; if (CapsTrigger != null) { res = int.TryParse(CapsTrigger.text, out number); CapitalizationManager.CharacterNumber = res ? (number > 2 ? number : 2) : 2; CapsTrigger.text = CapitalizationManager.CharacterNumber.ToString(); } if (PuncTrigger != null) { res = int.TryParse(PuncTrigger.text, out number); PunctuationManager.CharacterNumber = res ? (number > 2 ? number : 2) : 2; PuncTrigger.text = PunctuationManager.CharacterNumber.ToString(); } if (tested) { if (badWords.Count > 0) { BadWordList.text = string.Join(System.Environment.NewLine, badWords.ToArray()); BadWordListImage.color = BadColor; } else { BadWordList.text = "No bad words found"; BadWordListImage.color = GoodColor; } } if (BadWordCounter != null) { BadWordCounter.text = badWords.Count.ToString(); } if (OutputText != null) { OutputText.text = BWFManager.Mark(Text.text, badWords); } }
protected override void sanityTest(Model.ManagerMask mask) { System.Collections.Generic.List <string> noWords = new System.Collections.Generic.List <string>(); //null test if (BWFManager.Replace(null, noWords, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Nullable 'text test passed"); } } else { Debug.LogError("Nullable 'text' test failed"); failCounter++; } if (BWFManager.Replace(scunthorpe, null, mask).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Nullable 'badWords test passed"); } } else { Debug.LogError("Nullable 'badWords' test failed"); failCounter++; } //empty test if (BWFManager.Replace(string.Empty, noWords, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Empty test passed"); } } else { Debug.LogError("Empty test failed"); failCounter++; } if ((mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { System.Collections.Generic.List <string> badWords = new System.Collections.Generic.List <string>(); badWords.Add(badword); //replace test if (BWFManager.Replace(badword, badWords, mask).Equals(new string(ReplaceChar, badword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource replace test passed"); } } else { Debug.LogError("Bad word resource replace failed"); failCounter++; } } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { System.Collections.Generic.List <string> domainWords = new System.Collections.Generic.List <string>(); domainWords.Add(domain); //domain match test if (BWFManager.Replace(domain, domainWords, mask).Equals(new string(ReplaceChar, domain.Length))) { if (Util.Config.DEBUG) { Debug.Log("Domain replace test passed"); } } else { Debug.LogError("Domain match failed"); failCounter++; } } if ((mask & Model.ManagerMask.Capitalization) == Model.ManagerMask.Capitalization) { string caps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber + 1); System.Collections.Generic.List <string> capsWords = new System.Collections.Generic.List <string>(); capsWords.Add(caps); //capital match test if (BWFManager.Replace(caps, capsWords, mask).Equals(caps.ToLowerInvariant())) { if (Util.Config.DEBUG) { Debug.Log("Capital replace test passed"); } } else { Debug.LogError("Capital replace failed"); failCounter++; } } if ((mask & Model.ManagerMask.Punctuation) == Model.ManagerMask.Punctuation) { string punc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber + 1); System.Collections.Generic.List <string> puncWords = new System.Collections.Generic.List <string>(); puncWords.Add(punc); //punctuation match test if (BWFManager.Replace(punc, puncWords, mask).Equals(new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber))) { if (Util.Config.DEBUG) { Debug.Log("Punctuation replace test passed"); } } else { Debug.LogError("Punctuation replace failed"); failCounter++; } } }
public void OnEnable() { script = (BWFManager)target; }
protected override void sanityTest(Model.ManagerMask mask) { //null test if (!BWFManager.Contains(null, mask)) { if (Util.Config.DEBUG) { Debug.Log("Nullable test passed"); } } else { Debug.LogError("Nullable test failed"); failCounter++; } //empty test if (!BWFManager.Contains(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Empty test passed"); } } else { Debug.LogError("Empty test failed"); failCounter++; } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //wrong 'source' test if (!BWFManager.Contains(scunthorpe, mask, "test")) { if (Util.Config.DEBUG) { Debug.Log("Wrong 'source' test passed"); } } else { Debug.LogError("Wrong 'source' test failed"); failCounter++; } //null for 'source' test if (!BWFManager.Contains(scunthorpe, mask, null)) { if (Util.Config.DEBUG) { Debug.Log("Null for 'source' test passed"); } } else { Debug.LogError("Null for 'source' test failed"); failCounter++; } //Zero-length array for 'source' test if (!BWFManager.Contains(scunthorpe, mask, new string[0])) { if (Util.Config.DEBUG) { Debug.Log("Zero-length array for 'source' test passed"); } } else { Debug.LogError("Zero-length array for 'source' test failed"); failCounter++; } } if ((mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //normal bad word match test if (BWFManager.Contains(badword, mask)) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word match test passed"); } } else { Debug.LogError("Normal bad word match failed"); failCounter++; } //normal bad word non-match test if (!BWFManager.Contains(scunthorpe, mask)) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word non-match test passed"); } } else { Debug.LogError("Normal bad word non-match word test failed"); failCounter++; } //bad word resource match test if (BWFManager.Contains(badword, mask, "english")) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource match test passed"); } } else { Debug.LogError("Bad word resource match failed"); failCounter++; } //bad word resource non-match test if (!BWFManager.Contains(noBadword, mask, "english")) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource non-match test passed"); } } else { Debug.LogError("Bad word resource non-match word test failed"); failCounter++; } //arabic match test if (BWFManager.Contains(arabicBadword, mask)) { if (Util.Config.DEBUG) { Debug.Log("Arabic bad word match test passed"); } } else { Debug.LogError("Arabic bad word match failed"); failCounter++; } //global match test if (BWFManager.Contains(globalBadword, mask)) { if (Util.Config.DEBUG) { Debug.Log("Global bad word match test passed"); } } else { Debug.LogError("Global bad word match failed"); failCounter++; } //name match test if (BWFManager.Contains(nameBadword, mask)) { if (Util.Config.DEBUG) { Debug.Log("Name match test passed"); } } else { Debug.LogError("Name match failed"); failCounter++; } //emoji match test if (BWFManager.Contains(emoji, mask)) { if (Util.Config.DEBUG) { Debug.Log("Emoji match test passed"); } } else { Debug.LogError("Emoji match failed"); failCounter++; } } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //domain match test if (BWFManager.Contains(domain, mask)) { if (Util.Config.DEBUG) { Debug.Log("Domain match test passed"); } } else { Debug.LogError("Domain match failed"); failCounter++; } //domain match test if (BWFManager.Contains(email, mask)) { if (Util.Config.DEBUG) { Debug.Log("Email match test passed"); } } else { Debug.LogError("Email match failed"); failCounter++; } //domain non-match test if (!BWFManager.Contains(noDomain, mask)) { if (Util.Config.DEBUG) { Debug.Log("Domain non-match test passed"); } } else { Debug.LogError("Domain non-match word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Capitalization) == Model.ManagerMask.Capitalization) { string caps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber); string noCaps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber - 1); //capital match test if (BWFManager.Contains(caps, mask)) { if (Util.Config.DEBUG) { Debug.Log("Capital match test passed"); } } else { Debug.LogError("Capital match failed"); failCounter++; } //capital non-match test if (!BWFManager.Contains(noCaps, mask)) { if (Util.Config.DEBUG) { Debug.Log("Capital non-match test passed"); } } else { Debug.LogError("Capital non-match word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Punctuation) == Model.ManagerMask.Punctuation) { string punc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber); string noPunc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber - 1); //punctuation match test if (BWFManager.Contains(punc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation match test passed"); } } else { Debug.LogError("Punctuation match failed"); failCounter++; } //punctuation non-match test if (!BWFManager.Contains(noPunc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation non-match test passed"); } } else { Debug.LogError("Punctuation non-match word test failed"); failCounter++; } } }
public void SetUserInfo() { GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); CMD_GP_ModUserInfo pData = new CMD_GP_ModUserInfo(); pData.Init(); if (strName == null) { Buffer.BlockCopy(pGlobalUserData.szNickName, 0, pData.szNickName, 0, pGlobalUserData.szNickName.Length); } else { byte[] szNickName = Encoding.GetEncoding(936).GetBytes(strName); Buffer.BlockCopy(szNickName, 0, pData.szNickName, 0, szNickName.Length); } if (headIndex == -1) //预留自定义头像,使用自定义头像时headIndex需置为-1 { Buffer.BlockCopy(pGlobalUserData.szHeadHttp, 0, pData.szHeadHttp, 0, pGlobalUserData.szHeadHttp.Length); } else { byte[] szHeadIndex = Encoding.GetEncoding(936).GetBytes(headIndex.ToString()); Buffer.BlockCopy(szHeadIndex, 0, pData.szHeadHttp, 0, szHeadIndex.Length); } if (!BWFManager.Contains(strName)) { bool isNameEquals = true; bool isHeadEquals = true; string name1 = Encoding.Default.GetString(pData.szNickName); string name2 = Encoding.Default.GetString(pGlobalUserData.szNickName); string head1 = Encoding.Default.GetString(pData.szHeadHttp); string head2 = Encoding.Default.GetString(pGlobalUserData.szHeadHttp); if (name1.Length != name2.Length) { isNameEquals = false; } else { for (int i = 0; i < name1.Length; i++) { if (name1[i] == name2[i]) { continue; } else { isNameEquals = false; break; } } } if (head1.Length != head2.Length) { isHeadEquals = false; } else { for (int i = 0; i < head1.Length; i++) { if (head1[i] == head2[i]) { continue; } else { isHeadEquals = false; break; } } } if (!isNameEquals || !isHeadEquals) { UserInfo.getInstance().modeUserInfo(pData); //修改玩资料后,临时变量清空 strName = null; Canvas.transform.Find("Window/UserEditorWindow/UserInfo/UserNameField").GetComponent <InputField>().text = ""; } else if (isNameEquals) { GameSceneUIHandler.ShowLog("您当前正在使用该昵称!"); } } else { GameSceneUIHandler.ShowLog("该昵称包含敏感词汇,无法使用"); } }
public override void OnInspectorGUI() { if (script.isActiveAndEnabled) { GUILayout.Label("Stats", EditorStyles.boldLabel); GUILayout.Label("Ready:\t" + (BWFManager.isReady ? "Yes" : "No")); EditorHelper.SeparatorUI(); GUILayout.Label("Test-Drive", EditorStyles.boldLabel); if (Util.Helper.isEditorMode) { inputText = EditorGUILayout.TextField(new GUIContent("Input Text", "Text to check."), inputText); EditorHelper.ReadOnlyTextField("Output Text", outputText); GUILayout.Space(8); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent(" Contains", EditorHelper.Icon_Contains, "Contains any bad words?"))) { //Manager.BadWordManager.Load(); outputText = BWFManager.Contains(inputText).ToString(); GAApi.Event(typeof(BWFManagerEditor).Name, "Contains"); } if (GUILayout.Button(new GUIContent(" Get", EditorHelper.Icon_Get, "Get all bad words."))) { //Manager.BadWordManager.Load(); outputText = string.Join(", ", BWFManager.GetAll(inputText).ToArray()); GAApi.Event(typeof(BWFManagerEditor).Name, "Get"); } if (GUILayout.Button(new GUIContent(" Replace", EditorHelper.Icon_Replace, "Check and replace all bad words."))) { //Manager.BadWordManager.Load(); outputText = BWFManager.ReplaceAll(inputText); GAApi.Event(typeof(BWFManagerEditor).Name, "Replace"); } if (GUILayout.Button(new GUIContent(" Mark", EditorHelper.Icon_Mark, "Mark all bad words."))) { //Manager.BadWordManager.Load(); outputText = BWFManager.Mark(inputText, BWFManager.GetAll(inputText)); GAApi.Event(typeof(BWFManagerEditor).Name, "Mark"); } GUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info); } } else { EditorGUILayout.HelpBox("Script is disabled!", MessageType.Info); } }
protected override void sanityTest(Model.ManagerMask mask) { //null test // Debug.Log("MASK: " + mask); // // Debug.Log("REPLACE normal: '" + MultiManager.ReplaceAll(null, ManagerMask.All) + "'"); if (BWFManager.ReplaceAll(null, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Nullable test passed"); } } else { Debug.LogError("Nullable test failed"); failCounter++; } //empty test if (BWFManager.ReplaceAll(string.Empty, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Empty test passed"); } } else { Debug.LogError("Empty test failed"); failCounter++; } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //wrong 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, "test").Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Wrong 'source' test passed"); } } else { Debug.LogError("Wrong 'source' test failed"); failCounter++; } //null for 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, null).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Null for 'source' test passed"); } } else { Debug.LogError("Null for 'source' test failed"); failCounter++; } //Zero-length array for 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, new string[0]).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Zero-length array for 'source' test passed"); } } else { Debug.LogError("Zero-length array for 'source' test failed"); failCounter++; } } if ((mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //normal bad word match test if (BWFManager.ReplaceAll(badword, mask).Equals(new string(ReplaceChar, badword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word replace test passed"); } } else { Debug.LogError("Normal bad word replace test failed"); failCounter++; } //normal bad word non-match test if (BWFManager.ReplaceAll(scunthorpe, mask).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word non-replace test passed"); } } else { Debug.LogError("Normal bad word non-replace word test failed"); failCounter++; } //bad word resource match test if (BWFManager.ReplaceAll(badword, mask, "english").Equals(new string(ReplaceChar, badword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource replace test passed"); } } else { Debug.LogError("Bad word resource replace failed"); failCounter++; } //bad word resource non-match test if (BWFManager.ReplaceAll(noBadword, mask, "english").Equals(noBadword)) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource non-replace test passed"); } } else { Debug.LogError("Bad word resource non-replace word test failed"); failCounter++; } //arabic match test if (BWFManager.ReplaceAll(arabicBadword, mask).Equals(new string(ReplaceChar, arabicBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Arabic bad word replace test passed"); } } else { Debug.LogError("Arabic bad word replace failed"); failCounter++; } //global match test if (BWFManager.ReplaceAll(globalBadword, mask).Equals(new string(ReplaceChar, globalBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Global bad word replace test passed"); } } else { Debug.LogError("Global bad word replace failed"); failCounter++; } //name match test if (BWFManager.ReplaceAll(nameBadword, mask).Equals(new string(ReplaceChar, nameBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Name replace test passed"); } } else { Debug.LogError("Name replace failed"); failCounter++; } //emoji match test if (BWFManager.ReplaceAll(emoji, mask).Equals(new string(ReplaceChar, emoji.Length))) { if (Util.Config.DEBUG) { Debug.Log("Emoji replace test passed"); } } else { Debug.LogError("Emoji replace failed"); failCounter++; } } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //domain match test if (BWFManager.ReplaceAll(domain, mask).Equals(new string(ReplaceChar, domain.Length))) { if (Util.Config.DEBUG) { Debug.Log("Domain replace test passed"); } } else { Debug.LogError("Domain replace failed"); failCounter++; } //email match test if (BWFManager.ReplaceAll(email, mask).Equals(new string(ReplaceChar, email.Length))) { if (Util.Config.DEBUG) { Debug.Log("Email replace test passed"); } } else { Debug.LogError("Email replace failed"); failCounter++; } //domain non-match test if (BWFManager.ReplaceAll(noDomain, mask).Equals(noDomain)) { if (Util.Config.DEBUG) { Debug.Log("Domain non-replace test passed"); } } else { Debug.LogError("Domain non-replace word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Capitalization) == Model.ManagerMask.Capitalization) { //capital match test string caps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber + 1); string noCaps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber); if (BWFManager.ReplaceAll(caps, mask).Equals(caps.ToLowerInvariant())) { if (Util.Config.DEBUG) { Debug.Log("Capital replace test passed"); } } else { Debug.LogError("Capital replace failed"); failCounter++; } //capital non-match test if (BWFManager.ReplaceAll(noCaps, mask).Equals(noCaps)) { if (Util.Config.DEBUG) { Debug.Log("Capital non-replace test passed"); } } else { Debug.LogError("Capital non-replace word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Punctuation) == Model.ManagerMask.Punctuation) { //punctuation match test string punc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber + 1); string noPunc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber); if (BWFManager.ReplaceAll(punc, mask).Equals(noPunc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation replace test passed"); } } else { Debug.LogError("Punctuation replace failed"); failCounter++; } //punctuation non-match test if (BWFManager.ReplaceAll(noPunc, mask).Equals(noPunc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation non-replace test passed"); } } else { Debug.LogError("Punctuation non-replace word test failed"); failCounter++; } } }