2010-07-08 20:01:03 +02:00
|
|
|
#!/usr/bin/env python
|
2010-07-04 03:05:16 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-05-21 17:13:39 +02:00
|
|
|
"""Tables_Demo.py
|
|
|
|
|
|
|
|
Main program module to test/demo the Tables subclasses.
|
|
|
|
"""
|
2010-07-04 03:05:16 +02:00
|
|
|
# Copyright 2008-2010, Ray E. Barker
|
2009-05-21 17:13:39 +02:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
# Standard Library modules
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
# pyGTK modules
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
|
|
|
|
# fpdb/free poker tools modules
|
2010-03-02 01:26:45 +01:00
|
|
|
import Configuration
|
|
|
|
|
2010-08-15 20:50:49 +02:00
|
|
|
import locale
|
|
|
|
lang=locale.getdefaultlocale()[0][0:2]
|
|
|
|
if lang=="en":
|
|
|
|
def _(string): return string
|
|
|
|
else:
|
|
|
|
import gettext
|
|
|
|
try:
|
|
|
|
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
|
|
|
|
trans.install()
|
|
|
|
except IOError:
|
|
|
|
def _(string): return string
|
2010-08-15 07:38:44 +02:00
|
|
|
|
2009-05-21 17:13:39 +02:00
|
|
|
# get the correct module for the current os
|
|
|
|
if os.name == 'posix':
|
|
|
|
import XTables as Tables
|
|
|
|
elif os.name == 'nt':
|
|
|
|
import WinTables as Tables
|
|
|
|
|
2010-03-02 01:26:45 +01:00
|
|
|
config = Configuration.Config()
|
2009-05-21 17:13:39 +02:00
|
|
|
# Main function used for testing
|
|
|
|
if __name__=="__main__":
|
|
|
|
# c = Configuration.Config()
|
|
|
|
|
|
|
|
class fake_hud(object):
|
|
|
|
def __init__(self, table, dx = 100, dy = 100):
|
|
|
|
self.table = table
|
|
|
|
self.dx = dx
|
|
|
|
self.dy = dy
|
|
|
|
|
|
|
|
self.main_window = gtk.Window()
|
|
|
|
self.main_window.connect("destroy", self.client_destroyed)
|
|
|
|
self.label = gtk.Label('Fake Fake Fake Fake\nFake\nFake\nFake')
|
|
|
|
self.main_window.add(self.label)
|
2010-08-15 07:38:44 +02:00
|
|
|
self.main_window.set_title(_("Fake HUD Main Window"))
|
2009-05-21 17:13:39 +02:00
|
|
|
self.main_window.move(table.x + dx, table.y + dy)
|
|
|
|
self.main_window.show_all()
|
|
|
|
table.topify(self)
|
2010-09-07 15:50:29 +02:00
|
|
|
|
|
|
|
# These are the currently defined signals. Do this in the HUD.
|
2009-05-21 17:13:39 +02:00
|
|
|
self.main_window.connect("client_moved", self.client_moved)
|
|
|
|
self.main_window.connect("client_resized", self.client_resized)
|
|
|
|
self.main_window.connect("client_destroyed", self.client_destroyed)
|
2010-09-07 15:50:29 +02:00
|
|
|
self.main_window.connect("game_changed", self.game_changed)
|
|
|
|
self.main_window.connect("table_changed", self.table_changed)
|
2009-05-21 17:13:39 +02:00
|
|
|
|
2010-09-07 15:50:29 +02:00
|
|
|
# And these of the handlers that go with those signals.
|
|
|
|
# These would live inside the HUD code.
|
2009-05-21 17:13:39 +02:00
|
|
|
def client_moved(self, widget, hud):
|
|
|
|
self.main_window.move(self.table.x + self.dx, self.table.y + self.dy)
|
|
|
|
|
|
|
|
def client_resized(self, *args):
|
2010-09-07 15:50:29 +02:00
|
|
|
print "Client resized"
|
2009-05-21 17:13:39 +02:00
|
|
|
|
|
|
|
def client_destroyed(self, *args): # call back for terminating the main eventloop
|
2010-09-07 15:50:29 +02:00
|
|
|
print "Client destroyed."
|
2009-05-21 17:13:39 +02:00
|
|
|
gtk.main_quit()
|
|
|
|
|
2010-09-07 15:50:29 +02:00
|
|
|
def game_changed(self, *args):
|
|
|
|
print "Game Changed."
|
|
|
|
|
|
|
|
def table_changed(self, *args):
|
|
|
|
print "Table Changed."
|
2009-05-21 17:13:39 +02:00
|
|
|
|
2010-08-15 07:38:44 +02:00
|
|
|
print _("enter table name to find: "),
|
2009-05-21 17:13:39 +02:00
|
|
|
table_name = sys.stdin.readline()
|
|
|
|
if "," in table_name: # tournament
|
|
|
|
print "tournament"
|
|
|
|
(tour_no, tab_no) = table_name.split(",", 1)
|
|
|
|
tour_no = tour_no.rstrip()
|
|
|
|
tab_no = tab_no.rstrip()
|
2010-03-02 01:26:45 +01:00
|
|
|
type = "tour"
|
|
|
|
table_kwargs = dict(tournament = tour_no, table_number = tab_no)
|
2009-05-21 17:13:39 +02:00
|
|
|
else: # not a tournament
|
|
|
|
print "cash game"
|
|
|
|
table_name = table_name.rstrip()
|
2010-03-02 01:26:45 +01:00
|
|
|
type = "cash"
|
|
|
|
table_kwargs = dict(table_name = table_name)
|
|
|
|
|
2010-09-07 15:50:29 +02:00
|
|
|
table = Tables.Table(config, "Full Tilt Poker", **table_kwargs)
|
|
|
|
print table
|
2009-05-21 17:13:39 +02:00
|
|
|
|
|
|
|
fake = fake_hud(table)
|
2010-09-07 15:50:29 +02:00
|
|
|
gobject.timeout_add(1000, table.check_game, fake)
|
|
|
|
gobject.timeout_add(100, table.check_table, fake)
|
2009-06-10 18:58:14 +02:00
|
|
|
print "calling main"
|
2009-05-21 17:13:39 +02:00
|
|
|
gtk.main()
|
|
|
|
|