More killing

This commit is contained in:
Daniel 2015-03-29 14:59:51 +03:00
parent 6726d7e589
commit 887ab8443f
9 changed files with 106 additions and 451 deletions

View file

@ -4,8 +4,6 @@ from direct.fsm import State
from direct.gui.DirectGui import *
from direct.showbase import DirectObject
from pandac.PandaModules import *
from otp.login import PrivacyPolicyPanel
from otp.login import SecretFriendsInfoPanel
from otp.otpbase import OTPLocalizer
from toontown.chat.ChatGlobals import *
@ -52,8 +50,6 @@ class ChatManager(DirectObject.DirectObject):
self.noSecretChatAtAllAndNoWhitelist = None
self.noSecretChatWarning = None
self.activateChatGui = None
self.chatMoreInfo = None
self.chatPrivacyPolicy = None
self.secretChatActivated = None
self.problemActivatingChat = None
self.fsm = ClassicFSM.ClassicFSM('chatManager', [State.State('off', self.enterOff, self.exitOff),
@ -73,8 +69,6 @@ class ChatManager(DirectObject.DirectObject):
State.State('noFriendsWarning', self.enterNoFriendsWarning, self.exitNoFriendsWarning),
State.State('otherDialog', self.enterOtherDialog, self.exitOtherDialog),
State.State('activateChat', self.enterActivateChat, self.exitActivateChat),
State.State('chatMoreInfo', self.enterChatMoreInfo, self.exitChatMoreInfo),
State.State('chatPrivacyPolicy', self.enterChatPrivacyPolicy, self.exitChatPrivacyPolicy),
State.State('secretChatActivated', self.enterSecretChatActivated, self.exitSecretChatActivated),
State.State('problemActivatingChat', self.enterProblemActivatingChat, self.exitProblemActivatingChat),
State.State('whiteListOpenChat', self.enterWhiteListOpenChat, self.exitWhiteListOpenChat),
@ -111,12 +105,6 @@ class ChatManager(DirectObject.DirectObject):
if self.activateChatGui:
self.activateChatGui.destroy()
self.activateChatGui = None
if self.chatMoreInfo:
self.chatMoreInfo.destroy()
self.chatMoreInfo = None
if self.chatPrivacyPolicy:
self.chatPrivacyPolicy.destroy()
self.chatPrivacyPolicy = None
if self.secretChatActivated:
self.secretChatActivated.destroy()
self.secretChatActivated = None
@ -441,30 +429,6 @@ class ChatManager(DirectObject.DirectObject):
def exitOtherDialog(self):
pass
def enterChatMoreInfo(self):
if self.chatMoreInfo == None:
self.chatMoreInfo = SecretFriendsInfoPanel.SecretFriendsInfoPanel('secretFriendsInfoDone')
self.chatMoreInfo.show()
self.accept('secretFriendsInfoDone', self.__secretFriendsInfoDone)
return
def exitChatMoreInfo(self):
self.chatMoreInfo.hide()
self.ignore('secretFriendsInfoDone')
def enterChatPrivacyPolicy(self):
if self.chatPrivacyPolicy == None:
self.chatPrivacyPolicy = PrivacyPolicyPanel.PrivacyPolicyPanel('privacyPolicyDone')
self.chatPrivacyPolicy.show()
self.accept('privacyPolicyDone', self.__privacyPolicyDone)
return
def exitChatPrivacyPolicy(self):
cleanupDialog('privacyPolicyDialog')
self.chatPrivacyPolicy = None
self.ignore('privacyPolicyDone')
return
def enterSecretChatActivated(self):
self.notify.error('called enterSecretChatActivated() on parent class')
@ -475,10 +439,4 @@ class ChatManager(DirectObject.DirectObject):
self.notify.error('called enterProblemActivatingChat() on parent class')
def exitProblemActivatingChat(self):
self.notify.error('called exitProblemActivatingChat() on parent class')
def __secretFriendsInfoDone(self):
self.fsm.request('activateChat')
def __privacyPolicyDone(self):
self.fsm.request('activateChat')
self.notify.error('called exitProblemActivatingChat() on parent class')

View file

@ -1,80 +0,0 @@
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from otp.otpbase import OTPLocalizer
class MultiPageTextFrame(DirectFrame):
defWidth = 1.8
defHeight = 0.9
def __init__(self, textList, width = defWidth, height = defHeight, wordWrap = None, hidePageNum = 0, pageChangeCallback = None, parent = aspect2d, **kw):
self.textList = textList
self.numPages = len(self.textList)
self.pageChangeCallback = pageChangeCallback
if not wordWrap:
wordWrap = round(18.8 * width)
hWidth = width / 2.0
hHeight = height / 2.0
optiondefs = (('relief', DGG.SUNKEN, None),
('frameSize', (-hWidth,
hWidth,
-hHeight,
hHeight), None),
('frameColor', (0.85, 0.85, 0.6, 1), None),
('borderWidth', (0.01, 0.01), None),
('text', '', None),
('text_pos', (-hWidth * 0.95, hHeight * 0.93), None),
('text_scale', 0.05, None),
('text_align', TextNode.ALeft, None),
('text_wordwrap', wordWrap, None))
self.defineoptions(kw, optiondefs)
DirectFrame.__init__(self, parent)
self.initialiseoptions(MultiPageTextFrame)
guiButton = loader.loadModel('phase_3/models/gui/quit_button')
buttonScale = 0.7 * (float(height) / self.defHeight)
buttonZ = -hHeight * 0.83
self.nextButton = DirectButton(parent=self, relief=None, scale=buttonScale, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.75, 1, 1), pos=(hWidth * 0.35, 0, buttonZ), text=OTPLocalizer.MultiPageTextFrameNext, text_scale=0.05, text_pos=(0, -0.02), command=self.turnPage, extraArgs=[1])
self.prevButton = DirectButton(parent=self, relief=None, scale=buttonScale, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.75, 1, 1), pos=(-hWidth * 0.35, 0, buttonZ), text=OTPLocalizer.MultiPageTextFramePrev, text_scale=0.05, text_pos=(0, -0.02), command=self.turnPage, extraArgs=[-1])
self.pageNum = DirectLabel(relief=None, parent=self, pos=(0, 0, -hHeight * 0.86), text='', text_scale=0.05, text_pos=(0, 0))
if hidePageNum:
self.pageNum.hide()
self.setPage(0)
guiButton.removeNode()
return
def setPageChangeCallback(self, callback):
self.pageChangeCallback = callback
self.setPage(self.curPage)
def setPage(self, pageNum):
self.curPage = max(0, min(self.numPages - 1, pageNum))
if self.numPages == 1:
self.nextButton.hide()
self.prevButton.hide()
self.curPage = 0
elif self.curPage == self.numPages - 1:
self.nextButton.hide()
self.prevButton.show()
elif self.curPage == 0:
self.nextButton.show()
self.prevButton.hide()
else:
self.nextButton.show()
self.prevButton.show()
self.pageNum['text'] = OTPLocalizer.MultiPageTextFramePage % (self.curPage + 1, self.numPages)
self['text'] = self.textList[self.curPage]
if self.pageChangeCallback:
self.pageChangeCallback(self.getCurPage())
def getCurPage(self):
return self.curPage
def turnPage(self, delta):
self.setPage(self.curPage + delta)
def acceptAgreementKeypresses(self):
self.accept('page_down-up', self.turnPage, extraArgs=[1])
self.accept('page_up-up', self.turnPage, extraArgs=[-1])
def ignoreAgreementKeypresses(self):
self.ignore('page_down-up')
self.ignore('page_up-up')

View file

@ -1,97 +0,0 @@
from pandac.PandaModules import *
from otp.otpbase.OTPGlobals import *
from direct.gui.DirectGui import *
from MultiPageTextFrame import *
from direct.directnotify import DirectNotifyGlobal
from otp.otpbase import OTPLocalizer
from otp.otpgui import OTPDialog
class PrivacyPolicyTextPanel(getGlobalDialogClass()):
notify = DirectNotifyGlobal.directNotify.newCategory('PrivacyPolicyTextPanel')
def __init__(self, doneEvent, hidePageNum = 0, pageChangeCallback = None, textList = []):
dialogClass = getGlobalDialogClass()
dialogClass.__init__(self, parent=aspect2d, dialogName='privacyPolicyTextDialog', doneEvent=doneEvent, okButtonText=OTPLocalizer.PrivacyPolicyClose, style=OTPDialog.Acknowledge, text='', topPad=1.5, sidePad=1.2, pos=(0, 0, -.55), scale=0.9)
self.privacyPolicyText = MultiPageTextFrame(parent=self, textList=textList, hidePageNum=hidePageNum, pageChangeCallback=pageChangeCallback, pos=(0, 0, 0.7), width=2.4, height=1.5)
self['image'] = self['image']
self['image_pos'] = (0, 0, 0.65)
self['image_scale'] = (2.7, 1, 1.9)
closeButton = self.getChild(0)
closeButton.setZ(-.13)
class PrivacyPolicyPanel(getGlobalDialogClass()):
notify = DirectNotifyGlobal.directNotify.newCategory('PrivacyPolicyPanel')
def __init__(self, doneEvent, hidePageNum = 0, pageChangeCallback = None, textList = 1):
dialogClass = getGlobalDialogClass()
dialogClass.__init__(self, parent=aspect2d, dialogName='privacyPolicyDialog', doneEvent=doneEvent, okButtonText=OTPLocalizer.PrivacyPolicyClose, style=OTPDialog.Acknowledge, text='', topPad=1.5, sidePad=1.2, pos=(0, 0, -.15), scale=0.6)
self.chatPrivacyPolicy = None
self.fsm = ClassicFSM.ClassicFSM('privacyPolicyPanel', [State.State('off', self.enterOff, self.exitOff),
State.State('version1Adult', self.enterVersion1Adult, self.exitPrivacyPolicy),
State.State('version1Kids', self.enterVersion1Kids, self.exitPrivacyPolicy),
State.State('version2Adult', self.enterVersion2Adult, self.exitPrivacyPolicy),
State.State('version2Kids', self.enterVersion2Kids, self.exitPrivacyPolicy)], 'off', 'off')
self.fsm.enterInitialState()
guiButton = loader.loadModel('phase_3/models/gui/quit_button')
moreButtonImage = (guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR'))
DirectFrame(self, pos=(-0.4, 0.1, 0.4), relief=None, text=OTPLocalizer.PrivacyPolicyText_Intro, text_align=TextNode.ALeft, text_wordwrap=28, text_scale=0.09, text_pos=(-0.82, 1.0), textMayChange=0)
textScale = 0.05
buttonFrame = DirectFrame(self, pos=(0.0, 0.1, 0.0), scale=1.4, relief=None)
DirectButton(buttonFrame, image=moreButtonImage, image_scale=(1.75, 1.0, 1.0), relief=None, text=OTPLocalizer.ActivateChatPrivacyPolicy_Button1A, text_scale=textScale, text_pos=(0, -0.01), textMayChange=0, pos=(-0.45, 0.0, 0.4), command=self.__handlePrivacyPolicy, extraArgs=['version1Adult'])
DirectButton(buttonFrame, image=moreButtonImage, image_scale=(1.75, 1.0, 1.0), relief=None, text=OTPLocalizer.ActivateChatPrivacyPolicy_Button1K, text_scale=textScale, text_pos=(0, -0.01), textMayChange=0, pos=(-0.45, 0.0, 0.2), command=self.__handlePrivacyPolicy, extraArgs=['version1Kids'])
DirectButton(buttonFrame, image=moreButtonImage, image_scale=(1.75, 1.0, 1.0), relief=None, text=OTPLocalizer.ActivateChatPrivacyPolicy_Button2A, text_scale=textScale, text_pos=(0, -0.01), textMayChange=0, pos=(0.45, 0.0, 0.4), command=self.__handlePrivacyPolicy, extraArgs=['version2Adult'])
DirectButton(buttonFrame, image=moreButtonImage, image_scale=(1.75, 1.0, 1.0), relief=None, text=OTPLocalizer.ActivateChatPrivacyPolicy_Button2K, text_scale=textScale, text_pos=(0, -0.01), textMayChange=0, pos=(0.45, 0.0, 0.2), command=self.__handlePrivacyPolicy, extraArgs=['version2Kids'])
self['image'] = self['image']
self['image_pos'] = (0, 0, 0.65)
self['image_scale'] = (2.7, 1, 1.9)
closeButton = self.getChild(0)
closeButton.setZ(-.13)
return
def delete(self):
self.ignoreAll()
del self.fsm
if self.chatPrivacyPolicy:
self.chatPrivacyPolicy.destroy()
self.chatPrivacyPolicy = None
return
def __handlePrivacyPolicy(self, state, *oooo):
self.fsm.request(state)
def __privacyPolicyTextDone(self):
self.exitPrivacyPolicy()
def enterPrivacyPolicy(self, textList):
if self.chatPrivacyPolicy == None:
self.chatPrivacyPolicy = PrivacyPolicyTextPanel('privacyPolicyTextDone', textList=textList)
self.chatPrivacyPolicy.show()
self.acceptOnce('privacyPolicyTextDone', self.__privacyPolicyTextDone)
return
def exitPrivacyPolicy(self):
self.ignore('privacyPolicyTextDone')
if self.chatPrivacyPolicy:
cleanupDialog('privacyPolicyTextDialog')
self.chatPrivacyPolicy = None
return
def enterVersion1Adult(self):
self.enterPrivacyPolicy(OTPLocalizer.PrivacyPolicyText_1A)
def enterVersion1Kids(self):
self.enterPrivacyPolicy(OTPLocalizer.PrivacyPolicyText_1K)
def enterVersion2Adult(self):
self.enterPrivacyPolicy(OTPLocalizer.PrivacyPolicyText_2A)
def enterVersion2Kids(self):
self.enterPrivacyPolicy(OTPLocalizer.PrivacyPolicyText_2K)
def enterOff(self):
self.ignoreAll()
self.exitPrivacyPolicy()
def exitOff(self):
pass

View file

@ -1,70 +0,0 @@
from direct.directnotify import DirectNotifyGlobal
import HTTPUtil
class RemoteValueSet:
notify = DirectNotifyGlobal.directNotify.newCategory('RemoteValueSet')
def __init__(self, url, http, body = '', expectedHeader = None, expectedFields = [], onUnexpectedResponse = None):
if onUnexpectedResponse is None:
onUnexpectedResponse = self.__onUnexpectedResponse
response = HTTPUtil.getHTTPResponse(url, http, body)
if expectedHeader is not None:
if response[0] != expectedHeader:
errMsg = 'unexpected response: %s' % response
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
response = response[1:]
self.dict = {}
for line in response:
if not len(line):
continue
try:
name, value = line.split('=', 1)
except ValueError, e:
errMsg = 'unexpected response: %s' % response
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
if len(expectedFields):
if name not in expectedFields:
self.notify.warning("received field '%s' that is not in expected field list" % name)
self.dict[name] = value
for name in expectedFields:
if name not in self.dict:
errMsg = "missing expected field '%s'" % name
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
return
def __repr__(self):
return 'RemoteValueSet:%s' % str(self.dict)
def hasKey(self, key):
return key in self.dict
def getBool(self, name, default = None):
return self.__getValue(name, lambda x: int(x) != 0, default)
def getInt(self, name, default = None):
return self.__getValue(name, int, default)
def getFloat(self, name, default = None):
return self.__getValue(name, float, default)
def getString(self, name, default = None):
return self.__getValue(name, str, default)
def __getValue(self, name, convOp, default):
if default is None:
return convOp(self.dict[name])
else:
return convOp(self.dict.get(name, default))
return
def __onUnexpectedResponse(self, errStr):
raise HTTPUtil.UnexpectedResponse(errStr)

View file

@ -1,18 +0,0 @@
from pandac.PandaModules import *
from otp.otpbase.OTPGlobals import *
from direct.gui.DirectGui import *
from MultiPageTextFrame import *
from otp.otpbase import OTPLocalizer
from otp.otpgui import OTPDialog
class SecretFriendsInfoPanel(getGlobalDialogClass()):
def __init__(self, doneEvent, hidePageNum = 0, pageChangeCallback = None):
dialogClass = getGlobalDialogClass()
dialogClass.__init__(self, parent=aspect2d, dialogName='secretFriendsInfoDialog', doneEvent=doneEvent, okButtonText=OTPLocalizer.SecretFriendsInfoPanelClose, style=OTPDialog.Acknowledge, text='', topPad=1.5, sidePad=1.2, pos=(0, 0, 0.1), scale=0.9)
self.textPanel = MultiPageTextFrame(parent=self, textList=OTPLocalizer.SecretFriendsInfoPanelText, hidePageNum=hidePageNum, pageChangeCallback=pageChangeCallback)
self['image'] = self['image']
self['image_pos'] = (0, 0, -.1)
self['image_scale'] = (2, 1, 1.3)
closeButton = self.getChild(0)
closeButton.setZ(-.56)

View file

@ -118,25 +118,6 @@ ActivateChat = "True Friends allows one member to chat with another member only
ActivateChatYes = 'Update'
ActivateChatNo = lCancel
ActivateChatMoreInfo = 'More Info'
ActivateChatPrivacyPolicy = 'Privacy Policy'
ActivateChatPrivacyPolicy_Button1A = 'Version 1'
ActivateChatPrivacyPolicy_Button1K = 'Version 1'
ActivateChatPrivacyPolicy_Button2A = 'Version 2'
ActivateChatPrivacyPolicy_Button2K = 'Version 2'
PrivacyPolicyText_1A = [' ']
PrivacyPolicyText_1K = [' ']
PrivacyPolicyText_2A = [' ']
PrivacyPolicyText_2K = [' ']
PrivacyPolicyText_Intro = [' ']
PrivacyPolicyClose = lClose
SecretFriendsInfoPanelOk = lOK
SecretFriendsInfoPanelClose = lClose
SecretFriendsInfoPanelText = ['\nThe Open Chat with True Friends Feature\n\nThe Open Chat with True Friends feature enables a member to chat directly with another member within Toontown United (the "Service") once the members establish a True Friends connection. When your child attempts to use the Open Chat with True Friends feature, we will require that you indicate your consent to your child\'s use of this feature by entering your Parent Account Password. Here is a detailed description of the process of creating an Open Chat with True Friends connection between members whom we will call "Sally" and "Mike."\n1. Sally\'s parent and Mike\'s parent each enable the Open Chat with True Friends feature by entering their respective Parent Account Passwords either (a) in the Account Options areas within the Service, or (b) when prompted within the game by a Parental Controls pop-up.\n2. Sally requests a True Friend Code (described below) from within the Service.\n',
"\n3. Sally's True Friend Code is communicated to Mike outside of the Service. (Sally's True Friend Code may be communicated to Mike either directly by Sally, or indirectly through Sally's disclosure of the True Friend Code to another person.)\n4. Mike submits Sally's True Friend Code to the Service within 48 hours of the time that Sally requested the True Friend Code from the Service.\n5. The Service then notifies Mike that Sally has become Mike's True Friend. The Service similarly notifies Sally that Mike has become Sally's True Friend.\n6. Sally and Mike can now open chat directly with each other until either one chooses to terminate the other as a True Friend, or until the Open Chat with True Friends feature is disabled for either Sally or Mike by their respective parent. The True Friends connection can thus be disabled anytime by either: (a) a member removing the True Friend from his or her friends list (as described in the Service); or, (b) the parent of that member disabling the Open Chat with ",
"\nTrue Friends feature by going to the Account Options area within the Service and following the steps set forth there.\n\nA True Friend Code is a computer-generated random code assigned to a particular member. The True Friend Code must be used to activate a True Friend connection within 48 hours of the time that the member requests the True Friend Code; otherwise, the True Friend Code expires and cannot be used. Moreover, a single True Friend Code can only be used to establish one True Friend connection. To make additional True Friend connections, a member must request an additional True Friend Code for each additional True Friend.\n\nTrue Friendships do not transfer. For example, if Sally becomes a True Friend of Mike, and Mike becomes a True Friend of Jessica, Sally does not automatically become Jessica's True Friend. In order for Sally and Jessica to\n",
'\nbecome True Friends, one of them must request a new True Friend Code from the Service and communicate it to the other.\n\nTrue Friends communicate with one another in a free-form interactive open chat. The content of this chat is directly entered by the participating member and is processed through the Service, which is monitored by the Toontown United team. While we advise members not to exchange personal information such as first and last names, e-mail addresses, postal addresses, or phone numbers while using Open Chat with True Friends, we cannot guarantee that such exchanges of personal information will not happen. Although the True Friends chat is automatically filtered for most bad words, Open Chat with True Friends may be moderated, and we reserve the right to moderate any part of the Service that we,\n',
"\nin our sole and absolute discretion, deems necessary. However, because Open Chat with True Friends will not always be moderated, if the Parent Account allows a child to use his or her account with the Open Chat with True Friends feature enabled, we strongly encourage parents to supervise their child or children while they play in the Service. By enabling the Open Chat with True Friends feature, the Parent Account acknowledges that there are some risks inherent in the Open Chat with True Friends feature and that the Parent Account has been informed of, and agrees to accept, any such risks, whether foreseeable or otherwise. \n\nWDIG does not use the content of True Friends chat for any purpose other than communicating that content to the member's true friend, and does not disclose that content to any third party except: (1) if required by law, for example, to comply with a court order or subpoena; (2) to enforce the Terms of Use\n",
"\napplicable to the Service (which may be accessed on the home page of the Service); or, (3) to protect the safety and security of Members of the Service and the Service itself. In accordance with the Children's Online Privacy Protection Act, we are prohibited from conditioning, and do not condition, a child's participation in any activity (including Open Chat with True Friends) on the child's disclosing more personal information than is reasonably necessary to participate in such activity.\n\nIn addition, as noted above, we recognize the right of a parent to refuse to permit us to continue to allow a child to use the True Friends feature. By enabling the Open Chat with True Friends feature, you acknowledge that there are some risks inherent in the ability of members to open chat with one another through the Open Chat with True Friends feature, and that you have been informed of, and agree to accept, any such risks, whether foreseeable or otherwise.\n"]
LeaveToSetParentPassword = 'In order to set parent account password, the game will exit to the Toontown website.'
LeaveToSetParentPasswordYes = 'Set Password'
LeaveToSetParentPasswordNo = lCancel
@ -151,9 +132,6 @@ SecretChatActivatedOK = lOK
SecretChatActivatedChange = 'Change Options'
ProblemActivatingChat = 'Oops! We were unable to activate the "True Friends" chat feature.\n\n%s\n\nPlease try again later.'
ProblemActivatingChatOK = lOK
MultiPageTextFrameNext = lNext
MultiPageTextFramePrev = 'Previous'
MultiPageTextFramePage = 'Page %s/%s'
CRConnecting = 'Connecting...'
CRNoConnectTryAgain = 'Could not connect to %s:%s. Try again?'
CRNoConnectProxyNoPort = 'Could not connect to %s:%s.\n\nYou are communicating to the internet via a proxy, but your proxy does not permit connections on port %s.\n\nYou must open up this port, or disable your proxy, in order to play. If your proxy has been provided by your ISP, you must contact your ISP to request them to open up this port.'

View file

@ -1,116 +0,0 @@
from pandac.PandaModules import Vec4
from direct.gui.DirectGui import DirectFrame, DGG
from direct.task import Task
from direct.showbase.PythonUtil import bound
from otp.otpbase import OTPGlobals
class OTPTimer(DirectFrame):
ClockImage = None
TimerId = 0
def __init__(self, useImage = True, highlightNearEnd = True):
if useImage:
image = self.getImage()
else:
image = None
DirectFrame.__init__(self, state=DGG.DISABLED, relief=None, scale=0.45, image=image, image_pos=(0, 0, 0), text='0', text_fg=(0, 0, 0, 1), text_font=OTPGlobals.getInterfaceFont(), text_pos=(-0.01, -0.15), text_scale=0.35)
self.initialiseoptions(OTPTimer)
self.timerId = OTPTimer.TimerId
OTPTimer.TimerId += 1
self.highlightNearEnd = highlightNearEnd
self.countdownTask = None
self.currentTime = 0
self.taskTime = 0.0
self.setFontColor(Vec4(0, 0, 0, 1))
return
def setFontColor(self, vColor):
self.vFontColor = vColor
def getImage(self):
if OTPTimer.ClockImage == None:
model = loader.loadModel('phase_3.5/models/gui/clock_gui')
OTPTimer.ClockImage = model.find('**/alarm_clock')
model.removeNode()
return OTPTimer.ClockImage
def posInTopRightCorner(self):
self.reparentTo(base.a2dTopRight)
self.setPos(-0.173, 0, -0.17)
def posBelowTopRightCorner(self):
self.reparentTo(base.a2dTopRight)
self.setPos(-0.173, 0, -0.42)
def posAboveShtikerBook(self):
self.reparentTo(base.a2dBottomRight)
self.setPos(-0.173, 0, 0.37)
def setTime(self, time):
time = bound(time, 0, 999)
if time == self.currentTime:
return
self.currentTime = time
timeStr = str(time)
timeStrLen = len(timeStr)
if timeStrLen == 1:
if time <= 5 and self.highlightNearEnd:
self.setTimeStr(timeStr, 0.34, (-0.025, -0.125), Vec4(1, 0, 0, 1))
else:
self.setTimeStr(timeStr, 0.34, (-0.025, -0.125))
elif timeStrLen == 2:
self.setTimeStr(timeStr, 0.27, (-0.025, -0.1))
elif timeStrLen == 3:
self.setTimeStr(timeStr, 0.2, (-0.01, -0.08))
def setTimeStr(self, timeStr, scale = 0.2, pos = (-0.01, -0.08), fg = None):
self['text'] = ''
self['text_fg'] = fg or self.vFontColor
self['text_scale'] = scale
self['text_pos'] = pos
self['text'] = timeStr
def getElapsedTime(self):
return self.taskTime
def _timerTask(self, task):
countdownTime = int(task.duration - task.time)
self.setTime(countdownTime)
self.taskTime = task.time
if task.time >= task.duration:
self.timerExpired()
if task.callback:
task.callback()
return Task.done
else:
return Task.cont
def countdown(self, duration, callback = None):
self.countdownTask = Task.Task(self._timerTask)
self.countdownTask.duration = duration
self.countdownTask.callback = callback
taskMgr.remove('timerTask%s' % self.timerId)
return taskMgr.add(self.countdownTask, 'timerTask%s' % self.timerId)
def timerExpired(self):
pass
def stop(self):
if self.countdownTask:
taskMgr.remove(self.countdownTask)
def reset(self):
self.stop()
self.setTime(0)
taskMgr.remove('timerTask%s' % self.timerId)
self.taskTime = 0.0
def destroy(self):
self.reset()
self.countdownTask = None
DirectFrame.destroy(self)
return
def cleanup(self):
self.destroy()
self.notify.warning('Call destroy, not cleanup')

View file

@ -1,6 +1,5 @@
from direct.distributed import DistributedObject
from direct.directnotify import DirectNotifyGlobal
from otp.otpbase import OTPTimer
from toontown.toonbase import TTLocalizer
from toontown.racing import KartShopGlobals
from toontown.toonbase.ToonBaseGlobal import *

View file

@ -1,11 +1,31 @@
from otp.otpbase.OTPTimer import OTPTimer
from pandac.PandaModules import *
from pandac.PandaModules import Vec4
from direct.gui.DirectGui import DirectFrame, DGG
from direct.task import Task
from direct.showbase.PythonUtil import bound
from otp.otpbase import OTPGlobals
class ToontownTimer(OTPTimer):
class ToontownTimer(DirectFrame):
ClockImage = None
TimerId = 0
def __init__(self, useImage = True, highlightNearEnd = True):
OTPTimer.__init__(self, useImage, highlightNearEnd)
if useImage:
image = self.getImage()
else:
image = None
DirectFrame.__init__(self, state=DGG.DISABLED, relief=None, scale=0.45, image=image, image_pos=(0, 0, 0), text='0', text_fg=(0, 0, 0, 1), text_font=OTPGlobals.getInterfaceFont(), text_pos=(-0.01, -0.15), text_scale=0.35)
self.initialiseoptions(ToontownTimer)
self.timerId = ToontownTimer.TimerId
ToontownTimer.TimerId += 1
self.highlightNearEnd = highlightNearEnd
self.countdownTask = None
self.currentTime = 0
self.taskTime = 0.0
self.setFontColor(Vec4(0, 0, 0, 1))
return
def setFontColor(self, vColor):
self.vFontColor = vColor
def getImage(self):
if ToontownTimer.ClockImage == None:
@ -13,3 +33,84 @@ class ToontownTimer(OTPTimer):
ToontownTimer.ClockImage = model.find('**/alarm_clock')
model.removeNode()
return ToontownTimer.ClockImage
def posInTopRightCorner(self):
self.reparentTo(base.a2dTopRight)
self.setPos(-0.173, 0, -0.17)
def posBelowTopRightCorner(self):
self.reparentTo(base.a2dTopRight)
self.setPos(-0.173, 0, -0.42)
def posAboveShtikerBook(self):
self.reparentTo(base.a2dBottomRight)
self.setPos(-0.173, 0, 0.37)
def setTime(self, time):
time = bound(time, 0, 999)
if time == self.currentTime:
return
self.currentTime = time
timeStr = str(time)
timeStrLen = len(timeStr)
if timeStrLen == 1:
if time <= 5 and self.highlightNearEnd:
self.setTimeStr(timeStr, 0.34, (-0.025, -0.125), Vec4(1, 0, 0, 1))
else:
self.setTimeStr(timeStr, 0.34, (-0.025, -0.125))
elif timeStrLen == 2:
self.setTimeStr(timeStr, 0.27, (-0.025, -0.1))
elif timeStrLen == 3:
self.setTimeStr(timeStr, 0.2, (-0.01, -0.08))
def setTimeStr(self, timeStr, scale = 0.2, pos = (-0.01, -0.08), fg = None):
self['text'] = ''
self['text_fg'] = fg or self.vFontColor
self['text_scale'] = scale
self['text_pos'] = pos
self['text'] = timeStr
def getElapsedTime(self):
return self.taskTime
def _timerTask(self, task):
countdownTime = int(task.duration - task.time)
self.setTime(countdownTime)
self.taskTime = task.time
if task.time >= task.duration:
self.timerExpired()
if task.callback:
task.callback()
return Task.done
else:
return Task.cont
def countdown(self, duration, callback = None):
self.countdownTask = Task.Task(self._timerTask)
self.countdownTask.duration = duration
self.countdownTask.callback = callback
taskMgr.remove('timerTask%s' % self.timerId)
return taskMgr.add(self.countdownTask, 'timerTask%s' % self.timerId)
def timerExpired(self):
pass
def stop(self):
if self.countdownTask:
taskMgr.remove(self.countdownTask)
def reset(self):
self.stop()
self.setTime(0)
taskMgr.remove('timerTask%s' % self.timerId)
self.taskTime = 0.0
def destroy(self):
self.reset()
self.countdownTask = None
DirectFrame.destroy(self)
return
def cleanup(self):
self.destroy()
self.notify.warning('Call destroy, not cleanup')