From f335cb60a751901f8ececb6c738043a21da9dcb1 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 11 May 2010 13:06:05 +0930 Subject: [PATCH] wix: Tarot panel now appear on top of groupchat window when a Tarot game is started --- frontends/quick_frontend/quick_app.py | 4 ++++ frontends/wix/card_game.py | 3 +++ frontends/wix/chat.py | 20 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/frontends/quick_frontend/quick_app.py b/frontends/quick_frontend/quick_app.py index b7f3a2c7..c6926d77 100644 --- a/frontends/quick_frontend/quick_app.py +++ b/frontends/quick_frontend/quick_app.py @@ -251,6 +251,10 @@ class QuickApp(): if not self.__check_profile(profile): return print "Tarot Game Started \o/" + if self.chat_wins.has_key(room_jid): + self.chat_wins[room_jid].startGame("Tarot") + debug (_("new Tarot game started in room [%(room_jid)s]") % {'room_jid':room_jid}) + def subscribe(self, type, raw_jid, profile): diff --git a/frontends/wix/card_game.py b/frontends/wix/card_game.py index 0147f27e..7b9f8693 100644 --- a/frontends/wix/card_game.py +++ b/frontends/wix/card_game.py @@ -32,6 +32,8 @@ from contact_list import ContactList CARD_WIDTH = 74 CARD_HEIGHT = 136 +MIN_WIDTH = 950 #Minimum size of the panel +MIN_HEIGHT = 500 class Card(): """This class is used to represent a card, graphically and logically""" @@ -59,6 +61,7 @@ class CardPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) + self.SetMinSize(wx.Size(MIN_WIDTH, MIN_HEIGHT)) self.load_cards("/home/goffi/dev/divers/images/cards/") self.selected = None #contain the card to highlight self.hand_size = 13 #number of cards in a hand diff --git a/frontends/wix/chat.py b/frontends/wix/chat.py index 5090796c..3bed9083 100644 --- a/frontends/wix/chat.py +++ b/frontends/wix/chat.py @@ -28,6 +28,7 @@ from logging import debug, info, error, warning from tools.jid import JID from quick_frontend.quick_chat import QuickChat from contact_list import ContactList +from card_game import CardPanel idSEND = 1 @@ -40,8 +41,12 @@ class Chat(wx.Frame, QuickChat): wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200)) QuickChat.__init__(self, target, host, type) - self.splitter = wx.SplitterWindow(self, -1) + self.sizer = wx.BoxSizer(wx.VERTICAL) + self.SetSizer(self.sizer) + self.splitter = wx.SplitterWindow(self, -1) + self.sizer.Add(self.splitter, 1, flag = wx.EXPAND) + self.conv_panel = wx.Panel(self.splitter) self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL) self.subjectBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_READONLY) @@ -49,7 +54,7 @@ class Chat(wx.Frame, QuickChat): self.textBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_PROCESS_ENTER) self.conv_panel.sizer.Add(self.subjectBox, flag=wx.EXPAND) self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) - self.conv_panel.sizer.Add(self.textBox, flag=wx.EXPAND) + self.conv_panel.sizer.Add(self.textBox, 0, flag=wx.EXPAND) self.conv_panel.SetSizer(self.conv_panel.sizer) self.splitter.Initialize(self.conv_panel) self.SetMenuBar(wx.MenuBar()) @@ -88,6 +93,7 @@ class Chat(wx.Frame, QuickChat): self.__eraseMenus() self.__createMenus_group() self.historyPrint(profile=self.host.profile) + self.sizer.Layout() elif type is 'one2one' and self.splitter.IsSplit(): self.splitter.Unsplit(self.present_panel) del self.present_panel @@ -101,6 +107,16 @@ class Chat(wx.Frame, QuickChat): self.__eraseMenus() self.__createMenus_O2O() self.historyPrint(profile=self.host.profile) + + def startGame(self, game_type): + """Configure the chat window to start a game""" + if game_type=="Tarot": + debug (_("configure chat window for Tarot game")) + tarot_panel = CardPanel(self) + self.sizer.Prepend(tarot_panel, 0, flag=wx.EXPAND) + self.sizer.Layout() + self.Fit() + def setPresents(self, nicks): """Set the users presents in the contact list for a group chat