makeatoon: current progress
This commit is contained in:
parent
239de4ae62
commit
651de8ddd8
7 changed files with 166 additions and 26 deletions
|
@ -534,4 +534,6 @@ dclass AstronLoginManager : DistributedObject {
|
||||||
loginResponse(blob);
|
loginResponse(blob);
|
||||||
requestAvatarList() clsend;
|
requestAvatarList() clsend;
|
||||||
avatarListResponse(PotentialAvatar[]);
|
avatarListResponse(PotentialAvatar[]);
|
||||||
|
createAvatar(blob, uint8) clsend;
|
||||||
|
createAvatarResponse(uint32);
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Avatar(Actor, ShadowCaster):
|
||||||
ManagesNametagAmbientLightChanged = False
|
ManagesNametagAmbientLightChanged = False
|
||||||
|
|
||||||
def __init__(self, other = None):
|
def __init__(self, other = None):
|
||||||
self.name = ''
|
self._name = ''
|
||||||
try:
|
try:
|
||||||
self.Avatar_initialized
|
self.Avatar_initialized
|
||||||
return
|
return
|
||||||
|
@ -222,7 +222,7 @@ class Avatar(Actor, ShadowCaster):
|
||||||
return OTPGlobals.AvatarDefaultRadius
|
return OTPGlobals.AvatarDefaultRadius
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self._name
|
||||||
|
|
||||||
def getType(self):
|
def getType(self):
|
||||||
return self.avatarType
|
return self.avatarType
|
||||||
|
@ -231,7 +231,7 @@ class Avatar(Actor, ShadowCaster):
|
||||||
if hasattr(self, 'isDisguised'):
|
if hasattr(self, 'isDisguised'):
|
||||||
if self.isDisguised:
|
if self.isDisguised:
|
||||||
return
|
return
|
||||||
self.name = name
|
self._name = name
|
||||||
if hasattr(self, 'nametag'):
|
if hasattr(self, 'nametag'):
|
||||||
self.nametag.setName(name)
|
self.nametag.setName(name)
|
||||||
|
|
||||||
|
|
|
@ -1057,15 +1057,18 @@ class OTPClientRepository(ClientRepositoryBase):
|
||||||
|
|
||||||
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
|
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
|
||||||
def sendCreateAvatarMsg(self, avDNA, avName, avPosition):
|
def sendCreateAvatarMsg(self, avDNA, avName, avPosition):
|
||||||
datagram = PyDatagram()
|
if self.astronSupport:
|
||||||
datagram.addUint16(CLIENT_CREATE_AVATAR)
|
self.astronLoginManager.sendCreateAvatar(avDNA, avName, avPosition)
|
||||||
datagram.addUint16(0)
|
else:
|
||||||
datagram.addString(avDNA.makeNetString())
|
datagram = PyDatagram()
|
||||||
datagram.addUint8(avPosition)
|
datagram.addUint16(CLIENT_CREATE_AVATAR)
|
||||||
self.newName = avName
|
datagram.addUint16(0)
|
||||||
self.newDNA = avDNA
|
datagram.addString(avDNA.makeNetString())
|
||||||
self.newPosition = avPosition
|
datagram.addUint8(avPosition)
|
||||||
self.send(datagram)
|
self.newName = avName
|
||||||
|
self.newDNA = avDNA
|
||||||
|
self.newPosition = avPosition
|
||||||
|
self.send(datagram)
|
||||||
|
|
||||||
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
|
@report(types=['args', 'deltaStamp'], dConfigParam='teleport')
|
||||||
def sendCreateAvatar2Msg(self, avClass, avDNA, avName, avPosition):
|
def sendCreateAvatar2Msg(self, avClass, avDNA, avName, avPosition):
|
||||||
|
|
|
@ -120,3 +120,10 @@ class AstronLoginManager(DistributedObjectGlobal):
|
||||||
|
|
||||||
def avatarListResponse(self, avatarList):
|
def avatarListResponse(self, avatarList):
|
||||||
self.cr.handleAvatarListResponse(avatarList)
|
self.cr.handleAvatarListResponse(avatarList)
|
||||||
|
|
||||||
|
def sendCreateAvatar(self, avDNA, avName, avPosition):
|
||||||
|
# avName isn't used. Sad!
|
||||||
|
self.sendUpdate('createAvatar', [avDNA.makeNetString(), avPosition])
|
||||||
|
|
||||||
|
def createAvatarResponse(self, avId):
|
||||||
|
messenger.send('nameShopCreateAvatarDone', [avId])
|
||||||
|
|
|
@ -8,6 +8,8 @@ import time
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
||||||
from direct.distributed.PyDatagram import *
|
from direct.distributed.PyDatagram import *
|
||||||
|
from toontown.toon.ToonDNA import ToonDNA
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
|
||||||
class AccountDB:
|
class AccountDB:
|
||||||
"""
|
"""
|
||||||
|
@ -260,6 +262,89 @@ class GetAvatarsOperation:
|
||||||
del self.loginManager.account2operation[self.sender]
|
del self.loginManager.account2operation[self.sender]
|
||||||
|
|
||||||
|
|
||||||
|
class CreateAvatarOperation:
|
||||||
|
notify = DirectNotifyGlobal.directNotify.newCategory('CreateAvatarOperation')
|
||||||
|
|
||||||
|
def __init__(self, loginManager, sender):
|
||||||
|
self.loginManager = loginManager
|
||||||
|
self.sender = sender
|
||||||
|
self.avPosition = None
|
||||||
|
self.avDNA = None
|
||||||
|
|
||||||
|
def start(self, avDNA, avPosition):
|
||||||
|
if avPosition >= 6:
|
||||||
|
# NO!!!!!!!
|
||||||
|
return
|
||||||
|
|
||||||
|
valid = ToonDNA().isValidNetString(avDNA)
|
||||||
|
if not valid:
|
||||||
|
# time to eat paste
|
||||||
|
return
|
||||||
|
|
||||||
|
self.avPosition = avPosition
|
||||||
|
self.avDNA = avDNA
|
||||||
|
|
||||||
|
self.__handleRetrieveAccount()
|
||||||
|
|
||||||
|
def __handleRetrieveAccount(self):
|
||||||
|
self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved)
|
||||||
|
|
||||||
|
def __handleAccountRetrieved(self, dclass, fields):
|
||||||
|
if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']:
|
||||||
|
# no uwu
|
||||||
|
return
|
||||||
|
|
||||||
|
self.account = fields
|
||||||
|
self.avList = self.account['ACCOUNT_AV_SET']
|
||||||
|
self.avList = self.avList[:6]
|
||||||
|
self.avList += [0] * (6 - len(self.avList))
|
||||||
|
if self.avList[self.avPosition]:
|
||||||
|
# my leg
|
||||||
|
return
|
||||||
|
|
||||||
|
self.__handleCreateAvatar()
|
||||||
|
|
||||||
|
def __handleCreateAvatar(self):
|
||||||
|
dna = ToonDNA()
|
||||||
|
dna.makeFromNetString(self.avDNA)
|
||||||
|
colorString = TTLocalizer.NumToColor[dna.headColor]
|
||||||
|
animalType = TTLocalizer.AnimalToSpecies[dna.getAnimal()]
|
||||||
|
name = ' '.join((colorString, animalType))
|
||||||
|
toonFields = {'setName': (name,),
|
||||||
|
'WishNameState': ('OPEN',),
|
||||||
|
'WishName': ('',),
|
||||||
|
'setDNAString': (self.avDNA,),
|
||||||
|
'setDISLid': (self.sender,)}
|
||||||
|
|
||||||
|
self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, self.loginManager.air.dclassesByName['DistributedToonUD'], toonFields, self.__handleToonCreated)
|
||||||
|
|
||||||
|
def __handleToonCreated(self, avId):
|
||||||
|
if not avId:
|
||||||
|
# WHAT!
|
||||||
|
return
|
||||||
|
|
||||||
|
self.avId = avId
|
||||||
|
self.__handleStoreAvatar()
|
||||||
|
|
||||||
|
def __handleStoreAvatar(self):
|
||||||
|
self.avList[self.avPosition] = self.avId
|
||||||
|
self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.sender, self.loginManager.air.dclassesByName['AstronAccountUD'],
|
||||||
|
{'ACCOUNT_AV_SET': self.avList},
|
||||||
|
{'ACCOUNT_AV_SET': self.account['ACCOUNT_AV_SET']},
|
||||||
|
self.__handleAvatarStored)
|
||||||
|
|
||||||
|
def __handleAvatarStored(self, fields):
|
||||||
|
if fields:
|
||||||
|
# What happen!
|
||||||
|
# Someone set up us the bomb.
|
||||||
|
# We get signal.
|
||||||
|
# What!
|
||||||
|
return
|
||||||
|
|
||||||
|
self.loginManager.sendUpdateToAccountId(self.sender, 'createAvatarResponse', [self.avId])
|
||||||
|
del self.loginManager.account2operation[self.sender]
|
||||||
|
|
||||||
|
|
||||||
class AstronLoginManagerUD(DistributedObjectGlobalUD):
|
class AstronLoginManagerUD(DistributedObjectGlobalUD):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('AstronLoginManagerUD')
|
notify = DirectNotifyGlobal.directNotify.newCategory('AstronLoginManagerUD')
|
||||||
|
|
||||||
|
@ -288,6 +373,8 @@ class AstronLoginManagerUD(DistributedObjectGlobalUD):
|
||||||
self.sender2loginOperation[sender] = newLoginOperation
|
self.sender2loginOperation[sender] = newLoginOperation
|
||||||
newLoginOperation.start(playToken)
|
newLoginOperation.start(playToken)
|
||||||
|
|
||||||
|
# TODO: CLEAN UP ALL THIS CODE!!!!!!!!
|
||||||
|
|
||||||
def requestAvatarList(self):
|
def requestAvatarList(self):
|
||||||
sender = self.air.getAccountIdFromSender()
|
sender = self.air.getAccountIdFromSender()
|
||||||
if not sender:
|
if not sender:
|
||||||
|
@ -301,3 +388,17 @@ class AstronLoginManagerUD(DistributedObjectGlobalUD):
|
||||||
newOperation = GetAvatarsOperation(self, sender)
|
newOperation = GetAvatarsOperation(self, sender)
|
||||||
self.account2operation[sender] = newOperation
|
self.account2operation[sender] = newOperation
|
||||||
newOperation.start()
|
newOperation.start()
|
||||||
|
|
||||||
|
def createAvatar(self, avDNA, avPosition):
|
||||||
|
sender = self.air.getAccountIdFromSender()
|
||||||
|
if not sender:
|
||||||
|
# TODO KILL CONNECTION
|
||||||
|
return
|
||||||
|
|
||||||
|
if sender in self.account2operation:
|
||||||
|
# BAD!!!!
|
||||||
|
return
|
||||||
|
|
||||||
|
newOperation = CreateAvatarOperation(self, sender)
|
||||||
|
self.account2operation[sender] = newOperation
|
||||||
|
newOperation.start(avDNA, avPosition)
|
||||||
|
|
|
@ -324,10 +324,13 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
|
||||||
self.send(dg)
|
self.send(dg)
|
||||||
|
|
||||||
def handleCreateAvatar(self, msgType, di):
|
def handleCreateAvatar(self, msgType, di):
|
||||||
if msgType == CLIENT_CREATE_AVATAR_RESP or msgType == CLIENT_SET_NAME_PATTERN_ANSWER or msgType == CLIENT_SET_WISHNAME_RESP:
|
if self.astronSupport:
|
||||||
self.avCreate.ns.nameShopHandler(msgType, di)
|
|
||||||
else:
|
|
||||||
self.handleMessageType(msgType, di)
|
self.handleMessageType(msgType, di)
|
||||||
|
else:
|
||||||
|
if msgType == CLIENT_CREATE_AVATAR_RESP or msgType == CLIENT_SET_NAME_PATTERN_ANSWER or msgType == CLIENT_SET_WISHNAME_RESP:
|
||||||
|
self.avCreate.ns.nameShopHandler(msgType, di)
|
||||||
|
else:
|
||||||
|
self.handleMessageType(msgType, di)
|
||||||
|
|
||||||
def __handleMakeAToon(self, avList, avPosition):
|
def __handleMakeAToon(self, avList, avPosition):
|
||||||
done = self.avCreate.getDoneStatus()
|
done = self.avCreate.getDoneStatus()
|
||||||
|
|
|
@ -1004,18 +1004,46 @@ class NameShop(StateData.StateData):
|
||||||
self.requestingSkipTutorial = False
|
self.requestingSkipTutorial = False
|
||||||
if not self.avExists or self.avExists and self.avId == 'deleteMe':
|
if not self.avExists or self.avExists and self.avId == 'deleteMe':
|
||||||
messenger.send('nameShopCreateAvatar', [style, '', self.index])
|
messenger.send('nameShopCreateAvatar', [style, '', self.index])
|
||||||
|
if base.cr.astronSupport:
|
||||||
|
self.accept('nameShopCreateAvatarDone', self.handleCreateAvatarResponseMsg)
|
||||||
else:
|
else:
|
||||||
self.checkNameTyped()
|
self.checkNameTyped()
|
||||||
self.notify.debug('Ending Make A Toon: %s' % self.toon.style)
|
self.notify.debug('Ending Make A Toon: %s' % self.toon.style)
|
||||||
base.cr.centralLogger.writeClientEvent('MAT - endingMakeAToon: %s' % self.toon.style)
|
base.cr.centralLogger.writeClientEvent('MAT - endingMakeAToon: %s' % self.toon.style)
|
||||||
|
|
||||||
def handleCreateAvatarResponseMsg(self, di):
|
if not config.GetBool('astron-support', True):
|
||||||
self.notify.debug('handleCreateAvatarResponseMsg')
|
def handleCreateAvatarResponseMsg(self, di):
|
||||||
echoContext = di.getUint16()
|
self.notify.debug('handleCreateAvatarResponseMsg')
|
||||||
returnCode = di.getUint8()
|
echoContext = di.getUint16()
|
||||||
if returnCode == 0:
|
returnCode = di.getUint8()
|
||||||
|
if returnCode == 0:
|
||||||
|
self.notify.debug('avatar with default name accepted')
|
||||||
|
self.avId = di.getUint32()
|
||||||
|
self.avExists = 1
|
||||||
|
self.logAvatarCreation()
|
||||||
|
if self.nameAction == 0:
|
||||||
|
self.toon.setName(self.names[0])
|
||||||
|
newPotAv = PotentialAvatar.PotentialAvatar(self.avId, self.names, self.newDNA, self.index, 1)
|
||||||
|
self.avList.append(newPotAv)
|
||||||
|
self.doneStatus = 'done'
|
||||||
|
self.storeSkipTutorialRequest()
|
||||||
|
messenger.send(self.doneEvent)
|
||||||
|
elif self.nameAction == 1:
|
||||||
|
self.checkNamePattern()
|
||||||
|
elif self.nameAction == 2:
|
||||||
|
self.checkNameTyped()
|
||||||
|
else:
|
||||||
|
self.notify.debug('avatar invalid nameAction')
|
||||||
|
self.rejectName(TTLocalizer.NameError)
|
||||||
|
else:
|
||||||
|
self.notify.debug('avatar rejected')
|
||||||
|
self.rejectName(TTLocalizer.NameError)
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
def handleCreateAvatarResponseMsg(self, avId):
|
||||||
|
self.notify.debug('handleCreateAvatarResponseMsg')
|
||||||
self.notify.debug('avatar with default name accepted')
|
self.notify.debug('avatar with default name accepted')
|
||||||
self.avId = di.getUint32()
|
self.avId = avId
|
||||||
self.avExists = 1
|
self.avExists = 1
|
||||||
self.logAvatarCreation()
|
self.logAvatarCreation()
|
||||||
if self.nameAction == 0:
|
if self.nameAction == 0:
|
||||||
|
@ -1032,10 +1060,6 @@ class NameShop(StateData.StateData):
|
||||||
else:
|
else:
|
||||||
self.notify.debug('avatar invalid nameAction')
|
self.notify.debug('avatar invalid nameAction')
|
||||||
self.rejectName(TTLocalizer.NameError)
|
self.rejectName(TTLocalizer.NameError)
|
||||||
else:
|
|
||||||
self.notify.debug('avatar rejected')
|
|
||||||
self.rejectName(TTLocalizer.NameError)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def waitForServer(self):
|
def waitForServer(self):
|
||||||
self.waitForServerDialog = TTDialog.TTDialog(text=TTLocalizer.WaitingForNameSubmission, style=TTDialog.NoButtons)
|
self.waitForServerDialog = TTDialog.TTDialog(text=TTLocalizer.WaitingForNameSubmission, style=TTDialog.NoButtons)
|
||||||
|
@ -1068,7 +1092,7 @@ class NameShop(StateData.StateData):
|
||||||
self.promptTutorial()
|
self.promptTutorial()
|
||||||
|
|
||||||
def promptTutorial(self):
|
def promptTutorial(self):
|
||||||
self.promptTutorialDialog = TTDialog.TTDialog(parent=aspect2dp, text=TTLocalizer.PromptTutorial, text_scale=0.06, text_align=TextNode.ACenter, text_wordwrap=22, command=self.__openTutorialDialog, fadeScreen=0.5, style=TTDialog.TwoChoice, buttonTextList=[TTLocalizer.MakeAToonEnterTutorial, TTLocalizer.MakeAToonSkipTutorial], button_text_scale=0.06, buttonPadSF=5.5, sortOrder=NO_FADE_SORT_INDEX)
|
self.promptTutorialDialog = TTDialog.TTDialog(parent=aspect2dp, text=TTLocalizer.PromptTutorial, text_scale=0.06, text_align=TextNode.ACenter, text_wordwrap=22, command=self.__openTutorialDialog, fadeScreen=0.5, style=TTDialog.TwoChoice, buttonTextList=[TTLocalizer.MakeAToonEnterTutorial, TTLocalizer.MakeAToonSkipTutorial], button_text_scale=0.06, buttonPadSF=5.5, sortOrder=DGG.NO_FADE_SORT_INDEX)
|
||||||
self.promptTutorialDialog.show()
|
self.promptTutorialDialog.show()
|
||||||
|
|
||||||
def __openTutorialDialog(self, choice = 0):
|
def __openTutorialDialog(self, choice = 0):
|
||||||
|
|
Loading…
Reference in a new issue