Home | Trees | Indices | Help |
---|
|
1 # -*- encoding: utf-8 -*- 2 # pilas engine - a video game framework. 3 # 4 # copyright 2010 - hugo ruscitti 5 # license: lgplv3 (see http://www.gnu.org/licenses/lgpl.html) 6 # 7 # website - http://www.pilas-engine.com.ar 8 9 import pilas 10 from pilas.interfaz.base_interfaz import BaseInterfaz 11 12146516 BaseInterfaz.__init__(self, x=x, y=y) 17 self.opciones = opciones 18 self.funcion_a_ejecutar = funcion_a_ejecutar 19 20 ancho, alto = pilas.mundo.motor.obtener_area_de_texto("\n".join(opciones)) 21 22 self.alto_opcion = pilas.mundo.motor.obtener_area_de_texto("texto")[1] 23 self.alto_opciones = self.alto_opcion * len(self.opciones) 24 self.ancho_opciones = ancho 25 self.separacion_entre_opciones = 2 # en pixels 26 27 self.imagen = pilas.imagenes.cargar_superficie(int(ancho + 35), int(self.alto_opciones + (self.separacion_entre_opciones * len(self.opciones) * 2))) 28 29 self._pintar_opciones() 30 31 pilas.eventos.mueve_mouse.conectar(self.cuando_mueve_el_mouse) 32 pilas.eventos.click_de_mouse.conectar(self.cuando_hace_click_con_el_mouse) 33 34 self.centro = ("centro", "centro") 35 self.fijo = True3638 self.imagen.pintar(pilas.colores.blanco) 39 40 if pinta_indice_opcion != None: 41 self.imagen.rectangulo(0, pinta_indice_opcion * (self.alto_opcion + (self.separacion_entre_opciones * 2)), self.imagen.ancho(), self.alto_opcion + (self.separacion_entre_opciones * 2), relleno=True, color=pilas.colores.naranja) 42 43 for indice, opcion in enumerate(self.opciones): 44 self.imagen.texto(opcion, 15, y=self.alto_opcion * indice + self.alto_opcion + (self.separacion_entre_opciones * 2 * indice), color=pilas.colores.negro)4547 if (self.activo): 48 if self.colisiona_con_un_punto(evento.x, evento.y): 49 opcion_seleccionada = self._detectar_opcion_bajo_el_mouse(evento) 50 self._pintar_opciones(opcion_seleccionada)5153 if (self.activo): 54 if self.colisiona_con_un_punto(evento.x, evento.y): 55 opcion = self._detectar_opcion_bajo_el_mouse(evento) 56 if self.funcion_a_ejecutar: 57 self.funcion_a_ejecutar(self.opciones[opcion]) 58 else: 59 print "Cuidado, no has definido funcion a ejecutar en la lista de seleccion."60
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Jan 27 23:57:21 2013 | http://epydoc.sourceforge.net |