Fix mucked cards' position update

When menu->reposition is called, only the HUD windows were moved to
their new positions. The auxiliary windows used for mucked cards
remained where they were at the time the HUD instance was created. This
caused mucked cards to appear in wrong places after the poker table was
moved.

Split positioning code in Mucked.py to its own method. Now the same
routine that moves HUD windows to their new places also invokes code
to reposition auxiliary windows.

Now the mucked cards are displayed at correct screen coordinates too.
This commit is contained in:
Mika Bostrom 2009-08-15 10:44:04 +03:00
parent 185f9660c5
commit 53eaee4d7c
2 changed files with 29 additions and 1 deletions

View File

@ -181,6 +181,11 @@ class Hud:
for i, w in enumerate(self.stat_windows.itervalues()):
(x, y) = loc[adj[i+1]]
w.relocate(x, y)
# While we're at it, fix the positions of mucked cards too
for aux in self.aux_windows:
aux.update_card_positions()
return True
def on_button_press(self, widget, event):

View File

@ -345,6 +345,22 @@ class Aux_Seats(Aux_Window):
def create_contents(self): pass
def update_contents(self): pass
def update_card_positions(self):
# self.adj does not exist until .create() has been run
try:
adj = self.adj
except AttributeError:
return
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
for i in (range(1, self.hud.max + 1) + ['common']):
if i == 'common':
(x, y) = self.params['layout'][self.hud.max].common
else:
(x, y) = loc[adj[i]]
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
def create(self):
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
@ -362,7 +378,7 @@ class Aux_Seats(Aux_Window):
self.m_windows[i].set_transient_for(self.hud.main_window)
self.m_windows[i].set_focus_on_map(False)
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y)
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
if self.params.has_key('opacity'):
self.m_windows[i].set_opacity(float(self.params['opacity']))
@ -374,6 +390,13 @@ class Aux_Seats(Aux_Window):
if self.uses_timer:
self.m_windows[i].hide()
def card_positions(self, x, table_x, y, table_y):
_x = int(x) + int(table_x)
_y = int(y) + int(table_y)
return (_x, _y)
def update_gui(self, new_hand_id):
"""Update the gui, LDO."""
for i in self.m_windows.keys():