mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
*** empty log message ***
This commit is contained in:
parent
ad14a7bce2
commit
da87ad16d7
@ -317,15 +317,18 @@ class Actor(PandaObject, NodePath):
|
||||
If no anim specified, use the currently playing anim.
|
||||
If no part specified, return anim durations of first part.
|
||||
NOTE: returns info only for the first LOD"""
|
||||
# use the first LOD
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
|
||||
if (partName == None):
|
||||
partName = self.__animControlDict[0].keys()[0]
|
||||
partName = self.__animControlDict[lodName].keys()[0]
|
||||
|
||||
if (animName==None):
|
||||
animName = self.getCurrentAnim(partName)
|
||||
|
||||
# get duration for named part only
|
||||
if (self.__animControlDict[0].has_key(partName)):
|
||||
animControl = self.__getAnimControl(animName, partName)
|
||||
if (self.__animControlDict[lodName].has_key(partName)):
|
||||
animControl = self.__getAnimControl(animName, partName, lodName)
|
||||
if (animControl != None):
|
||||
return animControl.getFrameRate()
|
||||
else:
|
||||
@ -339,13 +342,16 @@ class Actor(PandaObject, NodePath):
|
||||
If no part is given, assume first part in dictionary.
|
||||
If no anim is given, find the current anim for the part.
|
||||
NOTE: Returns info only for the first LOD"""
|
||||
# use the first lod
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
|
||||
if (partName==None):
|
||||
partName = self.__animControlDict[0].keys()[0]
|
||||
partName = self.__animControlDict[lodName].keys()[0]
|
||||
|
||||
if (animName==None):
|
||||
animName = self.getCurrentAnim(partName)
|
||||
|
||||
animControl = self.__getAnimControl(animName, partName)
|
||||
animControl = self.__getAnimControl(animName, partName, lodName)
|
||||
if (animControl != None):
|
||||
return animControl.getPlayRate()
|
||||
else:
|
||||
@ -380,15 +386,16 @@ class Actor(PandaObject, NodePath):
|
||||
If no anim specified, use the currently playing anim.
|
||||
If no part specified, return anim duration of first part.
|
||||
NOTE: returns info for first LOD only"""
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
if (partName == None):
|
||||
partName = self.__animControlDict[0].keys()[0]
|
||||
partName = self.__animControlDict[lodName].keys()[0]
|
||||
|
||||
if (animName==None):
|
||||
animName = self.getCurrentAnim(partName)
|
||||
|
||||
# get duration for named part only
|
||||
if (self.__animControlDict[0].has_key(partName)):
|
||||
animControl = self.__getAnimControl(animName, partName)
|
||||
if (self.__animControlDict[lodName].has_key(partName)):
|
||||
animControl = self.__getAnimControl(animName, partName, lodName)
|
||||
if (animControl != None):
|
||||
return (animControl.getNumFrames() / \
|
||||
animControl.getFrameRate())
|
||||
@ -402,13 +409,14 @@ class Actor(PandaObject, NodePath):
|
||||
Return the anim current playing on the actor. If part not
|
||||
specified return current anim of first part in dictionary.
|
||||
NOTE: only returns info for the first LOD"""
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
if (partName==None):
|
||||
partName = self.__animControlDict[0].keys()[0]
|
||||
partName = self.__animControlDict[lodName].keys()[0]
|
||||
|
||||
# loop through all anims for named part and find if any are playing
|
||||
if (self.__animControlDict[0].has_key(partName)):
|
||||
for animName in self.__animControlDict[partName].keys():
|
||||
if (self.__getAnimControl(animName, partName).isPlaying()):
|
||||
if (self.__animControlDict[lodName].has_key(partName)):
|
||||
for animName in self.__animControlDict[lodName][partName].keys():
|
||||
if (self.__getAnimControl(animName, partName, lodName).isPlaying()):
|
||||
return animName
|
||||
else:
|
||||
Actor.notify.warning("no part named %s" % (partName))
|
||||
|
@ -11,29 +11,58 @@ class Button:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.managed = 0
|
||||
# up
|
||||
self.l1 = GuiLabel.GuiLabel.makeSimpleTextLabel(name, font)
|
||||
self.l1.setForegroundColor(0., 0., 0., 1.)
|
||||
self.l1.setBackgroundColor(1., 1., 1., 1.)
|
||||
# roll-over up
|
||||
self.l2 = GuiLabel.GuiLabel.makeSimpleTextLabel(name, font)
|
||||
self.l2.setForegroundColor(1., 1., 1., 1.)
|
||||
self.l2.setBackgroundColor(0., 0., 0., 1.)
|
||||
self.button = GuiButton.GuiButton(name, self.l1, self.l1,
|
||||
self.l2, self.l2, self.l1)
|
||||
self.l2.setForegroundColor(0., 0., 0., 1.)
|
||||
self.l2.setBackgroundColor(1., 1., 0., 1.)
|
||||
# roll-over down
|
||||
self.l3 = GuiLabel.GuiLabel.makeSimpleTextLabel(name, font)
|
||||
self.l3.setForegroundColor(1., 1., 1., 1.)
|
||||
self.l3.setBackgroundColor(0., 0., 0., 1.)
|
||||
self.button = GuiButton.GuiButton(name, self.l1, self.l2,
|
||||
self.l3, self.l3, self.l1)
|
||||
self.setScale(0.1)
|
||||
self.setPos(0., 0.)
|
||||
|
||||
def __del__(self):
|
||||
if (self.managed):
|
||||
self.button.unmanage()
|
||||
del(self.button)
|
||||
del(self.l1)
|
||||
del(self.l2)
|
||||
|
||||
def __str__(self):
|
||||
return "Button: %s" % self.name
|
||||
|
||||
def getName(self):
|
||||
return name
|
||||
return self.name
|
||||
|
||||
def getGuiItem(self):
|
||||
return self.button
|
||||
|
||||
def getWidth(self):
|
||||
# assume all buttons have the same width
|
||||
return self.l1.getWidth()
|
||||
|
||||
|
||||
def setWidth(self, width):
|
||||
self.l1.setWidth(width / self.button.getScale())
|
||||
self.l2.setWidth(width / self.button.getScale())
|
||||
self.l3.setWidth(width / self.button.getScale())
|
||||
|
||||
def manage(self):
|
||||
self.button.manage(guiMgr, base.eventMgr.eventHandler)
|
||||
self.managed = 1
|
||||
|
||||
def unmanage(self):
|
||||
self.button.unmanage()
|
||||
self.managed = 0
|
||||
|
||||
def setPos(self, x, y):
|
||||
v3 = Vec3.Vec3(x, 0., y)
|
||||
self.button.setPos(v3)
|
||||
|
@ -11,9 +11,15 @@ class Frame:
|
||||
# special methods
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.managed = 0
|
||||
self.frame = GuiFrame.GuiFrame(name)
|
||||
self.items = []
|
||||
|
||||
def __del__(self):
|
||||
if (self.managed):
|
||||
self.frame.unmanage()
|
||||
del(self.frame)
|
||||
|
||||
def __str__(self):
|
||||
return "Frame: %s = %s" % self.name, self.items
|
||||
|
||||
@ -23,7 +29,12 @@ class Frame:
|
||||
|
||||
def manage(self):
|
||||
self.frame.manage(guiMgr, base.eventMgr.eventHandler)
|
||||
|
||||
self.managed = 1
|
||||
|
||||
def unmanage(self):
|
||||
self.frame.unmanage()
|
||||
self.unmanage = 0
|
||||
|
||||
def setPos(Self, x, y):
|
||||
v3 = Vec3.Vec3(x, 0., y)
|
||||
self.frame.setPos(v3)
|
||||
@ -46,13 +57,38 @@ class Frame:
|
||||
self.frame.packItem(self.items[itemNum].getGuiItem(), relation,
|
||||
self.items[otherItemNum].getGuiItem())
|
||||
|
||||
def makeVetical(self):
|
||||
# convenience functions
|
||||
def makeVertical(self):
|
||||
# remove any previous packing
|
||||
#self.frame.clearAllPacking()
|
||||
# make each item (except first) align under the last
|
||||
for itemNum in range(1, len(self.items)):
|
||||
# self.frame.clearPacking(self.items[itemNum].getGuiItem())
|
||||
self.packItem(itemNum, GuiFrame.GuiFrame.UNDER, itemNum - 1)
|
||||
|
||||
def makeHorizontal(self):
|
||||
# remove any previous packing
|
||||
#self.frame.clearAllPacking()
|
||||
# make each item (except first) align right of the last
|
||||
for itemNum in range(1, len(self.items)):
|
||||
#self.frame.clearPacking(self.items[itemNum].getGuiItem())
|
||||
self.packItem(itemNum, GuiFrame.GuiFrame.RIGHT, itemNum - 1)
|
||||
|
||||
def makeWideAsWidest(self):
|
||||
# make all the buttons as wide as the widest button in
|
||||
# the frame
|
||||
widest = 0
|
||||
widestWidth = 0.0
|
||||
# find the widest
|
||||
for item in self.items:
|
||||
thisWidth = item.getWidth()
|
||||
if (thisWidth > widestWidth):
|
||||
widest = self.items.index(item)
|
||||
widestWidth = thisWidth
|
||||
|
||||
# make them all this wide
|
||||
for item in self.items:
|
||||
item.setWidth(widestWidth)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user