Commit 69eacbe172c1f8dd00dc5f8a38472ff72f88887d

Authored by Mateus Lustosa
1 parent 76620b0b
Exists in devel

Restricts allowed characters

Assets/Scripts/PlayerManager/GenericPlayerManager.cs
... ... @@ -86,6 +86,15 @@ public abstract class GenericPlayerManager : MonoBehaviour {
86 86  
87 87 private bool[] lastLetterAnimations = new bool[256];
88 88  
  89 + private HashSet<char> allowedCharacters = new HashSet<char>() {
  90 + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
  91 + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
  92 + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
  93 + 'Y', 'Z',
  94 + '1', '2', '3', '4', '5', '6', '7', '8',
  95 + '9', '0', '%', '.', ',', '!', '?',
  96 + };
  97 +
89 98 public virtual void Start()
90 99 {
91 100 // Configuração de velocidade das animações
... ... @@ -377,29 +386,35 @@ public abstract class GenericPlayerManager : MonoBehaviour {
377 386  
378 387 for (int i = 0; i < word.Length; i++)
379 388 {
380   - lastAnimationSubtitle = Subtitle.highlight(word, i);
381   - char anim = word[i];
382   -
383 389 switch (word[i])
384 390 {
385 391 case 'Á':
386 392 case 'Â':
387 393 case 'À':
388   - case 'Ã': anim = 'A';
389   - break;
  394 + case 'Ã': word = word.Replace(word[i], 'A'); break;
390 395 case 'É':
391   - case 'Ê': anim = 'E';
392   - break;
393   - case 'Í': anim = 'I';
394   - break;
  396 + case 'Ê': word = word.Replace(word[i], 'E'); break;
  397 + case 'Í': word = word.Replace(word[i], 'I'); break;
395 398 case 'Ó':
396 399 case 'Ô':
397   - case 'Õ': anim = 'O';
398   - break;
399   - case 'Ú': anim = 'U';
400   - break;
  400 + case 'Õ': word = word.Replace(word[i], 'O'); break;
  401 + case 'Ú': word = word.Replace(word[i], 'U'); break;
401 402 }
402 403  
  404 + if (!allowedCharacters.Contains(word[i]))
  405 + {
  406 + Debug.Log(word[i] + " is not allowed");
  407 +
  408 + word = word.Remove(i, 1);
  409 + i--;
  410 + }
  411 + }
  412 +
  413 + for (int i = 0; i < word.Length; i++)
  414 + {
  415 + lastAnimationSubtitle = Subtitle.highlight(word, i);
  416 + char anim = word[i];
  417 +
403 418 short type = getType(anim);
404 419 string animName = nextLetterAnimation(anim);
405 420  
... ... @@ -416,7 +431,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
416 431 this.subtitles.updateLetterSpeed();
417 432 }
418 433  
419   - UnityEngine.Debug.Log("GPM.sW(" + word + "): Animação \"" + animName + "\" inexistente.");
  434 + Debug.Log("GPM.sW(" + word + "): Animação \"" + animName + "\" inexistente.");
420 435 }
421 436 else
422 437 {
... ... @@ -473,7 +488,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
473 488  
474 489 StartCoroutine(subtitlesSynchronizer);
475 490  
476   - String[] stringPos = gloss.Split(' ');
  491 + string[] stringPos = gloss.Split(' ');
477 492  
478 493 Queue<ToPlay> toPlayQueue = new Queue<ToPlay>();
479 494 int wordsCount = 0;
... ... @@ -506,7 +521,7 @@ public abstract class GenericPlayerManager : MonoBehaviour {
506 521 Debug.Log("GPM:LAP(" + gloss + "): www.error == null");
507 522 bundle = www.assetBundle;
508 523  
509   - if (bundle != null && ! String.IsNullOrEmpty(bundle.mainAsset.name))
  524 + if (bundle != null && ! string.IsNullOrEmpty(bundle.mainAsset.name))
510 525 {
511 526 AnimationClip aniClip = bundle.mainAsset as AnimationClip;
512 527 bundle.Unload(false);
... ...
Assets/Scripts/ServerDebug.cs
1   -/**********************
2   -********LAVID**********
3   -*******VLibras*********
4   -*------------------------------------------------------------------------
5   -*Description:
6   -*Server gets pts from Core (client) by TCP connection
7   -*and runs the animations until a final tag is found.
8   -*------------------------------------------------------------------------
9   -*Author: Claudiomar Araujo # claudiomar.araujo@lavid.ufpb.br
10   -*------------------------------------------------------------------------
11   -***********************/
12   -
13 1 using UnityEngine;
14   -using System;
15   -using System.IO;
16   -using System.Net;
17   -using System.Net.Sockets;
18 2 using System.Collections.Generic;
19 3  
20 4 public class ServerDebug {
... ... @@ -30,23 +14,18 @@ public class ServerDebug {
30 14 public bool IsNotReady {
31 15 get { return !isReady; }
32 16 }
33   -
34   - /**
35   - * Starts receiving of glosa and time from server.
36   - * Stops when receive "FINALIZE".
37   - */
  17 +
38 18 public void StartCommunication()
39 19 {
40 20 List<string> messages = new List<string>() {
41   - "TESTE#1000", "TEST2'#2000", "FINALIZE"
  21 + "`TÉST\"E#1000", "TES´T2'#2000", "FINALIZE"
42 22 };
43   -
  23 +
44 24 Debug.Log("S.SC()");
45 25  
46 26 foreach (string text in messages)
47 27 {
48 28 Message message = new Message(text);
49   -
50 29 Debug.Log("S.SC(): Received: " + message.Text);
51 30  
52 31 if (message.Text.Equals("FINALIZE"))
... ... @@ -60,4 +39,6 @@ public class ServerDebug {
60 39 Debug.Log("S.SC(): END");
61 40 }
62 41  
  42 + public void SendFinalizeToCore() { }
  43 +
63 44 }
64 45 \ No newline at end of file
... ...