Skip to content

Commit

Permalink
Correcciones para Sugar
Browse files Browse the repository at this point in the history
  • Loading branch information
fdanesse committed Oct 11, 2014
1 parent 8005280 commit da567a6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 35 deletions.
24 changes: 20 additions & 4 deletions CucaraSims/CucaraSims.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ def __run_lectura(self, derecha, lectura):
if lectura == "salir":
self.emit("exit")
return
self.get_toplevel().juego.pause()
try:
self.get_toplevel().juego.pause()
except:
# Para Sugar
self.get_toplevel().interfaz.juego.pause()
dialog = Widget_Leccion(
parent=self.get_toplevel(), lectura=lectura)
dialog.run()
dialog.stop()
dialog.destroy()
self.get_toplevel().juego.unpause()
try:
self.get_toplevel().juego.unpause()
except:
# Para Sugar
self.get_toplevel().interfaz.juego.unpause()

def update(self, juego, _dict):
"""
Expand All @@ -136,13 +144,21 @@ def run_lectura(self, juego, lectura):
"""
if not lectura in self.lecciones:
self.lecciones.append(lectura)
self.get_toplevel().juego.pause()
try:
self.get_toplevel().juego.pause()
except:
# Para Sugar
self.get_toplevel().interfaz.juego.pause()
dialog = Widget_Leccion(
parent=self.get_toplevel(), lectura=lectura)
dialog.run()
dialog.stop()
dialog.destroy()
self.get_toplevel().juego.unpause()
try:
self.get_toplevel().juego.unpause()
except:
# Para Sugar
self.get_toplevel().interfaz.juego.unpause()
if lectura == "muerte":
self.toolbarestado.set_info(
"Se han producido muertes en el habitat.")
Expand Down
47 changes: 29 additions & 18 deletions SugarBichos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import gtk
import gobject

from sugar.activity.activity import Activity

from EventTraductor.EventTraductor import KeyPressTraduce
from EventTraductor.EventTraductor import KeyReleaseTraduce

Expand All @@ -22,32 +20,45 @@
from CucaraSims.Juego import CucaraSims
from OjosCompuestos.OjosCompuestos import OjosCompuestos

from sugar.activity.activity import Activity


class Bichos(Activity):

def __init__(self, handle):

Activity.__init__(self, handle)
Activity.__init__(self, handle, False)
self.socket = gtk.Socket()
self.set_canvas(self.socket)
self.interfaz = Interfaz()
self.socket.add_id(self.interfaz.get_id())
self.show_all()

self.set_title("Bichos")
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
#self.set_icon_from_file(os.path.join(BASE, "Iconos", "bichos.svg"))
self.set_resizable(True)
self.set_size_request(640, 480)
self.set_position(gtk.WIN_POS_CENTER)
self.connect("key-press-event", self.interfaz.key_press_even)
self.connect("key-release-event", self.interfaz.key_release_even)

def read_file(self, file_path):
pass

def write_file(self, file_path):
pass


class Interfaz(gtk.Plug):

def __init__(self):

gtk.Plug.__init__(self, 0L)

self.juego = False
self.widgetjuego = False

self.connect("key-press-event", self.__key_press_even)
self.connect("key-release-event", self.__key_release_even)

self.connect("delete-event", self.__salir)
self.connect("realize", self.__do_realize)

self.show_all()

def __key_press_even(self, widget, event):
def key_press_even(self, widget, event):
if self.juego:
KeyPressTraduce(event)
else:
Expand All @@ -56,7 +67,7 @@ def __key_press_even(self, widget, event):
self.switch(False, 1)
return False

def __key_release_even(self, widget, event):
def key_release_even(self, widget, event):
if self.juego:
KeyReleaseTraduce(event)
return False
Expand Down Expand Up @@ -148,7 +159,7 @@ def switch(self, widget, valor):
if valor == 1:
self.widgetjuego = Escenario()
self.widgetjuego.connect("new-size", self.__redraw)
self.set_canvas(self.widgetjuego)
self.add(self.widgetjuego)
gobject.idle_add(self.__run_intro, self.widgetjuego)

elif valor == 2:
Expand All @@ -159,18 +170,18 @@ def switch(self, widget, valor):
escenario.connect("new-size", self.__redraw)
escenario.connect("mouse-enter", self.__mouse_enter)
self.widgetjuego = CucaraSimsWidget(escenario)
self.set_canvas(self.widgetjuego)
self.add(self.widgetjuego)
gobject.idle_add(self.__run_cucarasims, escenario)

elif valor == 3:
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff"))
self.widgetjuego = CantaBichos()
self.set_canvas(self.widgetjuego)
self.add(self.widgetjuego)

elif valor == 4:
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff"))
escenario = Escenario()
escenario.modify_bg(
gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
self.widgetjuego = OjosCompuestos(escenario)
self.set_canvas(self.widgetjuego)
self.add(self.widgetjuego)
46 changes: 34 additions & 12 deletions Widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,46 @@ def __mouse_leave(self, widget, event):
self.emit("mouse-enter", False)

def __button_press_event(self, widget, event):
if self.get_toplevel().juego:
Traduce_button_press_event(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
try:
if self.get_toplevel().juego:
Traduce_button_press_event(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
except:
# Para Sugar
if self.get_toplevel().interfaz.juego:
Traduce_button_press_event(event,
self.get_allocation(),
self.get_toplevel().interfaz.juego.RESOLUCION_INICIAL)

return False

def __button_release_event(self, widget, event):
if self.get_toplevel().juego:
Traduce_button_release_event(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
try:
if self.get_toplevel().juego:
Traduce_button_release_event(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
except:
# Para Sugar
if self.get_toplevel().interfaz.juego:
Traduce_button_release_event(event,
self.get_allocation(),
self.get_toplevel().interfaz.juego.RESOLUCION_INICIAL)
return False

def __mouse_motion(self, widget, event):
if self.get_toplevel().juego:
MousemotionTraduce(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
try:
if self.get_toplevel().juego:
MousemotionTraduce(event,
self.get_allocation(),
self.get_toplevel().juego.RESOLUCION_INICIAL)
except:
# Para Sugar
if self.get_toplevel().interfaz.juego:
MousemotionTraduce(event,
self.get_allocation(),
self.get_toplevel().interfaz.juego.RESOLUCION_INICIAL)
return False

def __size_request(self, widget, event):
Expand Down
2 changes: 1 addition & 1 deletion proyecto.ide
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"[email protected]"
]
],
"categoria":"",
"categoria":"Game",
"descripcion":"",
"licencia":"GPL3",
"main":"Main.py",
Expand Down

0 comments on commit da567a6

Please sign in to comment.