From 051f04b69f54572efddad165032b9f11aeafb4c1 Mon Sep 17 00:00:00 2001 From: eblade Date: Sun, 26 Oct 2008 15:51:12 -0400 Subject: [PATCH 1/5] trying to get parenting of stats windows to work in nix. --- pyfpdb/Hud.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 42579eac..28cae1d8 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -92,6 +92,10 @@ class Hud: # set_keep_above(1) for windows if os.name == 'nt': self.topify_window(self.main_window) + else: + window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) + self.main_window.gdkhandle = gtk.gdk.window_foreign_new(window.window.xid) + self.main_window.gdkhandle.set_transient_for(window.parentgdkhandle) def on_button_press(self, widget, event): if event.button == 3: @@ -107,6 +111,7 @@ class Hud: def save_layout(self, *args): new_layout = [] +# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. for sw in self.stat_windows: loc = self.stat_windows[sw].window.get_position() new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) From 70bdc0bcb46683a192a18b09e82c9c1d46310017 Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 27 Oct 2008 03:12:12 -0400 Subject: [PATCH 2/5] fix for re-parenting to work in nix, remove decorations from table hud main window --- pyfpdb/Hud.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 28cae1d8..baafaddf 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -67,11 +67,11 @@ class Hud: 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) #self.main_window.set_transient_for(parent.get_toplevel()) self.ebox = gtk.EventBox() - self.label = gtk.Label("Close this window to\nkill the HUD for\n %s\nMinimizing it hides stats." % - (table.name)) + self.label = gtk.Label("Right click to close HUD for %s\nor Save Stat Positions." % (table.name)) self.main_window.add(self.ebox) self.ebox.add(self.label) self.main_window.move(self.table.x, self.table.y) @@ -93,9 +93,12 @@ class Hud: if os.name == 'nt': self.topify_window(self.main_window) else: - window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) - self.main_window.gdkhandle = gtk.gdk.window_foreign_new(window.window.xid) - self.main_window.gdkhandle.set_transient_for(window.parentgdkhandle) + self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) + self.main_window.gdkhandle = gtk.gdk.window_foreign_new(self.main_window.window.xid) + self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) + #window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) + #self.main_window.gdkhandle = gtk.gdk.window_foreign_new(window.window.xid) + #self.main_window.gdkhandle.set_transient_for(window.parentgdkhandle) def on_button_press(self, widget, event): if event.button == 3: From 2bde12a6cf54d11da3dec7735e47ed99c893c84f Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 27 Oct 2008 03:13:04 -0400 Subject: [PATCH 3/5] remove set keep above on stat windows --- pyfpdb/Hud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index baafaddf..c4099b5b 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -64,7 +64,7 @@ class 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_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) @@ -335,7 +335,7 @@ class Stat_Window: self.window = gtk.Window() self.window.set_decorated(0) self.window.set_gravity(gtk.gdk.GRAVITY_STATIC) - self.window.set_keep_above(1) + #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) From 5f15a4f9286befff3bc0fa745efa318e25bae13d Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 27 Oct 2008 06:29:39 -0400 Subject: [PATCH 4/5] Configuration.py: add "bgcolor" and "fgcolor" to node HUD: table hud and stat windows respect "bgcolor" and "fgcolor" on a per site basis Tables: force tw.number to be an int in Unix --- pyfpdb/Configuration.py | 8 ++++++++ pyfpdb/HUD_main.py | 1 - pyfpdb/Hud.py | 21 ++++++++++++++++++--- pyfpdb/Tables.py | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 4e29dba1..c6262c54 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -53,6 +53,14 @@ class Site: self.site_path = node.getAttribute("site_path") self.HH_path = node.getAttribute("HH_path") self.decoder = node.getAttribute("decoder") + + self.hudbgcolor = node.getAttribute("bgcolor") + if self.hudbgcolor == "": + self.hudbgcolor = "#FFFFFF" + self.hudfgcolor = node.getAttribute("fgcolor") + if self.hudfgcolor == "": + self.hudfgcolor = "#000000" + self.layout = {} for layout_node in node.getElementsByTagName('layout'): diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 8217deb5..a157cf46 100644 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -29,7 +29,6 @@ Main for FreePokerTools HUD. # to do no hud window for hero # to do things to add to config.xml # to do font and size -# to do bg and fg color # to do opacity # Standard Library modules diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index c4099b5b..940050ac 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -59,9 +59,9 @@ class Hud: 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() + 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) @@ -72,8 +72,15 @@ 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.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.main_window.move(self.table.x, self.table.y) # A popup window for the main window @@ -351,9 +358,17 @@ class Stat_Window: self.label.append([]) 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)) + 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.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].connect("button_press_event", self.button_press_cb) # font = pango.FontDescription("Sans 8") @@ -544,7 +559,7 @@ if __name__== "__main__": c = Configuration.Config() #tables = Tables.discover(c) - t = Tables.discover_table_by_name(c, "Corona") + t = Tables.discover_table_by_name(c, "Chelsea") if t is None: print "Table not found." db = Database.Database(c, 'fpdb', 'holdem') diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index a5090fd7..752c5929 100644 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -96,7 +96,7 @@ def discover_posix(c): if re.match('[\(\)\d\s]+', mo.group(2)): continue # this is a popup tw = Table_Window() tw.site = c.supported_sites[s].site_name - tw.number = mo.group(1) + tw.number = int(mo.group(1), 0) tw.title = mo.group(2) tw.width = int( mo.group(3) ) tw.height = int( mo.group(4) ) From 64dbe3237dff1740eb0936412eab3c1b9f2c4ad7 Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 27 Oct 2008 07:12:04 -0400 Subject: [PATCH 5/5] add "hudopacity" to site config, valid settings are potentially from 0.00 to 1.00 --- pyfpdb/Configuration.py | 6 ++++++ pyfpdb/Hud.py | 1 + 2 files changed, 7 insertions(+) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index c6262c54..4690a84c 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -53,6 +53,12 @@ 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 == "": diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 940050ac..e9ac814c 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -341,6 +341,7 @@ 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_gravity(gtk.gdk.GRAVITY_STATIC) #self.window.set_keep_above(1) self.window.set_title("%s" % seat)