From 53eaee4d7c2a775d4a5a1aae0f90b0301d63ec64 Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Sat, 15 Aug 2009 10:44:04 +0300 Subject: [PATCH] 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. --- pyfpdb/Hud.py | 5 +++++ pyfpdb/Mucked.py | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 8a7aa740..bdc0cdc8 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -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): diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 3bd84cb7..ebe31b3a 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -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():