~ubuntu-branches/ubuntu/intrepid/gnome-games/intrepid

« back to all changes in this revision

Viewing changes to glchess/src/lib/gtkui/chessview.py

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2008-10-21 00:30:34 UTC
  • mfrom: (1.1.58)
  • Revision ID: package-import@ubuntu.com-20081021003034-cb0iknvzten935zn
Tags: 1:2.24.1-0ubuntu1
* New upstream release (LP: #286667)
  - General:
    - Fix up compatiblity with Gtk/Glib 2.14
    - Reclassify Gnibbles as Arcade game not logic game
    - Read saved window configuration from correct GConf group (affects
      gnometris, gnibbles, gnobots)
  - Aisleriot:
    - Remove vestigal flowRoot elements from solitaire svg icons. They
      caused a black box when rendering.
    - Don't crash when the session manager terminates aisleriot
  - GLChess:
    - Fix crash in error handler when GGZ connection closed
    - Fix crash in empty scene when no AI engines available
    - Fix crash when have OpenGL libraries but cannot get valid display
    - Implement GGZ config parser instead of using Python config parser
      which does not handle '%' characters as GGZ does
    - Ignore GGZ server remove player/table for unknown players/tables
    - Handle exceptions loading OpenGL textures
    - Reset pause menu when starting new game
    - Only allow one new/load game dialog to be visible at once
    - Fix incorrect function call for single buffered 3D display
    - Handle fork() errors in AI processes
    - Fixes to compile in Solaris
    - Print failure to start message to stdout if cannot import GTK+
    - Handle invalid response from glRenderMode(GL_RENDER) and print
      debugging information
    - More logging messages about selection rendering bugs
    - After looking at failure case in PyOpenGL code we don't need to change
      render modes after failed to change to GL_SELECT
    - Fix potential bugs found by PyChecker
    - Fix crash when validly claiming a draw
    - Don't display failed to claim draw dialog when successfully claimed
      draw
  - GTali:
    - Undoing 5 of a kind reduces the score by 50 as there might be multiple
      scores (LP: #238978)
  - Sudoku:
    - Add not overwrite time and also remember to actually save the time in
      the file (LP: #279616)
    - Correct typo in error message that led to an exception
  - Gnotravex:
    - Stop paused tiles becoming visible after changing colour settings
  - Blackjack:
    - Fix compiler warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
try:
15
15
    import OpenGL.GL
16
16
except:
 
17
    # Translators: Error message displayed when 3D mode is not available due to no Python OpenGL libraries
17
18
    openGLErrors.append(_('No Python OpenGL support'))
18
19
try:
19
20
    import gtk.gtkgl
20
21
    import gtk.gdkgl
21
22
except:
 
23
    # Translators: Error message displayed when 3D mode is not available due to no Python GTKGLExt libraries
22
24
    openGLErrors.append(_('No Python GTKGLExt support'))
23
25
else:
24
26
    display_mode = (gtk.gdkgl.MODE_RGB | gtk.gdkgl.MODE_DEPTH | gtk.gdkgl.MODE_DOUBLE)
29
31
        try:
30
32
            glConfig = gtk.gdkgl.Config(mode = display_mode)
31
33
        except gtk.gdkgl.NoMatches:
 
34
            # Translators: Error message displayed when 3D mode is not available due to their 3D drivers not being able to provide a suitable display mode
32
35
            openGLErrors.append(_('OpenGL libraries do not support required display mode'))
33
36
haveGLSupport = len(openGLErrors) == 0
34
37
 
67
70
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.BUTTON_MOTION_MASK)
68
71
        
69
72
        # Make openGL drawable
70
 
        if hasattr(gtk, 'gtkgl'):
 
73
        if haveGLSupport:
71
74
            gtk.gtkgl.widget_set_gl_capability(self, glConfig)# FIXME:, share_list=glContext)
72
75
 
73
76
        # Connect signals
172
175
            if self.__glDrawable.is_double_buffered():
173
176
                self.__glDrawable.swap_buffers()
174
177
            else:
175
 
                glFlush()
 
178
                OpenGL.GL.glFlush()
176
179
 
177
180
            self.__endGL()
178
181
            
248
251
        # Make a model for navigation (move object, number, description) 
249
252
        model = gtk.ListStore(gobject.TYPE_PYOBJECT, int, str)
250
253
        iter = model.append()
 
254
        # Translators: Move History Combo: Go to the start of the game
251
255
        model.set(iter, 0, None, 1, 0, 2, _('Game Start'))
252
256
        self.moveModel = model
253
257
 
285
289
            else:
286
290
                titleLabel.set_markup('<big><b>%s</b></big>' % self.generateMoveString(move))
287
291
            
 
292
            # Translators: Comment text when move has no comment
288
293
            comment = _('No comment')
289
294
            if move is not None and len(move.comment) > 0:
290
295
                comment = move.comment
461
466
            self.ui._updateViewButtons()
462
467
 
463
468
    def endGame(self, game):
 
469
        # Translators: Message displayed when a player wins. The %s is substituted with the winning player's name
 
470
        format = _('%s wins')
 
471
        
464
472
        # If game completed show this in the GUI
465
473
        if game.result is glchess.game.RESULT_WHITE_WINS:
466
 
            title = _('%s wins') % game.getWhite().getName()
 
474
            title = format % game.getWhite().getName()
467
475
        elif game.result is glchess.game.RESULT_BLACK_WINS:
468
 
            title = _('%s wins') % game.getBlack().getName()
 
476
            title = format % game.getBlack().getName()
469
477
        else:
 
478
            # Translators: Message displayed when a game is drawn
470
479
            title = _('Game is drawn')
471
480
 
472
481
        description = ''
473
482
        if game.rule is glchess.game.RULE_CHECKMATE:
 
483
            # Translators: Message displayed when the game ends due to a player being checkmated
474
484
            description = _('Opponent is in check and cannot move (checkmate)')
475
485
        elif game.rule is glchess.game.RULE_STALEMATE:
 
486
            # Translators: Message displayed when the game terminates due to a stalemate
476
487
            description = _('Opponent cannot move (stalemate)')
477
488
        elif game.rule is glchess.game.RULE_FIFTY_MOVES:
 
489
            # Translators: Message displayed when the game is drawn due to the fifty move rule
478
490
            description = _('No piece has been taken or pawn moved in the last fifty moves')
479
491
        elif game.rule is glchess.game.RULE_TIMEOUT:
 
492
            # Translators: Message displayed when the game ends due to one player's clock stopping
480
493
            description = _('Opponent has run out of time')
481
494
        elif game.rule is glchess.game.RULE_THREE_FOLD_REPETITION:
 
495
            # Translators: Message displayed when the game is drawn due to the three-fold-repitition rule
482
496
            description = _('The same board state has occured three times (three fold repetition)')
483
497
        elif game.rule is glchess.game.RULE_INSUFFICIENT_MATERIAL:
 
498
            # Translators: Message displayed when the game is drawn due to the insufficient material rule
484
499
            description = _('Neither player can cause checkmate (insufficient material)')
485
500
        elif game.rule is glchess.game.RULE_RESIGN:
486
501
            if game.result is glchess.game.RESULT_WHITE_WINS:
 
502
                # Translators: Message displayed when the game ends due to the black player resigning
487
503
                description = _('The black player has resigned')
488
504
            elif game.result is glchess.game.RESULT_BLACK_WINS:
 
505
                # Translators: Message displayed when the game ends due to the white player resigning
489
506
                description = _('The white player has resigned')
490
507
            else:
491
508
                assert(False)
492
509
        elif game.rule is glchess.game.RULE_DEATH:
 
510
            # Translators: Message displayed when the game ends due to a player dying
493
511
            description = _('One of the players has died')
494
512
 
495
513
        self.gameResult = (title, description)