2015-03-03 16:10:12 -06:00
|
|
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
|
|
|
from direct.distributed.DistributedObjectGlobal import DistributedObjectGlobal
|
|
|
|
import hmac
|
2015-06-23 18:11:48 -05:00
|
|
|
from panda3d.core import *
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
from otp.distributed.PotentialAvatar import PotentialAvatar
|
|
|
|
from otp.otpbase import OTPGlobals
|
2015-06-26 02:09:27 -05:00
|
|
|
from otp.nametag.NametagConstants import WTSystem
|
|
|
|
from otp.margins.WhisperPopup import WhisperPopup
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
|
|
|
|
class ClientServicesManager(DistributedObjectGlobal):
|
|
|
|
notify = directNotify.newCategory('ClientServicesManager')
|
|
|
|
|
|
|
|
# --- LOGIN LOGIC ---
|
|
|
|
def performLogin(self, doneEvent):
|
|
|
|
self.doneEvent = doneEvent
|
|
|
|
|
|
|
|
self.systemMessageSfx = None
|
|
|
|
|
|
|
|
token = self.cr.playToken or 'dev'
|
|
|
|
|
2015-03-13 12:46:16 -05:00
|
|
|
key = 'c603c5833021ce79f734943f6e662250fd4ecf7432bf85905f71707dc4a9370c6ae15a8716302ead43810e5fba3cf0876bbbfce658e2767b88d916f5d89fd31'
|
2015-03-03 16:10:12 -06:00
|
|
|
digest_maker = hmac.new(key)
|
|
|
|
digest_maker.update(token)
|
|
|
|
clientKey = digest_maker.hexdigest()
|
|
|
|
|
|
|
|
self.sendUpdate('login', [token, clientKey])
|
|
|
|
|
|
|
|
def acceptLogin(self, timestamp):
|
|
|
|
messenger.send(self.doneEvent, [{'mode': 'success', 'timestamp': timestamp}])
|
|
|
|
|
|
|
|
|
|
|
|
# --- AVATARS LIST ---
|
|
|
|
def requestAvatars(self):
|
|
|
|
self.sendUpdate('requestAvatars')
|
|
|
|
|
2015-08-13 16:31:23 -05:00
|
|
|
def setAvatars(self, chatSettings, avatars):
|
2015-03-03 16:10:12 -06:00
|
|
|
avList = []
|
|
|
|
for avNum, avName, avDNA, avPosition, nameState in avatars:
|
|
|
|
nameOpen = int(nameState == 1)
|
|
|
|
names = [avName, '', '', '']
|
|
|
|
if nameState == 2: # PENDING
|
|
|
|
names[1] = avName
|
|
|
|
elif nameState == 3: # APPROVED
|
|
|
|
names[2] = avName
|
|
|
|
elif nameState == 4: # REJECTED
|
|
|
|
names[3] = avName
|
|
|
|
avList.append(PotentialAvatar(avNum, names, avDNA, avPosition, nameOpen))
|
|
|
|
|
2015-08-13 16:31:23 -05:00
|
|
|
self.cr.handleChatSettings(chatSettings)
|
2015-03-03 16:10:12 -06:00
|
|
|
self.cr.handleAvatarsList(avList)
|
|
|
|
|
|
|
|
# --- AVATAR CREATION/DELETION ---
|
2015-05-30 10:06:50 -05:00
|
|
|
def sendCreateAvatar(self, avDNA, _, index):
|
|
|
|
self.sendUpdate('createAvatar', [avDNA.makeNetString(), index])
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def createAvatarResp(self, avId):
|
|
|
|
messenger.send('nameShopCreateAvatarDone', [avId])
|
|
|
|
|
|
|
|
def sendDeleteAvatar(self, avId):
|
|
|
|
self.sendUpdate('deleteAvatar', [avId])
|
|
|
|
|
|
|
|
# No deleteAvatarResp; it just sends a setAvatars when the deed is done.
|
|
|
|
|
|
|
|
# --- AVATAR NAMING ---
|
|
|
|
def sendSetNameTyped(self, avId, name, callback):
|
|
|
|
self._callback = callback
|
|
|
|
self.sendUpdate('setNameTyped', [avId, name])
|
|
|
|
|
|
|
|
def setNameTypedResp(self, avId, status):
|
|
|
|
self._callback(avId, status)
|
|
|
|
|
|
|
|
def sendSetNamePattern(self, avId, p1, f1, p2, f2, p3, f3, p4, f4, callback):
|
|
|
|
self._callback = callback
|
|
|
|
self.sendUpdate('setNamePattern', [avId, p1, f1, p2, f2, p3, f3, p4, f4])
|
|
|
|
|
|
|
|
def setNamePatternResp(self, avId, status):
|
|
|
|
self._callback(avId, status)
|
|
|
|
|
|
|
|
def sendAcknowledgeAvatarName(self, avId, callback):
|
|
|
|
self._callback = callback
|
|
|
|
self.sendUpdate('acknowledgeAvatarName', [avId])
|
|
|
|
|
|
|
|
def acknowledgeAvatarNameResp(self):
|
|
|
|
self._callback()
|
|
|
|
|
|
|
|
# --- AVATAR CHOICE ---
|
|
|
|
def sendChooseAvatar(self, avId):
|
|
|
|
self.sendUpdate('chooseAvatar', [avId])
|
|
|
|
|
|
|
|
def systemMessage(self, message):
|
|
|
|
whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WTSystem)
|
|
|
|
whisper.manage(base.marginManager)
|
|
|
|
|
|
|
|
if self.systemMessageSfx is None:
|
|
|
|
self.systemMessageSfx = base.loadSfx('phase_3/audio/sfx/clock03.ogg')
|
|
|
|
|
2015-03-13 12:46:16 -05:00
|
|
|
base.playSfx(self.systemMessageSfx)
|