comparison frontends/src/wix/card_game.py @ 1011:5a6354ff468c

wix: use of new logging system
author Goffi <goffi@goffi.org>
date Mon, 05 May 2014 20:12:21 +0200
parents 36c6495d86b0
children e2e1e27a3680
comparison
equal deleted inserted replaced
1010:73a0b7f94674 1011:5a6354ff468c
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 20
21
22 from sat.core.i18n import _ 21 from sat.core.i18n import _
23 import wx 22 import wx
24 import os.path, glob 23 import os.path, glob
25 import pdb 24 from sat.core.log import getLogger
26 from logging import debug, info, error 25 log = getLogger(__name__)
27 from sat.tools.jid import JID
28 from sat_frontends.tools.games import TarotCard 26 from sat_frontends.tools.games import TarotCard
29 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame 27 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame
30 from sat_frontends.wix.xmlui import XMLUI 28 from sat_frontends.wix.xmlui import XMLUI
31 29
32 CARD_WIDTH = 74 30 CARD_WIDTH = 74
33 CARD_HEIGHT = 136 31 CARD_HEIGHT = 136
34 MIN_WIDTH = 950 #Minimum size of the panel 32 MIN_WIDTH = 950 #Minimum size of the panel
35 MIN_HEIGHT = 500 33 MIN_HEIGHT = 500
34
36 35
37 class WxCard(TarotCard): 36 class WxCard(TarotCard):
38 """This class is used to represent a card, graphically and logically""" 37 """This class is used to represent a card, graphically and logically"""
39 38
40 def __init__(self, file): 39 def __init__(self, file):
41 """@param file: path of the PNG file""" 40 """@param file: path of the PNG file"""
42 self.bitmap = wx.Image(file).ConvertToBitmap() 41 self.bitmap = wx.Image(file).ConvertToBitmap()
43 root_name = os.path.splitext(os.path.basename(file))[0] 42 root_name = os.path.splitext(os.path.basename(file))[0]
44 suit,value = root_name.split('_') 43 suit,value = root_name.split('_')
45 TarotCard.__init__(self, (suit, value)) 44 TarotCard.__init__(self, (suit, value))
46 print "Carte:",suit, value #, self.bout 45 log.debug("Card: %s %s" % (suit, value)) #, self.bout
47 46
48 def draw(self, dc, x, y): 47 def draw(self, dc, x, y):
49 """Draw the card on the device context 48 """Draw the card on the device context
50 @param dc: device context 49 @param dc: device context
51 @param x: abscissa 50 @param x: abscissa
95 self.Refresh() 94 self.Refresh()
96 95
97 def contratSelected(self, data): 96 def contratSelected(self, data):
98 """Called when the contrat has been choosed 97 """Called when the contrat has been choosed
99 @param data: form result""" 98 @param data: form result"""
100 debug (_("Contrat choosed")) 99 log.debug (_("Contrat choosed"))
101 contrat = data[0][1] 100 contrat = data[0][1]
102 QuickCardGame.contratSelected(self, contrat) 101 QuickCardGame.contratSelected(self, contrat)
103 102
104 def chooseContrat(self, xml_data): 103 def chooseContrat(self, xml_data):
105 """Called when the player has to select his contrat 104 """Called when the player has to select his contrat
209 else: 208 else:
210 self.mouse_over_card = None 209 self.mouse_over_card = None
211 self.Refresh() 210 self.Refresh()
212 211
213 def onMouseClick(self, event): 212 def onMouseClick(self, event):
214 print "mouse click:",event.GetPosition() 213 log.debug("mouse click: %s" % event.GetPosition())
215 pos_x,pos_y = event.GetPosition() 214 pos_x,pos_y = event.GetPosition()
216 215
217 if self.state == "chien": 216 if self.state == "chien":
218 self.to_show = [] 217 self.to_show = []
219 self.state = "wait" 218 self.state = "wait"