support CInterval.popupControls()

This commit is contained in:
David Rose 2002-08-29 20:13:46 +00:00
parent 5318552bcd
commit 045688d305
4 changed files with 122 additions and 25 deletions

View File

@ -27,12 +27,23 @@
# Kill task
taskMgr.remove(self.getName() + '-play')
return self.getT()
def setT(self, t, event = ETStep):
# Overridden from the C++ layer. We rename the C++ function
# in FFIRename to make this possible.
self.__cSetT(t, event)
if hasattr(self, "setTHooks"):
for func in self.setTHooks:
func(t)
def setFinalT(self):
# We have to define this at the Python level so we can
# implicitly call stop().
self.stop()
self.finalize()
if hasattr(self, "setTHooks"):
for func in self.setTHooks:
func(self.getT())
def isPlaying(self):
return taskMgr.hasTaskNamed(self.getName() + '-play')
@ -40,7 +51,81 @@
def __playTask(self, task):
import Task
loopCount = self.stepPlay()
if hasattr(self, "setTHooks"):
for func in self.setTHooks:
func(self.getT())
if loopCount == 0 or self.__loop:
return Task.cont
else:
return Task.done
def popupControls(self, tl = None):
""" popupControls()
Popup control panel for interval.
"""
import TkGlobal
import fpformat
import string
# I moved this here because Toontown does not ship Tk
from Tkinter import Toplevel, Frame, Button, LEFT, X
import Pmw
import EntryScale
if tl == None:
tl = Toplevel()
tl.title('Interval Controls')
outerFrame = Frame(tl)
self.es = es = EntryScale.EntryScale(
outerFrame, text = self.getName(),
min = 0, max = string.atof(fpformat.fix(self.getDuration(), 2)),
command = lambda t, s = self: s.setT(t))
# So when you drag scale with mouse its like you started a playback
def onPress(s=self,es=es):
# Kill playback task
s.stop()
# INIT interval
s.setT(es.get(), CInterval.ETInitialize)
es.onPress = onPress
# To make sure you stop free running intervals
es.onRelease = lambda s=self: s.stop()
# To update scale and execute intervals with ETInitialize
def onReturn(s = self, es = es):
s.setT(es.get(), CInterval.ETInitialize)
s.stop()
es.onReturnRelease = onReturn
es.pack(expand = 1, fill = X)
bf = Frame(outerFrame)
# Jump to start and end
def toStart(s=self, es=es):
s.setT(0.0, CInterval.ETInitialize)
s.stop()
def toEnd(s=self):
s.setT(s.getDuration(), CInterval.ETInitialize)
s.stop()
jumpToStart = Button(bf, text = '<<', command = toStart)
# Stop/play buttons
stop = Button(bf, text = 'Stop',
command = lambda s=self: s.stop())
play = Button(
bf, text = 'Play',
command = lambda s=self, es=es: s.play(es.get()))
jumpToEnd = Button(bf, text = '>>', command = toEnd)
jumpToStart.pack(side = LEFT, expand = 1, fill = X)
play.pack(side = LEFT, expand = 1, fill = X)
stop.pack(side = LEFT, expand = 1, fill = X)
jumpToEnd.pack(side = LEFT, expand = 1, fill = X)
bf.pack(expand = 1, fill = X)
outerFrame.pack(expand = 1, fill = X)
# Add function to update slider during setT calls
def update(t,es=es):
es.set(t, fCommand = 0)
if not hasattr(self, "setTHooks"):
self.setTHooks = []
self.setTHooks.append(update)
# Clear out function on destroy
def onDestroy(e, s=self, u=update):
if u in s.setTHooks:
s.setTHooks.remove(u)
tl.bind('<Destroy>', onDestroy)

View File

@ -479,7 +479,8 @@ class FFIInterrogateDatabase:
for typeDesc in typeDescs:
funcSpec = FFISpecs.MethodSpecification()
funcSpec.name = FFIRename.methodNameFromCppName(
interrogate_function_name(funcIndex))
interrogate_function_name(funcIndex),
getTypeName(typeIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
funcSpecs.append(funcSpec)
@ -528,7 +529,8 @@ class FFIInterrogateDatabase:
for typeDesc in typeDescs:
funcSpec = FFISpecs.GlobalFunctionSpecification()
funcSpec.name = FFIRename.methodNameFromCppName(
interrogate_function_name(funcIndex))
interrogate_function_name(funcIndex),
getTypeName(typeIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
# Here we look for the class in the first argument

View File

@ -43,7 +43,8 @@ methodRenameDictionary = {
'operator->' : 'dereference',
'operator<<=' : '__ilshift__',
'operator>>=' : '__irshift__',
'print' : 'Cprint'
'print' : 'Cprint',
'CInterval.setT' : '__cSetT',
}
classRenameDictionary = {
@ -124,7 +125,7 @@ def nonClassNameFromCppName(cppName):
newName = checkKeyword(newName)
return newName
def methodNameFromCppName(cppName):
def methodNameFromCppName(cppName, className = None):
methodName = ''
badChars = ' '
nextCap = 0
@ -138,9 +139,12 @@ def methodNameFromCppName(cppName):
methodName = methodName + capitalize(char)
nextCap = 0
else:
methodName = methodName + char
if methodRenameDictionary.has_key(methodName):
methodName = methodRenameDictionary[methodName]
methodName = methodName + char
if className != None:
methodName = methodRenameDictionary.get(className + '.' + methodName, methodName)
methodName = methodRenameDictionary.get(methodName, methodName)
# Mangle names that happen to be python keywords so they are not anymore
methodName = checkKeyword(methodName)
return methodName

View File

@ -71,7 +71,8 @@ class LerpPosInterval(LerpNodePathInterval):
node, other)
# Check for functors in the input parameters.
if self.anyCallable(pos, startPos):
self.paramSetup = self.anyCallable(pos, startPos)
if self.paramSetup:
self.endPos = pos
self.startPos = startPos
self.inPython = 1
@ -80,10 +81,10 @@ class LerpPosInterval(LerpNodePathInterval):
if startPos != None:
self.setStartPos(startPos)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndPos, self.endPos)
self.setupParam(self.setStartPos, self.startPos)
LerpNodePathInterval.setT(self, t, event)
@ -96,7 +97,8 @@ class LerpHprInterval(LerpNodePathInterval):
node, other)
# Check for functors in the input parameters.
if self.anyCallable(hpr, startHpr):
self.paramSetup = self.anyCallable(hpr, startHpr)
if self.paramSetup:
self.endHpr = hpr
self.startHpr = startHpr
self.inPython = 1
@ -105,10 +107,10 @@ class LerpHprInterval(LerpNodePathInterval):
if startHpr != None:
self.setStartHpr(startHpr)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndHpr, self.endHpr)
self.setupParam(self.setStartHpr, self.startHpr)
LerpNodePathInterval.setT(self, t, event)
@ -119,7 +121,8 @@ class LerpScaleInterval(LerpNodePathInterval):
LerpNodePathInterval.__init__(self, name, duration, blendType,
node, other)
# Check for functors in the input parameters.
if self.anyCallable(scale, startScale):
self.paramSetup = self.anyCallable(scale, startScale)
if self.paramSetup:
self.endScale = scale
self.startScale = startScale
self.inPython = 1
@ -128,10 +131,10 @@ class LerpScaleInterval(LerpNodePathInterval):
if startScale != None:
self.setStartScale(startScale)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndScale, self.endScale)
self.setupParam(self.setStartScale, self.startScale)
LerpNodePathInterval.setT(self, t, event)
@ -143,7 +146,8 @@ class LerpPosHprInterval(LerpNodePathInterval):
LerpNodePathInterval.__init__(self, name, duration, blendType,
node, other)
# Check for functors in the input parameters.
if self.anyCallable(pos, startPos, hpr, startHpr):
self.paramSetup = self.anyCallable(pos, startPos, hpr, startHpr)
if self.paramSetup:
self.endPos = pos
self.startPos = startPos
self.endHpr = hpr
@ -157,10 +161,10 @@ class LerpPosHprInterval(LerpNodePathInterval):
if startHpr != None:
self.setStartHpr(startHpr)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndPos, self.endPos)
self.setupParam(self.setStartPos, self.startPos)
self.setupParam(self.setEndHpr, self.endHpr)
@ -175,7 +179,8 @@ class LerpHprScaleInterval(LerpNodePathInterval):
node, other)
# Check for functors in the input parameters.
if self.anyCallable(hpr, startHpr, scale, startScale):
self.paramSetup = self.anyCallable(hpr, startHpr, scale, startScale)
if self.paramSetup:
self.endHpr = hpr
self.startHpr = startHpr
self.endScale = scale
@ -189,10 +194,10 @@ class LerpHprScaleInterval(LerpNodePathInterval):
if startScale != None:
self.setStartScale(startScale)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndHpr, self.endHpr)
self.setupParam(self.setStartHpr, self.startHpr)
self.setupParam(self.setEndScale, self.endScale)
@ -206,7 +211,8 @@ class LerpPosHprScaleInterval(LerpNodePathInterval):
LerpNodePathInterval.__init__(self, name, duration, blendType,
node, other)
# Check for functors in the input parameters.
if self.anyCallable(pos, startPos, hpr, startHpr, scale, startScale):
self.paramSetup = self.anyCallable(pos, startPos, hpr, startHpr, scale, startScale)
if self.paramSetup:
self.endPos = pos
self.startPos = startPos
self.endHpr = hpr
@ -225,10 +231,10 @@ class LerpPosHprScaleInterval(LerpNodePathInterval):
if startScale != None:
self.setStartScale(startScale)
def setT(self, t, event):
def setT(self, t, event = Interval.IVAL_NONE):
# This function is only used if Python functors were passed in
# for some of the input parameters.
if event == Interval.IVAL_INIT:
if self.paramSetup and event == Interval.IVAL_INIT:
self.setupParam(self.setEndPos, self.endPos)
self.setupParam(self.setStartPos, self.startPos)
self.setupParam(self.setEndHpr, self.endHpr)