Ejemplo n.º 1
0
  def action(self, objet, target, truc, idpt):
    """Action to do at each step during normal execution of the game"""
    if truc.type == gtk.gdk.BUTTON_PRESS :
      if idpt == (self.actu+1): #Action to execute if the selected point is the following of previous one
        xd,yd,xa,ya = self.POINT[(idpt-1)].x, self.POINT[(idpt-1)].y, self.POINT[idpt].x, self.POINT[idpt].y
        goocanvas.Polyline(
          parent = self.ROOT,
          points = goocanvas.Points([(xd,yd), (xa,ya)]),
          fill_color = 'black',
          line_cap = cairo.LINE_CAP_ROUND,
          line_width = 2)

        if idpt == 2: # Always raise the first point
          self.POINT[self.MAX].raise_(None)

        objet.props.visibility = goocanvas.ITEM_INVISIBLE
        if idpt==self.MAX : #Action to exectute if all points have been selected in good way
          gcompris.set_background(self.ROOT,
                                  self.data[self.gcomprisBoard.sublevel][0][2])
          self.gamewon = 1
          gcompris.bar_hide(True)
          self.timeout = gobject.timeout_add(1500, self.lauch_bonus) # The level is complete -> Bonus display

        else : # Action to execute if the selected point isn''t the last one of this level
          # Set color in blue to next point. Too easy ???
          self.POINT[(idpt+1)].set_properties(fill_color_rgba=0x003DF5D0)
          self.actu = self.actu+1 #self.actu update to set it at actual value of selected point
Ejemplo n.º 2
0
    def action(self, objet, target, truc, idpt):
        """Action to do at each step during normal execution of the game"""
        if truc.type == gtk.gdk.BUTTON_PRESS:
            if idpt == (
                    self.actu + 1
            ):  #Action to execute if the selected point is the following of previous one
                xd, yd, xa, ya = self.POINT[(idpt - 1)].x, self.POINT[(
                    idpt - 1)].y, self.POINT[idpt].x, self.POINT[idpt].y
                item = goocanvas.Polyline(parent=self.ROOT,
                                          points=goocanvas.Points([(xd, yd),
                                                                   (xa, ya)]),
                                          stroke_color='black',
                                          line_cap=cairo.LINE_CAP_ROUND,
                                          line_width=1.5)

                if idpt == 2:  # Always raise the first point
                    self.POINT[self.MAX].raise_(None)
                    self.TEXT[self.MAX].raise_(None)

                self.POINT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE
                self.TEXT[idpt].props.visibility = goocanvas.ITEM_INVISIBLE
                if idpt == self.MAX:  #Action to execute if all points have been selected in good way
                    gcompris.set_background(
                        self.ROOT,
                        self.data[self.gcomprisBoard.sublevel - 1].img2)
                    self.gamewon = 1
                    gcompris.bar_hide(True)
                    self.timeout = gobject.timeout_add(
                        1500, self.lauch_bonus
                    )  # The level is complete -> Bonus display

                else:  #Action to execute if the selected point isn''t the last one of this level
                    #Set color in blue to next point. Too easy ???
                    #self.POINT[(idpt+1)].set_properties(fill_color_rgba=0x003DF5F0)
                    self.actu = self.actu + 1  #self.actu update to set it at actual value of selected point
Ejemplo n.º 3
0
  def start(self):
    progname='tuxpaint'
    tuxpaint_dir = None
    flags = gobject.SPAWN_DO_NOT_REAP_CHILD | gobject.SPAWN_SEARCH_PATH

    print platform.platform(), platform.platform().split('-')[0]
    if (platform.platform().split('-')[0] == 'Windows'):
      progname = 'tuxpaint.exe'

      try:
         import _winreg

         tuxpaint_key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE,
                                         "Software\\TuxPaint" )
         tuxpaint_dir, type = _winreg.QueryValueEx(tuxpaint_key, "Install_Dir")
         flags = gobject.SPAWN_DO_NOT_REAP_CHILD
         # escape mandatory in Win pygtk2.6
         tuxpaint_dir = '"' + tuxpaint_dir + '"'

      except:
	   pass

    self.window = self.gcomprisBoard.canvas.get_toplevel()

    Prop = gcompris.get_properties()

    #get default values
    self.config_dict = self.init_config()

    #replace configured values
    self.config_dict.update(gcompris.get_board_conf())

    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())



    # first run: find version
    options = [progname]
    options.append('--version')
    global pid
    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir,
            standard_output=True
            )

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            standard_output=True
            )

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    output=os.read(stdout, 255)

    parsenext = False
    oldfullscreensyntax = False
    for i in output.split():
      if ( parsenext):
        tpversion = i.split(".")
        major, minor, sub = tpversion
        if (int(major) < 1 and int(minor) < 10 and int(sub) < 22):
          oldfullscreensyntax=True
        break

      if (i == "Version"):
        # next is the version number
        parsenext = True


    # second run: adapt the parms to the version and run
    options = [progname]

    if (Prop.fullscreen and eval(self.config_dict['fullscreen'])):
      if (oldfullscreensyntax):
        options.append('--fullscreen')
        options.append('--native')
      else:
        options.append('--fullscreen=native')

    if eval(self.config_dict['disable_shape_rotation']):
      options.append('--simpleshapes')

    if eval(self.config_dict['uppercase_text']):
      options.append('--uppercase')

    if eval(self.config_dict['disable_stamps']):
      options.append('--nostamps')

    if eval(self.config_dict['disable_stamps_control']):
      options.append('--nostampcontrols')

    gcompris.sound.close()

    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir)

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags)

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.bar_hide(1)

    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    textItem = goocanvas.Text(
      parent = self.rootitem,
      text = _("Waiting for Tuxpaint to finish"),
      x = gcompris.BOARD_WIDTH/2,
      y = 185,
      fill_color_rgba = 0x000000ffL,
      anchor = gtk.ANCHOR_CENTER,
      font = gcompris.skin.get_font("gcompris/board/title bold"),
      )
Ejemplo n.º 4
0
  def start(self):
    progname='tuxpaint'
    tuxpaint_dir = None
    flags = gobject.SPAWN_DO_NOT_REAP_CHILD | gobject.SPAWN_SEARCH_PATH

    print platform.platform(), platform.platform().split('-')[0]
    if (platform.platform().split('-')[0] == 'Windows'):
      progname = 'tuxpaint.exe'

      try:
         import _winreg

         tuxpaint_key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE,
                                         "Software\\TuxPaint" )
         tuxpaint_dir, type = _winreg.QueryValueEx(tuxpaint_key, "Install_Dir")
         flags = gobject.SPAWN_DO_NOT_REAP_CHILD
         # escape mandatory in Win pygtk2.6
         tuxpaint_dir = '"' + tuxpaint_dir + '"'

      except:
	   pass

    self.window = self.gcomprisBoard.canvas.get_toplevel()

    Prop = gcompris.get_properties()

    #get default values
    self.config_dict = self.init_config()

    #replace configured values
    self.config_dict.update(gcompris.get_board_conf())

    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

    options = [progname]

    if (Prop.fullscreen and eval(self.config_dict['fullscreen'])):
      options.append('--fullscreen')

    if eval(self.config_dict['disable_shape_rotation']):
      options.append('--simpleshapes')

    if eval(self.config_dict['uppercase_text']):
      options.append('--uppercase')

    if eval(self.config_dict['disable_stamps']):
      options.append('--nostamps')

    if eval(self.config_dict['disable_stamps_control']):
      options.append('--nostampcontrols')

    gcompris.sound.close()

    global pid
    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir)

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags)

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.bar_hide(1)

    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    textItem = goocanvas.Text(
      parent = self.rootitem,
      text = _("Waiting for Tuxpaint to finish"),
      x = gcompris.BOARD_WIDTH/2,
      y = 185,
      fill_color_rgba = 0x000000ffL,
      anchor = gtk.ANCHOR_CENTER,
      font = gcompris.skin.get_font("gcompris/board/title bold"),
      )