Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setupPowerBar(self):
self.powerBar = DirectWaitBar(pos=(0.0, 0, -0.94), relief=DGG.SUNKEN, frameSize=(-2.0,
2.0,
-0.2,
0.2), borderWidth=(0.02, 0.02), scale=0.25, range=1, sortOrder=50, frameColor=(0.5, 0.5, 0.5, 0.5), barColor=(0.75, 0.75, 1.0, 0.8), text='', text_scale=0.26, text_fg=(1, 1, 1, 1), text_align=TextNode.ACenter, text_pos=(0, -0.05))
self.power = 0
self.powerBar['value'] = self.power
self.powerBar.hide()
def addInstructions(pos, msg):
return OnscreenText(text=msg, style=1, fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1),
parent=base.a2dTopLeft, align=TextNode.ALeft,
pos=(0.08, -pos - 0.04), scale=.05)
def load(self):
from toontown.toonbase import ToontownGlobals
from panda3d.core import TextNode
textNode = TextNode('moviedialogue')
textNode.setTextColor(0, 0, 0, 1)
textNode.setCardColor(1, 1, 1, 1)
textNode.setCardAsMargin(0, 0, 0, 0)
textNode.setCardDecal(True)
textNode.setWordwrap(27.0)
textNode.setAlign(TextNode.ACenter)
textNode.setFont(ToontownGlobals.getToonFont())
self._dialogueLabel = aspect2d.attachNewNode(textNode)
self._dialogueLabel.setScale(0.06, 0.06, 0.06)
self._dialogueLabel.setPos(0.32, 0, -0.75)
self._dialogueLabel.reparentTo(hidden)
self.minLineHeight = minLineHeight
self.maxRows = maxRows
self.recordedText = [] #recorder text sections used in backup
NodePath.__init__(self,'')
self.setScale(scale)
self.setPos(pos)
self.currentHeight = 0
self.reparentTo(self.__parent) # @UndefinedVariable
self.textMaker = TextNode('textMaker')
if font:
self.setFont(font, specNode = None)
if fg:
self.setFg(fg, specNode = None)
if shadow:
self.setShadow(shadow, shadowOffset, specNode = None)
if textScale:
self.setTexScale(textScale,specNode = None)
self.textMaker.setAlign(TextNode.ALeft)
if shadow:
pass
if text:
self.appendText(text)
numLines = 1,
width = 200,
entryFont=self.font,
focus=1,
suppressKeys=1)
self.query.bind("press-escape-", self.escape)
self.query.bind("press-tab-", self.select)
self.query.accept(self.query.guiItem.getTypeEvent(), self.completion)
self.query.accept(self.query.guiItem.getEraseEvent(), self.completion)
pos = self.prefix.getPos()
bounds = self.query.getBounds()
llz = bounds[2] / self.text_size
self.suggestions = OnscreenText(text = "",
font=self.font,
fg=settings.hud_color,
align=TextNode.ALeft,
mayChange=True,
parent=base.a2dBottomLeft,
scale=tuple(self.scale * self.suggestions_text_size),
pos=(pos[0], pos[1] + llz),
)
def addTitle(text):
return OnscreenText(text=text, style=1, pos=(-0.1, 0.09), scale=.08,
parent=base.a2dBottomRight, align=TextNode.ARight,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1))
def add_instructions(pos, msg):
"""Function to put instructions on the screen."""
return OnscreenText(text=msg, style=1, fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1),
parent=base.a2dTopLeft, align=TextNode.ALeft,
pos=(0.08, -pos - 0.04), scale=.05)
def __init__(self):
# Our standard title and instructions text
self.title = OnscreenText(text="Panda3D: Tutorial - Music Box",
parent=base.a2dBottomCenter,
pos=(0, 0.08), scale=0.08,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, .5))
self.escapeText = OnscreenText(text="ESC: Quit", parent=base.a2dTopLeft,
fg=(1, 1, 1, 1), pos=(0.06, -0.1),
align=TextNode.ALeft, scale=.05)
# Set up the key input
self.accept('escape', sys.exit)
# Fix the camera position
base.disableMouse()
# Loading sounds is done in a similar way to loading other things
# Loading the main music box song
self.musicBoxSound = loader.loadMusic('music/musicbox.ogg')
self.musicBoxSound.setVolume(.5) # Volume is a percentage from 0 to 1
# 0 means loop forever, 1 (default) means
# play once. 2 or higher means play that many times
self.musicBoxSound.setLoopCount(0)
# Set up a simple light.
def add_title(text):
"""Function to put title on the screen."""
return OnscreenText(text=text, style=1, pos=(-0.1, 0.09), scale=.08,
parent=base.a2dBottomRight, align=TextNode.ARight,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1))
def genLabelText(self, text, i):
text = OnscreenText(text = text, pos = (-1.3, .5-.05*i), fg=(0,1,0,1),
align = TextNode.ALeft, scale = .05)
return text