From 86191622cf222f722d1d57cc4bed2abadaca9068 Mon Sep 17 00:00:00 2001 From: John Cote Date: Mon, 30 Dec 2019 19:42:34 -0500 Subject: [PATCH] makeatoon: type a name works now --- otp/namepanel/NameCheck.py | 12 ++++++------ toontown/makeatoon/NameShop.py | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/otp/namepanel/NameCheck.py b/otp/namepanel/NameCheck.py index 97df7eb..3f275aa 100644 --- a/otp/namepanel/NameCheck.py +++ b/otp/namepanel/NameCheck.py @@ -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: diff --git a/toontown/makeatoon/NameShop.py b/toontown/makeatoon/NameShop.py index 196770b..6ca7f5b 100644 --- a/toontown/makeatoon/NameShop.py +++ b/toontown/makeatoon/NameShop.py @@ -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)