Hide 'to move' information when the game is over

This commit is contained in:
Anna Rose 2012-04-23 21:30:31 -04:00
parent 08e89fd3f6
commit 8e573f1a86

View File

@ -29,26 +29,20 @@ class GoGame(gtk.HBox):
# All of this is to create the info box along the right side of the board # All of this is to create the info box along the right side of the board
info_box = gtk.VBox() info_box = gtk.VBox()
info_rows = [] info_rows = []
for i in range(3): for i in range(2):
info_rows.append(gtk.HBox()) info_rows.append(gtk.HBox())
to_move_label = gtk.Label('To Move:') to_move_label = gtk.Label('To Move:')
black_cap_label = gtk.Label('Black Captures:') black_cap_label = gtk.Label('Black Captures:')
white_cap_label = gtk.Label('White Captures:') white_cap_label = gtk.Label('White Captures:')
self.to_move_value = gtk.Label('None')
self.black_cap_value = gtk.Label('0') self.black_cap_value = gtk.Label('0')
self.white_cap_value = gtk.Label('0') self.white_cap_value = gtk.Label('0')
info_rows[0].pack_start(to_move_label, expand=False, padding=5) self.to_move_box = gtk.HBox()
info_rows[1].pack_start(black_cap_label, expand=False, padding=5) self.to_move_value = gtk.Label('None')
info_rows[2].pack_start(white_cap_label, expand=False, padding=5) self.to_move_box.pack_start(to_move_label, expand=False, padding=5)
info_rows[0].pack_end(self.to_move_value, expand=False, padding=5) self.to_move_box.pack_end(self.to_move_value, expand=False, padding=5)
info_rows[1].pack_end(self.black_cap_value, expand=False, padding=5)
info_rows[2].pack_end(self.white_cap_value, expand=False, padding=5)
for row in info_rows:
info_box.pack_start(row, expand=False)
self.winner_box = gtk.HBox() self.winner_box = gtk.HBox()
self.winner_value = gtk.Label('None') self.winner_value = gtk.Label('None')
@ -56,6 +50,15 @@ class GoGame(gtk.HBox):
self.winner_box.pack_end(self.winner_value, expand=False, padding=5) self.winner_box.pack_end(self.winner_value, expand=False, padding=5)
info_box.pack_start(self.winner_box, expand=False) info_box.pack_start(self.winner_box, expand=False)
info_box.pack_start(self.to_move_box, expand=False)
info_rows[0].pack_start(black_cap_label, expand=False, padding=5)
info_rows[1].pack_start(white_cap_label, expand=False, padding=5)
info_rows[0].pack_end(self.black_cap_value, expand=False, padding=5)
info_rows[1].pack_end(self.white_cap_value, expand=False, padding=5)
for row in info_rows:
info_box.pack_start(row, expand=False)
self.pass_button = gtk.Button('Pass') self.pass_button = gtk.Button('Pass')
self.resign_button = gtk.Button('Resign') self.resign_button = gtk.Button('Resign')
@ -188,10 +191,13 @@ class GoGame(gtk.HBox):
def update_info(self): def update_info(self):
if self.goban.to_move == goban.Goban.BLACK: if self.goban.to_move == goban.Goban.BLACK:
move = 'Black' move = 'Black'
self.to_move_box.show()
elif self.goban.to_move == goban.Goban.WHITE: elif self.goban.to_move == goban.Goban.WHITE:
move = 'White' move = 'White'
self.to_move_box.show()
else: else:
move = 'None' move = 'None'
self.to_move_box.hide()
if self.goban.winner != goban.Goban.EMPTY: if self.goban.winner != goban.Goban.EMPTY:
if self.goban.winner == goban.Goban.BLACK: if self.goban.winner == goban.Goban.BLACK: