Merge branch 'master' of git://git.assembla.com/free_poker_tools

This commit is contained in:
eblade 2008-10-30 00:05:15 -04:00
commit 3f7347d8f6
3 changed files with 53 additions and 82 deletions

View File

@ -53,19 +53,9 @@ class Site:
self.site_path = node.getAttribute("site_path") self.site_path = node.getAttribute("site_path")
self.HH_path = node.getAttribute("HH_path") self.HH_path = node.getAttribute("HH_path")
self.decoder = node.getAttribute("decoder") self.decoder = node.getAttribute("decoder")
self.hudopacity = node.getAttribute("hudopacity") self.hudopacity = node.getAttribute("hudopacity")
if self.hudopacity == "":
self.hudopacity = 0.90
else:
self.hudopacity = float(self.hudopacity)
self.hudbgcolor = node.getAttribute("bgcolor") self.hudbgcolor = node.getAttribute("bgcolor")
if self.hudbgcolor == "":
self.hudbgcolor = "#FFFFFF"
self.hudfgcolor = node.getAttribute("fgcolor") self.hudfgcolor = node.getAttribute("fgcolor")
if self.hudfgcolor == "":
self.hudfgcolor = "#000000"
self.layout = {} self.layout = {}
@ -88,7 +78,7 @@ class Site:
if key == 'layout': continue if key == 'layout': continue
value = getattr(self, key) value = getattr(self, key)
if callable(value): continue if callable(value): continue
temp = temp + ' ' + key + " = " + value + "\n" temp = temp + ' ' + key + " = " + str(value) + "\n"
for layout in self.layout: for layout in self.layout:
temp = temp + "%s" % self.layout[layout] temp = temp + "%s" % self.layout[layout]
@ -372,6 +362,33 @@ class Config:
paths['bulkImport-defaultPath'] = "default" paths['bulkImport-defaultPath'] = "default"
return paths return paths
def get_default_colors(self, site = "PokerStars"):
colors = {}
try:
colors['hudopacity'] = float(self.supported_sites[site].hudopacity)
except:
colors['hudopacity'] = 0.90
try:
colors['hudbgcolor'] = float(self.supported_sites[site].hudbgcolor)
except:
colors['hudbgcolor'] = "#FFFFFF"
try:
colors['hudfgcolor'] = float(self.supported_sites[site].hudbgcolor)
except:
colors['hudfgcolor'] = "#000000"
return colors
def get_locations(self, site = "PokerStars", max = "8"):
try:
locations = self.supported_sites[site].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
if __name__== "__main__": if __name__== "__main__":
c = Config() c = Config()
@ -403,17 +420,19 @@ if __name__== "__main__":
print "----------- END MUCKED WINDOW FORMATS -----------" print "----------- END MUCKED WINDOW FORMATS -----------"
print "\n----------- IMPORT -----------" print "\n----------- IMPORT -----------"
print c.imp # print c.imp
print "----------- END IMPORT -----------" print "----------- END IMPORT -----------"
print "\n----------- TABLE VIEW -----------" print "\n----------- TABLE VIEW -----------"
print c.tv # print c.tv
print "----------- END TABLE VIEW -----------" print "----------- END TABLE VIEW -----------"
c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) ))
c.save(file="testout.xml") c.save(file="testout.xml")
print "db = ", c.get_db_parameters() print "db = ", c.get_db_parameters()
print "tv = ", c.get_tv_parameters() # print "tv = ", c.get_tv_parameters()
print "imp = ", c.get_import_parameters() # print "imp = ", c.get_import_parameters()
print "paths = ", c.get_default_paths("PokerStars") print "paths = ", c.get_default_paths("PokerStars")
print "colors = ", c.get_default_colors("PokerStars")
print "locs = ", c.get_locations("PokerStars", 8)

View File

@ -55,6 +55,7 @@ class Hud:
self.db_name = db_name self.db_name = db_name
self.deleted = False self.deleted = False
self.stacked = True self.stacked = True
self.colors = config.get_default_colors(self.table.site)
self.stat_windows = {} self.stat_windows = {}
self.popup_windows = {} self.popup_windows = {}
@ -64,7 +65,6 @@ class Hud:
self.main_window = gtk.Window() self.main_window = gtk.Window()
# self.window.set_decorated(0) # self.window.set_decorated(0)
self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC) self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC)
# self.main_window.set_keep_above(True)
self.main_window.set_title(table.name + " FPDBHUD") self.main_window.set_title(table.name + " FPDBHUD")
self.main_window.connect("destroy", self.kill_hud) self.main_window.connect("destroy", self.kill_hud)
self.main_window.set_decorated(False) self.main_window.set_decorated(False)
@ -73,13 +73,13 @@ class Hud:
self.ebox = gtk.EventBox() self.ebox = gtk.EventBox()
self.label = gtk.Label("Right click to close HUD for %s\nor Save Stat Positions." % (table.name)) self.label = gtk.Label("Right click to close HUD for %s\nor Save Stat Positions." % (table.name))
self.label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudbgcolor)) self.label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor']))
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudfgcolor)) self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
self.main_window.add(self.ebox) self.main_window.add(self.ebox)
self.ebox.add(self.label) self.ebox.add(self.label)
self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudbgcolor)) self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor']))
self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudfgcolor)) self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
self.main_window.move(self.table.x, self.table.y) self.main_window.move(self.table.x, self.table.y)
@ -153,58 +153,11 @@ class Hud:
# windows via calls to the Stat_Window class # windows via calls to the Stat_Window class
adj = self.adj_seats(hand, config) adj = self.adj_seats(hand, config)
loc = self.config.get_locations(self.table.site, self.max)
# create the stat windows # create the stat windows
for i in range(1, self.max + 1): for i in range(1, self.max + 1):
# the below IF always appears to be passed as TRUE, I don't know why. If you have an 8-max game, but (x, y) = loc[adj[i]]
# your config file doesn't understand 8 max, it's a crash. It was even a crash when I tried using the
# full-fledged exception handling blocks.
# - Eric
if self.max in config.supported_sites[self.table.site].layout:
(x, y) = config.supported_sites[self.table.site].layout[self.max].location[adj[i]]
else:
if i == 1:
x = 684
y = 61
elif i == 2:
x = 689
y = 239
elif i == 3:
x = 692
y = 346
elif i == 4:
x = 586
y = 393
elif i == 5:
x = 421
y = 440
elif i == 6:
x = 267
y = 440
elif i == 7:
x = 0
y = 361
elif i == 8:
x = 0
y = 280
elif i == 9:
x = 121
y = 280
elif i == 10:
x = 46
y = 30
sys.stderr.write("at location "+str(x)+" "+str(y)+"\n")
sys.stderr.write("config:"+str(config)+"\n")
gameslist = config.supported_games
sys.stderr.write("supported games:"+str(gameslist)+"\n")
sys.stderr.write("desired game:"+str(self.poker_game)+"\n")
thisgame = gameslist['holdem']
sys.stderr.write("this game:"+str(thisgame)+"\n")
# the above code looks absolutely completely useless. The below line was freezing the interpreter, so I added the above lines to try and debug
# which piece of the below line was causing it to lock up. Adding the "thisgame = gameslist['holdem']" line fixed it, for some unknown reason.
# removing any one of the lines above causes the interpreter to freeze for me on the next statement.
# -eric
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game], self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
parent = self, parent = self,
table = self.table, table = self.table,
@ -338,10 +291,9 @@ class Stat_Window:
self.window = gtk.Window() self.window = gtk.Window()
self.window.set_decorated(0) self.window.set_decorated(0)
self.window.set_opacity(parent.config.supported_sites[self.table.site].hudopacity) self.window.set_opacity(parent.colors['hudopacity'])
self.window.set_gravity(gtk.gdk.GRAVITY_STATIC) self.window.set_gravity(gtk.gdk.GRAVITY_STATIC)
# self.window.set_keep_above(1)
self.window.set_title("%s" % seat) self.window.set_title("%s" % seat)
self.window.set_property("skip-taskbar-hint", True) self.window.set_property("skip-taskbar-hint", True)
self.window.set_transient_for(parent.main_window) self.window.set_transient_for(parent.main_window)
@ -358,15 +310,15 @@ class Stat_Window:
for c in range(self.game.cols): for c in range(self.game.cols):
self.e_box[r].append( gtk.EventBox() ) self.e_box[r].append( gtk.EventBox() )
self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudbgcolor)) self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor']))
self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudfgcolor)) self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor']))
Stats.do_tip(self.e_box[r][c], 'farts') Stats.do_tip(self.e_box[r][c], 'farts')
self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
self.label[r].append( gtk.Label('xxx') ) self.label[r].append( gtk.Label('xxx') )
self.label[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudbgcolor)) self.label[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor']))
self.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudfgcolor)) self.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor']))
self.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].add(self.label[r][c])
self.e_box[r][c].connect("button_press_event", self.button_press_cb) self.e_box[r][c].connect("button_press_event", self.button_press_cb)

View File

@ -138,7 +138,7 @@ class Importer:
# ^^ May not work on windows # ^^ May not work on windows
for dir in self.dirlist: for dir in self.dirlist:
for file in os.listdir(dir): for file in os.listdir(dir):
self.filelist = self.filelist + [dir+os.sep+file] self.filelist = self.filelist + [os.path.join(dir, file)]
self.filelist = list(set(self.filelist)) self.filelist = list(set(self.filelist))