Merge branch 'master' of git://git.assembla.com/free_poker_tools
This commit is contained in:
commit
7053b7f748
|
@ -37,6 +37,7 @@ import os
|
||||||
import thread
|
import thread
|
||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
|
import re
|
||||||
|
|
||||||
errorfile = open('HUD-error.txt', 'w', 0)
|
errorfile = open('HUD-error.txt', 'w', 0)
|
||||||
sys.stderr = errorfile
|
sys.stderr = errorfile
|
||||||
|
@ -70,9 +71,10 @@ def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_conn
|
||||||
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name)
|
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name)
|
||||||
hud_dict[table_name].create(new_hand_id, config)
|
hud_dict[table_name].create(new_hand_id, config)
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
||||||
|
hud_dict[table_name].reposition_windows()
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave
|
gtk.gdk.threads_leave()
|
||||||
gobject.idle_add(idle_func)
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
def update_HUD(new_hand_id, table_name, config, stat_dict):
|
def update_HUD(new_hand_id, table_name, config, stat_dict):
|
||||||
|
@ -83,13 +85,15 @@ def update_HUD(new_hand_id, table_name, config, stat_dict):
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave
|
gtk.gdk.threads_leave()
|
||||||
gobject.idle_add(idle_func)
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
def read_stdin(): # This is the thread function
|
def read_stdin(): # This is the thread function
|
||||||
global hud_dict
|
global hud_dict
|
||||||
|
|
||||||
db_connection = Database.Database(config, db_name, 'temp')
|
db_connection = Database.Database(config, db_name, 'temp')
|
||||||
|
# tourny_finder = re.compile('(\d+) (\d+)')
|
||||||
|
|
||||||
while True: # wait for a new hand number on stdin
|
while True: # wait for a new hand number on stdin
|
||||||
new_hand_id = sys.stdin.readline()
|
new_hand_id = sys.stdin.readline()
|
||||||
new_hand_id = string.rstrip(new_hand_id)
|
new_hand_id = string.rstrip(new_hand_id)
|
||||||
|
@ -101,20 +105,39 @@ def read_stdin(): # This is the thread function
|
||||||
if hud_dict[h].deleted:
|
if hud_dict[h].deleted:
|
||||||
del(hud_dict[h])
|
del(hud_dict[h])
|
||||||
|
|
||||||
# connect to the db and get basic info about the new hand
|
# get basic info about the new hand from the db
|
||||||
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)
|
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)
|
||||||
|
|
||||||
|
# find out if this hand is from a tournament
|
||||||
|
is_tournament = False
|
||||||
|
# (t_number, s_number) = (0, 0)
|
||||||
|
# mat_obj = tourny_finder(table_name)
|
||||||
|
# if len(mat_obj.groups) == 2:
|
||||||
|
# is_tournament = True
|
||||||
|
# (t_number, s_number) = mat_obj.group(1, 2)
|
||||||
|
|
||||||
stat_dict = db_connection.get_stats_from_hand(new_hand_id)
|
stat_dict = db_connection.get_stats_from_hand(new_hand_id)
|
||||||
|
|
||||||
# if a hud for this table exists, just update it
|
# if a hud for this CASH table exists, just update it
|
||||||
if hud_dict.has_key(table_name):
|
if hud_dict.has_key(table_name):
|
||||||
update_HUD(new_hand_id, table_name, config, stat_dict)
|
update_HUD(new_hand_id, table_name, config, stat_dict)
|
||||||
|
# if a hud for this TOURNAMENT table exists, just update it
|
||||||
|
# elif hud_dict.has_key(t_number):
|
||||||
|
# update_HUD(new_hand_id, t_number, config, stat_dict)
|
||||||
# otherwise create a new hud
|
# otherwise create a new hud
|
||||||
else:
|
else:
|
||||||
tablewindow = Tables.discover_table_by_name(config, table_name)
|
if is_tournament:
|
||||||
if tablewindow == None:
|
tablewindow = Tables.discover_tournament_table(config, t_number, s_number)
|
||||||
sys.stderr.write("table name "+table_name+" not found\n")
|
if tablewindow == None:
|
||||||
|
sys.stderr.write("table name "+table_name+" not found\n")
|
||||||
|
else:
|
||||||
|
create_HUD(new_hand_id, tablewindow, db_name, t_number, max, poker_game, db_connection, config, stat_dict)
|
||||||
else:
|
else:
|
||||||
create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict)
|
tablewindow = Tables.discover_table_by_name(config, table_name)
|
||||||
|
if tablewindow == None:
|
||||||
|
sys.stderr.write("table name "+table_name+" not found\n")
|
||||||
|
else:
|
||||||
|
create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict)
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
sys.stderr.write("HUD_main starting\n")
|
sys.stderr.write("HUD_main starting\n")
|
||||||
|
|
|
@ -93,6 +93,10 @@ class Hud:
|
||||||
self.menu.append(self.item2)
|
self.menu.append(self.item2)
|
||||||
self.item2.connect("activate", self.save_layout)
|
self.item2.connect("activate", self.save_layout)
|
||||||
self.item2.show()
|
self.item2.show()
|
||||||
|
self.item3 = gtk.MenuItem('Reposition Stats')
|
||||||
|
self.menu.append(self.item3)
|
||||||
|
self.item3.connect("activate", self.reposition_windows)
|
||||||
|
self.item3.show()
|
||||||
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
||||||
|
|
||||||
self.main_window.show_all()
|
self.main_window.show_all()
|
||||||
|
@ -118,6 +122,10 @@ class Hud:
|
||||||
self.main_window.destroy()
|
self.main_window.destroy()
|
||||||
self.deleted = True
|
self.deleted = True
|
||||||
|
|
||||||
|
def reposition_windows(self, args):
|
||||||
|
for w in self.stat_windows:
|
||||||
|
self.stat_windows[w].window.move(self.stat_windows[w].x,
|
||||||
|
self.stat_windows[w].y)
|
||||||
def save_layout(self, *args):
|
def save_layout(self, *args):
|
||||||
new_layout = []
|
new_layout = []
|
||||||
# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y.
|
# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y.
|
||||||
|
@ -180,7 +188,6 @@ class Hud:
|
||||||
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
|
||||||
|
|
||||||
# self.mucked_window = gtk.Window()
|
# self.mucked_window = gtk.Window()
|
||||||
# self.m = Mucked.Mucked(self.mucked_window, self.db_connection)
|
# self.m = Mucked.Mucked(self.mucked_window, self.db_connection)
|
||||||
# self.mucked_window.show_all()
|
# self.mucked_window.show_all()
|
||||||
|
@ -342,7 +349,8 @@ class Stat_Window:
|
||||||
# font = pango.FontDescription("Sans 8")
|
# font = pango.FontDescription("Sans 8")
|
||||||
self.label[r][c].modify_font(font)
|
self.label[r][c].modify_font(font)
|
||||||
|
|
||||||
self.window.set_opacity(parent.colors['hudopacity'])
|
if not os.name == 'nt': # seems to be a bug in opacity on windows
|
||||||
|
self.window.set_opacity(parent.colors['hudopacity'])
|
||||||
self.window.realize
|
self.window.realize
|
||||||
self.window.move(self.x, self.y)
|
self.window.move(self.x, self.y)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user