makeatoon: type a name works now

This commit is contained in:
John Cote 2019-12-30 19:42:34 -05:00
parent 616a9b9f6c
commit 86191622cf
2 changed files with 10 additions and 11 deletions

View file

@ -63,7 +63,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
notify.info('name contains non-printable char #%s' % ord(char)) notify.info('name contains non-printable char #%s' % ord(char))
return OTPLocalizer.NCGeneric return OTPLocalizer.NCGeneric
validAsciiChars = set(".,'-" + string.letters + string.whitespace) validAsciiChars = set(".,'-" + string.ascii_letters + string.whitespace)
def _validCharacter(c, validAsciiChars = validAsciiChars, font = font): def _validCharacter(c, validAsciiChars = validAsciiChars, font = font):
if c in validAsciiChars: if c in validAsciiChars:
@ -108,7 +108,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
if ord(char) >= 128: if ord(char) >= 128:
return None return None
letters = filterString(word, string.letters) letters = filterString(word, string.ascii_letters)
if len(letters) > 2: if len(letters) > 2:
vowels = filterString(letters, 'aeiouyAEIOUY') vowels = filterString(letters, 'aeiouyAEIOUY')
if len(vowels) == 0: if len(vowels) == 0:
@ -127,7 +127,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
word = word word = word
letters = justLetters(word) letters = justLetters(word)
if len(letters) > 2: if len(letters) > 2:
letters = TextEncoder().decodeText(TextEncoder.lower(TextEncoder().encodeWtext(letters))) letters = TextEncoder().decodeText(TextEncoder.lower(TextEncoder().encodeWtext(letters).decode('utf-8')).encode('utf-8'))
filtered = filterString(letters, letters[0]) filtered = filterString(letters, letters[0])
if filtered == letters: if filtered == letters:
notify.info('word "%s" uses only one letter' % TextEncoder().encodeWtext(word)) notify.info('word "%s" uses only one letter' % TextEncoder().encodeWtext(word))
@ -223,7 +223,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
def allCaps(name): def allCaps(name):
letters = justLetters(name) letters = justLetters(name)
if len(letters) > 2: if len(letters) > 2:
upperLetters = TextEncoder().decodeText(TextEncoder.upper(TextEncoder().encodeWtext(letters))) upperLetters = TextEncoder().decodeText(TextEncoder.upper(TextEncoder().encodeWtext(letters).decode('utf-8')).encode('utf-8'))
for i in range(len(upperLetters)): for i in range(len(upperLetters)):
if not upperLetters[0].isupper(): if not upperLetters[0].isupper():
return return
@ -308,8 +308,8 @@ def checkName(name, otherCheckFuncs = [], font = None):
mixedCase, mixedCase,
repeatedChars] + otherCheckFuncs repeatedChars] + otherCheckFuncs
symmetricChecks = [] symmetricChecks = []
name = TextEncoder().decodeText(name) name = TextEncoder().decodeText(name.encode('utf-8'))
notify.info('checking name "%s"...' % TextEncoder().encodeWtext(name)) notify.info('checking name "%s"...' % TextEncoder().encodeWtext(name).decode('utf-8'))
for check in checks: for check in checks:
problem = check(name[:]) problem = check(name[:])
if not problem and check in symmetricChecks: if not problem and check in symmetricChecks:

View file

@ -13,7 +13,6 @@ from direct.fsm import ClassicFSM, State
from direct.fsm import State from direct.fsm import State
from toontown.toontowngui import TTDialog from toontown.toontowngui import TTDialog
import re import re
import string
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
from . import NameGenerator from . import NameGenerator
import random import random
@ -537,8 +536,8 @@ class NameShop(StateData.StateData):
def match(npcName, name = name): def match(npcName, name = name):
name = TextEncoder().encodeWtext(name) name = TextEncoder().encodeWtext(name)
name = string.strip(name) name = name.strip()
return TextEncoder.upper(npcName) == TextEncoder.upper(name) return TextEncoder.upper(npcName) == TextEncoder.upper(name.decode('utf-8'))
for npcId in list(NPCToons.NPCToonDict.keys()): for npcId in list(NPCToons.NPCToonDict.keys()):
npcName = NPCToons.NPCToonDict[npcId][1] npcName = NPCToons.NPCToonDict[npcId][1]
@ -774,10 +773,10 @@ class NameShop(StateData.StateData):
self.notify.debug('__typedAName') self.notify.debug('__typedAName')
self.nameEntry['focus'] = 0 self.nameEntry['focus'] = 0
name = self.nameEntry.get() name = self.nameEntry.get()
name = TextEncoder().decodeText(name) name = TextEncoder().decodeText(name.encode('utf-8'))
name = name.strip() name = name.strip()
name = TextEncoder().encodeWtext(name) name = TextEncoder().encodeWtext(name)
self.nameEntry.enterText(name) self.nameEntry.enterText(name.decode('utf-8'))
problem = self.nameIsValid(self.nameEntry.get()) problem = self.nameIsValid(self.nameEntry.get())
if problem: if problem:
self.rejectName(problem) self.rejectName(problem)