Further on Aux_Seats interface. Works. Not ready for prime time.
This commit is contained in:
parent
2f8918ebc9
commit
7f7ad2a13e
|
@ -335,6 +335,7 @@ class Aux_Seats(Aux_Window):
|
||||||
|
|
||||||
# placeholders that should be overridden--so we don't throw errors
|
# placeholders that should be overridden--so we don't throw errors
|
||||||
def create_contents(self): pass
|
def create_contents(self): pass
|
||||||
|
def update_contents(self): pass
|
||||||
|
|
||||||
def create(self):
|
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
|
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
|
||||||
|
@ -363,6 +364,11 @@ class Aux_Seats(Aux_Window):
|
||||||
self.m_windows[i].show_all()
|
self.m_windows[i].show_all()
|
||||||
self.m_windows[i].hide()
|
self.m_windows[i].hide()
|
||||||
|
|
||||||
|
def update_gui(self, new_hand_id):
|
||||||
|
"""Update the gui, LDO."""
|
||||||
|
for i in self.m_windows.keys():
|
||||||
|
self.update_contents(self.m_windows[i], i)
|
||||||
|
|
||||||
# Methods likely to be of use for any Seat_Window implementation
|
# Methods likely to be of use for any Seat_Window implementation
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
"""Destroy all of the seat windows."""
|
"""Destroy all of the seat windows."""
|
||||||
|
@ -377,6 +383,17 @@ class Aux_Seats(Aux_Window):
|
||||||
w.hide()
|
w.hide()
|
||||||
self.displayed = False
|
self.displayed = False
|
||||||
|
|
||||||
|
def save_layout(self, *args):
|
||||||
|
"""Save new layout back to the aux element in the config file."""
|
||||||
|
new_locs = {}
|
||||||
|
# print "adj =", self.adj
|
||||||
|
for (i, pos) in self.positions.iteritems():
|
||||||
|
if i != 'common':
|
||||||
|
new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
||||||
|
else:
|
||||||
|
new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
||||||
|
self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs)
|
||||||
|
|
||||||
class Flop_Mucked(Aux_Seats):
|
class Flop_Mucked(Aux_Seats):
|
||||||
"""Aux_Window class for displaying mucked cards for flop games."""
|
"""Aux_Window class for displaying mucked cards for flop games."""
|
||||||
|
|
||||||
|
@ -393,22 +410,12 @@ class Flop_Mucked(Aux_Seats):
|
||||||
container.seen_cards = gtk.image_new_from_pixbuf(self.card_images[0])
|
container.seen_cards = gtk.image_new_from_pixbuf(self.card_images[0])
|
||||||
container.eb.add(container.seen_cards)
|
container.eb.add(container.seen_cards)
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_contents(self, container, i):
|
||||||
"""Prepare and show the mucked cards."""
|
if not self.hud.cards.has_key(i): return
|
||||||
if self.displayed: self.hide()
|
cards = self.hud.cards[i]
|
||||||
|
|
||||||
# See how many players showed a hand. Skip if only 1 shows (= hero)
|
|
||||||
n_sd = 0
|
|
||||||
for (i, cards) in self.hud.cards.iteritems():
|
|
||||||
n_cards = self.has_cards(cards)
|
n_cards = self.has_cards(cards)
|
||||||
if n_cards > 0:
|
if n_cards > 1:
|
||||||
n_sd = n_sd + 1
|
|
||||||
if n_sd < 2: return
|
|
||||||
|
|
||||||
# More than 1 player showed, so display the hole cards
|
|
||||||
for (i, cards) in self.hud.cards.iteritems():
|
|
||||||
n_cards = self.has_cards(cards)
|
|
||||||
if n_cards > 0:
|
|
||||||
# scratch is a working pixbuf, used to assemble the image
|
# scratch is a working pixbuf, used to assemble the image
|
||||||
scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
|
scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
|
||||||
int(self.params['card_wd'])*n_cards,
|
int(self.params['card_wd'])*n_cards,
|
||||||
|
@ -422,14 +429,29 @@ class Flop_Mucked(Aux_Seats):
|
||||||
int(self.params['card_wd']), int(self.params['card_ht']),
|
int(self.params['card_wd']), int(self.params['card_ht']),
|
||||||
scratch, x, 0)
|
scratch, x, 0)
|
||||||
x = x + int(self.params['card_wd'])
|
x = x + int(self.params['card_wd'])
|
||||||
self.m_windows[i].seen_cards.set_from_pixbuf(scratch)
|
container.seen_cards.set_from_pixbuf(scratch)
|
||||||
self.m_windows[i].resize(1,1)
|
container.resize(1,1)
|
||||||
self.m_windows[i].show()
|
container.show()
|
||||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
container.move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
self.displayed = True
|
self.displayed = True
|
||||||
|
if i != "common":
|
||||||
|
self.m_windows[i].eb.set_tooltip_text(self.hud.stat_dict[i]['screen_name'])
|
||||||
|
|
||||||
for stats in self.hud.stat_dict.itervalues():
|
def update_gui(self, new_hand_id):
|
||||||
self.m_windows[i].eb.set_tooltip_text(stats['screen_name'])
|
"""Prepare and show the mucked cards."""
|
||||||
|
if self.displayed: self.hide()
|
||||||
|
|
||||||
|
# See how many players showed a hand. Skip if only 1 shows (= hero)
|
||||||
|
n_sd = 0
|
||||||
|
for (i, cards) in self.hud.cards.iteritems():
|
||||||
|
n_cards = self.has_cards(cards)
|
||||||
|
if n_cards > 0:
|
||||||
|
n_sd = n_sd + 1
|
||||||
|
if n_sd < 2:
|
||||||
|
print "skipping, n_sd =", n_sd
|
||||||
|
return
|
||||||
|
|
||||||
|
super(Flop_Mucked, self).update_gui(new_hand_id)
|
||||||
|
|
||||||
if self.displayed and float(self.params['timeout']) > 0:
|
if self.displayed and float(self.params['timeout']) > 0:
|
||||||
self.timer_on = True
|
self.timer_on = True
|
||||||
|
@ -478,14 +500,3 @@ class Flop_Mucked(Aux_Seats):
|
||||||
self.m_windows[i].show()
|
self.m_windows[i].show()
|
||||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
self.displayed = True
|
self.displayed = True
|
||||||
|
|
||||||
def save_layout(self, *args):
|
|
||||||
"""Save new layout back to the aux element in the config file."""
|
|
||||||
new_locs = {}
|
|
||||||
# print "adj =", self.adj
|
|
||||||
for (i, pos) in self.positions.iteritems():
|
|
||||||
if i != 'common':
|
|
||||||
new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
|
||||||
else:
|
|
||||||
new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
|
||||||
self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user