def __init__(self, pos=(-0.25,0.5), # position of the image center in the aspect2d viewport # may also be a callable object (e.g.a draw from a random number generator) scale=0.2, # scaling of the image; may also be callable rotation=(0,0,0), # yaw, pitch, roll -- the most relevant is the roll coordinate; may also be callable color=(1,1,1,1), # (r,g,b,a) image color renderviewport=None, # the parent viewport if desired image='blank.tga', # the initial image to present *args,**kwargs ): """Construct a new ImagePresenter.""" MessagePresenter.__init__(self,*args,**kwargs) self.pos = pos self.scale = scale self.rotation = rotation self.color = color self.renderviewport = renderviewport # set up the text panel... #if not (type(self.pos) is List or type(self.pos) is tuple): #pos = self.pos() #if callable(self.scale): #scale = self.scale() #if callable(self.rotation): #rotation = self.rotation() #if callable(self.color): #color = self.color() self.icon = OnscreenImage(image=image,pos=(pos[0],0,pos[1]),scale=scale,hpr=rotation,color= ((0,0,0,0) if image=="blank.tga" else self.color),parent=self.renderviewport) self.icon.setTransparency(TransparencyAttrib.MAlpha)
def __init__( self, presenters=[], # the backend presenter to wrap *args, **kwargs): MessagePresenter.__init__(self, *args, **kwargs) self.presenters = presenters
def __init__(self, wrappresenter=None, # the backend presenter to wrap messages={'target':['sample-target0,sample-target1,sample-target2'],'nontarget':['nt0','nt1']}, # the message map; each of the keys in this dictionary will be # replaced upon submit() by a random choice out of the corresponding value list *args,**kwargs ): MessagePresenter.__init__(self,*args,**kwargs) self.wrappresenter = wrappresenter self.messages = messages
def __init__( self, horzmargin=0.5, # horizontal margin in characters vertmargin=1, # vertical margin in charaters width=30, # width of the text box in characters height=5, # height of the text box in lines scale=0.05, # scaling of the text box pos=( -3.1, -0.6 ), # position of the upper-left corner inside the aspect2d viewport font='arial.ttf', # font to use for the text align='left', # alignment of the text (can be 'left', 'center', or 'right') textcolor=(1, 1, 1, 1), # (r,g,b,a) text color framecolor=(0, 0, 0, 1), # (r,g,b,a) frame color *args, **kwargs): """Construct a new TextPresenter.""" MessagePresenter.__init__(self, *args, **kwargs) if align == 'left': align = TextNode.ALeft elif align == 'right': align = TextNode.ARight else: align = TextNode.ACenter text = TextNode('TextPresenter') text.setText('\n') font = loader.loadFont(font) text.setFont(font) text.setAlign(align) text.setWordwrap(width) text.setTextColor(textcolor[0], textcolor[1], textcolor[2], textcolor[3]) if framecolor[3] > 0: text.setCardColor(framecolor[0], framecolor[1], framecolor[2], framecolor[3]) text.setCardActual(-horzmargin, width + horzmargin, -(height + vertmargin), vertmargin) self.text = text self.text_nodepath = aspect2d.attachNewNode(text) self.text_nodepath.setScale(scale) self.pos = pos self.textcolor = textcolor pos = self.pos self.text_nodepath.setPos(pos[0], 0, pos[1])
def __init__(self, horzmargin=0.5, # horizontal margin in characters vertmargin=1, # vertical margin in charaters width=30, # width of the text box in characters height=5, # height of the text box in lines scale=0.05, # scaling of the text box pos=(-3.1,-0.6), # position of the upper-left corner inside the aspect2d viewport font='arial.ttf', # font to use for the text align='left', # alignment of the text (can be 'left', 'center', or 'right') textcolor=(1,1,1,1), # (r,g,b,a) text color framecolor=(0,0,0,1), # (r,g,b,a) frame color *args,**kwargs ): """Construct a new TextPresenter.""" MessagePresenter.__init__(self,*args,**kwargs) if align == 'left': align = TextNode.ALeft elif align == 'right': align = TextNode.ARight else: align = TextNode.ACenter text = TextNode('TextPresenter') text.setText('\n') font = loader.loadFont(font) text.setFont(font) text.setAlign(align) text.setWordwrap(width) text.setTextColor(textcolor[0],textcolor[1],textcolor[2],textcolor[3]) if framecolor[3] > 0: text.setCardColor(framecolor[0],framecolor[1],framecolor[2],framecolor[3]) text.setCardActual(-horzmargin,width+horzmargin,-(height+vertmargin),vertmargin) self.text = text self.text_nodepath = aspect2d.attachNewNode(text) self.text_nodepath.setScale(scale) self.pos = pos self.textcolor = textcolor pos = self.pos self.text_nodepath.setPos(pos[0],0,pos[1])
def __init__(self, direction=0.0, # horizontal sound direction (-1..+1 is left to right panned) volume=0.3, # sound source volume playrate=1.0, # the playrate of the sound (changes pitch and time) timeoffset=0.0, # time offset into the file looping=False, # whether the sound should be looping; can be turned off by calling .stop() on the return value of this function loopcount=None, # optionally the number of repeats if looping surround=True, # if True, the direction will go from -Pi/2 to Pi/2 *args,**kwargs ): """Construct a new AudioPresenter.""" MessagePresenter.__init__(self,*args,**kwargs) self.direction = direction self.volume = volume self.playrate = playrate self.timeoffset = timeoffset self.looping = looping self.loopcount = loopcount self.surround = surround self.speak = None self.audio3d = None
def __init__( self, pos=(-0.25, 0.5), # position of the image center in the aspect2d viewport # may also be a callable object (e.g.a draw from a random number generator) scale=0.2, # scaling of the image; may also be callable rotation=( 0, 0, 0 ), # yaw, pitch, roll -- the most relevant is the roll coordinate; may also be callable color=(1, 1, 1, 1), # (r,g,b,a) image color renderviewport=None, # the parent viewport if desired image='blank.tga', # the initial image to present *args, **kwargs): """Construct a new ImagePresenter.""" MessagePresenter.__init__(self, *args, **kwargs) self.pos = pos self.scale = scale self.rotation = rotation self.color = color self.renderviewport = renderviewport # set up the text panel... #if not (type(self.pos) is List or type(self.pos) is tuple): #pos = self.pos() #if callable(self.scale): #scale = self.scale() #if callable(self.rotation): #rotation = self.rotation() #if callable(self.color): #color = self.color() self.icon = OnscreenImage( image=image, pos=(pos[0], 0, pos[1]), scale=scale, hpr=rotation, color=((0, 0, 0, 0) if image == "blank.tga" else self.color), parent=self.renderviewport) self.icon.setTransparency(TransparencyAttrib.MAlpha)
def __init__( self, direction=0.0, # horizontal sound direction (-1..+1 is left to right panned) volume=0.3, # sound source volume playrate=1.0, # the playrate of the sound (changes pitch and time) timeoffset=0.0, # time offset into the file looping=False, # whether the sound should be looping; can be turned off by calling .stop() on the return value of this function loopcount=None, # optionally the number of repeats if looping surround=True, # if True, the direction will go from -Pi/2 to Pi/2 *args, **kwargs): """Construct a new AudioPresenter.""" MessagePresenter.__init__(self, *args, **kwargs) self.direction = direction self.volume = volume self.playrate = playrate self.timeoffset = timeoffset self.looping = looping self.loopcount = loopcount self.surround = surround self.speak = None self.audio3d = None
def __init__(self, presenters=[], # the backend presenter to wrap *args,**kwargs ): MessagePresenter.__init__(self,*args,**kwargs) self.presenters = presenters