Esempio n. 1
0
  def start(self):
    print "decryption start"

    self.wordlist = None

    try:
      self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) )
      self.wordlist = gcompris.get_wordlist("decryption/default-$LOCALE.xml")
    except:
      pass
    # Fallback to wordsgame list
    if not self.wordlist:
      try:
        self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) )
        self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml")
      except:
        pass
    # Fallback to english
    if not self.wordlist:
      try:
        self.wordlist = gcompris.get_wordlist("decryption/default-en.xml")
        self.language = _("English")
      except:
        pass
    # Fallback to English wordsgame list
    if not self.wordlist:
      self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml")
      self.language = _("English")

    if not self.wordlist:
      gcompris.utils.dialog(_("Could not find the list of words."),
                            stop_board)
      return;

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                   self.gcomprisBoard.canvas.get_root_item())

    self.next_level()
Esempio n. 2
0
  def start(self):
    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
    self.backitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    svghandle = gcompris.utils.load_svg("hangman/back.svgz")
    goocanvas.Svg(
      parent = self.backitem,
      svg_handle = svghandle,
      pointer_events = goocanvas.EVENTS_NONE
      )

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.backitem)

    # Get the name of the language for the current locale
    self.wordlist = None
    try:
      self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) )
      self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml")
    except:
      pass

    if not self.wordlist:
      # Fallback to english
      self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml")
      self.language = _("English")

    if not self.wordlist:
      gcompris.utils.dialog(_("Could not find the list of words."),
                            stop_board)
      return;

    self.gcomprisBoard.level = 1
    self.gcomprisBoard.maxlevel = self.wordlist.number_of_level * 3
    self.gcomprisBoard.sublevel = 1
    self.gcomprisBoard.number_of_sublevel = 10

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6)

    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    self.display_level()
Esempio n. 3
0
  def start(self):
    logged = gcompris.admin.get_current_user()

    # API Test, return the absolute path to this file
    print gcompris.utils.find_file_absolute("sounds/bleep.wav")
#    wordlist = gcompris.get_wordlist('wordslevel_max_pt_BR')
#    print wordlist
#    print wordlist.filename
#    print wordlist.level
#    print wordlist.locale
#    print wordlist.description
#    print wordlist.words


    if logged:
      print "User Logged in:"
      print "   ", logged.login, logged.firstname, logged.lastname

    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=1
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1

    # init config to default values
    self.config_dict = self.init_config()

    print "init self.config_dict :", self.config_dict

    # change configured values
    print "gcompris.get_board_conf() : ", gcompris.get_board_conf()
    self.config_dict.update(gcompris.get_board_conf())

    print "self.config_dict final :", self.config_dict

    self.previous_locale = gcompris.get_locale()

    if self.config_dict.has_key('locale'):
      gcompris.change_locale(self.config_dict['locale'])

    # self.colors['line'] s set in init.
    # I put here the configuration use

    color_name = self.config_dict['color_line']
    self.colors['line'] = self.config_colors[color_name]

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
    gcompris.bar_set_level(self.gcomprisBoard)

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

    # distance is used to demo of gcompris.spin_int
    distance = eval(self.config_dict['distance_circle'])

    # pattern is for gcompris.radio_buttons
    pattern = self.config_dict['pattern']

    patterns = { 'circle': goocanvas.Ellipse,
                 'rectangle': goocanvas.Rect
                 }

    #error check
    if not patterns.has_key(pattern):
      pattern = 'circle'

    self.canvasitems[1] = patterns[pattern](
      parent = self.rootitem,
      fill_color_rgba= self.colors['circle_in'],
      stroke_color_rgba= self.colors['circle_out'],
      line_width=1.0
      )
    self.canvasitems[1].connect("button_press_event", self.circle_item_event)
    self.canvasitems[1].connect("button_release_event", self.circle_item_event)
    self.canvasitems[1].connect("motion_notify_event", self.circle_item_event)

    if(pattern == 'circle'):
      self.canvasitems[1].set_properties(
        center_x = 400.0 - distance,
        center_y = 200.0,
        radius_x = 20,
        radius_y = 20)
    else:
      self.canvasitems[1].set_properties(
        x = 400.0 - distance,
        y = 200.0,
        width = 20,
        height = 20)

    self.canvasitems[2] = patterns[pattern](
      parent = self.rootitem,
      fill_color_rgba= self.colors['circle_in'],
      stroke_color_rgba= self.colors['circle_out'],
      line_width=1.0
      )
    self.canvasitems[2].connect("button_press_event", self.circle_item_event)
    self.canvasitems[2].connect("button_release_event", self.circle_item_event)
    self.canvasitems[2].connect("motion_notify_event", self.circle_item_event)

    if(pattern == 'circle'):
      self.canvasitems[2].set_properties(
        center_x = 400.0 + distance,
        center_y = 200.0,
        radius_x = 20,
        radius_y = 20)
    else:
      self.canvasitems[2].set_properties(
        x = 400.0 + distance,
        y = 200.0,
        width = 20,
        height = 20)

    self.canvasitems[3] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=100.0,
      text=_("This is the first plugin in GCompris coded in the Python\nProgramming language."),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.canvasitems[4] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=140.0,
      text=_("It is now possible to develop GCompris activities in C or in Python.\nThanks to Olivier Samys who makes this possible."),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.canvasitems[5] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=250.0,
      text=_("This activity is not playable, just a test"),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    #----------------------------------------
    # A simple game.
    # Try to hit left shift and right shift together. The peed increases
    goocanvas.Rect(
      parent = self.rootitem,
      x = 20,
      y = gcompris.BOARD_HEIGHT-220,
      width = gcompris.BOARD_WIDTH-40,
      height = 150,
      fill_color_rgba=0xFF663333L,
      stroke_color_rgba=0xFF33CCAAL,
      line_width=2.0)

    # For the game status WIN/LOOSE
    self.canvasitems[6] = goocanvas.Text(
      parent = self.rootitem,
      x=gcompris.BOARD_WIDTH / 2,
      y=gcompris.BOARD_HEIGHT - 100,
      font=gcompris.skin.get_font("gcompris/content"),
      fill_color_rgba=0x102010FFL,
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=360.0,
      text=("Test your reflex with the counter. Hit the 2 shifts key together.\nHit space to reset the counter and increase the speed.\nBackspace to reset the speed"),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    # The basic tick for object moves
    self.timerinc = 1000

    self.timer_inc  = gobject.timeout_add(self.timerinc, self.timer_inc_display)

    self.counter_left  = 0
    self.counter_right = 0

    self.canvasitems[7] =goocanvas.Text(
      parent = self.rootitem,
      x=gcompris.BOARD_WIDTH / 2,
      y=gcompris.BOARD_HEIGHT - 120,
      font=gcompris.skin.get_font("gcompris/content"),
      text="Speed="+str(self.timerinc)+" ms",
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.textitem_left = goocanvas.Text(
      parent = self.rootitem,
      font=gcompris.skin.get_font("gcompris/content"),
      x=gcompris.BOARD_WIDTH / 3,
      y=gcompris.BOARD_HEIGHT - 100,
      fill_color_rgba=0xFF000FFFL
      )

    self.textitem_right =goocanvas.Text(
      parent = self.rootitem,
      font=gcompris.skin.get_font("gcompris/content"),
      x=gcompris.BOARD_WIDTH / 1.5,
      y=gcompris.BOARD_HEIGHT - 100,
      fill_color_rgba=0xFF000FFFL
      )

    self.left_continue  = True
    self.right_continue = True

    print("Gcompris_pythontest start.")