diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 4690a84c..6e38d50f 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -53,19 +53,9 @@ class Site: self.site_path = node.getAttribute("site_path") self.HH_path = node.getAttribute("HH_path") self.decoder = node.getAttribute("decoder") - self.hudopacity = node.getAttribute("hudopacity") - if self.hudopacity == "": - self.hudopacity = 0.90 - else: - self.hudopacity = float(self.hudopacity) - self.hudbgcolor = node.getAttribute("bgcolor") - if self.hudbgcolor == "": - self.hudbgcolor = "#FFFFFF" self.hudfgcolor = node.getAttribute("fgcolor") - if self.hudfgcolor == "": - self.hudfgcolor = "#000000" self.layout = {} @@ -88,7 +78,7 @@ class Site: if key == 'layout': continue value = getattr(self, key) if callable(value): continue - temp = temp + ' ' + key + " = " + value + "\n" + temp = temp + ' ' + key + " = " + str(value) + "\n" for layout in self.layout: temp = temp + "%s" % self.layout[layout] @@ -372,6 +362,33 @@ class Config: paths['bulkImport-defaultPath'] = "default" 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__": c = Config() @@ -403,17 +420,19 @@ if __name__== "__main__": print "----------- END MUCKED WINDOW FORMATS -----------" print "\n----------- IMPORT -----------" - print c.imp +# print c.imp print "----------- END IMPORT -----------" print "\n----------- TABLE VIEW -----------" - print c.tv +# print c.tv print "----------- END TABLE VIEW -----------" c.edit_layout("PokerStars", 6, locations=( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6) )) c.save(file="testout.xml") - print "db = ", c.get_db_parameters() - print "tv = ", c.get_tv_parameters() - print "imp = ", c.get_import_parameters() - print "paths = ", c.get_default_paths("PokerStars") + print "db = ", c.get_db_parameters() +# print "tv = ", c.get_tv_parameters() +# print "imp = ", c.get_import_parameters() + print "paths = ", c.get_default_paths("PokerStars") + print "colors = ", c.get_default_colors("PokerStars") + print "locs = ", c.get_locations("PokerStars", 8) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index dc4ab242..1d50022e 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -55,16 +55,16 @@ class Hud: self.db_name = db_name self.deleted = False self.stacked = True + self.colors = config.get_default_colors(self.table.site) self.stat_windows = {} self.popup_windows = {} self.font = pango.FontDescription("Sans 8") - -# Set up a main window for this this instance of the HUD - self.main_window = gtk.Window() + +# Set up a main window for this this instance of the HUD + self.main_window = gtk.Window() # self.window.set_decorated(0) 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.connect("destroy", self.kill_hud) self.main_window.set_decorated(False) @@ -73,13 +73,13 @@ class Hud: self.ebox = gtk.EventBox() 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_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudfgcolor)) + 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(self.colors['hudfgcolor'])) self.main_window.add(self.ebox) 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_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.supported_sites[self.table.site].hudfgcolor)) + 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(self.colors['hudfgcolor'])) self.main_window.move(self.table.x, self.table.y) @@ -153,58 +153,11 @@ class Hud: # windows via calls to the Stat_Window class adj = self.adj_seats(hand, config) + loc = self.config.get_locations(self.table.site, self.max) + # create the stat windows 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 - # 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 + (x, y) = loc[adj[i]] self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game], parent = self, table = self.table, @@ -338,10 +291,9 @@ class Stat_Window: self.window = gtk.Window() 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_keep_above(1) self.window.set_title("%s" % seat) self.window.set_property("skip-taskbar-hint", True) self.window.set_transient_for(parent.main_window) @@ -358,15 +310,15 @@ class Stat_Window: for c in range(self.game.cols): 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_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudfgcolor)) + 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.colors['hudfgcolor'])) 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.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_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.config.supported_sites[self.table.site].hudfgcolor)) + 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.colors['hudfgcolor'])) self.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].connect("button_press_event", self.button_press_cb) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index fb170240..4a855d1d 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -138,7 +138,7 @@ class Importer: # ^^ May not work on windows for dir in self.dirlist: 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))