ChatGlobals cleanup

This commit is contained in:
John 2015-06-09 23:24:18 +03:00 committed by Loudrob
parent 9416b70e91
commit db17bbdc84
8 changed files with 10 additions and 301 deletions

View file

@ -7,7 +7,6 @@ from direct.showbase.DirectObject import *
from direct.task import Task
from pandac.PandaModules import *
from otp.otpbase import OTPGlobals
from toontown.chat.ChatGlobals import *
import time
class TimeManager(DistributedObject.DistributedObject):

View file

@ -1,26 +1,9 @@
import string
NORMAL_CHAT = 1
WHISPER_CHAT = 2
ERROR_NONE = None
ERROR_NO_OPEN_CHAT = 1
ERROR_NOT_FRIENDS = 2
ERROR_NO_RECEIVER = 3
TYPEDCHAT = 0
SPEEDCHAT_NORMAL = 1
SPEEDCHAT_EMOTE = 2
SPEEDCHAT_CUSTOM = 3
SYSTEMCHAT = 4
GAMECHAT = 5
PARTYCHAT = 6
SPEEDCHAT_QUEST = 7
FRIEND_UPDATE = 8
AVATAR_UNAVAILABLE = 9
ChatEvent = 'ChatEvent'
SPEEDCHAT_QUEST = 4
NormalChatEvent = 'NormalChatEvent'
SCChatEvent = 'SCChatEvent'
SCCustomChatEvent = 'SCCustomChatEvent'
SCEmoteChatEvent = 'SCEmoteChatEvent'
SCQuestEvent = 'SCQuestEvent'
OnScreen = 0
OffScreen = 1
Thought = 2
SCEmoteChatEvent = 'SCEmoteChatEvent'

View file

@ -1,112 +0,0 @@
from direct.gui.DirectGui import *
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 *
class ChatInputNormal(DirectObject.DirectObject):
def __init__(self, chatMgr):
self.chatMgr = chatMgr
self.normalPos = Vec3(-1.083, 0, 0.804)
self.whisperPos = Vec3(0.0, 0, 0.71)
self.whisperAvatarName = None
self.whisperAvatarId = None
self.wantHistory = base.config.GetBool('want-chat-history', 0)
self.history = ['']
self.historySize = base.config.GetInt('chat-history-size', 10)
self.historyIndex = 0
return
def typeCallback(self, extraArgs):
messenger.send('enterNormalChat')
def delete(self):
self.ignore('arrow_up-up')
self.ignore('arrow_down-up')
self.chatFrame.destroy()
del self.chatFrame
del self.chatButton
del self.cancelButton
del self.chatEntry
del self.whisperLabel
del self.chatMgr
def activateByData(self, whisperAvatarId = None):
self.whisperAvatarId = whisperAvatarId
if self.whisperAvatarId:
self.whisperAvatarName = ChatUtil.findAvatarName(self.whisperAvatarId)
self.chatFrame.setPos(self.whisperPos)
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperAvatarName
self.whisperLabel.show()
else:
self.chatFrame.setPos(self.normalPos)
self.whisperLabel.hide()
self.chatEntry['focus'] = 1
self.chatFrame.show()
if self.wantHistory:
self.accept('arrow_up-up', self.getPrevHistory)
self.accept('arrow_down-up', self.getNextHistory)
return True
def deactivate(self):
self.chatEntry.set('')
self.chatEntry['focus'] = 0
self.chatFrame.hide()
self.whisperLabel.hide()
base.win.closeIme()
self.ignore('arrow_up-up')
self.ignore('arrow_down-up')
def checkForOverRide(self):
return False
def sendChat(self, text):
if self.checkForOverRide():
self.chatEntry.enterText('')
return
self.deactivate()
self.chatMgr.fsm.request('mainMenu')
if text:
if self.whisperAvatarId:
self.chatMgr.sendWhisperString(text, self.whisperAvatarId)
self.whisperAvatarName = None
self.whisperAvatarId = None
else:
base.talkAssistant.sendOpenTalk(text)
if self.wantHistory:
self.addToHistory(text)
def chatOverflow(self, overflowText):
self.sendChat(self.chatEntry.get())
def cancelButtonPressed(self):
self.chatEntry.set('')
self.chatMgr.fsm.request('mainMenu')
def chatButtonPressed(self):
self.sendChat(self.chatEntry.get())
def addToHistory(self, text):
self.history = [text] + self.history[:self.historySize - 1]
self.historyIndex = 0
def getPrevHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex += 1
self.historyIndex %= len(self.history)
def getNextHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex -= 1
self.historyIndex %= len(self.history)
def setPos(self, posX, posY = None, posZ = None):
if posX and posY and posZ:
self.chatFrame.setPos(posX, posY, posZ)
else:
self.chatFrame.setPos(posX)

View file

@ -1,124 +0,0 @@
from direct.gui.DirectGui import *
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 *
class ChatInputTyped(DirectObject.DirectObject):
def __init__(self, mainEntry = 0):
self.whisperName = None
self.whisperId = None
self.mainEntry = mainEntry
self.wantHistory = base.config.GetBool('want-chat-history', 0)
self.history = ['']
self.historySize = base.config.GetInt('chat-history-size', 10)
self.historyIndex = 0
return
def typeCallback(self, extraArgs):
self.activate()
def delete(self):
self.ignore('arrow_up-up')
self.ignore('arrow_down-up')
self.chatFrame.destroy()
del self.chatFrame
del self.chatButton
del self.cancelButton
del self.chatEntry
del self.whisperLabel
del self.chatMgr
def show(self, whisperId = None):
self.whisperId = whisperId
self.whisperName = None
if self.whisperId:
self.whisperName = ChatUtil.findAvatarName(whisperId)
if hasattr(self, 'whisperPos'):
self.chatFrame.setPos(self.whisperPos)
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
self.whisperLabel.show()
else:
if hasattr(self, 'normalPos'):
self.chatFrame.setPos(self.normalPos)
self.whisperLabel.hide()
self.chatEntry['focus'] = 1
self.chatEntry.set('')
self.chatFrame.show()
self.chatEntry.show()
self.cancelButton.show()
self.typedChatButton.hide()
self.typedChatBar.hide()
if self.wantHistory:
self.accept('arrow_up-up', self.getPrevHistory)
self.accept('arrow_down-up', self.getNextHistory)
return
def hide(self):
self.chatEntry.set('')
self.chatEntry['focus'] = 0
self.chatFrame.hide()
self.chatEntry.hide()
self.cancelButton.hide()
self.typedChatButton.show()
self.typedChatBar.show()
self.ignore('arrow_up-up')
self.ignore('arrow_down-up')
def activate(self):
self.chatEntry.set('')
self.chatEntry['focus'] = 1
self.chatFrame.show()
self.chatEntry.show()
self.cancelButton.show()
self.typedChatButton.hide()
self.typedChatBar.hide()
def deactivate(self):
self.chatEntry.set('')
self.chatEntry['focus'] = 0
self.chatFrame.show()
self.chatEntry.hide()
self.cancelButton.hide()
self.typedChatButton.show()
self.typedChatBar.show()
def sendChat(self, text):
self.deactivate()
if text:
if self.whisperId:
pass
else:
base.talkAssistant.sendOpenTalk(text)
if self.wantHistory:
self.addToHistory(text)
self.chatEntry.set('')
def chatOverflow(self, overflowText):
self.sendChat(self.chatEntry.get())
def cancelButtonPressed(self):
self.chatEntry.set('')
self.deactivate()
def chatButtonPressed(self):
self.sendChat(self.chatEntry.get())
def addToHistory(self, text):
self.history = [text] + self.history[:self.historySize - 1]
self.historyIndex = 0
def getPrevHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex += 1
self.historyIndex %= len(self.history)
def getNextHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex -= 1
self.historyIndex %= len(self.history)

View file

@ -1,15 +1,8 @@
from direct.directnotify import DirectNotifyGlobal
from direct.fsm import FSM
from direct.gui.DirectGui import *
from direct.task import Task
from pandac.PandaModules import *
import sys
from otp.chat.ChatInputTyped import ChatInputTyped
from direct.directnotify import DirectNotifyGlobal
from direct.gui.DirectGui import *
from direct.fsm import FSM
from otp.otpbase import OTPGlobals
from otp.otpbase import OTPLocalizer
from toontown.chat.ChatGlobals import *
class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
notify = DirectNotifyGlobal.directNotify.newCategory('ChatInputWhiteList')
@ -21,10 +14,7 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
optiondefs = {'parent': self,
'relief': DGG.SUNKEN,
'scale': 0.05,
'frameSize': (-0.2,
25.3,
-0.5,
1.2),
'frameSize': (-0.2, 25.3, -0.5, 1.2),
'borderWidth': (0.1, 0.1),
'frameColor': (0.9, 0.9, 0.85, 0.8),
'pos': (-0.2, 0, 0.11),
@ -43,23 +33,12 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
self.chatEntry = DirectEntry(**entryOptions)
self.whisperId = None
self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow)
self.wantHistory = base.config.GetBool('want-chat-history', 0)
self.history = ['']
self.historySize = base.config.GetInt('chat-history-size', 10)
self.historyIndex = 0
self.active = 0
self.autoOff = 0
self.sendBy = 'Mode'
from direct.gui import DirectGuiGlobals
self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter)
self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter)
tpMgr = TextPropertiesManager.getGlobalPtr()
Red = tpMgr.getProperties('red')
Red.setTextColor(1.0, 0.0, 0.0, 1)
tpMgr.setProperties('WLRed', Red)
del tpMgr
self.origFrameColor = self.chatEntry['frameColor']
return
def destroy(self):
from direct.gui import DirectGuiGlobals
@ -97,7 +76,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
def exitAvatarWhisper(self):
self.chatEntry.set(self.tempText)
self.whisperId = None
return
def activateByData(self, receiverId = None):
self.receiverId = receiverId
@ -171,20 +149,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
self.notify.debug('chatOverflow')
self.sendChat(self.chatEntry.get(plain=True), overflow=True)
def addToHistory(self, text):
self.history = [text] + self.history[:self.historySize - 1]
self.historyIndex = 0
def getPrevHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex += 1
self.historyIndex %= len(self.history)
def getNextHistory(self):
self.chatEntry.set(self.history[self.historyIndex])
self.historyIndex -= 1
self.historyIndex %= len(self.history)
def applyFilter(self, keyArgs):
if base.whiteList:
self.chatEntry.set(base.whiteList.processThroughAll(self.chatEntry.get(plain=True)))

View file

@ -13,9 +13,6 @@ NormalChatEvent = 'NormalChatEvent'
SCChatEvent = 'SCChatEvent'
SCCustomChatEvent = 'SCCustomChatEvent'
SCEmoteChatEvent = 'SCEmoteChatEvent'
OnScreen = 0
OffScreen = 1
Thought = 2
class ChatManager(DirectObject.DirectObject):
notify = DirectNotifyGlobal.directNotify.newCategory('ChatManager')

View file

@ -8,7 +8,6 @@ from direct.showbase.PythonUtil import makeTuple
import types
class SCMenu(SCObject, NodePath):
config = getConfigShowbase()
SpeedChatRolloverTolerance = config.GetFloat('speedchat-rollover-tolerance', 0.08)
WantFade = config.GetBool('want-speedchat-fade', 1)
FadeDuration = config.GetFloat('speedchat-fade-duration', 0.4)

View file

@ -130,6 +130,9 @@ class ToonBase(OTPBase.OTPBase):
WLDisplay = TextProperties()
WLDisplay.setSlant(0.3)
tpMgr.setProperties('WLDisplay', WLDisplay)
WLRed = tpMgr.getProperties('red')
WLRed.setTextColor(1.0, 0.0, 0.0, 1)
tpMgr.setProperties('WLRed', WLRed)
del tpMgr
self.lastScreenShotTime = globalClock.getRealTime()
self.accept('InputState-forward', self.__walking)