Merge branch 'master' of git://git.assembla.com/free_poker_tools.git
Conflicts: pyfpdb/Configuration.py
This commit is contained in:
commit
60e66dcf31
50
pyfpdb/Configuration.py
Executable file → Normal file
50
pyfpdb/Configuration.py
Executable file → Normal file
|
@ -32,14 +32,30 @@ import shutil
|
|||
import xml.dom.minidom
|
||||
from xml.dom.minidom import Node
|
||||
|
||||
|
||||
class Layout:
|
||||
def __init__(self, max):
|
||||
self.max = int(max)
|
||||
def __init__(self, node):
|
||||
|
||||
self.max = int( node.getAttribute('max') )
|
||||
if node.hasAttribute('fav_seat'): self.fav_seat = int( node.getAttribute('fav_seat') )
|
||||
self.width = int( node.getAttribute('width') )
|
||||
self.height = int( node.getAttribute('height') )
|
||||
|
||||
self.location = []
|
||||
self.location = map(lambda x: None, range(self.max+1)) # there must be a better way to do this?
|
||||
|
||||
for location_node in node.getElementsByTagName('location'):
|
||||
if location_node.getAttribute('seat') != "":
|
||||
self.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
|
||||
elif location_node.getAttribute('common') != "":
|
||||
self.common = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
|
||||
|
||||
def __str__(self):
|
||||
temp = " Layout = %d max, width= %d, height = %d, fav_seat = %d\n" % (self.max, self.width, self.height, self.fav_seat)
|
||||
temp = " Layout = %d max, width= %d, height = %d" % (self.max, self.width, self.height)
|
||||
if hasattr(self, 'fav_seat'): temp = temp + ", fav_seat = %d\n" % self.fav_seat
|
||||
else: temp = temp + "\n"
|
||||
if hasattr(self, "common"):
|
||||
temp = temp + " Common = (%d, %d)\n" % (self.common[0], self.common[1])
|
||||
temp = temp + " Locations = "
|
||||
for i in xrange(1, len(self.location)):
|
||||
temp = temp + "(%d,%d)" % self.location[i]
|
||||
|
@ -158,21 +174,23 @@ class Aux_window:
|
|||
def __init__(self, node):
|
||||
for (name, value) in node.attributes.items():
|
||||
setattr(self, name, value)
|
||||
# self.name = node.getAttribute("mw_name")
|
||||
# self.cards = node.getAttribute("deck")
|
||||
# self.card_wd = node.getAttribute("card_wd")
|
||||
# self.card_ht = node.getAttribute("card_ht")
|
||||
# self.rows = node.getAttribute("rows")
|
||||
# self.cols = node.getAttribute("cols")
|
||||
# self.format = node.getAttribute("stud")
|
||||
|
||||
self.layout = {}
|
||||
for layout_node in node.getElementsByTagName('layout'):
|
||||
lo = Layout(layout_node)
|
||||
self.layout[lo.max] = lo
|
||||
|
||||
def __str__(self):
|
||||
temp = 'Aux = ' + self.name + "\n"
|
||||
for key in dir(self):
|
||||
if key.startswith('__'): continue
|
||||
if key == 'layout': continue
|
||||
value = getattr(self, key)
|
||||
if callable(value): continue
|
||||
temp = temp + ' ' + key + " = " + value + "\n"
|
||||
|
||||
for layout in self.layout:
|
||||
temp = temp + "%s" % self.layout[layout]
|
||||
return temp
|
||||
|
||||
class Popup:
|
||||
|
@ -493,6 +511,16 @@ class Config:
|
|||
( 0, 280), (121, 280), ( 46, 30) )
|
||||
return locations
|
||||
|
||||
def get_aux_locations(self, aux = "mucked", max = "9"):
|
||||
|
||||
try:
|
||||
locations = self.aux_windows[aux].layout[max].location
|
||||
except:
|
||||
locations = ( ( 0, 0), (684, 61), (689, 239), (692, 346),
|
||||
(586, 393), (421, 440), (267, 440), ( 0, 361),
|
||||
( 0, 280), (121, 280), ( 46, 30) )
|
||||
return locations
|
||||
|
||||
def get_supported_sites(self):
|
||||
"""Returns the list of supported sites."""
|
||||
return self.supported_sites.keys()
|
||||
|
@ -645,6 +673,8 @@ if __name__== "__main__":
|
|||
for mw in c.get_aux_windows():
|
||||
print c.get_aux_parameters(mw)
|
||||
|
||||
print "mucked locations =", c.get_aux_locations('mucked', 9)
|
||||
|
||||
for site in c.supported_sites.keys():
|
||||
print "site = ", site,
|
||||
print c.get_site_parameters(site)
|
||||
|
|
114
pyfpdb/Mucked.py
114
pyfpdb/Mucked.py
|
@ -52,6 +52,32 @@ class Aux_Window:
|
|||
def destroy(self):
|
||||
self.container.destroy()
|
||||
|
||||
############################################################################
|
||||
# Some utility routines useful for Aux_Windows
|
||||
#
|
||||
def get_card_images(self):
|
||||
card_images = {}
|
||||
suits = ('S', 'H', 'D', 'C')
|
||||
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
|
||||
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
||||
|
||||
for j in range(0, 14):
|
||||
for i in range(0, 4):
|
||||
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
||||
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
||||
card_images[(ranks[j], suits[i])] = temp_pb
|
||||
return(card_images)
|
||||
# cards are 30 wide x 42 high
|
||||
|
||||
def split_cards(self, card):
|
||||
if card == 'xx': return ('B', 'S')
|
||||
return (card[0], card[1].upper())
|
||||
|
||||
def has_cards(self, cards):
|
||||
for c in cards:
|
||||
if c in set('shdc'): return True
|
||||
return False
|
||||
|
||||
class Stud_mucked(Aux_Window):
|
||||
def __init__(self, hud, config, params):
|
||||
|
||||
|
@ -273,9 +299,6 @@ class Stud_cards:
|
|||
return self.parent.hud.stat_dict[k]['screen_name']
|
||||
return "No Name"
|
||||
|
||||
def split_cards(self, card):
|
||||
return (card[0], card[1].upper())
|
||||
|
||||
def clear(self):
|
||||
for r in range(0, self.rows):
|
||||
self.grid_contents[(1, r)].set_text(" ")
|
||||
|
@ -283,19 +306,80 @@ class Stud_cards:
|
|||
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')])
|
||||
self.eb[(c, r)].set_tooltip_text('')
|
||||
|
||||
def get_card_images(self):
|
||||
card_images = {}
|
||||
suits = ('S', 'H', 'D', 'C')
|
||||
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
|
||||
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
||||
class Flop_Mucked(Aux_Window):
|
||||
"""Aux_Window class for displaying mucked cards for flop games."""
|
||||
|
||||
for j in range(0, 14):
|
||||
for i in range(0, 4):
|
||||
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
||||
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
||||
card_images[(ranks[j], suits[i])] = temp_pb
|
||||
return(card_images)
|
||||
# cards are 30 wide x 42 high
|
||||
def __init__(self, hud, config, params):
|
||||
self.hud = hud # hud object that this aux window supports
|
||||
self.config = config # configuration object for this aux window to use
|
||||
self.params = params # hash aux params from config
|
||||
self.card_images = self.get_card_images()
|
||||
|
||||
def create(self):
|
||||
|
||||
adj = self.hud.adj_seats(0, self.config)
|
||||
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||
|
||||
# make a scratch pixbuf 7 cards wide for creating our images
|
||||
self.scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
|
||||
7* int(self.params['card_wd']), int(self.params['card_ht']))
|
||||
|
||||
# create the stat windows
|
||||
self.m_windows = {} # windows to put the card images
|
||||
self.eb = {} # event boxes so we can interact with the mucked cards
|
||||
self.seen_cards = {} # pixbufs to stash the cards in
|
||||
|
||||
for i in range(1, self.hud.max + 1):
|
||||
(x, y) = loc[adj[i]]
|
||||
self.m_windows[i] = gtk.Window()
|
||||
self.m_windows[i].set_decorated(0)
|
||||
self.m_windows[i].set_property("skip-taskbar-hint", True)
|
||||
self.m_windows[i].set_transient_for(self.hud.main_window)
|
||||
self.eb[i] = gtk.EventBox()
|
||||
self.m_windows[i].add(self.eb[i])
|
||||
self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')])
|
||||
self.eb[i].add(self.seen_cards[i])
|
||||
self.m_windows[i].move(int(x) + self.hud.table.x, int(y) + self.hud.table.y)
|
||||
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
||||
self.m_windows[i].show_all()
|
||||
self.m_windows[i].hide()
|
||||
|
||||
def update_data(self, new_hand_id, db_connection):
|
||||
pass
|
||||
|
||||
def update_gui(self, new_hand_id):
|
||||
"""Prepare and show the mucked cards."""
|
||||
for (i, cards) in self.hud.cards.iteritems():
|
||||
pos = self.m_windows[i].get_position() # need this to reposition later
|
||||
if self.has_cards(cards):
|
||||
# scratch is a working pixbuf, used to assemble the image
|
||||
scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
|
||||
int(self.params['card_wd'])*len(cards)/2,
|
||||
int(self.params['card_ht']))
|
||||
x = 0 # x coord where the next card starts in scratch
|
||||
for card in [cards[k:k+2] for k in xrange(0, len(cards), 2)]:
|
||||
# concatenate each card image to scratch
|
||||
self.card_images[self.split_cards(card)].copy_area(0, 0,
|
||||
int(self.params['card_wd']), int(self.params['card_ht']),
|
||||
scratch, x, 0)
|
||||
x = x + int(self.params['card_wd'])
|
||||
self.seen_cards[i].set_from_pixbuf(scratch)
|
||||
self.m_windows[i].move(pos[0], pos[1]) # I don't know why I need this
|
||||
self.m_windows[i].show_all()
|
||||
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards)
|
||||
|
||||
def destroy(self):
|
||||
"""Destroy all of the mucked windows."""
|
||||
for w in self.m_windows.values():
|
||||
w.destroy()
|
||||
|
||||
|
||||
def hide_mucked_cards(self):
|
||||
"""Hide the mucked card windows."""
|
||||
# this is the callback from the timeout
|
||||
for w in self.m_windows.values():
|
||||
w.hide()
|
||||
return False # this tells the system to NOT run this timeout again
|
||||
|
||||
if __name__== "__main__":
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import fpdb_save_to_db
|
|||
|
||||
#parses a holdem hand
|
||||
def mainParser(backend, db, cursor, site, category, hand):
|
||||
category=fpdb_simple.recogniseCategory(hand[0])
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
base="hold"
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user