mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-24 04:02:40 -06:00
DANIEL: TalkAssistant cleanup
This commit is contained in:
parent
c513032a49
commit
1749768a8d
16 changed files with 46 additions and 390 deletions
21
dependencies/astron/dclass/stride.dc
vendored
21
dependencies/astron/dclass/stride.dc
vendored
|
@ -12,7 +12,6 @@ from otp.friends import FriendManager/AI
|
|||
from otp.distributed import DistributedDistrict/AI/UD
|
||||
from otp.distributed import DistributedDirectory/AI
|
||||
from otp.chat import ChatAgent/UD
|
||||
from otp.avatar import AvatarHandle
|
||||
|
||||
typedef uint8 bool;
|
||||
|
||||
|
@ -128,30 +127,14 @@ dclass DistributedCamera : DistributedNode {
|
|||
setFixtures(Fixture []) required broadcast ram ownsend airecv;
|
||||
};
|
||||
|
||||
struct TalkModification {
|
||||
uint16 offset;
|
||||
uint16 size;
|
||||
};
|
||||
|
||||
dclass TalkPath_whisper {
|
||||
setTalkWhisper(uint32 avId, string(0-400) chat) ownrecv clsend;
|
||||
};
|
||||
|
||||
dclass TalkPath_group {
|
||||
setTalkGroup(DoId fromAv, DoId fromAcc, string(0-256) avName,
|
||||
string(0-400) chat, TalkModification [], uint8 flags) clsend airecv;
|
||||
};
|
||||
|
||||
dclass AvatarHandle : TalkPath_whisper {
|
||||
};
|
||||
|
||||
dclass DistributedAvatar : DistributedSmoothNode, TalkPath_whisper {
|
||||
dclass DistributedAvatar : DistributedSmoothNode {
|
||||
string DcObjectType db;
|
||||
setName(string = "[Name not set]") required broadcast db airecv;
|
||||
friendsNotify(DoId avId, int8 status) ownrecv airecv;
|
||||
checkAvOnShard(DoId) clsend airecv;
|
||||
confirmAvOnShard(DoId avId, int8 isOnShard);
|
||||
setTalk(string(0-400) chat) broadcast;
|
||||
setTalkWhisper(uint32 avId, string(0-400) chat) ownrecv clsend;
|
||||
};
|
||||
|
||||
struct FriendEntry {
|
||||
|
|
|
@ -8,6 +8,7 @@ import random
|
|||
from otp.ai import MagicWordManager
|
||||
from otp.ai.MagicWordGlobal import *
|
||||
from otp.avatar.ShadowCaster import ShadowCaster
|
||||
from otp.chat import ChatUtil
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from otp.otpbase import OTPRender
|
||||
|
@ -362,8 +363,8 @@ class Avatar(Actor, ShadowCaster):
|
|||
self.clearChat()
|
||||
self.nametag.setChatType(NametagGlobals.CHAT)
|
||||
self.nametag.setChatButton(NametagGlobals.noButton)
|
||||
if base.talkAssistant.isThought(chatString):
|
||||
chatString = base.talkAssistant.removeThoughtPrefix(chatString)
|
||||
if ChatUtil.isThought(chatString):
|
||||
chatString = ChatUtil.removeThoughtPrefix(chatString)
|
||||
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON)
|
||||
self.nametag.setChatText(chatString)
|
||||
else:
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
class AvatarHandle:
|
||||
dclassName = 'AvatarHandle'
|
||||
|
||||
def getName(self):
|
||||
return ''
|
||||
|
||||
def isOnline(self):
|
||||
return False
|
||||
|
||||
def isUnderstandable(self):
|
||||
return True
|
||||
|
||||
def setTalkWhisper(self, avId, chat):
|
||||
pass
|
|
@ -24,19 +24,3 @@ SCQuestEvent = 'SCQuestEvent'
|
|||
OnScreen = 0
|
||||
OffScreen = 1
|
||||
Thought = 2
|
||||
ThoughtPrefix = '.'
|
||||
|
||||
def isThought(message):
|
||||
if len(message) == 0:
|
||||
return 0
|
||||
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def removeThoughtPrefix(message):
|
||||
if isThought(message):
|
||||
return message[len(ThoughtPrefix):]
|
||||
else:
|
||||
return message
|
||||
|
|
|
@ -3,6 +3,7 @@ from direct.showbase import DirectObject
|
|||
from pandac.PandaModules import *
|
||||
import sys
|
||||
|
||||
from otp.chat import ChatUtil
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
@ -38,7 +39,7 @@ class ChatInputNormal(DirectObject.DirectObject):
|
|||
def activateByData(self, whisperAvatarId = None):
|
||||
self.whisperAvatarId = whisperAvatarId
|
||||
if self.whisperAvatarId:
|
||||
self.whisperAvatarName = base.talkAssistant.findAvatarName(self.whisperAvatarId)
|
||||
self.whisperAvatarName = ChatUtil.findAvatarName(self.whisperAvatarId)
|
||||
self.chatFrame.setPos(self.whisperPos)
|
||||
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperAvatarName
|
||||
self.whisperLabel.show()
|
||||
|
|
|
@ -3,6 +3,7 @@ from direct.showbase import DirectObject
|
|||
from pandac.PandaModules import *
|
||||
import sys
|
||||
|
||||
from otp.chat import ChatUtil
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
@ -37,7 +38,7 @@ class ChatInputTyped(DirectObject.DirectObject):
|
|||
self.whisperId = whisperId
|
||||
self.whisperName = None
|
||||
if self.whisperId:
|
||||
self.whisperName = base.talkAssistant.findAvatarName(whisperId)
|
||||
self.whisperName = ChatUtil.findAvatarName(whisperId)
|
||||
if hasattr(self, 'whisperPos'):
|
||||
self.chatFrame.setPos(self.whisperPos)
|
||||
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
|
||||
|
|
|
@ -6,7 +6,7 @@ from direct.showbase import DirectObject
|
|||
from pandac.PandaModules import *
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
||||
import ChatUtil
|
||||
|
||||
ChatEvent = 'ChatEvent'
|
||||
NormalChatEvent = 'NormalChatEvent'
|
||||
|
@ -16,23 +16,6 @@ SCEmoteChatEvent = 'SCEmoteChatEvent'
|
|||
OnScreen = 0
|
||||
OffScreen = 1
|
||||
Thought = 2
|
||||
ThoughtPrefix = '.'
|
||||
|
||||
def isThought(message):
|
||||
if len(message) == 0:
|
||||
return 0
|
||||
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def removeThoughtPrefix(message):
|
||||
if isThought(message):
|
||||
return message[len(ThoughtPrefix):]
|
||||
else:
|
||||
return message
|
||||
|
||||
|
||||
class ChatManager(DirectObject.DirectObject):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('ChatManager')
|
||||
|
@ -106,8 +89,8 @@ class ChatManager(DirectObject.DirectObject):
|
|||
|
||||
def sendChatString(self, message):
|
||||
chatFlags = CFSpeech | CFTimeout
|
||||
if isThought(message):
|
||||
message = removeThoughtPrefix(message)
|
||||
if ChatUtil.isThought(message):
|
||||
message = ChatUtil.removeThoughtPrefix(message)
|
||||
chatFlags = CFThought
|
||||
messenger.send(NormalChatEvent)
|
||||
self.announceChat()
|
||||
|
|
15
otp/chat/ChatUtil.py
Normal file
15
otp/chat/ChatUtil.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
ThoughtPrefix = '.'
|
||||
|
||||
def isThought(message):
|
||||
return message and message.startswith(ThoughtPrefix)
|
||||
|
||||
def removeThoughtPrefix(message):
|
||||
if isThought(message):
|
||||
return message[len(ThoughtPrefix):]
|
||||
else:
|
||||
return message
|
||||
|
||||
def findAvatarName(id):
|
||||
info = base.cr.identifyAvatar(id)
|
||||
|
||||
return info.getName() if info else ''
|
|
@ -1,50 +1,14 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.showbase import DirectObject
|
||||
from pandac.PandaModules import *
|
||||
import sys
|
||||
import time
|
||||
|
||||
from otp.chat.ChatGlobals import *
|
||||
from otp.chat.TalkGlobals import *
|
||||
from otp.chat.TalkHandle import TalkHandle
|
||||
from otp.chat.TalkMessage import TalkMessage
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from otp.speedchat import SCDecoders
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
||||
|
||||
ThoughtPrefix = '.'
|
||||
|
||||
import ChatUtil
|
||||
|
||||
class TalkAssistant(DirectObject.DirectObject):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('TalkAssistant')
|
||||
|
||||
def __init__(self):
|
||||
self.logWhispers = 1
|
||||
self.clearHistory()
|
||||
self.zeroTimeDay = time.time()
|
||||
self.zeroTimeGame = globalClock.getRealTime()
|
||||
self.floodThreshold = 10.0
|
||||
self.lastWhisperDoId = None
|
||||
self.lastWhisper = None
|
||||
self.SCDecoder = SCDecoders
|
||||
return
|
||||
|
||||
def clearHistory(self):
|
||||
self.historyComplete = []
|
||||
self.historyOpen = []
|
||||
self.historyUpdates = []
|
||||
self.historyByDoId = {}
|
||||
self.historyByDISLId = {}
|
||||
self.floodDataByDoId = {}
|
||||
self.spamDictByDoId = {}
|
||||
self.handleDict = {}
|
||||
self.messageCount = 0
|
||||
|
||||
def delete(self):
|
||||
self.ignoreAll()
|
||||
self.clearHistory()
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
@ -52,110 +16,20 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
def stop(self):
|
||||
pass
|
||||
|
||||
def countMessage(self):
|
||||
self.messageCount += 1
|
||||
return self.messageCount - 1
|
||||
|
||||
def getOpenText(self, numLines, startPoint = 0):
|
||||
return self.historyOpen[startPoint:startPoint + numLines]
|
||||
|
||||
def getSizeOpenText(self):
|
||||
return len(self.historyOpen)
|
||||
|
||||
def getCompleteText(self, numLines, startPoint = 0):
|
||||
return self.historyComplete[startPoint:startPoint + numLines]
|
||||
|
||||
def getCompleteTextFromRecent(self, numLines, startPoint = 0):
|
||||
start = len(self.historyComplete) - startPoint
|
||||
if start < 0:
|
||||
start = 0
|
||||
backStart = max(start - numLines, 0)
|
||||
text = self.historyComplete[backStart:start]
|
||||
text.reverse()
|
||||
return text
|
||||
|
||||
def getAllCompleteText(self):
|
||||
return self.historyComplete
|
||||
|
||||
def getAllHistory(self):
|
||||
return self.historyComplete
|
||||
|
||||
def getSizeCompleteText(self):
|
||||
return len(self.historyComplete)
|
||||
|
||||
def getHandle(self, doId):
|
||||
return self.handleDict.get(doId)
|
||||
|
||||
def addToHistoryDISLId(self, message, dISLId, scrubbed = 0):
|
||||
if dISLId not in self.historyByDISLId:
|
||||
self.historyByDISLId[dISLId] = []
|
||||
self.historyByDISLId[dISLId].append(message)
|
||||
|
||||
def addHandle(self, doId, message):
|
||||
if doId == localAvatar.doId:
|
||||
return
|
||||
handle = self.handleDict.get(doId)
|
||||
if not handle:
|
||||
handle = TalkHandle(doId, message)
|
||||
self.handleDict[doId] = handle
|
||||
else:
|
||||
handle.addMessageInfo(message)
|
||||
|
||||
def stampTime(self):
|
||||
return globalClock.getRealTime() - self.zeroTimeGame
|
||||
|
||||
def findAvatarName(self, id):
|
||||
info = base.cr.identifyAvatar(id)
|
||||
|
||||
return info.getName() if info else ''
|
||||
|
||||
def isThought(self, message):
|
||||
if not message:
|
||||
return 0
|
||||
elif len(message) == 0:
|
||||
return 0
|
||||
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
def removeThoughtPrefix(self, message):
|
||||
if self.isThought(message):
|
||||
return message[len(ThoughtPrefix):]
|
||||
else:
|
||||
return message
|
||||
|
||||
def printHistoryComplete(self):
|
||||
print 'HISTORY COMPLETE'
|
||||
for message in self.historyComplete:
|
||||
print '%s %s %s\n%s\n' % (message.getTimeStamp(),
|
||||
message.getSenderAvatarName(),
|
||||
message.getSenderAccountName(),
|
||||
message.getBody())
|
||||
|
||||
def sendOpenTalk(self, message):
|
||||
error = None
|
||||
doId = base.localAvatar.doId
|
||||
if base.config.GetBool('want-talkative-tyler', False):
|
||||
if base.localAvatar.zoneId == 2000:
|
||||
tyler = base.cr.doFind('Talkative Tyler')
|
||||
if tyler:
|
||||
tyler.sendUpdate('talkMessage', [doId, message])
|
||||
if base.cr.wantMagicWords and len(message) > 0 and message[0] == '~':
|
||||
messenger.send('magicWord', [message])
|
||||
else:
|
||||
chatFlags = CFSpeech | CFTimeout
|
||||
if self.isThought(message):
|
||||
if ChatUtil.isThought(message):
|
||||
chatFlags = CFThought
|
||||
base.cr.chatAgent.sendChatMessage(message)
|
||||
messenger.send('chatUpdate', [message, chatFlags])
|
||||
return error
|
||||
|
||||
def sendWhisperTalk(self, message, receiverAvId):
|
||||
base.cr.ttsFriendsManager.sendUpdate('sendTalkWhisper', [receiverAvId, message])
|
||||
|
||||
def sendOpenSpeedChat(self, type, messageIndex):
|
||||
error = None
|
||||
if type == SPEEDCHAT_NORMAL:
|
||||
messenger.send(SCChatEvent)
|
||||
messenger.send('chatUpdateSC', [messageIndex])
|
||||
|
@ -168,26 +42,11 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
messenger.send('chatUpdateSCCustom', [messageIndex])
|
||||
messenger.send(SCCustomChatEvent)
|
||||
base.localAvatar.b_setSCCustom(messageIndex)
|
||||
return error
|
||||
|
||||
def sendAvatarWhisperSpeedChat(self, type, messageIndex, receiverId):
|
||||
error = None
|
||||
if type == SPEEDCHAT_NORMAL:
|
||||
base.localAvatar.whisperSCTo(messageIndex, receiverId)
|
||||
message = self.SCDecoder.decodeSCStaticTextMsg(messageIndex)
|
||||
elif type == SPEEDCHAT_EMOTE:
|
||||
base.localAvatar.whisperSCEmoteTo(messageIndex, receiverId)
|
||||
message = self.SCDecoder.decodeSCEmoteWhisperMsg(messageIndex, localAvatar.getName())
|
||||
elif type == SPEEDCHAT_CUSTOM:
|
||||
base.localAvatar.whisperSCCustomTo(messageIndex, receiverId)
|
||||
message = self.SCDecoder.decodeSCCustomMsg(messageIndex)
|
||||
if self.logWhispers:
|
||||
avatarName = None
|
||||
accountId = None
|
||||
avatar = base.cr.identifyAvatar(receiverId)
|
||||
if avatar:
|
||||
avatarName = avatar.getName()
|
||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, receiverId, avatarName, None, None, TALK_WHISPER, None)
|
||||
self.historyComplete.append(newMessage)
|
||||
messenger.send('NewOpenMessage', [newMessage])
|
||||
return error
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
TALK_NONE = 0
|
||||
TALK_OPEN = 1
|
||||
TALK_WHISPER = 2
|
||||
TALK_PARTY = 3
|
||||
TALK_PVP = 4
|
||||
UPDATE_FRIEND = 5
|
||||
UPDATE_PARTY = 6
|
||||
UPDATE_PVP = 7
|
||||
INFO_SYSTEM = 8
|
||||
INFO_GAME = 9
|
||||
INFO_AVATAR_UNAVAILABLE = 10
|
||||
INFO_OPEN = 11
|
||||
AVATAR_THOUGHT = 12
|
|
@ -1,36 +0,0 @@
|
|||
from otp.avatar.AvatarHandle import AvatarHandle
|
||||
|
||||
class TalkHandle(AvatarHandle):
|
||||
|
||||
def __init__(self, doId, message):
|
||||
self.avatarId = doId
|
||||
self.avatarName = None
|
||||
self.accountId = None
|
||||
self.accountName = None
|
||||
self.addMessageInfo(message)
|
||||
return
|
||||
|
||||
def getName(self):
|
||||
return self.avatarName
|
||||
|
||||
def isUnderstandable(self):
|
||||
return False
|
||||
|
||||
def isOnline(self):
|
||||
return False
|
||||
|
||||
def addMessageInfo(self, message):
|
||||
if self.avatarId == message.getSenderAvatarId():
|
||||
if not self.avatarName and message.getSenderAvatarName():
|
||||
self.avatarName = message.getSenderAvatarName()
|
||||
if not self.accountId and message.getSenderAccountId():
|
||||
self.accountId = message.getSenderAccountId()
|
||||
if not self.accountName and message.getSenderAccountName():
|
||||
self.accountName = message.getSenderAccountName()
|
||||
elif self.avatarId == message.getReceiverAvatarId():
|
||||
if not self.avatarName and message.getReceiverAvatarName():
|
||||
self.avatarName = message.getReceiverAvatarName()
|
||||
if not self.accountId and message.getReceiverAccountId():
|
||||
self.accountId = message.getReceiverAccountId()
|
||||
if not self.accountName and message.getReceiverAccountName():
|
||||
self.accountName = message.getReceiverAccountName()
|
|
@ -1,93 +0,0 @@
|
|||
class TalkMessage:
|
||||
def __init__(self, messageId, timeStamp, body, senderAvatarId, senderAvatarName, senderAccountId, senderAccountName, receiverAvatarId, receiverAvatarName, receiverAccountId, receiverAccountName, talkType, extraInfo = None):
|
||||
self.timeStamp = timeStamp
|
||||
self.body = body
|
||||
self.senderAvatarId = senderAvatarId
|
||||
self.senderAvatarName = senderAvatarName
|
||||
self.senderAccountId = senderAccountId
|
||||
self.senderAccountName = senderAccountName
|
||||
self.receiverAvatarId = receiverAvatarId
|
||||
self.receiverAvatarName = receiverAvatarName
|
||||
self.receiverAccountId = receiverAccountId
|
||||
self.receiverAccountName = receiverAccountName
|
||||
self.talkType = talkType
|
||||
self.extraInfo = extraInfo
|
||||
self.messageId = messageId
|
||||
|
||||
def getMessageId(self):
|
||||
return self.messageId
|
||||
|
||||
def setMessageId(self, id):
|
||||
self.messageId = id
|
||||
|
||||
def getTimeStamp(self):
|
||||
return self.timeStamp
|
||||
|
||||
def setTimeStamp(self, timeStamp):
|
||||
self.timeStamp = timeStamp
|
||||
|
||||
def getBody(self):
|
||||
return self.body
|
||||
|
||||
def setBody(self, body):
|
||||
self.body = body
|
||||
|
||||
def getSenderAvatarId(self):
|
||||
return self.senderAvatarId
|
||||
|
||||
def setSenderAvatarId(self, senderAvatarId):
|
||||
self.senderAvatarId = senderAvatarId
|
||||
|
||||
def getSenderAvatarName(self):
|
||||
return self.senderAvatarName
|
||||
|
||||
def setSenderAvatarName(self, senderAvatarName):
|
||||
self.senderAvatarName = senderAvatarName
|
||||
|
||||
def getSenderAccountId(self):
|
||||
return self.senderAccountId
|
||||
|
||||
def setSenderAccountId(self, senderAccountId):
|
||||
self.senderAccountId = senderAccountId
|
||||
|
||||
def getSenderAccountName(self):
|
||||
return self.senderAccountName
|
||||
|
||||
def setSenderAccountName(self, senderAccountName):
|
||||
self.senderAccountName = senderAccountName
|
||||
|
||||
def getReceiverAvatarId(self):
|
||||
return self.receiverAvatarId
|
||||
|
||||
def setReceiverAvatarId(self, receiverAvatarId):
|
||||
self.receiverAvatarId = receiverAvatarId
|
||||
|
||||
def getReceiverAvatarName(self):
|
||||
return self.receiverAvatarName
|
||||
|
||||
def setReceiverAvatarName(self, receiverAvatarName):
|
||||
self.receiverAvatarName = receiverAvatarName
|
||||
|
||||
def getReceiverAccountId(self):
|
||||
return self.receiverAccountId
|
||||
|
||||
def setReceiverAccountId(self, receiverAccountId):
|
||||
self.receiverAccountId = receiverAccountId
|
||||
|
||||
def getReceiverAccountName(self):
|
||||
return self.receiverAccountName
|
||||
|
||||
def setReceiverAccountName(self, receiverAccountName):
|
||||
self.receiverAccountName = receiverAccountName
|
||||
|
||||
def getTalkType(self):
|
||||
return self.talkType
|
||||
|
||||
def setTalkType(self, talkType):
|
||||
self.talkType = talkType
|
||||
|
||||
def getExtraInfo(self):
|
||||
return self.extraInfo
|
||||
|
||||
def setExtraInfo(self, extraInfo):
|
||||
self.extraInfo = extraInfo
|
|
@ -4,6 +4,7 @@ from otp.otpbase import OTPGlobals
|
|||
import sys
|
||||
from direct.gui.DirectGui import *
|
||||
from pandac.PandaModules import *
|
||||
from otp.chat import ChatUtil
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
|
@ -146,7 +147,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
|||
|
||||
def labelWhisper(self):
|
||||
if self.receiverId:
|
||||
self.whisperName = base.talkAssistant.findAvatarName(self.receiverId)
|
||||
self.whisperName = ChatUtil.findAvatarName(self.receiverId)
|
||||
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
|
||||
self.whisperLabel.show()
|
||||
else:
|
||||
|
|
|
@ -1,34 +1,10 @@
|
|||
import string
|
||||
import sys
|
||||
from direct.showbase import DirectObject
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from toontown.toonbase import TTLocalizer
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.speedchat import SCDecoders
|
||||
from pandac.PandaModules import *
|
||||
from otp.chat.ChatGlobals import *
|
||||
from otp.chat.TalkGlobals import *
|
||||
from otp.speedchat import SpeedChatGlobals
|
||||
from otp.chat.TalkMessage import TalkMessage
|
||||
from otp.chat.TalkAssistant import TalkAssistant
|
||||
from toontown.speedchat import TTSCDecoders
|
||||
import time
|
||||
from otp.chat.ChatGlobals import *
|
||||
|
||||
class TTTalkAssistant(TalkAssistant):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('TTTalkAssistant')
|
||||
|
||||
def __init__(self):
|
||||
TalkAssistant.__init__(self)
|
||||
|
||||
def clearHistory(self):
|
||||
TalkAssistant.clearHistory(self)
|
||||
|
||||
def sendToonTaskSpeedChat(self, taskId, toNpcId, toonProgress, msgIndex):
|
||||
error = None
|
||||
messenger.send(SCChatEvent)
|
||||
messenger.send('chatUpdateSCToontask', [taskId,
|
||||
toNpcId,
|
||||
toonProgress,
|
||||
msgIndex])
|
||||
return error
|
||||
messenger.send('chatUpdateSCToontask', [taskId, toNpcId, toonProgress, msgIndex])
|
|
@ -17,14 +17,22 @@ class DistributedSmartNPC(DistributedNPCToonBase):
|
|||
|
||||
def __init__(self, cr):
|
||||
DistributedNPCToonBase.__init__(self, cr)
|
||||
self.accept('chatUpdate', self.chatUpdate)
|
||||
|
||||
def disable(self):
|
||||
self.ignoreAll()
|
||||
DistributedNPCToonBase.disable(self)
|
||||
|
||||
def delayDelete(self):
|
||||
DistributedNPCToonBase.delayDelete(self)
|
||||
DistributedNPCToonBase.disable(self)
|
||||
self.disable()
|
||||
|
||||
def handleCollisionSphereEnter(self, collEntry):
|
||||
self.sendUpdate('avatarEnter', [])
|
||||
|
||||
def chatUpdate(self, message):
|
||||
self.sendUpdate('talkMessage', [base.localAvatar.doId, message])
|
||||
|
||||
def greet(self, npcId, avId):
|
||||
if avId in base.cr.doId2do:
|
||||
avName = base.cr.doId2do.get(avId).getName()
|
||||
|
|
|
@ -21,7 +21,7 @@ import Toon
|
|||
from otp.ai.MagicWordGlobal import *
|
||||
from otp.avatar import Avatar, DistributedAvatar
|
||||
from otp.avatar import DistributedPlayer
|
||||
from otp.chat import TalkAssistant
|
||||
from otp.chat import TalkAssistant, ChatUtil
|
||||
from otp.otpbase import OTPGlobals
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from otp.speedchat import SCDecoders
|
||||
|
@ -2159,10 +2159,10 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
|||
def displayTalk(self, chatString):
|
||||
flags = CFSpeech | CFTimeout
|
||||
self.nametag.setChatType(NametagGlobals.CHAT)
|
||||
if base.talkAssistant.isThought(chatString):
|
||||
if ChatUtil.isThought(chatString):
|
||||
flags = CFThought
|
||||
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON)
|
||||
chatString = base.talkAssistant.removeThoughtPrefix(chatString)
|
||||
chatString = ChatUtil.removeThoughtPrefix(chatString)
|
||||
else:
|
||||
self.nametag.setChatBalloonType(NametagGlobals.CHAT_BALLOON)
|
||||
self.nametag.setChatText(chatString, timeout=(flags & CFTimeout))
|
||||
|
|
Loading…
Reference in a new issue