Commit 0bad1d7fcc31dd056ce9a2fbdb4938ad06982106
1 parent
d55acff5
Exists in
master
Correção de problema ao soletrar palavras com acento.
Showing
2 changed files
with
78 additions
and
25 deletions
Show diff stats
Assets/Scripts/Player Manager/GenericPlayerManager.cs
| @@ -7,6 +7,10 @@ | @@ -7,6 +7,10 @@ | ||
| 7 | * Versão 2.2 | 7 | * Versão 2.2 |
| 8 | * - Acompanhamento da legenda | 8 | * - Acompanhamento da legenda |
| 9 | * Corrigido problema na soletração quando o estado muda para pausado. | 9 | * Corrigido problema na soletração quando o estado muda para pausado. |
| 10 | + * | ||
| 11 | + * Versão 2.3 | ||
| 12 | + * - Legenda | ||
| 13 | + * A letras acentuadas reproduzem a mesma sem o acento | ||
| 10 | */ | 14 | */ |
| 11 | 15 | ||
| 12 | //Log Dir http://docs.unity3d.com/Manual/LogFiles.html | 16 | //Log Dir http://docs.unity3d.com/Manual/LogFiles.html |
| @@ -342,6 +346,24 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -342,6 +346,24 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
| 342 | return animation; | 346 | return animation; |
| 343 | } | 347 | } |
| 344 | 348 | ||
| 349 | + private static short getType(char c) | ||
| 350 | + { | ||
| 351 | + // Se for uma letra | ||
| 352 | + if (c >= 65 && c <= 90) | ||
| 353 | + return Subtitle.TYPE_LETTER; | ||
| 354 | + | ||
| 355 | + // Se for um número | ||
| 356 | + else if (c >= 48 && c <= 57) | ||
| 357 | + return Subtitle.TYPE_NUMBER; | ||
| 358 | + | ||
| 359 | + // Se for uma vírgula | ||
| 360 | + else if (c == 44) | ||
| 361 | + return Subtitle.TYPE_WORD; | ||
| 362 | + | ||
| 363 | + else | ||
| 364 | + return Subtitle.TYPE_NONE; | ||
| 365 | + } | ||
| 366 | + | ||
| 345 | /* Enfileira soletração de palavra */ | 367 | /* Enfileira soletração de palavra */ |
| 346 | private string spellWord(Queue<ToPlay> toPlayQueue, string word) | 368 | private string spellWord(Queue<ToPlay> toPlayQueue, string word) |
| 347 | { | 369 | { |
| @@ -350,50 +372,57 @@ public abstract class GenericPlayerManager : MonoBehaviour { | @@ -350,50 +372,57 @@ public abstract class GenericPlayerManager : MonoBehaviour { | ||
| 350 | 372 | ||
| 351 | // A reprodução da primeira letra deve ser longa para não ser cortada no fade | 373 | // A reprodução da primeira letra deve ser longa para não ser cortada no fade |
| 352 | this.subtitles.updateLetterSpeed(); | 374 | this.subtitles.updateLetterSpeed(); |
| 353 | - | ||
| 354 | - string lastAnim = ""; | ||
| 355 | 375 | ||
| 356 | for (int i = 0; i < word.Length; i++) | 376 | for (int i = 0; i < word.Length; i++) |
| 357 | { | 377 | { |
| 358 | lastAnimationSubtitle = Subtitle.highlight(word, i); | 378 | lastAnimationSubtitle = Subtitle.highlight(word, i); |
| 359 | - lastAnim = nextLetterAnimation(word[i]); | ||
| 360 | - //anim.Equals(lastAnim) ? "d_" + anim : anim; | 379 | + char anim = word[i]; |
| 361 | 380 | ||
| 362 | - short type; | ||
| 363 | - | ||
| 364 | - // Se for uma letra | ||
| 365 | - if (word[i] >= 65 && word[i] <= 90) | ||
| 366 | - type = Subtitle.TYPE_LETTER; | ||
| 367 | - | ||
| 368 | - // Se for um número | ||
| 369 | - else if (word[i] >= 48 && word[i] <= 57) | ||
| 370 | - type = Subtitle.TYPE_NUMBER; | 381 | + switch (word[i]) |
| 382 | + { | ||
| 383 | + case 'Á': | ||
| 384 | + case 'Â': | ||
| 385 | + case 'À': | ||
| 386 | + case 'Ã': anim = 'A'; | ||
| 387 | + break; | ||
| 388 | + case 'É': | ||
| 389 | + case 'Ê': anim = 'E'; | ||
| 390 | + break; | ||
| 391 | + case 'Í': anim = 'I'; | ||
| 392 | + break; | ||
| 393 | + case 'Ó': | ||
| 394 | + case 'Ô': | ||
| 395 | + case 'Õ': anim = 'O'; | ||
| 396 | + break; | ||
| 397 | + case 'Ú': anim = 'U'; | ||
| 398 | + break; | ||
| 399 | + } | ||
| 371 | 400 | ||
| 372 | - // Se for uma vírgula | ||
| 373 | - else if (word[i] == 44) | ||
| 374 | - type = Subtitle.TYPE_WORD; | 401 | + short type = getType(anim); |
| 402 | + string animName = nextLetterAnimation(anim); | ||
| 375 | 403 | ||
| 376 | // Não há animação | 404 | // Não há animação |
| 377 | - else | 405 | + if (type == Subtitle.TYPE_NONE) |
| 378 | { | 406 | { |
| 379 | // Reproduz animação default apenas uma vez | 407 | // Reproduz animação default apenas uma vez |
| 380 | if ( ! defaultPlayed) | 408 | if ( ! defaultPlayed) |
| 381 | { | 409 | { |
| 382 | defaultPlayed = true; | 410 | defaultPlayed = true; |
| 383 | - toPlayQueue.Enqueue(new ToPlay(Subtitle.TYPE_NONE, DEFAULT_ANIMATION_MIDDLE, lastAnimationSubtitle, this)); | 411 | + toPlayQueue.Enqueue(new ToPlay(Subtitle.TYPE_WORD, DEFAULT_ANIMATION_MIDDLE, lastAnimationSubtitle, this)); |
| 384 | 412 | ||
| 385 | // A reprodução da próxima letra deve ser longa para não ser cortada no fade | 413 | // A reprodução da próxima letra deve ser longa para não ser cortada no fade |
| 386 | this.subtitles.updateLetterSpeed(); | 414 | this.subtitles.updateLetterSpeed(); |
| 387 | } | 415 | } |
| 388 | 416 | ||
| 389 | - UnityEngine.Debug.Log("Animação \"" + word[i] + "\" inexistente."); | ||
| 390 | - continue; | 417 | + UnityEngine.Debug.Log("Animação \"" + animName + "\" inexistente."); |
| 391 | } | 418 | } |
| 392 | - | ||
| 393 | - toPlayQueue.Enqueue(new ToPlay(type, lastAnim, lastAnimationSubtitle, this)); | 419 | + else |
| 420 | + { | ||
| 421 | + toPlayQueue.Enqueue(new ToPlay(type, animName, lastAnimationSubtitle, this)); | ||
| 394 | 422 | ||
| 395 | - defaultPlayed = false; | ||
| 396 | - this.subtitles.updateLetterSpeed(); | 423 | + defaultPlayed = false; |
| 424 | + this.subtitles.updateLetterSpeed(); | ||
| 425 | + } | ||
| 397 | } | 426 | } |
| 398 | 427 | ||
| 399 | return lastAnimationSubtitle; | 428 | return lastAnimationSubtitle; |
Assets/Scripts/Player Manager/Subtitle.cs
| @@ -2,6 +2,9 @@ using UnityEngine.UI; | @@ -2,6 +2,9 @@ using UnityEngine.UI; | ||
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Gerenciador de legendas | 4 | * Gerenciador de legendas |
| 5 | + * | ||
| 6 | + * Versão 1.1 | ||
| 7 | + * - Caracteres de letras acentuadas e % são separados com "-". | ||
| 5 | */ | 8 | */ |
| 6 | public class Subtitle { | 9 | public class Subtitle { |
| 7 | 10 | ||
| @@ -116,6 +119,27 @@ public class Subtitle { | @@ -116,6 +119,27 @@ public class Subtitle { | ||
| 116 | this.NumberSpeed = this.DefaultNumberSpeed.getProportional(this.SliderPosition); | 119 | this.NumberSpeed = this.DefaultNumberSpeed.getProportional(this.SliderPosition); |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 122 | + public static bool isSeparable(char c) | ||
| 123 | + { | ||
| 124 | + switch (c) | ||
| 125 | + { | ||
| 126 | + case '%': | ||
| 127 | + case 'Á': | ||
| 128 | + case 'Â': | ||
| 129 | + case 'À': | ||
| 130 | + case 'Ã': | ||
| 131 | + case 'É': | ||
| 132 | + case 'Ê': | ||
| 133 | + case 'Í': | ||
| 134 | + case 'Ó': | ||
| 135 | + case 'Ô': | ||
| 136 | + case 'Õ': | ||
| 137 | + case 'Ú': return true; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + return (c >= 65 && c <= 90) || (c >= 48 && c <= 57); | ||
| 141 | + } | ||
| 142 | + | ||
| 119 | /* Destaca caractere de uma string. */ | 143 | /* Destaca caractere de uma string. */ |
| 120 | public static string highlight(string word, int index) | 144 | public static string highlight(string word, int index) |
| 121 | { | 145 | { |
| @@ -123,7 +147,7 @@ public class Subtitle { | @@ -123,7 +147,7 @@ public class Subtitle { | ||
| 123 | 147 | ||
| 124 | for (int i = 0; i < word.Length; i++) | 148 | for (int i = 0; i < word.Length; i++) |
| 125 | { | 149 | { |
| 126 | - if (i > 0 && ((word[i] >= 65 && word[i] <= 90) || (word[i] >= 48 && word[i] <= 57))) | 150 | + if (i > 0 && isSeparable(word[i])) |
| 127 | subtitle += "-"; | 151 | subtitle += "-"; |
| 128 | 152 | ||
| 129 | if (i == index) | 153 | if (i == index) |