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))
return OTPLocalizer.NCGeneric
validAsciiChars = set(".,'-" + string.letters + string.whitespace)
validAsciiChars = set(".,'-" + string.ascii_letters + string.whitespace)
def _validCharacter(c, validAsciiChars = validAsciiChars, font = font):
if c in validAsciiChars:
@ -108,7 +108,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
if ord(char) >= 128:
return None
letters = filterString(word, string.letters)
letters = filterString(word, string.ascii_letters)
if len(letters) > 2:
vowels = filterString(letters, 'aeiouyAEIOUY')
if len(vowels) == 0:
@ -127,7 +127,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
word = word
letters = justLetters(word)
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])
if filtered == letters:
notify.info('word "%s" uses only one letter' % TextEncoder().encodeWtext(word))
@ -223,7 +223,7 @@ def checkName(name, otherCheckFuncs = [], font = None):
def allCaps(name):
letters = justLetters(name)
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)):
if not upperLetters[0].isupper():
return
@ -308,8 +308,8 @@ def checkName(name, otherCheckFuncs = [], font = None):
mixedCase,
repeatedChars] + otherCheckFuncs
symmetricChecks = []
name = TextEncoder().decodeText(name)
notify.info('checking name "%s"...' % TextEncoder().encodeWtext(name))
name = TextEncoder().decodeText(name.encode('utf-8'))
notify.info('checking name "%s"...' % TextEncoder().encodeWtext(name).decode('utf-8'))
for check in checks:
problem = check(name[:])
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 toontown.toontowngui import TTDialog
import re
import string
from toontown.toonbase import TTLocalizer
from . import NameGenerator
import random
@ -537,8 +536,8 @@ class NameShop(StateData.StateData):
def match(npcName, name = name):
name = TextEncoder().encodeWtext(name)
name = string.strip(name)
return TextEncoder.upper(npcName) == TextEncoder.upper(name)
name = name.strip()
return TextEncoder.upper(npcName) == TextEncoder.upper(name.decode('utf-8'))
for npcId in list(NPCToons.NPCToonDict.keys()):
npcName = NPCToons.NPCToonDict[npcId][1]
@ -774,10 +773,10 @@ class NameShop(StateData.StateData):
self.notify.debug('__typedAName')
self.nameEntry['focus'] = 0
name = self.nameEntry.get()
name = TextEncoder().decodeText(name)
name = TextEncoder().decodeText(name.encode('utf-8'))
name = name.strip()
name = TextEncoder().encodeWtext(name)
self.nameEntry.enterText(name)
self.nameEntry.enterText(name.decode('utf-8'))
problem = self.nameIsValid(self.nameEntry.get())
if problem:
self.rejectName(problem)