Back to index

freevial  1.2
Public Member Functions | Public Attributes
common.dialog_question.Question Class Reference

List of all members.

Public Member Functions

def __init__
def setSelColor
def ask

Public Attributes

 color

Detailed Description

Definition at line 33 of file dialog_question.py.


Constructor & Destructor Documentation

Definition at line 35 of file dialog_question.py.

00035 
00036        def __init__(self):
00037        
00038               self.color = (255, 0, 0)
       

Member Function Documentation

def common.dialog_question.Question.ask (   self,
  screen,
  pregunta,
  respostes,
  predeterminat = 0,
  cancel = -1 
)

Definition at line 44 of file dialog_question.py.

00044 
00045        def ask( self, screen, pregunta, respostes, predeterminat = 0, cancel = -1 ):
00046 
00047               frate = frameRate( 40 )
00048 
00049               seleccio = predeterminat
00050 
00051               sfc_copiascreen = pygame.Surface( ( screen.get_width(), screen.get_height()), pygame.SRCALPHA, 32 )
00052               sfc_screen2 = pygame.Surface( ( screen.get_width(), screen.get_height()), pygame.SRCALPHA, 32 )
00053 
00054               sfc_copiascreen.blit( screen, (0,0) )
00055 
00056               total_duracio_fadeout = duracio_fadeout = 10
00057               intensitat_fadeout = 20
00058 
00059               sfc_pregunta = render_text( pregunta, (255,255,255), 50, 1, '', 600 )
00060               sfc_respostes = []
00061 
00062               espai_entre_respostes = 32
00063               respostes_ample = 0
00064               for compta in range(0, len(respostes) ):
00065                      sfc = render_text( respostes[compta], (255,255,255), 50, 1, '', 500 )
00066                      respostes_ample += sfc.get_width()
00067                      if compta: respostes_ample += espai_entre_respostes
00068 
00069                      sfc_respostes.append( sfc )
00070 
00071               while 1:
00072 
00073                      for event in pygame.event.get():
00074 
00075                             eventhandle = EventHandle(event)
00076                             
00077                             if event.type == pygame.JOYBUTTONDOWN:
00078                                    translateJoystickEvent(event)
00079                             
00080                             if eventhandle.isQuit():
00081                                    sys.exit()
00082                             
00083                             if eventhandle.keyUp('ESCAPE', 'q'):
00084                                    return cancel
00085                             
00086                             if eventhandle.keyDown('PRINT'):
00087                                    screenshot(self.joc.screen)
00088                             
00089                             if eventhandle.keyUp('f', 'F11'):
00090                                    pygame.display.toggle_fullscreen()
00091                             
00092                             if eventhandle.keyUp('RIGHT'):     
00093                                    seleccio += 1
00094                                    seleccio %= len(respostes)
00095                             
00096                             if eventhandle.keyUp('LEFT'):      
00097                                    seleccio -= 1
00098                                    seleccio %= len(respostes)
00099                             
00100                             if eventhandle.isRelease('primary') or eventhandle.keyUp('RETURN', 'SPACE', 'KP_ENTER'):
00101                                    return seleccio
00102                             
00103                      if duracio_fadeout:
00104                             sfc_screen2.blit( sfc_copiascreen, (0,0) )
00105                             sfc_screen2.fill( (0,0,0, total_duracio_fadeout * intensitat_fadeout - duracio_fadeout * intensitat_fadeout) ) 
00106        
00107                             duracio_fadeout -= 1
00108                             
00109                      screen.blit( sfc_copiascreen, (0,0) )
00110                      screen.blit( sfc_screen2, (0,0) )
00111 
00112                      screen.blit( sfc_pregunta, (screen.get_width() / 2 -sfc_pregunta.get_width() / 2, 300) )
00113 
00114                      posx = (screen.get_width() / 2 - respostes_ample / 2 )
00115 
00116                      for compta in range(0, len(respostes) ):
00117 
00118                             if seleccio == compta:
00119                                    for salt in range(0, 25):
00120                                           screen.fill( (self.color[0] * salt / 25, self.color[1]* salt / 25, self.color[2]* salt / 25), (posx - 25 + salt, 450, sfc_respostes[compta].get_width() + 25*2-salt*2, sfc_respostes[compta].get_height()  ))
00121 
00122                             screen.blit( sfc_respostes[compta], (posx, 450) )
00123                             posx += sfc_respostes[compta].get_width() + espai_entre_respostes
00124 
00125                      frate.next( screen )
00126 
00127                      pygame.display.flip()
00128 

Here is the call graph for this function:

def common.dialog_question.Question.setSelColor (   self,
  color 
)

Definition at line 39 of file dialog_question.py.

00039 
00040        def setSelColor ( self, color ):
00041 
00042               self.color = color
00043 


Member Data Documentation

Definition at line 37 of file dialog_question.py.


The documentation for this class was generated from the following file: