class TTChatInputSpeedChat(DirectObject.DirectObject): DefaultSCColorScheme = SCColorScheme() def __init__(self, chatMgr): self.chatMgr = chatMgr self.firstTime = 0 self.whisperAvatarId = None self.toPlayer = 0 buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') okButtonImage = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')) self.emoteNoAccessPanel = DirectFrame(parent=hidden, relief=None, state='normal', text=OTPLocalizer.SCEmoteNoAccessMsg, frameSize=(-1, 1, -1, 1), geom=DGG.getDefaultDialogGeom(), geom_color=OTPGlobals.GlobalDialogColor, geom_scale=(0.92, 1, 0.6), geom_pos=(0, 0, -.08), text_scale=0.08) self.okButton = DirectButton(parent=self.emoteNoAccessPanel, image=okButtonImage, relief=None, text=OTPLocalizer.SCEmoteNoAccessOK, text_scale=0.05, text_pos=(0.0, -0.1), textMayChange=0, pos=(0.0, 0.0, -0.2), command=self.handleEmoteNoAccessDone) self.insidePartiesMenu = None self.createSpeedChat() self.whiteList = None self.allowWhiteListSpeedChat = base.config.GetBool('white-list-speed-chat', 0) if self.allowWhiteListSpeedChat: self.addWhiteList() self.factoryMenu = None self.kartRacingMenu = None self.cogMenu = None self.cfoMenu = None self.cjMenu = None self.ceoMenu = None self.golfMenu = None self.boardingGroupMenu = None self.singingGroupMenu = None self.aprilToonsMenu = None self.victoryPartiesMenu = None self.sillyPhaseOneMenu = None self.sillyPhaseTwoMenu = None self.sillyPhaseThreeMenu = None self.sillyPhaseFourMenu = None self.sillyPhaseFiveMenu = None self.sellbotNerfMenu = None self.jellybeanJamMenu = None self.halloweenMenu = None self.winterMenu = None self.sellbotInvasionMenu = None self.sellbotFieldOfficeMenu = None self.idesOfMarchMenu = None def listenForSCEvent(eventBaseName, handler, self = self): eventName = self.speedChat.getEventName(eventBaseName) self.accept(eventName, handler) listenForSCEvent(SpeedChatGlobals.SCTerminalLinkedEmoteEvent, self.handleLinkedEmote) listenForSCEvent(SpeedChatGlobals.SCStaticTextMsgEvent, self.handleStaticTextMsg) listenForSCEvent(SpeedChatGlobals.SCCustomMsgEvent, self.handleCustomMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteMsgEvent, self.handleEmoteMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteNoAccessEvent, self.handleEmoteNoAccess) listenForSCEvent(TTSpeedChatGlobals.TTSCToontaskMsgEvent, self.handleToontaskMsg) listenForSCEvent(TTSpeedChatGlobals.TTSCResistanceMsgEvent, self.handleResistanceMsg) listenForSCEvent(TTSCSingingTerminal.TTSCSingingMsgEvent, self.handleSingingMsg) listenForSCEvent('SpeedChatStyleChange', self.handleSpeedChatStyleChange) listenForSCEvent(TTSCIndexedTerminal.TTSCIndexedMsgEvent, self.handleStaticTextMsg) self.fsm = ClassicFSM.ClassicFSM('SpeedChat', [State.State('off', self.enterOff, self.exitOff, ['active']), State.State('active', self.enterActive, self.exitActive, ['off'])], 'off', 'off') self.fsm.enterInitialState() return def delete(self): self.ignoreAll() self.removeWhiteList() self.okButton.destroy() self.emoteNoAccessPanel.destroy() del self.emoteNoAccessPanel self.speedChat.destroy() del self.speedChat del self.fsm del self.chatMgr def show(self, whisperAvatarId = None, toPlayer = 0): self.whisperAvatarId = whisperAvatarId self.toPlayer = toPlayer self.fsm.request('active') def hide(self): self.fsm.request('off') def createSpeedChat(self): structure = [] if launcher and not launcher.isTestServer() or __dev__: structure.append([TTSCPromotionalMenu, OTPLocalizer.SCMenuPromotion]) structure.append([SCEmoteMenu, OTPLocalizer.SCMenuEmotions]) structure.append([SCCustomMenu, OTPLocalizer.SCMenuCustom]) structure.append([TTSCResistanceMenu, OTPLocalizer.SCMenuResistance]) if hasattr(base, 'wantPets') and base.wantPets: structure += scPetMenuStructure structure += scStructure self.createSpeedChatObject(structure) self.enterActive() def enterOff(self): pass def exitOff(self): pass def enterActive(self): def handleCancel(self = self): self.chatMgr.fsm.request('mainMenu') self.accept('mouse1', handleCancel) def selectionMade(self = self): self.chatMgr.fsm.request('mainMenu') self.terminalSelectedEvent = self.speedChat.getEventName(SpeedChatGlobals.SCTerminalSelectedEvent) if base.config.GetBool('want-sc-auto-hide', 1): self.accept(self.terminalSelectedEvent, selectionMade) self.speedChat.reparentTo(base.a2dpTopLeft, DGG.FOREGROUND_SORT_INDEX) scZ = -0.04 self.speedChat.setPos(0.283, 0, scZ) if not self.firstTime: self.speedChat.setPos(-99, -99, -99) self.firstTime = 1 self.speedChat.setWhisperMode(self.whisperAvatarId != None) self.speedChat.enter() return def exitActive(self): self.ignore('mouse1') self.ignore(self.terminalSelectedEvent) self.speedChat.exit() self.speedChat.reparentTo(hidden) self.emoteNoAccessPanel.reparentTo(hidden) def handleLinkedEmote(self, emoteId): if self.whisperAvatarId is None: lt = base.localAvatar lt.b_setEmoteState(emoteId, animMultiplier=lt.animMultiplier) return def handleStaticTextMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCChatMessage(textId) else: self.chatMgr.sendSCWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleSingingMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCSingingChatMessage(textId) else: self.chatMgr.sendSCSingingWhisperMessage(textId) self.toPlayer = 0 return def handleCustomMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCCustomChatMessage(textId) else: self.chatMgr.sendSCCustomWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleEmoteMsg(self, emoteId): if self.whisperAvatarId is None: self.chatMgr.sendSCEmoteChatMessage(emoteId) else: self.chatMgr.sendSCEmoteWhisperMessage(emoteId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleEmoteNoAccess(self): if self.whisperAvatarId is None: self.emoteNoAccessPanel.setPos(0, 0, 0) else: self.emoteNoAccessPanel.setPos(0.37, 0, 0) self.emoteNoAccessPanel.reparentTo(aspect2d) return def handleEmoteNoAccessDone(self): self.emoteNoAccessPanel.reparentTo(hidden) def handleToontaskMsg(self, taskId, toNpcId, toonProgress, msgIndex): if self.whisperAvatarId is None: self.chatMgr.sendSCToontaskChatMessage(taskId, toNpcId, toonProgress, msgIndex) else: self.chatMgr.sendSCToontaskWhisperMessage(taskId, toNpcId, toonProgress, msgIndex, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleResistanceMsg(self, textId): self.chatMgr.sendSCResistanceChatMessage(textId) def handleSpeedChatStyleChange(self): nameKey, arrowColor, rolloverColor, frameColor = speedChatStyles[base.localAvatar.getSpeedChatStyleIndex()] newSCColorScheme = SCColorScheme(arrowColor=arrowColor, rolloverColor=rolloverColor, frameColor=frameColor) self.speedChat.setColorScheme(newSCColorScheme) def createSpeedChatObject(self, structure): if hasattr(self, 'speedChat'): self.speedChat.exit() self.speedChat.destroy() del self.speedChat self.speedChat = SpeedChat(structure=structure, backgroundModelName='phase_3/models/gui/ChatPanel', guiModelName='phase_3.5/models/gui/speedChatGui') self.speedChat.setScale(TTLocalizer.TTCISCspeedChat) self.speedChat.setBin('gui-popup', 0) self.speedChat.setTopLevelOverlap(TTLocalizer.TTCISCtopLevelOverlap) self.speedChat.setColorScheme(self.DefaultSCColorScheme) self.speedChat.finalizeAll() def addFactoryMenu(self): if self.factoryMenu == None: menu = TTSCFactoryMenu() self.factoryMenu = SCMenuHolder(OTPLocalizer.SCMenuFactory, menu=menu) self.speedChat[2:2] = [self.factoryMenu] return def removeFactoryMenu(self): if self.factoryMenu: i = self.speedChat.index(self.factoryMenu) del self.speedChat[i] self.factoryMenu.destroy() self.factoryMenu = None return def addKartRacingMenu(self): if self.kartRacingMenu == None: menu = TTSCKartRacingMenu() self.kartRacingMenu = SCMenuHolder(OTPLocalizer.SCMenuKartRacing, menu=menu) self.speedChat[2:2] = [self.kartRacingMenu] return def removeKartRacingMenu(self): if self.kartRacingMenu: i = self.speedChat.index(self.kartRacingMenu) del self.speedChat[i] self.kartRacingMenu.destroy() self.kartRacingMenu = None return def addCogMenu(self, indices): if self.cogMenu == None: menu = TTSCCogMenu(indices) self.cogMenu = SCMenuHolder(OTPLocalizer.SCMenuCog, menu=menu) self.speedChat[2:2] = [self.cogMenu] return def removeCogMenu(self): if self.cogMenu: i = self.speedChat.index(self.cogMenu) del self.speedChat[i] self.cogMenu.destroy() self.cogMenu = None return def addCFOMenu(self): if self.cfoMenu == None: menu = SCMenu() menu.rebuildFromStructure(cfoMenuStructure) self.cfoMenu = SCMenuHolder(OTPLocalizer.SCMenuCFOBattle, menu=menu) self.speedChat[2:2] = [self.cfoMenu] return def removeCFOMenu(self): if self.cfoMenu: i = self.speedChat.index(self.cfoMenu) del self.speedChat[i] self.cfoMenu.destroy() self.cfoMenu = None return def addCJMenu(self, bonusWeight = -1): if self.cjMenu == None: menu = SCMenu() myMenuCopy = cjMenuStructure[:] if bonusWeight >= 0: myMenuCopy.append(2211 + bonusWeight) menu.rebuildFromStructure(myMenuCopy) self.cjMenu = SCMenuHolder(OTPLocalizer.SCMenuCJBattle, menu=menu) self.speedChat[2:2] = [self.cjMenu] return def removeCJMenu(self): if self.cjMenu: i = self.speedChat.index(self.cjMenu) del self.speedChat[i] self.cjMenu.destroy() self.cjMenu = None return def addCEOMenu(self): if self.ceoMenu == None: menu = SCMenu() menu.rebuildFromStructure(ceoMenuStructure) self.ceoMenu = SCMenuHolder(OTPLocalizer.SCMenuCEOBattle, menu=menu) self.speedChat[2:2] = [self.ceoMenu] return def removeCEOMenu(self): if self.ceoMenu: i = self.speedChat.index(self.ceoMenu) del self.speedChat[i] self.ceoMenu.destroy() self.ceoMenu = None return def addInsidePartiesMenu(self): def isActivityInParty(activityId): activityList = base.distributedParty.partyInfo.activityList for activity in activityList: if activity.activityId == activityId: return True return False def isDecorInParty(decorId): decorList = base.distributedParty.partyInfo.decors for decor in decorList: if decor.decorId == decorId: return True return False insidePartiesMenuStructure = [5305, 5306, 5307, 5308, 5309] if self.insidePartiesMenu == None: menu = SCMenu() if hasattr(base, 'distributedParty') and base.distributedParty: if base.distributedParty.partyInfo.hostId == localAvatar.doId: insidePartiesMenuStructure.insert(0, 5304) if isActivityInParty(0): insidePartiesMenuStructure.extend([5310, 5311]) if isActivityInParty(1): insidePartiesMenuStructure.append(5312) if isActivityInParty(2): insidePartiesMenuStructure.extend([5313, 5314]) if isActivityInParty(3): insidePartiesMenuStructure.append(5315) if isActivityInParty(4): insidePartiesMenuStructure.extend([5316, 5317]) if isActivityInParty(5): insidePartiesMenuStructure.append(5318) if isActivityInParty(6): insidePartiesMenuStructure.extend([5319, 5320]) if len(base.distributedParty.partyInfo.decors): insidePartiesMenuStructure.append(5321) if isDecorInParty(3): insidePartiesMenuStructure.append(5322) menu.rebuildFromStructure(insidePartiesMenuStructure) self.insidePartiesMenu = SCMenuHolder(OTPLocalizer.SCMenuParties, menu=menu) self.speedChat[2:2] = [self.insidePartiesMenu] return def removeInsidePartiesMenu(self): if self.insidePartiesMenu: i = self.speedChat.index(self.insidePartiesMenu) del self.speedChat[i] self.insidePartiesMenu.destroy() self.insidePartiesMenu = None return def addGolfMenu(self): if self.golfMenu == None: menu = TTSCGolfMenu() self.golfMenu = SCMenuHolder(OTPLocalizer.SCMenuGolf, menu=menu) self.speedChat[2:2] = [self.golfMenu] return def removeGolfMenu(self): if self.golfMenu: i = self.speedChat.index(self.golfMenu) del self.speedChat[i] self.golfMenu.destroy() self.golfMenu = None return def addBoardingGroupMenu(self, zoneId): if self.boardingGroupMenu == None: menu = TTSCBoardingMenu(zoneId) self.boardingGroupMenu = SCMenuHolder(OTPLocalizer.SCMenuBoardingGroup, menu=menu) self.speedChat[2:2] = [self.boardingGroupMenu] return def removeBoardingGroupMenu(self): if self.boardingGroupMenu: i = self.speedChat.index(self.boardingGroupMenu) del self.speedChat[i] self.boardingGroupMenu.destroy() self.boardingGroupMenu = None return def addSingingGroupMenu(self): if self.singingGroupMenu == None: menu = TTSCSingingMenu() self.singingGroupMenu = SCMenuHolder(OTPLocalizer.SCMenuSingingGroup, menu=menu) self.speedChat[2:2] = [self.singingGroupMenu] return def removeSingingMenu(self): if self.singingGroupMenu: i = self.speedChat.index(self.singingGroupMenu) del self.speedChat[i] self.singingGroupMenu.destroy() self.singingGroupMenu = None return def addAprilToonsMenu(self): if self.aprilToonsMenu == None: menu = TTSCAprilToonsMenu() self.aprilToonsMenu = SCMenuHolder(OTPLocalizer.SCMenuAprilToons, menu=menu) self.speedChat[3:3] = [self.aprilToonsMenu] return def removeAprilToonsMenu(self): if self.aprilToonsMenu: i = self.speedChat.index(self.aprilToonsMenu) del self.speedChat[i] self.aprilToonsMenu.destroy() self.aprilToonsMenu = None return def addSillyPhaseOneMenu(self): if self.sillyPhaseOneMenu == None: menu = TTSCSillyPhaseOneMenu() self.sillyPhaseOneMenu = SCMenuHolder(OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseOneMenu] return def removeSillyPhaseOneMenu(self): if self.sillyPhaseOneMenu: i = self.speedChat.index(self.sillyPhaseOneMenu) del self.speedChat[i] self.sillyPhaseOneMenu.destroy() self.sillyPhaseOneMenu = None return def addSillyPhaseTwoMenu(self): if self.sillyPhaseTwoMenu == None: menu = TTSCSillyPhaseTwoMenu() self.sillyPhaseTwoMenu = SCMenuHolder(OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseTwoMenu] return def removeSillyPhaseTwoMenu(self): if self.sillyPhaseTwoMenu: i = self.speedChat.index(self.sillyPhaseTwoMenu) del self.speedChat[i] self.sillyPhaseTwoMenu.destroy() self.sillyPhaseTwoMenu = None return def addSillyPhaseThreeMenu(self): if self.sillyPhaseThreeMenu == None: menu = TTSCSillyPhaseThreeMenu() self.sillyPhaseThreeMenu = SCMenuHolder(OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseThreeMenu] return def removeSillyPhaseThreeMenu(self): if self.sillyPhaseThreeMenu: i = self.speedChat.index(self.sillyPhaseThreeMenu) del self.speedChat[i] self.sillyPhaseThreeMenu.destroy() self.sillyPhaseThreeMenu = None return def addSillyPhaseFourMenu(self): if self.sillyPhaseFourMenu == None: menu = TTSCSillyPhaseFourMenu() self.sillyPhaseFourMenu = SCMenuHolder(OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFourMenu] return def removeSillyPhaseFourMenu(self): if self.sillyPhaseFourMenu: i = self.speedChat.index(self.sillyPhaseFourMenu) del self.speedChat[i] self.sillyPhaseFourMenu.destroy() self.sillyPhaseFourMenu = None return def addSillyPhaseFiveMenu(self): if self.sillyPhaseFiveMenu == None: menu = TTSCSillyPhaseFiveMenu() self.sillyPhaseFiveMenu = SCMenuHolder(OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFiveMenu] return def removeSillyPhaseFiveMenu(self): if self.sillyPhaseFiveMenu: i = self.speedChat.index(self.sillyPhaseFiveMenu) del self.speedChat[i] self.sillyPhaseFiveMenu.destroy() self.sillyPhaseFiveMenu = None return def addVictoryPartiesMenu(self): if self.victoryPartiesMenu == None: menu = TTSCVictoryPartiesMenu() self.victoryPartiesMenu = SCMenuHolder(OTPLocalizer.SCMenuVictoryParties, menu=menu) self.speedChat[3:3] = [self.victoryPartiesMenu] return def removeVictoryPartiesMenu(self): if self.victoryPartiesMenu: i = self.speedChat.index(self.victoryPartiesMenu) del self.speedChat[i] self.victoryPartiesMenu.destroy() self.victoryPartiesMenu = None return def addSellbotNerfMenu(self): if self.sellbotNerfMenu == None: menu = TTSCSellbotNerfMenu() self.sellbotNerfMenu = SCMenuHolder(OTPLocalizer.SCMenuSellbotNerf, menu=menu) self.speedChat[2:2] = [self.sellbotNerfMenu] return def removeSellbotNerfMenu(self): if self.sellbotNerfMenu: i = self.speedChat.index(self.sellbotNerfMenu) del self.speedChat[i] self.sellbotNerfMenu.destroy() self.sellbotNerfMenu = None return def addJellybeanJamMenu(self, phase): if self.jellybeanJamMenu == None: menu = TTSCJellybeanJamMenu(phase) self.jellybeanJamMenu = SCMenuHolder(OTPLocalizer.SCMenuJellybeanJam, menu=menu) self.speedChat[2:2] = [self.jellybeanJamMenu] return def removeJellybeanJamMenu(self): if self.jellybeanJamMenu: i = self.speedChat.index(self.jellybeanJamMenu) del self.speedChat[i] self.jellybeanJamMenu.destroy() self.jellybeanJamMenu = None return def addHalloweenMenu(self): if self.halloweenMenu == None: menu = TTSCHalloweenMenu() self.halloweenMenu = SCMenuHolder(OTPLocalizer.SCMenuHalloween, menu=menu) self.speedChat[2:2] = [self.halloweenMenu] return def removeHalloweenMenu(self): if self.halloweenMenu: i = self.speedChat.index(self.halloweenMenu) del self.speedChat[i] self.halloweenMenu.destroy() self.halloweenMenu = None return def addWinterMenu(self, carol = False): if self.winterMenu == None: menu = TTSCWinterMenu(carol) self.winterMenu = SCMenuHolder(OTPLocalizer.SCMenuWinter, menu=menu) self.speedChat[2:2] = [self.winterMenu] return def removeWinterMenu(self): if self.winterMenu: i = self.speedChat.index(self.winterMenu) del self.speedChat[i] self.winterMenu.destroy() self.winterMenu = None return def addCarolMenu(self): self.removeWinterMenu() self.addWinterMenu(carol=True) def removeCarolMenu(self): pass def addWhiteList(self): if self.whiteList == None: from toontown.chat.TTSCWhiteListTerminal import TTSCWhiteListTerminal self.whiteList = TTSCWhiteListTerminal(4, self) self.speedChat[1:1] = [self.whiteList] return def removeWhiteList(self): if self.whiteList: i = self.speedChat.index(self.whiteList) del self.speedChat[i] self.whiteList.destroy() self.whiteList = None return def addSellbotInvasionMenu(self): if self.sellbotInvasionMenu == None: menu = TTSCSellbotInvasionMenu() self.sellbotInvasionMenu = SCMenuHolder(OTPLocalizer.SCMenuSellbotInvasion, menu=menu) self.speedChat[2:2] = [self.sellbotInvasionMenu] return def removeSellbotInvasionMenu(self): if self.sellbotInvasionMenu: i = self.speedChat.index(self.sellbotInvasionMenu) del self.speedChat[i] self.sellbotInvasionMenu.destroy() self.sellbotInvasionMenu = None return def addSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu == None: menu = TTSCSellbotFieldOfficeMenu() self.sellbotFieldOfficeMenu = SCMenuHolder(OTPLocalizer.SCMenuFieldOffice, menu=menu) self.speedChat[2:2] = [self.sellbotFieldOfficeMenu] return def removeSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu: i = self.speedChat.index(self.sellbotFieldOfficeMenu) del self.speedChat[i] self.sellbotFieldOfficeMenu.destroy() self.sellbotFieldOfficeMenu = None return def addIdesOfMarchMenu(self): if self.idesOfMarchMenu == None: menu = TTSCIdesOfMarchMenu() self.idesOfMarchMenu = SCMenuHolder(OTPLocalizer.SCMenuIdesOfMarch, menu=menu) self.speedChat[2:2] = [self.idesOfMarchMenu] return def removeIdesOfMarchMenu(self): if self.idesOfMarchMenu: i = self.speedChat.index(self.idesOfMarchMenu) del self.speedChat[i] self.idesOfMarchMenu.destroy() self.idesOfMarchMenu = None return
class TTChatInputSpeedChat(DirectObject.DirectObject): __module__ = __name__ DefaultSCColorScheme = SCColorScheme() def __init__(self, chatMgr): self.chatMgr = chatMgr self.whisperAvatarId = None self.toPlayer = 0 buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') okButtonImage = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')) self.emoteNoAccessPanel = DirectFrame( parent=hidden, relief=None, state='normal', text=OTPLocalizer.SCEmoteNoAccessMsg, frameSize=(-1, 1, -1, 1), geom=DGG.getDefaultDialogGeom(), geom_color=OTPGlobals.GlobalDialogColor, geom_scale=(0.92, 1, 0.6), geom_pos=(0, 0, -0.08), text_scale=0.08) self.okButton = DirectButton(parent=self.emoteNoAccessPanel, image=okButtonImage, relief=None, text=OTPLocalizer.SCEmoteNoAccessOK, text_scale=0.05, text_pos=(0.0, -0.1), textMayChange=0, pos=(0.0, 0.0, -0.2), command=self.handleEmoteNoAccessDone) self.insidePartiesMenu = None self.createSpeedChat() self.whiteList = None self.allowWhiteListSpeedChat = base.config.GetBool( 'white-list-speed-chat', 0) if self.allowWhiteListSpeedChat: self.addWhiteList() self.factoryMenu = None self.kartRacingMenu = None self.cogMenu = None self.cfoMenu = None self.cjMenu = None self.ceoMenu = None self.golfMenu = None self.boardingGroupMenu = None self.singingGroupMenu = None self.aprilToonsMenu = None self.victoryPartiesMenu = None self.sillyPhaseOneMenu = None self.sillyPhaseTwoMenu = None self.sillyPhaseThreeMenu = None self.sillyPhaseFourMenu = None self.sillyPhaseFiveMenu = None self.sellbotNerfMenu = None self.jellybeanJamMenu = None self.halloweenMenu = None self.winterMenu = None self.sellbotInvasionMenu = None self.sellbotFieldOfficeMenu = None self.idesOfMarchMenu = None def listenForSCEvent(eventBaseName, handler, self=self): eventName = self.speedChat.getEventName(eventBaseName) self.accept(eventName, handler) listenForSCEvent(SpeedChatGlobals.SCTerminalLinkedEmoteEvent, self.handleLinkedEmote) listenForSCEvent(SpeedChatGlobals.SCStaticTextMsgEvent, self.handleStaticTextMsg) listenForSCEvent(SpeedChatGlobals.SCCustomMsgEvent, self.handleCustomMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteMsgEvent, self.handleEmoteMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteNoAccessEvent, self.handleEmoteNoAccess) listenForSCEvent(TTSpeedChatGlobals.TTSCToontaskMsgEvent, self.handleToontaskMsg) listenForSCEvent(TTSpeedChatGlobals.TTSCResistanceMsgEvent, self.handleResistanceMsg) listenForSCEvent(TTSCSingingTerminal.TTSCSingingMsgEvent, self.handleSingingMsg) listenForSCEvent('SpeedChatStyleChange', self.handleSpeedChatStyleChange) listenForSCEvent(TTSCIndexedTerminal.TTSCIndexedMsgEvent, self.handleStaticTextMsg) self.fsm = ClassicFSM.ClassicFSM('SpeedChat', [ State.State('off', self.enterOff, self.exitOff, ['active']), State.State('active', self.enterActive, self.exitActive, ['off']) ], 'off', 'off') self.fsm.enterInitialState() return def delete(self): self.ignoreAll() self.removeWhiteList() self.okButton.destroy() self.emoteNoAccessPanel.destroy() del self.emoteNoAccessPanel self.speedChat.destroy() del self.speedChat del self.fsm del self.chatMgr def show(self, whisperAvatarId=None, toPlayer=0): self.whisperAvatarId = whisperAvatarId self.toPlayer = toPlayer self.fsm.request('active') def hide(self): self.fsm.request('off') def createSpeedChat(self): structure = [] if launcher and not launcher.isTestServer() or __dev__: structure.append( [TTSCPromotionalMenu, OTPLocalizer.SCMenuPromotion]) structure.append([SCEmoteMenu, OTPLocalizer.SCMenuEmotions]) structure.append([SCCustomMenu, OTPLocalizer.SCMenuCustom]) structure.append([TTSCResistanceMenu, OTPLocalizer.SCMenuResistance]) if hasattr(base, 'wantPets') and base.wantPets: structure += scPetMenuStructure structure += scStructure self.createSpeedChatObject(structure) def enterOff(self): pass def exitOff(self): pass def enterActive(self): def handleCancel(self=self): self.chatMgr.fsm.request('mainMenu') self.accept('mouse1', handleCancel) def selectionMade(self=self): self.chatMgr.fsm.request('mainMenu') self.terminalSelectedEvent = self.speedChat.getEventName( SpeedChatGlobals.SCTerminalSelectedEvent) if base.config.GetBool('want-sc-auto-hide', 1): self.accept(self.terminalSelectedEvent, selectionMade) self.speedChat.reparentTo(aspect2dp, DGG.FOREGROUND_SORT_INDEX) scZ = 0.96 self.speedChat.setPos(-1.05, 0, scZ) self.speedChat.setWhisperMode(self.whisperAvatarId != None) self.speedChat.enter() return def exitActive(self): self.ignore('mouse1') self.ignore(self.terminalSelectedEvent) self.speedChat.exit() self.speedChat.reparentTo(hidden) self.emoteNoAccessPanel.reparentTo(hidden) def handleLinkedEmote(self, emoteId): if self.whisperAvatarId is None: lt = base.localAvatar lt.b_setEmoteState(emoteId, animMultiplier=lt.animMultiplier) return def handleStaticTextMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCChatMessage(textId) else: self.chatMgr.sendSCWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleSingingMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCSingingChatMessage(textId) else: self.chatMgr.sendSCSingingWhisperMessage(textId) self.toPlayer = 0 return def handleCustomMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCCustomChatMessage(textId) else: self.chatMgr.sendSCCustomWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleEmoteMsg(self, emoteId): if self.whisperAvatarId is None: self.chatMgr.sendSCEmoteChatMessage(emoteId) else: self.chatMgr.sendSCEmoteWhisperMessage(emoteId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleEmoteNoAccess(self): if self.whisperAvatarId is None: self.emoteNoAccessPanel.setPos(0, 0, 0) else: self.emoteNoAccessPanel.setPos(0.37, 0, 0) self.emoteNoAccessPanel.reparentTo(aspect2d) return def handleEmoteNoAccessDone(self): self.emoteNoAccessPanel.reparentTo(hidden) def handleToontaskMsg(self, taskId, toNpcId, toonProgress, msgIndex): if self.whisperAvatarId is None: self.chatMgr.sendSCToontaskChatMessage(taskId, toNpcId, toonProgress, msgIndex) else: self.chatMgr.sendSCToontaskWhisperMessage(taskId, toNpcId, toonProgress, msgIndex, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 return def handleResistanceMsg(self, textId): self.chatMgr.sendSCResistanceChatMessage(textId) def handleSpeedChatStyleChange(self): nameKey, arrowColor, rolloverColor, frameColor = speedChatStyles[ base.localAvatar.getSpeedChatStyleIndex()] newSCColorScheme = SCColorScheme(arrowColor=arrowColor, rolloverColor=rolloverColor, frameColor=frameColor) self.speedChat.setColorScheme(newSCColorScheme) def createSpeedChatObject(self, structure): if hasattr(self, 'speedChat'): self.speedChat.exit() self.speedChat.destroy() del self.speedChat self.speedChat = SpeedChat( structure=structure, backgroundModelName='phase_3/models/gui/ChatPanel', guiModelName='phase_3.5/models/gui/speedChatGui') self.speedChat.setScale(TTLocalizer.TTCISCspeedChat) self.speedChat.setBin('gui-popup', 0) self.speedChat.setTopLevelOverlap(TTLocalizer.TTCISCtopLevelOverlap) self.speedChat.setColorScheme(self.DefaultSCColorScheme) self.speedChat.finalizeAll() def addFactoryMenu(self): if self.factoryMenu == None: menu = TTSCFactoryMenu() self.factoryMenu = SCMenuHolder(OTPLocalizer.SCMenuFactory, menu=menu) self.speedChat[2:2] = [self.factoryMenu] return def removeFactoryMenu(self): if self.factoryMenu: i = self.speedChat.index(self.factoryMenu) del self.speedChat[i] self.factoryMenu.destroy() self.factoryMenu = None return def addKartRacingMenu(self): if self.kartRacingMenu == None: menu = TTSCKartRacingMenu() self.kartRacingMenu = SCMenuHolder(OTPLocalizer.SCMenuKartRacing, menu=menu) self.speedChat[2:2] = [self.kartRacingMenu] return def removeKartRacingMenu(self): if self.kartRacingMenu: i = self.speedChat.index(self.kartRacingMenu) del self.speedChat[i] self.kartRacingMenu.destroy() self.kartRacingMenu = None return def addCogMenu(self, indices): if self.cogMenu == None: menu = TTSCCogMenu(indices) self.cogMenu = SCMenuHolder(OTPLocalizer.SCMenuCog, menu=menu) self.speedChat[2:2] = [self.cogMenu] return def removeCogMenu(self): if self.cogMenu: i = self.speedChat.index(self.cogMenu) del self.speedChat[i] self.cogMenu.destroy() self.cogMenu = None return def addCFOMenu(self): if self.cfoMenu == None: menu = SCMenu() menu.rebuildFromStructure(cfoMenuStructure) self.cfoMenu = SCMenuHolder(OTPLocalizer.SCMenuCFOBattle, menu=menu) self.speedChat[2:2] = [self.cfoMenu] return def removeCFOMenu(self): if self.cfoMenu: i = self.speedChat.index(self.cfoMenu) del self.speedChat[i] self.cfoMenu.destroy() self.cfoMenu = None return def addCJMenu(self, bonusWeight=-1): if self.cjMenu == None: menu = SCMenu() myMenuCopy = cjMenuStructure[:] if bonusWeight >= 0: myMenuCopy.append(2211 + bonusWeight) menu.rebuildFromStructure(myMenuCopy) self.cjMenu = SCMenuHolder(OTPLocalizer.SCMenuCJBattle, menu=menu) self.speedChat[2:2] = [self.cjMenu] return def removeCJMenu(self): if self.cjMenu: i = self.speedChat.index(self.cjMenu) del self.speedChat[i] self.cjMenu.destroy() self.cjMenu = None return def addCEOMenu(self): if self.ceoMenu == None: menu = SCMenu() menu.rebuildFromStructure(ceoMenuStructure) self.ceoMenu = SCMenuHolder(OTPLocalizer.SCMenuCEOBattle, menu=menu) self.speedChat[2:2] = [self.ceoMenu] return def removeCEOMenu(self): if self.ceoMenu: i = self.speedChat.index(self.ceoMenu) del self.speedChat[i] self.ceoMenu.destroy() self.ceoMenu = None return def addInsidePartiesMenu(self): def isActivityInParty(activityId): activityList = base.distributedParty.partyInfo.activityList for activity in activityList: if activity.activityId == activityId: return True return False def isDecorInParty(decorId): decorList = base.distributedParty.partyInfo.decors for decor in decorList: if decor.decorId == decorId: return True return False insidePartiesMenuStructure = [5305, 5306, 5307, 5308, 5309] if self.insidePartiesMenu == None: menu = SCMenu() if hasattr(base, 'distributedParty') and base.distributedParty: if base.distributedParty.partyInfo.hostId == localAvatar.doId: insidePartiesMenuStructure.insert(0, 5304) if isActivityInParty(0): insidePartiesMenuStructure.extend([5310, 5311]) if isActivityInParty(1): insidePartiesMenuStructure.append(5312) if isActivityInParty(2): insidePartiesMenuStructure.extend([5313, 5314]) if isActivityInParty(3): insidePartiesMenuStructure.append(5315) if isActivityInParty(4): insidePartiesMenuStructure.extend([5316, 5317]) if isActivityInParty(5): insidePartiesMenuStructure.append(5318) if isActivityInParty(6): insidePartiesMenuStructure.extend([5319, 5320]) if len(base.distributedParty.partyInfo.decors): insidePartiesMenuStructure.append(5321) if isDecorInParty(3): insidePartiesMenuStructure.append(5322) menu.rebuildFromStructure(insidePartiesMenuStructure) self.insidePartiesMenu = SCMenuHolder(OTPLocalizer.SCMenuParties, menu=menu) self.speedChat[2:2] = [self.insidePartiesMenu] return def removeInsidePartiesMenu(self): if self.insidePartiesMenu: i = self.speedChat.index(self.insidePartiesMenu) del self.speedChat[i] self.insidePartiesMenu.destroy() self.insidePartiesMenu = None return def addGolfMenu(self): if self.golfMenu == None: menu = TTSCGolfMenu() self.golfMenu = SCMenuHolder(OTPLocalizer.SCMenuGolf, menu=menu) self.speedChat[2:2] = [self.golfMenu] return def removeGolfMenu(self): if self.golfMenu: i = self.speedChat.index(self.golfMenu) del self.speedChat[i] self.golfMenu.destroy() self.golfMenu = None return def addBoardingGroupMenu(self, zoneId): if self.boardingGroupMenu == None: menu = TTSCBoardingMenu(zoneId) self.boardingGroupMenu = SCMenuHolder( OTPLocalizer.SCMenuBoardingGroup, menu=menu) self.speedChat[2:2] = [self.boardingGroupMenu] return def removeBoardingGroupMenu(self): if self.boardingGroupMenu: i = self.speedChat.index(self.boardingGroupMenu) del self.speedChat[i] self.boardingGroupMenu.destroy() self.boardingGroupMenu = None return def addSingingGroupMenu(self): if self.singingGroupMenu == None: menu = TTSCSingingMenu() self.singingGroupMenu = SCMenuHolder( OTPLocalizer.SCMenuSingingGroup, menu=menu) self.speedChat[2:2] = [self.singingGroupMenu] return def removeSingingMenu(self): if self.singingGroupMenu: i = self.speedChat.index(self.singingGroupMenu) del self.speedChat[i] self.singingGroupMenu.destroy() self.singingGroupMenu = None return def addAprilToonsMenu(self): if self.aprilToonsMenu == None: menu = TTSCAprilToonsMenu() self.aprilToonsMenu = SCMenuHolder(OTPLocalizer.SCMenuAprilToons, menu=menu) self.speedChat[3:3] = [self.aprilToonsMenu] return def removeAprilToonsMenu(self): if self.aprilToonsMenu: i = self.speedChat.index(self.aprilToonsMenu) del self.speedChat[i] self.aprilToonsMenu.destroy() self.aprilToonsMenu = None return def addSillyPhaseOneMenu(self): if self.sillyPhaseOneMenu == None: menu = TTSCSillyPhaseOneMenu() self.sillyPhaseOneMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseOneMenu] return def removeSillyPhaseOneMenu(self): if self.sillyPhaseOneMenu: i = self.speedChat.index(self.sillyPhaseOneMenu) del self.speedChat[i] self.sillyPhaseOneMenu.destroy() self.sillyPhaseOneMenu = None return def addSillyPhaseTwoMenu(self): if self.sillyPhaseTwoMenu == None: menu = TTSCSillyPhaseTwoMenu() self.sillyPhaseTwoMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseTwoMenu] return def removeSillyPhaseTwoMenu(self): if self.sillyPhaseTwoMenu: i = self.speedChat.index(self.sillyPhaseTwoMenu) del self.speedChat[i] self.sillyPhaseTwoMenu.destroy() self.sillyPhaseTwoMenu = None return def addSillyPhaseThreeMenu(self): if self.sillyPhaseThreeMenu == None: menu = TTSCSillyPhaseThreeMenu() self.sillyPhaseThreeMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseThreeMenu] return def removeSillyPhaseThreeMenu(self): if self.sillyPhaseThreeMenu: i = self.speedChat.index(self.sillyPhaseThreeMenu) del self.speedChat[i] self.sillyPhaseThreeMenu.destroy() self.sillyPhaseThreeMenu = None return def addSillyPhaseFourMenu(self): if self.sillyPhaseFourMenu == None: menu = TTSCSillyPhaseFourMenu() self.sillyPhaseFourMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFourMenu] return def removeSillyPhaseFourMenu(self): if self.sillyPhaseFourMenu: i = self.speedChat.index(self.sillyPhaseFourMenu) del self.speedChat[i] self.sillyPhaseFourMenu.destroy() self.sillyPhaseFourMenu = None return def addSillyPhaseFiveMenu(self): if self.sillyPhaseFiveMenu == None: menu = TTSCSillyPhaseFiveMenu() self.sillyPhaseFiveMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFiveMenu] return def removeSillyPhaseFiveMenu(self): if self.sillyPhaseFiveMenu: i = self.speedChat.index(self.sillyPhaseFiveMenu) del self.speedChat[i] self.sillyPhaseFiveMenu.destroy() self.sillyPhaseFiveMenu = None return def addVictoryPartiesMenu(self): if self.victoryPartiesMenu == None: menu = TTSCVictoryPartiesMenu() self.victoryPartiesMenu = SCMenuHolder( OTPLocalizer.SCMenuVictoryParties, menu=menu) self.speedChat[3:3] = [self.victoryPartiesMenu] return def removeVictoryPartiesMenu(self): if self.victoryPartiesMenu: i = self.speedChat.index(self.victoryPartiesMenu) del self.speedChat[i] self.victoryPartiesMenu.destroy() self.victoryPartiesMenu = None return def addSellbotNerfMenu(self): if self.sellbotNerfMenu == None: menu = TTSCSellbotNerfMenu() self.sellbotNerfMenu = SCMenuHolder(OTPLocalizer.SCMenuSellbotNerf, menu=menu) self.speedChat[2:2] = [self.sellbotNerfMenu] return def removeSellbotNerfMenu(self): if self.sellbotNerfMenu: i = self.speedChat.index(self.sellbotNerfMenu) del self.speedChat[i] self.sellbotNerfMenu.destroy() self.sellbotNerfMenu = None return def addJellybeanJamMenu(self, phase): if self.jellybeanJamMenu == None: menu = TTSCJellybeanJamMenu(phase) self.jellybeanJamMenu = SCMenuHolder( OTPLocalizer.SCMenuJellybeanJam, menu=menu) self.speedChat[2:2] = [self.jellybeanJamMenu] return def removeJellybeanJamMenu(self): if self.jellybeanJamMenu: i = self.speedChat.index(self.jellybeanJamMenu) del self.speedChat[i] self.jellybeanJamMenu.destroy() self.jellybeanJamMenu = None return def addHalloweenMenu(self): if self.halloweenMenu == None: menu = TTSCHalloweenMenu() self.halloweenMenu = SCMenuHolder(OTPLocalizer.SCMenuHalloween, menu=menu) self.speedChat[2:2] = [self.halloweenMenu] return def removeHalloweenMenu(self): if self.halloweenMenu: i = self.speedChat.index(self.halloweenMenu) del self.speedChat[i] self.halloweenMenu.destroy() self.halloweenMenu = None return def addWinterMenu(self, carol=False): if self.winterMenu == None: menu = TTSCWinterMenu(carol) self.winterMenu = SCMenuHolder(OTPLocalizer.SCMenuWinter, menu=menu) self.speedChat[2:2] = [self.winterMenu] return def removeWinterMenu(self): if self.winterMenu: i = self.speedChat.index(self.winterMenu) del self.speedChat[i] self.winterMenu.destroy() self.winterMenu = None return def addCarolMenu(self): self.removeWinterMenu() self.addWinterMenu(carol=True) def removeCarolMenu(self): pass def addWhiteList(self): if self.whiteList == None: from toontown.chat.TTSCWhiteListTerminal import TTSCWhiteListTerminal self.whiteList = TTSCWhiteListTerminal(4, self) self.speedChat[1:1] = [self.whiteList] return def removeWhiteList(self): if self.whiteList: i = self.speedChat.index(self.whiteList) del self.speedChat[i] self.whiteList.destroy() self.whiteList = None return def addSellbotInvasionMenu(self): if self.sellbotInvasionMenu == None: menu = TTSCSellbotInvasionMenu() self.sellbotInvasionMenu = SCMenuHolder( OTPLocalizer.SCMenuSellbotInvasion, menu=menu) self.speedChat[2:2] = [self.sellbotInvasionMenu] return def removeSellbotInvasionMenu(self): if self.sellbotInvasionMenu: i = self.speedChat.index(self.sellbotInvasionMenu) del self.speedChat[i] self.sellbotInvasionMenu.destroy() self.sellbotInvasionMenu = None return def addSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu == None: menu = TTSCSellbotFieldOfficeMenu() self.sellbotFieldOfficeMenu = SCMenuHolder( OTPLocalizer.SCMenuFieldOffice, menu=menu) self.speedChat[2:2] = [self.sellbotFieldOfficeMenu] return def removeSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu: i = self.speedChat.index(self.sellbotFieldOfficeMenu) del self.speedChat[i] self.sellbotFieldOfficeMenu.destroy() self.sellbotFieldOfficeMenu = None return def addIdesOfMarchMenu(self): if self.idesOfMarchMenu == None: menu = TTSCIdesOfMarchMenu() self.idesOfMarchMenu = SCMenuHolder(OTPLocalizer.SCMenuIdesOfMarch, menu=menu) self.speedChat[2:2] = [self.idesOfMarchMenu] return def removeIdesOfMarchMenu(self): if self.idesOfMarchMenu: i = self.speedChat.index(self.idesOfMarchMenu) del self.speedChat[i] self.idesOfMarchMenu.destroy() self.idesOfMarchMenu = None return
class TTChatInputSpeedChat(DirectObject.DirectObject): """TTChatInputSpeedChat class: controls the SpeedChat, and generates SpeedChat messages""" DefaultSCColorScheme = SCColorScheme() # special methods def __init__(self, chatMgr): self.chatMgr = chatMgr self.whisperAvatarId = None self.toPlayer = 0 # create the panel that tells the user that they don't have # access to an emotion yet buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') okButtonImage = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')) self.emoteNoAccessPanel = DirectFrame( parent=hidden, relief=None, state='normal', text=OTPLocalizer.SCEmoteNoAccessMsg, frameSize=(-1, 1, -1, 1), geom=DGG.getDefaultDialogGeom(), geom_color=OTPGlobals.GlobalDialogColor, geom_scale=(.92, 1, .6), geom_pos=(0, 0, -.08), text_scale=.08, ) self.okButton = DirectButton(parent=self.emoteNoAccessPanel, image=okButtonImage, relief=None, text=OTPLocalizer.SCEmoteNoAccessOK, text_scale=0.05, text_pos=(0.0, -0.1), textMayChange=0, pos=(0.0, 0.0, -0.2), command=self.handleEmoteNoAccessDone) self.insidePartiesMenu = None self.createSpeedChat() self.whiteList = None self.allowWhiteListSpeedChat = ConfigVariableBool( 'white-list-speed-chat', 0).getValue() if self.allowWhiteListSpeedChat: self.addWhiteList() self.factoryMenu = None self.kartRacingMenu = None self.cogMenu = None self.cfoMenu = None self.cjMenu = None self.ceoMenu = None self.golfMenu = None self.boardingGroupMenu = None self.singingGroupMenu = None self.aprilToonsMenu = None # self.carolMenu = None self.victoryPartiesMenu = None self.sillyPhaseOneMenu = None self.sillyPhaseTwoMenu = None self.sillyPhaseThreeMenu = None self.sillyPhaseFourMenu = None self.sillyPhaseFiveMenu = None self.sellbotNerfMenu = None self.jellybeanJamMenu = None self.halloweenMenu = None self.winterMenu = None self.sellbotInvasionMenu = None self.sellbotFieldOfficeMenu = None self.idesOfMarchMenu = None if __debug__: base.speedChat = self.speedChat # listen for selection messages def listenForSCEvent(eventBaseName, handler, self=self): eventName = self.speedChat.getEventName(eventBaseName) self.accept(eventName, handler) listenForSCEvent(SpeedChatGlobals.SCTerminalLinkedEmoteEvent, self.handleLinkedEmote) listenForSCEvent(SpeedChatGlobals.SCStaticTextMsgEvent, self.handleStaticTextMsg) listenForSCEvent(SpeedChatGlobals.SCCustomMsgEvent, self.handleCustomMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteMsgEvent, self.handleEmoteMsg) listenForSCEvent(SpeedChatGlobals.SCEmoteNoAccessEvent, self.handleEmoteNoAccess) listenForSCEvent(TTSpeedChatGlobals.TTSCToontaskMsgEvent, self.handleToontaskMsg) listenForSCEvent(TTSpeedChatGlobals.TTSCResistanceMsgEvent, self.handleResistanceMsg) listenForSCEvent(TTSCSingingTerminal.TTSCSingingMsgEvent, self.handleSingingMsg) listenForSCEvent("SpeedChatStyleChange", self.handleSpeedChatStyleChange) listenForSCEvent(TTSCIndexedTerminal.TTSCIndexedMsgEvent, self.handleStaticTextMsg) self.fsm = ClassicFSM.ClassicFSM( 'SpeedChat', [ State.State('off', self.enterOff, self.exitOff, ['active']), State.State('active', self.enterActive, self.exitActive, ['off']), ], # Initial state 'off', # Final state 'off', ) self.fsm.enterInitialState() def delete(self): self.ignoreAll() self.removeWhiteList() self.okButton.destroy() self.emoteNoAccessPanel.destroy() del self.emoteNoAccessPanel self.speedChat.destroy() del self.speedChat del self.fsm del self.chatMgr def show(self, whisperAvatarId=None, toPlayer=0): self.whisperAvatarId = whisperAvatarId self.toPlayer = toPlayer self.fsm.request("active") def hide(self): self.fsm.request("off") def createSpeedChat(self): # If we have them configed on, add some menus to the top of the # speedchat. structure = [] if (launcher and not launcher.isTestServer()) or __dev__: # menu title will be overwritten structure.append( [TTSCPromotionalMenu, OTPLocalizer.SCMenuPromotion]) structure.append([SCEmoteMenu, OTPLocalizer.SCMenuEmotions]) structure.append([SCCustomMenu, OTPLocalizer.SCMenuCustom]) structure.append([TTSCResistanceMenu, OTPLocalizer.SCMenuResistance]) if hasattr(base, 'wantPets') and base.wantPets: structure += scPetMenuStructure structure += scStructure self.createSpeedChatObject(structure) ### ClassicFSM STATE HANDLERS # 'off' state def enterOff(self): pass def exitOff(self): pass # 'active' state def enterActive(self): # if they click anywhere else, close up def handleCancel(self=self): self.chatMgr.fsm.request("mainMenu") self.accept('mouse1', handleCancel) # listen for any selection event from the SpeedChat menu def selectionMade(self=self): self.chatMgr.fsm.request("mainMenu") self.terminalSelectedEvent = self.speedChat.getEventName( SpeedChatGlobals.SCTerminalSelectedEvent) if ConfigVariableBool('want-sc-auto-hide', 1).getValue(): # We're not hiding the whole speedchat after a single phrase is selected. # Hence, we're not accepting self.terminalSelectedEvent any more. self.accept(self.terminalSelectedEvent, selectionMade) # set up the menu self.speedChat.reparentTo(base.a2dpTopLeft, DGG.FOREGROUND_SORT_INDEX) scZ = -0.04 self.speedChat.setPos(0.283, 0, scZ) self.speedChat.setWhisperMode(self.whisperAvatarId != None) self.speedChat.enter() def exitActive(self): self.ignore('mouse1') self.ignore(self.terminalSelectedEvent) self.speedChat.exit() self.speedChat.reparentTo(hidden) self.emoteNoAccessPanel.reparentTo(hidden) # these handle selection messages coming from the speedchat object def handleLinkedEmote(self, emoteId): # don't do the emote if we're whispering if self.whisperAvatarId is None: lt = base.localAvatar lt.b_setEmoteState(emoteId, animMultiplier=lt.animMultiplier) def handleStaticTextMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCChatMessage(textId) else: self.chatMgr.sendSCWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 def handleSingingMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCSingingChatMessage(textId) else: self.chatMgr.sendSCSingingWhisperMessage(textId) self.toPlayer = 0 def handleCustomMsg(self, textId): if self.whisperAvatarId is None: self.chatMgr.sendSCCustomChatMessage(textId) else: self.chatMgr.sendSCCustomWhisperMessage(textId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 def handleEmoteMsg(self, emoteId): if self.whisperAvatarId is None: self.chatMgr.sendSCEmoteChatMessage(emoteId) else: self.chatMgr.sendSCEmoteWhisperMessage(emoteId, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 def handleEmoteNoAccess(self): if self.whisperAvatarId is None: self.emoteNoAccessPanel.setPos(0, 0, 0) else: self.emoteNoAccessPanel.setPos(.37, 0, 0) self.emoteNoAccessPanel.reparentTo(aspect2d) def handleEmoteNoAccessDone(self): self.emoteNoAccessPanel.reparentTo(hidden) def handleToontaskMsg(self, taskId, toNpcId, toonProgress, msgIndex): if self.whisperAvatarId is None: self.chatMgr.sendSCToontaskChatMessage(taskId, toNpcId, toonProgress, msgIndex) else: self.chatMgr.sendSCToontaskWhisperMessage(taskId, toNpcId, toonProgress, msgIndex, self.whisperAvatarId, self.toPlayer) self.toPlayer = 0 def handleResistanceMsg(self, textId): self.chatMgr.sendSCResistanceChatMessage(textId) def handleSpeedChatStyleChange(self): # get the color scheme information nameKey, arrowColor, rolloverColor, frameColor = \ speedChatStyles[base.localAvatar.getSpeedChatStyleIndex()] # create the new color scheme object newSCColorScheme = SCColorScheme( arrowColor=arrowColor, rolloverColor=rolloverColor, frameColor=frameColor, ) # set the new color scheme self.speedChat.setColorScheme(newSCColorScheme) def createSpeedChatObject(self, structure): if hasattr(self, 'speedChat'): self.speedChat.exit() self.speedChat.destroy() del self.speedChat # get a speedchat object self.speedChat = SpeedChat( structure=structure, backgroundModelName='phase_3/models/gui/ChatPanel', guiModelName='phase_3.5/models/gui/speedChatGui') self.speedChat.setScale(TTLocalizer.CISCspeedChat) self.speedChat.setBin('gui-popup', 0) self.speedChat.setTopLevelOverlap(TTLocalizer.CISCtopLevelOverlap) self.speedChat.setColorScheme(self.DefaultSCColorScheme) # tell the speedchat to generate the gui elements for the entire # tree, so that the menu won't be chuggy the first time it's used self.speedChat.finalizeAll() def addFactoryMenu(self): if self.factoryMenu == None: menu = TTSCFactoryMenu() self.factoryMenu = SCMenuHolder(OTPLocalizer.SCMenuFactory, menu=menu) self.speedChat[2:2] = [self.factoryMenu] def removeFactoryMenu(self): if self.factoryMenu: i = self.speedChat.index(self.factoryMenu) del self.speedChat[i] self.factoryMenu.destroy() self.factoryMenu = None # methods for creating Kart Racing speed chat menus def addKartRacingMenu(self): if self.kartRacingMenu == None: menu = TTSCKartRacingMenu() self.kartRacingMenu = SCMenuHolder(OTPLocalizer.SCMenuKartRacing, menu=menu) self.speedChat[2:2] = [self.kartRacingMenu] def removeKartRacingMenu(self): if self.kartRacingMenu: i = self.speedChat.index(self.kartRacingMenu) del self.speedChat[i] self.kartRacingMenu.destroy() self.kartRacingMenu = None def addCogMenu(self, indices): if self.cogMenu == None: menu = TTSCCogMenu(indices) self.cogMenu = SCMenuHolder(OTPLocalizer.SCMenuCog, menu=menu) self.speedChat[2:2] = [self.cogMenu] def removeCogMenu(self): if self.cogMenu: i = self.speedChat.index(self.cogMenu) del self.speedChat[i] self.cogMenu.destroy() self.cogMenu = None def addCFOMenu(self): if self.cfoMenu == None: menu = SCMenu() menu.rebuildFromStructure(cfoMenuStructure) self.cfoMenu = SCMenuHolder(OTPLocalizer.SCMenuCFOBattle, menu=menu) self.speedChat[2:2] = [self.cfoMenu] def removeCFOMenu(self): if self.cfoMenu: i = self.speedChat.index(self.cfoMenu) del self.speedChat[i] self.cfoMenu.destroy() self.cfoMenu = None def addCJMenu(self, bonusWeight=-1): """ If bonusWeight is -1, don't show the bonus weight option at all """ if self.cjMenu == None: menu = SCMenu() myMenuCopy = cjMenuStructure[:] if bonusWeight >= 0: myMenuCopy.append(2211 + bonusWeight) menu.rebuildFromStructure(myMenuCopy) self.cjMenu = SCMenuHolder(OTPLocalizer.SCMenuCJBattle, menu=menu) self.speedChat[2:2] = [self.cjMenu] def removeCJMenu(self): if self.cjMenu: i = self.speedChat.index(self.cjMenu) del self.speedChat[i] self.cjMenu.destroy() self.cjMenu = None def addCEOMenu(self): if self.ceoMenu == None: menu = SCMenu() menu.rebuildFromStructure(ceoMenuStructure) self.ceoMenu = SCMenuHolder(OTPLocalizer.SCMenuCEOBattle, menu=menu) self.speedChat[2:2] = [self.ceoMenu] def removeCEOMenu(self): if self.ceoMenu: i = self.speedChat.index(self.ceoMenu) del self.speedChat[i] self.ceoMenu.destroy() self.ceoMenu = None def addInsidePartiesMenu(self): """Add the party phrases that can be said inside a party.""" def isActivityInParty(activityId): activityList = base.distributedParty.partyInfo.activityList for activity in activityList: if (activity.activityId == activityId): return True return False def isDecorInParty(decorId): decorList = base.distributedParty.partyInfo.decors for decor in decorList: if (decor.decorId == decorId): return True return False # This is the basic parties speedchat list. insidePartiesMenuStructure = [5305, 5306, 5307, 5308, 5309] if self.insidePartiesMenu == None: menu = SCMenu() # Add elements to the basic list on a case by case basic. if hasattr(base, 'distributedParty') and base.distributedParty: # Add host specific speedchat elements. if (base.distributedParty.partyInfo.hostId == localAvatar.doId ): insidePartiesMenuStructure.insert(0, 5304) # Add Jukebox specific speedchat elements. if isActivityInParty(0): insidePartiesMenuStructure.extend([5310, 5311]) # Add Cannons specific speedchat elements. if isActivityInParty(1): insidePartiesMenuStructure.append(5312) # Add Trampolines specific speedchat elements. if isActivityInParty(2): insidePartiesMenuStructure.extend([5313, 5314]) # Add Catch Game specific speedchat elements. if isActivityInParty(3): insidePartiesMenuStructure.append(5315) # Add Dance Floor specific speedchat elements. if isActivityInParty(4): insidePartiesMenuStructure.extend([5316, 5317]) # Add Tug of War specific speedchat elements. if isActivityInParty(5): insidePartiesMenuStructure.append(5318) # Add Fireworks specific speedchat elements. if isActivityInParty(6): insidePartiesMenuStructure.extend([5319, 5320]) # Add Decoration specific speedchat elements. if len(base.distributedParty.partyInfo.decors): insidePartiesMenuStructure.append(5321) # Add Birthday Cake specific speedchat elements. if isDecorInParty(3): insidePartiesMenuStructure.append(5322) menu.rebuildFromStructure(insidePartiesMenuStructure) self.insidePartiesMenu = SCMenuHolder(OTPLocalizer.SCMenuParties, menu=menu) self.speedChat[2:2] = [self.insidePartiesMenu] def removeInsidePartiesMenu(self): """Remove party phrases that can be said inside a party.""" if self.insidePartiesMenu: i = self.speedChat.index(self.insidePartiesMenu) del self.speedChat[i] self.insidePartiesMenu.destroy() self.insidePartiesMenu = None # methods for creating Golf speed chat menus def addGolfMenu(self): if self.golfMenu == None: menu = TTSCGolfMenu() self.golfMenu = SCMenuHolder(OTPLocalizer.SCMenuGolf, menu=menu) self.speedChat[2:2] = [self.golfMenu] def removeGolfMenu(self): if self.golfMenu: i = self.speedChat.index(self.golfMenu) del self.speedChat[i] self.golfMenu.destroy() self.golfMenu = None # Methods for creating Boarding Group chat menus def addBoardingGroupMenu(self, zoneId): if (self.boardingGroupMenu == None): menu = TTSCBoardingMenu(zoneId) self.boardingGroupMenu = SCMenuHolder( OTPLocalizer.SCMenuBoardingGroup, menu=menu) self.speedChat[2:2] = [self.boardingGroupMenu] def removeBoardingGroupMenu(self): if self.boardingGroupMenu: i = self.speedChat.index(self.boardingGroupMenu) del self.speedChat[i] self.boardingGroupMenu.destroy() self.boardingGroupMenu = None # Methods for creating Singing chat menus def addSingingGroupMenu(self): if (self.singingGroupMenu == None): menu = TTSCSingingMenu() self.singingGroupMenu = SCMenuHolder( OTPLocalizer.SCMenuSingingGroup, menu=menu) self.speedChat[2:2] = [self.singingGroupMenu] def removeSingingMenu(self): if self.singingGroupMenu: i = self.speedChat.index(self.singingGroupMenu) del self.speedChat[i] self.singingGroupMenu.destroy() self.singingGroupMenu = None # Methods for creating April toons' chat menus def addAprilToonsMenu(self): if (self.aprilToonsMenu == None): menu = TTSCAprilToonsMenu() self.aprilToonsMenu = SCMenuHolder(OTPLocalizer.SCMenuAprilToons, menu=menu) self.speedChat[3:3] = [self.aprilToonsMenu] def removeAprilToonsMenu(self): if self.aprilToonsMenu: i = self.speedChat.index(self.aprilToonsMenu) del self.speedChat[i] self.aprilToonsMenu.destroy() self.aprilToonsMenu = None def addSillyPhaseOneMenu(self): if (self.sillyPhaseOneMenu == None): menu = TTSCSillyPhaseOneMenu() self.sillyPhaseOneMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseOneMenu] def removeSillyPhaseOneMenu(self): if self.sillyPhaseOneMenu: i = self.speedChat.index(self.sillyPhaseOneMenu) del self.speedChat[i] self.sillyPhaseOneMenu.destroy() self.sillyPhaseOneMenu = None def addSillyPhaseTwoMenu(self): if (self.sillyPhaseTwoMenu == None): menu = TTSCSillyPhaseTwoMenu() self.sillyPhaseTwoMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseTwoMenu] def removeSillyPhaseTwoMenu(self): if self.sillyPhaseTwoMenu: i = self.speedChat.index(self.sillyPhaseTwoMenu) del self.speedChat[i] self.sillyPhaseTwoMenu.destroy() self.sillyPhaseTwoMenu = None def addSillyPhaseThreeMenu(self): if (self.sillyPhaseThreeMenu == None): menu = TTSCSillyPhaseThreeMenu() self.sillyPhaseThreeMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseThreeMenu] def removeSillyPhaseThreeMenu(self): if self.sillyPhaseThreeMenu: i = self.speedChat.index(self.sillyPhaseThreeMenu) del self.speedChat[i] self.sillyPhaseThreeMenu.destroy() self.sillyPhaseThreeMenu = None def addSillyPhaseFourMenu(self): if (self.sillyPhaseFourMenu == None): menu = TTSCSillyPhaseFourMenu() self.sillyPhaseFourMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFourMenu] def removeSillyPhaseFourMenu(self): if self.sillyPhaseFourMenu: i = self.speedChat.index(self.sillyPhaseFourMenu) del self.speedChat[i] self.sillyPhaseFourMenu.destroy() self.sillyPhaseFourMenu = None def addSillyPhaseFiveMenu(self): if (self.sillyPhaseFiveMenu == None): menu = TTSCSillyPhaseFiveMenu() self.sillyPhaseFiveMenu = SCMenuHolder( OTPLocalizer.SCMenuSillyHoliday, menu=menu) self.speedChat[3:3] = [self.sillyPhaseFiveMenu] def removeSillyPhaseFiveMenu(self): if self.sillyPhaseFiveMenu: i = self.speedChat.index(self.sillyPhaseFiveMenu) del self.speedChat[i] self.sillyPhaseFiveMenu.destroy() self.sillyPhaseFiveMenu = None def addVictoryPartiesMenu(self): if self.victoryPartiesMenu == None: menu = TTSCVictoryPartiesMenu() self.victoryPartiesMenu = SCMenuHolder( OTPLocalizer.SCMenuVictoryParties, menu=menu) self.speedChat[3:3] = [self.victoryPartiesMenu] def removeVictoryPartiesMenu(self): if self.victoryPartiesMenu: i = self.speedChat.index(self.victoryPartiesMenu) del self.speedChat[i] self.victoryPartiesMenu.destroy() self.victoryPartiesMenu = None def addSellbotNerfMenu(self): if self.sellbotNerfMenu == None: menu = TTSCSellbotNerfMenu() self.sellbotNerfMenu = SCMenuHolder(OTPLocalizer.SCMenuSellbotNerf, menu=menu) self.speedChat[2:2] = [self.sellbotNerfMenu] def removeSellbotNerfMenu(self): if self.sellbotNerfMenu: i = self.speedChat.index(self.sellbotNerfMenu) del self.speedChat[i] self.sellbotNerfMenu.destroy() self.sellbotNerfMenu = None def addJellybeanJamMenu(self, phase): if self.jellybeanJamMenu == None: menu = TTSCJellybeanJamMenu(phase) self.jellybeanJamMenu = SCMenuHolder( OTPLocalizer.SCMenuJellybeanJam, menu=menu) self.speedChat[2:2] = [self.jellybeanJamMenu] def removeJellybeanJamMenu(self): if self.jellybeanJamMenu: i = self.speedChat.index(self.jellybeanJamMenu) del self.speedChat[i] self.jellybeanJamMenu.destroy() self.jellybeanJamMenu = None def addHalloweenMenu(self): if self.halloweenMenu == None: menu = TTSCHalloweenMenu() self.halloweenMenu = SCMenuHolder(OTPLocalizer.SCMenuHalloween, menu=menu) self.speedChat[2:2] = [self.halloweenMenu] def removeHalloweenMenu(self): if self.halloweenMenu: i = self.speedChat.index(self.halloweenMenu) del self.speedChat[i] self.halloweenMenu.destroy() self.halloweenMenu = None def addWinterMenu(self, carol=False): if self.winterMenu == None: menu = TTSCWinterMenu(carol) self.winterMenu = SCMenuHolder(OTPLocalizer.SCMenuWinter, menu=menu) self.speedChat[2:2] = [self.winterMenu] def removeWinterMenu(self): if self.winterMenu: i = self.speedChat.index(self.winterMenu) del self.speedChat[i] self.winterMenu.destroy() self.winterMenu = None # def addCarolMenu(self): # if (self.carolMenu == None): # if base.cr.isPaid(): # menu = TTSCCarolMenu() # self.carolMenu = SCMenuHolder(OTPLocalizer.SCMenuCarol, menu = menu) # self.speedChat[3:3] = [self.carolMenu] # def removeCarolMenu(self): # if self.carolMenu: # i = self.speedChat.index(self.carolMenu) # del self.speedChat[i] # self.carolMenu.destroy() # self.carolMenu = None def addCarolMenu(self): self.removeWinterMenu() self.addWinterMenu(carol=True) def removeCarolMenu(self): pass # methods for creating White List chat menus def addWhiteList(self): if self.whiteList == None: from toontown.chat.TTSCWhiteListTerminal import TTSCWhiteListTerminal self.whiteList = TTSCWhiteListTerminal(4, self) #menu = TTSCWhiteListMenu() #self.whiteListMenu = SCMenuHolder(OTPLocalizer.SCMenuWhiteList, menu=menu) self.speedChat[1:1] = [self.whiteList] def removeWhiteList(self): if self.whiteList: i = self.speedChat.index(self.whiteList) del self.speedChat[i] self.whiteList.destroy() self.whiteList = None def addSellbotInvasionMenu(self): if self.sellbotInvasionMenu == None: menu = TTSCSellbotInvasionMenu() self.sellbotInvasionMenu = SCMenuHolder( OTPLocalizer.SCMenuSellbotInvasion, menu=menu) self.speedChat[2:2] = [self.sellbotInvasionMenu] def removeSellbotInvasionMenu(self): if self.sellbotInvasionMenu: i = self.speedChat.index(self.sellbotInvasionMenu) del self.speedChat[i] self.sellbotInvasionMenu.destroy() self.sellbotInvasionMenu = None def addSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu == None: menu = TTSCSellbotFieldOfficeMenu() self.sellbotFieldOfficeMenu = SCMenuHolder( OTPLocalizer.SCMenuFieldOffice, menu=menu) self.speedChat[2:2] = [self.sellbotFieldOfficeMenu] def removeSellbotFieldOfficeMenu(self): if self.sellbotFieldOfficeMenu: i = self.speedChat.index(self.sellbotFieldOfficeMenu) del self.speedChat[i] self.sellbotFieldOfficeMenu.destroy() self.sellbotFieldOfficeMenu = None def addIdesOfMarchMenu(self): if self.idesOfMarchMenu == None: menu = TTSCIdesOfMarchMenu() self.idesOfMarchMenu = SCMenuHolder(OTPLocalizer.SCMenuIdesOfMarch, menu=menu) self.speedChat[2:2] = [self.idesOfMarchMenu] def removeIdesOfMarchMenu(self): if self.idesOfMarchMenu: i = self.speedChat.index(self.idesOfMarchMenu) del self.speedChat[i] self.idesOfMarchMenu.destroy() self.idesOfMarchMenu = None