From 84653ff99c09b69d532a6652e0f52c6b801e3120 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 5 Jan 2009 10:49:27 -0500 Subject: [PATCH 1/5] updating HUD_config.xml.example --- pyfpdb/HUD_config.xml.example | 51 ++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example index 355c9d2f..2ea2d93a 100644 --- a/pyfpdb/HUD_config.xml.example +++ b/pyfpdb/HUD_config.xml.example @@ -2,7 +2,18 @@ - + @@ -49,7 +60,18 @@ - + @@ -84,7 +106,18 @@ - + @@ -120,7 +153,7 @@ - + @@ -144,7 +177,7 @@ - + @@ -152,7 +185,7 @@ - + @@ -193,9 +226,9 @@ - - - + + + From c0557c7ef962f97178ff712bf084e1fa13b3ad98 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 5 Jan 2009 20:26:39 -0500 Subject: [PATCH 2/5] rationalized button presses, fixed reposition windows --- pyfpdb/Hud.py | 75 ++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 2dfb51fd..84b5c627 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -62,11 +62,9 @@ class Hud: self.popup_windows = {} self.aux_windows = [] (font, font_size) = config.get_default_font(self.table.site) - print "font = ", font, "size = ", font_size if font == None or font_size == None: self.font = pango.FontDescription("Sans 7") else: - print "Setting font to ", font + " " + font_size self.font = pango.FontDescription(font + " " + font_size) # do we need to add some sort of condition here for dealing with a request for a font that doesn't exist? @@ -96,7 +94,7 @@ class Hud: self.main_window.move(self.table.x, self.table.y) -# A popup window for the main window +# A popup menu for the main window self.menu = gtk.Menu() self.item1 = gtk.MenuItem('Kill this HUD') self.menu.append(self.item1) @@ -165,7 +163,14 @@ class Hud: self.deleted = True def reposition_windows(self, *args): - self.update_table_position() +# self.update_table_position() + self.main_window.move(self.table.x, self.table.y) + adj = self.adj_seats(self.hand, self.config) + loc = self.config.get_locations(self.table.site, self.max) + for i in range(1, self.max + 1): + (x, y) = loc[adj[i]] + if self.stat_windows.has_key(i): + self.stat_windows[i].relocate(x, y) return True def debug_stat_windows(self, *args): @@ -245,7 +250,9 @@ class Hud: def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later + self.stat_dict = stat_dict # so this is available for popups, etc self.update_table_position() + self.stat_dict = stat_dict for s in stat_dict.keys(): try: self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] @@ -307,18 +314,10 @@ class Stat_Window: # and double-clicks. if event.button == 3: # right button event - if event.type == gtk.gdk.BUTTON_PRESS: # left button single click - if self.sb_click > 0: return - self.sb_click = gobject.timeout_add(250, self.single_click, widget) - elif event.type == gtk.gdk._2BUTTON_PRESS: # left button double click - if self.sb_click > 0: - gobject.source_remove(self.sb_click) - self.sb_click = 0 - self.double_click(widget, event, *args) + Popup_window(widget, self) if event.button == 2: # middle button event self.window.hide() - pass if event.button == 1: # left button event # TODO: make position saving save sizes as well? @@ -326,28 +325,6 @@ class Stat_Window: self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time) else: self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) - - def single_click(self, widget): -# Callback from the timeout in the single-click finding part of the -# button press call back. This needs to be modified to get all the -# arguments from the call. - self.sb_click = 0 - Popup_window(widget, self) - return False - - def double_click(self, widget, event, *args): - self.toggle_decorated(widget) - - def toggle_decorated(self, widget): - top = widget.get_toplevel() - (x, y) = top.get_position() - - if top.get_decorated(): - top.set_decorated(0) - top.move(x, y) - else: - top.set_decorated(1) - top.move(x, y) def relocate(self, x, y): self.x = x + self.table.x @@ -388,7 +365,7 @@ class Stat_Window: self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) - Stats.do_tip(self.e_box[r][c], 'farts') + Stats.do_tip(self.e_box[r][c], 'stuff') 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') ) @@ -466,9 +443,9 @@ class Popup_window: # calculate the stat_dict and then create the text for the pu # stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand, stat_window.player_id) - stat_dict = self.db_connection.get_stats_from_hand(stat_window.parent.hand) +# stat_dict = self.db_connection.get_stats_from_hand(stat_window.parent.hand) # db_connection.close_connection() - + stat_dict = stat_window.parent.stat_dict pu_text = "" for s in stat_list: number = Stats.do_stat(stat_dict, player = int(stat_window.player_id), stat = s) @@ -487,31 +464,13 @@ class Popup_window: # the popup windows. There is a bit of an ugly kludge to separate single- # and double-clicks. This is the same code as in the Stat_window class if event.button == 1: # left button event - if event.type == gtk.gdk.BUTTON_PRESS: # left button single click - if self.sb_click > 0: return - self.sb_click = gobject.timeout_add(250, self.single_click, widget) - elif event.type == gtk.gdk._2BUTTON_PRESS: # left button double click - if self.sb_click > 0: - gobject.source_remove(self.sb_click) - self.sb_click = 0 - self.double_click(widget, event, *args) + pass if event.button == 2: # middle button event pass if event.button == 3: # right button event - pass - - def single_click(self, widget): -# Callback from the timeout in the single-click finding part of the -# button press call back. This needs to be modified to get all the -# arguments from the call. - self.sb_click = 0 - self.window.destroy() - return False - - def double_click(self, widget, event, *args): - self.toggle_decorated(widget) + self.window.destroy() def toggle_decorated(self, widget): top = widget.get_toplevel() From 37a418484fc3947155e2959da5798e3b18330e1c Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 8 Jan 2009 06:17:56 -0500 Subject: [PATCH 3/5] Replace all occurences in Tables.py where RegExps and the string 'find()' method were being used for simple string checks, with "in" operator --- pyfpdb/Tables.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index f345d4ce..8346a37f 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -129,12 +129,14 @@ def discover_posix(c): # xwininfo -root -tree -id 0xnnnnn gets the info on a single window for s in c.get_supported_sites(): params = c.get_site_parameters(s) + +# TODO: We need to make a list of phrases, shared between the WIndows and Unix code!!!!!! if re.search(params['table_finder'], listing): - if re.search('Lobby', listing): continue - if re.search('Instant Hand History', listing): continue - if re.search('\"Full Tilt Poker\"', listing): continue # FTP Lobby - if re.search('History for table:', listing): continue - if re.search('has no name', listing): continue + if 'Lobby' in listing: continue + if 'Instant Hand History' in listing: continue + if '\"Full Tilt Poker\"' in listing: continue + if 'History for table:' in listing: continue + if 'has no name' in listing: continue: info = decode_xwininfo(c, listing) if info['site'] == None: continue if info['title'] == info['exe']: continue @@ -147,8 +149,8 @@ def discover_posix(c): def discover_posix_by_name(c, tablename): """Find an XWindows poker client of the given name.""" for listing in os.popen('xwininfo -root -tree').readlines(): - if re.search(tablename, listing): - if re.search('History for table:', listing): continue + if tablename in listing: + if 'History for table:' in listing: continue info = decode_xwininfo(c, listing) if not info['name'] == tablename: continue return info @@ -195,9 +197,9 @@ def discover_nt(c): titles = {} tables = {} win32gui.EnumWindows(win_enum_handler, titles) - for hwnd in titles.keys(): - if re.search('Logged In as', titles[hwnd], re.IGNORECASE) and not re.search('Lobby', titles[hwnd]): - if re.search('Full Tilt Poker', titles[hwnd]): + for hwnd in titles: + if 'Logged In as' in titles[hwnd] and not 'Lobby' in titles[hwnd]: + if 'Full Tilt Poker' in titles[hwnd]: continue tw = Table_Window() tw.number = hwnd @@ -207,9 +209,11 @@ def discover_nt(c): tw.height = int( height ) - b_width - tb_height tw.x = int( x ) + b_width tw.y = int( y ) + tb_height - if re.search('Logged In as', titles[hwnd]): + +# TODO: Isn't the site being determined by the EXE name it belongs to? is this section of code even useful? cleaning it anyway + if 'Logged In as' in titles[hwnd]: tw.site = "PokerStars" - elif re.search('Logged In As', titles[hwnd]): #wait, what??! + elif 'Logged In As' in titles[hwnd]: tw.site = "Full Tilt" else: tw.site = "Unknown" @@ -226,10 +230,10 @@ def discover_nt_by_name(c, tablename): titles = {} win32gui.EnumWindows(win_enum_handler, titles) for hwnd in titles: - if titles[hwnd].find(tablename) == -1: continue - if titles[hwnd].find("History for table:") > -1: continue - if titles[hwnd].find("HUD:") > -1: continue - if titles[hwnd].find("Chat:") > -1: continue + if not tablename in titles[hwnd]: continue + if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window + if 'HUD:' in titles[hwnd]: continue # FPDB HUD window + if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows return decode_windows(c, titles[hwnd], hwnd) return None From 0cd97db5486692e446dd34c8fd7385ba275d80a8 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 8 Jan 2009 06:25:25 -0500 Subject: [PATCH 4/5] fix typo from last commit --- pyfpdb/Tables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 8346a37f..ddd04fc0 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -136,7 +136,7 @@ def discover_posix(c): if 'Instant Hand History' in listing: continue if '\"Full Tilt Poker\"' in listing: continue if 'History for table:' in listing: continue - if 'has no name' in listing: continue: + if 'has no name' in listing: continue info = decode_xwininfo(c, listing) if info['site'] == None: continue if info['title'] == info['exe']: continue From 0fd6c4a9b20f1a6197eb51ccd00c7d5881e11626 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 8 Jan 2009 10:40:18 -0500 Subject: [PATCH 5/5] fpdb_parse_logic: use 'in' instead of 'find' --- pyfpdb/fpdb_parse_logic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index d30a7b3f..f13b1d6d 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -41,7 +41,7 @@ def mainParser(backend, db, cursor, site, category, hand): isTourney=fpdb_simple.isTourney(hand[0]) smallBlindLine=0 for i in range(len(hand)): - if hand[i].find("posts small blind")!=-1 or hand[i].find("posts the small blind")!=-1: + if 'posts small blind' in hand[i] or 'posts the small blind' in hand[i]: if hand[i][-2:] == "$0": continue smallBlindLine=i