Пример #1
0
    def __init__(self, fill_color):
        Eye.__init__(self, fill_color)

        self._pixbufs = []
        self._pixbufs.append(svg_str_to_pixbuf(lefteye_svg()))
        self._pixbufs.append(svg_str_to_pixbuf(centereye_svg()))
        self._pixbufs.append(svg_str_to_pixbuf(righteye_svg()))
        self._which_eye = 1
Пример #2
0
    def __init__(self, fill_color):
        Eye.__init__(self, fill_color)

        self._pixbufs = []
        self._pixbufs.append(svg_str_to_pixbuf(lefteye_svg()))
        self._pixbufs.append(svg_str_to_pixbuf(centereye_svg()))
        self._pixbufs.append(svg_str_to_pixbuf(righteye_svg()))
        self._which_eye = 2
Пример #3
0
def highlight_graphic(sprites, scale=1.0):
    return [Sprite(sprites, -100, 0, svg_str_to_pixbuf(
                generate_corners(0, 0.125 * scale))),
            Sprite(sprites, -100, 0, svg_str_to_pixbuf(
                generate_corners(1, 0.125 * scale))),
            Sprite(sprites, -100, 0, svg_str_to_pixbuf(
                generate_corners(2, 0.125 * scale))),
            Sprite(sprites, -100, 0, svg_str_to_pixbuf(
                generate_corners(3, 0.125 * scale)))]
Пример #4
0
def highlight_graphic(sprites, scale=1.0):
    return [
        Sprite(sprites, -100, 0,
               svg_str_to_pixbuf(generate_corners(0, 0.125 * scale))),
        Sprite(sprites, -100, 0,
               svg_str_to_pixbuf(generate_corners(1, 0.125 * scale))),
        Sprite(sprites, -100, 0,
               svg_str_to_pixbuf(generate_corners(2, 0.125 * scale))),
        Sprite(sprites, -100, 0,
               svg_str_to_pixbuf(generate_corners(3, 0.125 * scale)))
    ]
Пример #5
0
 def __init__(self, sprites, svg, svgs, tile_type='tile', number=0):
     self.spr = Sprite(sprites, 0, 0, svg_str_to_pixbuf(svg))
     self.highlight = [self.spr.images[0]]
     for s in svgs:
         self.highlight.append(svg_str_to_pixbuf(s))
     self.paths = []  # [[N, E, S, W], [N, E, S, W]]
     self.shape = None
     self.orientation = 0
     self.type = tile_type
     self.number = number
     self.value = 1
     self.spr.set_label_color('#FF0000')
Пример #6
0
 def _genblanks(self, colors):
     ''' Need to cache these '''
     self._title_pixbuf = svg_str_to_pixbuf(
         genblank(self._width, int(TITLEH * self._scale), colors))
     self._preview_pixbuf = svg_str_to_pixbuf(
         genblank(int(PREVIEWW * self._scale), int(PREVIEWH * self._scale),
                  colors))
     self._desc_pixbuf = svg_str_to_pixbuf(
         genblank(int(self._width - (2 * DESCRIPTIONX * self._scale)),
                  int(DESCRIPTIONH * self._scale), colors))
     self._canvas_pixbuf = svg_str_to_pixbuf(
         genblank(self._width, self._height, (colors[0], colors[0])))
Пример #7
0
 def __init__(self, sprites, svg, svgs, tile_type='tile', number=0):
     self.highlight = [svg_str_to_pixbuf(svg)]
     self.spr = Sprite(sprites, 0, 0, self.highlight[0])
     for s in svgs:
         self.highlight.append(svg_str_to_pixbuf(s))
     self.paths = []  # [[N, E, S, W], [N, E, S, W]]
     self.shape = None
     self.orientation = 0
     self.type = tile_type
     self.number = number
     self.value = 1
     self.spr.set_label_color('#FF0000')
Пример #8
0
 def _show_thumb(self, i, x, y, w, h):
     ''' Display a preview image and title as a thumbnail. '''
     pixbuf = self.slides[i].pixbuf
     if pixbuf is not None:
         pixbuf_thumb = pixbuf.scale_simple(
             int(w), int(h), gtk.gdk.INTERP_TILES)
     else:
         pixbuf_thumb = svg_str_to_pixbuf(
             genblank(int(w), int(h), self.slides[i].colors))
     # Create a Sprite for this thumbnail
     self._thumbs.append([Sprite(self._sprites, x, y, pixbuf_thumb),
                          x, y, i])
     self._thumbs[i][0].set_image(
         svg_str_to_pixbuf(svg_rectangle(int(w), int(h),
                                         self.slides[i].colors)), i=1)
     self._thumbs[i][0].set_layer(TOP)
Пример #9
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        if have_toolbox:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

            toolbox.toolbar.insert(activity_button, 0)
            activity_button.show()

            self.set_toolbar_box(toolbox)
            toolbox.show()
            self.toolbar = toolbox.toolbar

        else:
            # Use pre-0.86 toolbar design
            games_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Game'), games_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)
            self.toolbar = games_toolbar

        self._new_game_button = _button_factory(
            'new-game', _('Start a new game.'), self._new_game_cb,
            self.toolbar)

        self.robot_button = _button_factory(
            'robot-off', _('Play with the robot.'), self._robot_cb,
            self.toolbar)

        self.player = _image_factory(
            svg_str_to_pixbuf(generate_xo(scale=0.8,
                                          colors=['#303030', '#303030'])),
            self.toolbar, tooltip=self.nick)

        self.dialog_button = _button_factory('go-next',
                                             _('Turn complete'),
                                             self._dialog_cb, self.toolbar)

        self.status = _label_factory('', self.toolbar)

        self.hint_button = _button_factory('help-toolbar',
                                             _('Help'),
                                             self._hint_cb, self.toolbar)

        self.score = _label_factory(_('Score: ') + '0', self.toolbar)

        if _have_toolbox:
            _separator_factory(toolbox.toolbar, False, True)

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbox.toolbar.insert(stop_button, -1)
            stop_button.show()
Пример #10
0
    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        if have_toolbox:
            toolbox = ToolbarBox()

            # Activity toolbar
            activity_button = ActivityToolbarButton(self)

            toolbox.toolbar.insert(activity_button, 0)
            activity_button.show()

            self.set_toolbar_box(toolbox)
            toolbox.show()
            self.toolbar = toolbox.toolbar

        else:
            # Use pre-0.86 toolbar design
            games_toolbar = gtk.Toolbar()
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.add_toolbar(_('Game'), games_toolbar)
            toolbox.show()
            toolbox.set_current_toolbar(1)
            self.toolbar = games_toolbar

        self._new_game_button = button_factory(
            'new-game', self.toolbar, self._new_game_cb,
            tooltip=_('Start a new game.'))

        self.robot_button = button_factory(
            'robot-off', self.toolbar, self._robot_cb,
            tooltip= _('Play with the robot.'))

        self.player = image_factory(
            svg_str_to_pixbuf(generate_xo(scale=0.8,
                                          colors=['#303030', '#303030'])),
            self.toolbar, tooltip=self.nick)

        self.dialog_button = button_factory(
            'go-next', self.toolbar, self._dialog_cb,
            tooltip=_('Turn complete'))

        self.status = label_factory(self.toolbar, '')

        self.hint_button = button_factory(
            'help-toolbar', self.toolbar, self._hint_cb,
            tooltip=_('Help'))

        self.score = label_factory(self.toolbar, _('Score: ') + '0')

        if _have_toolbox:
            separator_factory(toolbox.toolbar, True, False)

            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbox.toolbar.insert(stop_button, -1)
            stop_button.show()
Пример #11
0
 def _append_player(self, nick, colors):
     ''' Keep a list of players, their colors, and an XO pixbuf '''
     if not nick in self._game.buddies:
         self._game.buddies.append(nick)
         self._player_colors.append(colors)
         self._player_pixbuf.append(
             svg_str_to_pixbuf(generate_xo(scale=0.8, colors=colors)))
Пример #12
0
 def _append_player(self, nick, colors):
     ''' Keep a list of players, their colors, and an XO pixbuf '''
     if not nick in self._game.buddies:
         self._game.buddies.append(nick)
         self._player_colors.append(colors)
         self._player_pixbuf.append(svg_str_to_pixbuf(
             generate_xo(scale=0.8, colors=colors)))
Пример #13
0
    def _setup_toolbars(self):
        """ Setup the toolbars. """

        self.max_participants = MAX_HANDS

        toolbox = ToolbarBox()

        # Activity toolbar
        activity_button = ActivityToolbarButton(self)

        toolbox.toolbar.insert(activity_button, 0)
        activity_button.show()

        self.set_toolbar_box(toolbox)
        toolbox.show()
        self.toolbar = toolbox.toolbar

        self._new_game_button = button_factory('new-game',
                                               self.toolbar,
                                               self._new_game_cb,
                                               tooltip=_('Start a new game.'))

        self.robot_button = button_factory('robot-off',
                                           self.toolbar,
                                           self._robot_cb,
                                           tooltip=_('Play with the robot.'))

        self.player = image_factory(svg_str_to_pixbuf(
            generate_xo(scale=0.8, colors=['#303030', '#303030'])),
                                    self.toolbar,
                                    tooltip=self.nick)

        self.dialog_button = button_factory('go-next',
                                            self.toolbar,
                                            self._dialog_cb,
                                            tooltip=_('Turn complete'))

        self.status = label_factory(self.toolbar, '')

        self.hint_button = button_factory('help-toolbar',
                                          self.toolbar,
                                          self._hint_cb,
                                          tooltip=_('Help'))

        self.score = label_factory(self.toolbar, _('Score: ') + '0')

        separator_factory(toolbox.toolbar, True, False)

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
Пример #14
0
    def _setup_presence_service(self):
        """ Setup the Presence Service. """
        self.pservice = presenceservice.get_instance()
        self.initiating = None  # sharing (True) or joining (False)

        owner = self.pservice.get_owner()
        self.owner = owner
        self._game.buddies.append(self.nick)
        self._player_colors = [self.colors]
        self._player_pixbuf = [svg_str_to_pixbuf(
                generate_xo(scale=0.8, colors=self.colors))]
        self._share = ""
        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)
Пример #15
0
    def _setup_presence_service(self):
        """ Setup the Presence Service. """
        self.pservice = presenceservice.get_instance()
        self.initiating = None  # sharing (True) or joining (False)

        owner = self.pservice.get_owner()
        self.owner = owner
        self._game.buddies.append(self.nick)
        self._player_colors = [self.colors]
        self._player_pixbuf = [svg_str_to_pixbuf(
                generate_xo(scale=0.8, colors=self.colors))]
        self._share = ""
        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)
Пример #16
0
    def __init__(self, fill_color):
        Eye.__init__(self, fill_color)

        self._pixbuf = svg_str_to_pixbuf(eye_svg())
Пример #17
0
    def __init__(self, fill_color):
        Eye.__init__(self, fill_color)

        self._pixbuf = svg_str_to_pixbuf(eyelashes_svg())
Пример #18
0
    def _setup_workspace(self):
        ''' Prepare to render the datastore entries. '''
        self._colors = profile.get_color().to_string().split(',')

        # Use the lighter color for the text background
        if lighter_color(self._colors) == 0:
            tmp = self._colors[0]
            self._colors[0] = self._colors[1]
            self._colors[1] = tmp

        self._width = gtk.gdk.screen_width()
        self._height = gtk.gdk.screen_height()
        self._scale = gtk.gdk.screen_height() / 900.

        if self._hw[0:2] == 'xo':
            titlef = 18
            descriptionf = 12
        else:
            titlef = 36
            descriptionf = 24

        # Generate the sprites we'll need...
        self._sprites = Sprites(self._canvas)

        self._title = Sprite(
            self._sprites, 0, 0,
            svg_str_to_pixbuf(
                genblank(self._width, int(TITLEH * self._scale),
                         self._colors)))
        self._title.set_label_attributes(int(titlef * self._scale),
                                         rescale=False)
        self._preview = Sprite(
            self._sprites, int(
                (self._width - int(PREVIEWW * self._scale)) / 2),
            int(PREVIEWY * self._scale),
            svg_str_to_pixbuf(
                genblank(int(PREVIEWW * self._scale),
                         int(PREVIEWH * self._scale), self._colors)))

        self._full_screen = Sprite(
            self._sprites, int((self._width - int(FULLW * self._scale)) / 2),
            int(PREVIEWY * self._scale),
            svg_str_to_pixbuf(
                genblank(int(FULLW * self._scale), int(FULLH * self._scale),
                         self._colors)))

        self._description = Sprite(
            self._sprites, int(DESCRIPTIONX * self._scale),
            int(DESCRIPTIONY * self._scale),
            svg_str_to_pixbuf(
                genblank(int(self._width - (2 * DESCRIPTIONX * self._scale)),
                         int(DESCRIPTIONH * self._scale), self._colors)))
        self._description.set_label_attributes(int(descriptionf * self._scale))

        self._description2 = Sprite(
            self._sprites, int(SHORTX * self._scale),
            int(SHORTY * self._scale),
            svg_str_to_pixbuf(
                genblank(int(self._width - (2 * SHORTX * self._scale)),
                         int(SHORTH * self._scale), self._colors)))
        self._description2.set_label_attributes(int(descriptionf *
                                                    self._scale))

        self._my_canvas = Sprite(
            self._sprites, 0, 0,
            gtk.gdk.Pixmap(self._canvas.window, self._width, self._height, -1))
        self._my_gc = self._my_canvas.images[0].new_gc()
        self._my_canvas.set_layer(BOTTOM)

        self._clear_screen()

        self._find_starred()
        self.i = 0
        self._show_slide()

        self._playing = False
        self._rate = 10
Пример #19
0
def blank_tile(sprites, scale=1.0, color='#80FF80'):
    return Sprite(sprites, 0, 0,
                  svg_str_to_pixbuf(generate_blank(scale, color)))
Пример #20
0
def error_graphic(sprites, scale=1.0):
    return Sprite(sprites, -100, 0, svg_str_to_pixbuf(generate_x(0.5 * scale)))
Пример #21
0
def board_card(sprites, scale=1.0):
    return Sprite(sprites, 0, 0, svg_str_to_pixbuf(generate_board(scale)))
Пример #22
0
def blank_tile(sprites, scale=1.0, color='#80FF80'):
    return Sprite(sprites, 0, 0, svg_str_to_pixbuf(
            generate_blank(scale, color)))
Пример #23
0
def error_graphic(sprites, scale=1.0):
    return Sprite(sprites, -100, 0, svg_str_to_pixbuf(generate_x(0.5 * scale)))
Пример #24
0
def board_card(sprites, scale=1.0):
    return Sprite(sprites, 0, 0, svg_str_to_pixbuf(generate_board(scale)))