2 # -*- coding: utf-8 -*-
5 Mucked cards display for FreePokerTools HUD.
7 # Copyright 2008-2011, Ray E. Barker
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ########################################################################
27 # Standard Library modules
33 # FreePokerTools modules
36 class Stat_Window(Mucked
.Seat_Window
):
37 """Simple window class for stat windows."""
39 def create_contents(self
, i
):
40 self
.grid
= gtk
.Table(rows
= self
.aw
.nrows
, columns
= self
.aw
.ncols
, homogeneous
= False)
43 self
.stat_box
= [ [None]*self
.aw
.ncols
for i
in range(self
.aw
.nrows
) ]
44 for r
in xrange(self
.aw
.nrows
):
45 for c
in xrange(self
.aw
.ncols
):
46 self
.stat_box
[r
][c
] = Simple_stat(self
.aw
.stats
[r
][c
])
47 self
.grid
.attach(self
.stat_box
[r
][c
].widget
, c
, c
+1, r
, r
+1, xpadding
= self
.aw
.xpad
, ypadding
= self
.aw
.ypad
)
49 def update_contents(self
, i
):
50 if i
== "common": return
51 player_id
= self
.aw
.get_id_from_seat(i
)
52 if player_id
is None: return
53 for r
in xrange(self
.aw
.nrows
):
54 for c
in xrange(self
.aw
.ncols
):
55 self
.stat_box
[r
][c
].update(player_id
, self
.aw
.hud
.stat_dict
)
57 class Simple_HUD(Mucked
.Aux_Seats
):
58 """A simple HUD class based on the Aux_Window interface."""
60 def __init__(self
, hud
, config
, params
):
61 super(Simple_HUD
, self
).__init
__(hud
, config
, params
)
62 # Save everything you need to know about the hud as attrs.
63 # That way a subclass doesn't have to grab them.
64 self
.poker_game
= self
.hud
.poker_game
65 self
.game_params
= self
.hud
.config
.get_game_parameters(self
.hud
.poker_game
)
66 self
.game
= self
.hud
.config
.supported_games
[self
.hud
.poker_game
]
67 self
.max = self
.hud
.max
68 self
.nrows
= self
.game_params
['rows']
69 self
.ncols
= self
.game_params
['cols']
70 self
.xpad
= self
.game_params
['xpad']
71 self
.ypad
= self
.game_params
['ypad']
72 self
.xshift
= self
.game_params
['xshift']
73 self
.yshift
= self
.game_params
['yshift']
75 self
.aw_window_type
= Stat_Window
77 # layout is handled by superclass!
78 self
.stats
= [ [None]*self
.ncols
for i
in range(self
.nrows
) ]
79 for stat
in self
.game
.stats
:
80 self
.stats
[self
.config
.supported_games
[self
.poker_game
].stats
[stat
].row
] \
81 [self
.config
.supported_games
[self
.poker_game
].stats
[stat
].col
] = \
82 self
.config
.supported_games
[self
.poker_game
].stats
[stat
].stat_name
84 def create_contents(self
, container
, i
):
85 container
.create_contents(i
)
87 def update_contents(self
, container
, i
):
88 container
.update_contents(i
)
90 class Simple_stat(object):
91 """A simple class for displaying a single stat."""
92 def __init__(self
, stat
):
94 self
.eb
= Simple_eb();
95 self
.lab
= Simple_label(self
.stat
)
99 def update(self
, player_id
, stat_dict
):
100 self
.lab
.set_text( str(Stats
.do_stat(stat_dict
, player_id
, self
.stat
)[1]) )
102 # Override thise methods to customize your eb or label
103 class Simple_eb(gtk
.EventBox
): pass
104 class Simple_label(gtk
.Label
): pass