Merge branch 'master' of git://git.assembla.com/fpdb-eric

This commit is contained in:
Ray 2009-03-24 17:54:23 -04:00
commit a404f0f3ee

View File

@ -82,7 +82,7 @@ class Hud:
font = "Sans" font = "Sans"
if font_size == None: if font_size == None:
font_size = "8" font_size = "8"
self.font = pango.FontDescription(font + " " + font_size) self.font = pango.FontDescription("%s %s" % (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? # do we need to add some sort of condition here for dealing with a request for a font that doesn't exist?
game_params = config.get_game_parameters(self.poker_game) game_params = config.get_game_parameters(self.poker_game)
@ -102,6 +102,7 @@ class Hud:
self.main_window.set_title("%s FPDBHUD" % (self.table.name)) self.main_window.set_title("%s FPDBHUD" % (self.table.name))
self.main_window.set_decorated(False) self.main_window.set_decorated(False)
self.main_window.set_opacity(self.colors["hudopacity"]) self.main_window.set_opacity(self.colors["hudopacity"])
self.main_window.set_focus_on_map(False)
self.ebox = gtk.EventBox() self.ebox = gtk.EventBox()
self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move") self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move")
@ -173,10 +174,11 @@ class Hud:
self.main_window.move(x, y) self.main_window.move(x, y)
adj = self.adj_seats(self.hand, self.config) adj = self.adj_seats(self.hand, self.config)
loc = self.config.get_locations(self.table.site, self.max) loc = self.config.get_locations(self.table.site, self.max)
for i in xrange(1, self.max + 1): for i, w in enumerate(self.stat_windows):
if not type(w) == int: # how do we get pure ints in this list??
(x, y) = loc[adj[i]] (x, y) = loc[adj[i]]
if i in self.stat_windows: w.relocate(x, y)
self.stat_windows[i].relocate(x, y)
return True return True
def on_button_press(self, widget, event): def on_button_press(self, widget, event):
@ -196,12 +198,12 @@ class Hud:
s.window.destroy() s.window.destroy()
self.stat_windows = {} self.stat_windows = {}
# also kill any aux windows # also kill any aux windows
[aux.destroy() for aux in self.aux_windows] (aux.destroy() for aux in self.aux_windows)
self.aux_windows = [] self.aux_windows = []
def reposition_windows(self, *args): def reposition_windows(self, *args):
if self.stat_windows != {} and len(self.stat_windows) > 0: if self.stat_windows != {} and len(self.stat_windows) > 0:
map(lambda x: x.window.move(x.x, x.y), self.stat_windows.itervalues()) (x.window.move(x.x, x.y) for x in self.stat_windows.itervalues() if type(x) != int)
return True return True
def debug_stat_windows(self, *args): def debug_stat_windows(self, *args):
@ -217,7 +219,7 @@ class Hud:
new_layout[self.stat_windows[sw].adj - 1] = new_loc new_layout[self.stat_windows[sw].adj - 1] = new_loc
self.config.edit_layout(self.table.site, self.max, locations = new_layout) self.config.edit_layout(self.table.site, self.max, locations = new_layout)
# ask each aux to save its layout back to the config object # ask each aux to save its layout back to the config object
[aux.save_layout() for aux in self.aux_windows] (aux.save_layout() for aux in self.aux_windows)
# save the config object back to the file # save the config object back to the file
print "saving new xml file" print "saving new xml file"
self.config.save() self.config.save()
@ -227,9 +229,9 @@ class Hud:
# Need range here, not xrange -> need the actual list # Need range here, not xrange -> need the actual list
adj = range(0, self.max + 1) # default seat adjustments = no adjustment adj = range(0, self.max + 1) # default seat adjustments = no adjustment
# does the user have a fav_seat? # does the user have a fav_seat?
if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
try: try:
sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat)) sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat))
if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat
sys.stderr.write("found fav seat = %d\n" % fav_seat) sys.stderr.write("found fav seat = %d\n" % fav_seat)
# actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name) # actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
@ -237,9 +239,11 @@ class Hud:
sys.stderr.write("found actual seat = %d\n" % actual_seat) sys.stderr.write("found actual seat = %d\n" % actual_seat)
for i in xrange(0, self.max + 1): for i in xrange(0, self.max + 1):
j = actual_seat + i j = actual_seat + i
if j > self.max: j = j - self.max if j > self.max:
j = j - self.max
adj[j] = fav_seat + i adj[j] = fav_seat + i
if adj[j] > self.max: adj[j] = adj[j] - self.max if adj[j] > self.max:
adj[j] = adj[j] - self.max
except Exception, inst: except Exception, inst:
sys.stderr.write("exception in adj!!!\n\n") sys.stderr.write("exception in adj!!!\n\n")
sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly
@ -286,10 +290,12 @@ class Hud:
font = self.font) font = self.font)
self.stats = [] self.stats = []
for i in xrange(0, config.supported_games[self.poker_game].rows + 1): game = config.supported_games[self.poker_game]
row_list = [''] * config.supported_games[self.poker_game].cols
for i in xrange(0, game.rows + 1):
row_list = [''] * game.cols
self.stats.append(row_list) self.stats.append(row_list)
for stat in config.supported_games[self.poker_game].stats: for stat in game.stats:
self.stats[config.supported_games[self.poker_game].stats[stat].row] \ self.stats[config.supported_games[self.poker_game].stats[stat].row] \
[config.supported_games[self.poker_game].stats[stat].col] = \ [config.supported_games[self.poker_game].stats[stat].col] = \
config.supported_games[self.poker_game].stats[stat].stat_name config.supported_games[self.poker_game].stats[stat].stat_name
@ -303,30 +309,30 @@ class Hud:
self.update_table_position() self.update_table_position()
for s in self.stat_dict: for s in self.stat_dict:
statd = self.stat_dict[s]
try: try:
self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id']
except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here
self.max = 10 self.max = 10
self.create(hand, config, self.stat_dict, self.cards) self.create(hand, config, self.stat_dict, self.cards)
self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] self.stat_windows[statd['seat']].player_id = statd['player_id']
for r in xrange(0, config.supported_games[self.poker_game].rows): for r in xrange(0, config.supported_games[self.poker_game].rows):
for c in xrange(0, config.supported_games[self.poker_game].cols): for c in xrange(0, config.supported_games[self.poker_game].cols):
this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]] this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]]
number = Stats.do_stat(self.stat_dict, player = self.stat_dict[s]['player_id'], stat = self.stats[r][c]) number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c])
statstring = this_stat.hudprefix + str(number[1]) + this_stat.hudsuffix statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix)
window = self.stat_windows[statd['seat']]
if this_stat.hudcolor != "": if this_stat.hudcolor != "":
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
self.stat_windows[self.stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor))
self.stat_windows[self.stat_dict[s]['seat']].label[r][c].set_text(statstring) window.label[r][c].set_text(statstring)
if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no?
self.stat_windows[self.stat_dict[s]['seat']].window.show_all() window.window.show_all()
# self.reposition_windows() tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4])
tip = self.stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ Stats.do_tip(window.e_box[r][c], tip)
number[3] + ", " + number[4]
Stats.do_tip(self.stat_windows[self.stat_dict[s]['seat']].e_box[r][c], tip)
def topify_window(self, window): def topify_window(self, window):
"""Set the specified gtk window to stayontop in MS Windows.""" """Set the specified gtk window to stayontop in MS Windows."""
@ -407,8 +413,9 @@ class Stat_Window:
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)
self.window.set_focus_on_map(False)
self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False) self.grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False)
self.window.add(self.grid) self.window.add(self.grid)
self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
@ -418,12 +425,12 @@ class Stat_Window:
usegtkframes = self.useframes usegtkframes = self.useframes
e_box = self.e_box e_box = self.e_box
label = self.label label = self.label
for r in xrange(self.game.rows): for r in xrange(game.rows):
if usegtkframes: if usegtkframes:
self.frame.append([]) self.frame.append([])
e_box.append([]) e_box.append([])
label.append([]) label.append([])
for c in xrange(self.game.cols): for c in xrange(game.cols):
if usegtkframes: if usegtkframes:
self.frame[r].append( gtk.Frame() ) self.frame[r].append( gtk.Frame() )
e_box[r].append( gtk.EventBox() ) e_box[r].append( gtk.EventBox() )