# HG changeset patch # User Goffi # Date 1273217970 -34200 # Node ID fc7583282d4015bc05105ef75fb5c51bae17f78a # Parent 7471ffcda33bcb0cf59ffb9a062752a99fc58032 Tarot Game plugin: first draft - SàT: beginning of the plugin - Tarot Plugin: 1 method createTarotGame et 1 signal tarotGameStarted - wix: added "Game" menu in group chat to start Tarot game diff -r 7471ffcda33b -r fc7583282d40 frontends/quick_frontend/quick_app.py --- a/frontends/quick_frontend/quick_app.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/quick_frontend/quick_app.py Fri May 07 17:09:30 2010 +0930 @@ -46,6 +46,7 @@ self.bridge.register("roomUserJoined", self.roomUserJoined) self.bridge.register("roomUserLeft", self.roomUserLeft) self.bridge.register("roomNewSubject", self.roomNewSubject) + self.bridge.register("tarotGameStarted", self.tarotGameStarted) self.bridge.register("subscribe", self.subscribe) self.bridge.register("paramUpdate", self.paramUpdate) self.bridge.register("contactDeleted", self.contactDeleted) @@ -215,6 +216,7 @@ room_jid=room_id+'@'+room_service self.chat_wins[room_jid].setUserNick(user_nick) self.chat_wins[room_jid].setType("group") + self.chat_wins[room_jid].id = room_jid self.chat_wins[room_jid].setPresents([user_nick]+room_nicks) @@ -244,6 +246,11 @@ if self.chat_wins.has_key(room_jid): self.chat_wins[room_jid].setSubject(subject) debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject}) + + def tarotGameStarted(self, room_jid, players, profile): + if not self.__check_profile(profile): + return + print "Tarot Game Started \o/" def subscribe(self, type, raw_jid, profile): diff -r 7471ffcda33b -r fc7583282d40 frontends/quick_frontend/quick_chat.py --- a/frontends/quick_frontend/quick_chat.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/quick_frontend/quick_chat.py Fri May 07 17:09:30 2010 +0930 @@ -30,7 +30,9 @@ self.target = target self.host = host self.type = type + self.id = "" self.nick = None + self.occupants = set() def setType(self, type): """Set the type of the chat diff -r 7471ffcda33b -r fc7583282d40 frontends/sat_bridge_frontend/DBus.py --- a/frontends/sat_bridge_frontend/DBus.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/sat_bridge_frontend/DBus.py Fri May 07 17:09:30 2010 +0930 @@ -119,6 +119,9 @@ def joinMUC(self, service, roomId, nick, profile_key='@DEFAULT@'): return self.db_comm_iface.joinMUC(service, roomId, nick, profile_key) + def createTarotGame(self, room_jid, players, profile_key='@DEFAULT@'): + return self.db_comm_iface.createTarotGame(room_jid, players, profile_key) + def sendFile(self, to, path, profile_key='@DEFAULT@'): return self.db_comm_iface.sendFile(to, path, profile_key) diff -r 7471ffcda33b -r fc7583282d40 frontends/wix/chat.py --- a/frontends/wix/chat.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/wix/chat.py Fri May 07 17:09:30 2010 +0930 @@ -24,13 +24,14 @@ import wx import os.path import pdb -from logging import debug, info, error +from logging import debug, info, error, warning from tools.jid import JID from quick_frontend.quick_chat import QuickChat from contact_list import ContactList idSEND = 1 +idTAROT = 2 class Chat(wx.Frame, QuickChat): """The chat Window for one to one conversations""" @@ -85,19 +86,22 @@ self.__createPresents() self.subjectBox.Show() self.__eraseMenus() + self.__createMenus_group() self.historyPrint(profile=self.host.profile) elif type is 'one2one' and self.splitter.IsSplit(): self.splitter.Unsplit(self.present_panel) del self.present_panel self.GetMenuBar().Show() self.subjectBox.Hide() + self.__eraseMenus() self.__createMenus_O2O() self.nick = None else: self.subjectBox.Hide() + self.__eraseMenus() self.__createMenus_O2O() self.historyPrint(profile=self.host.profile) - + def setPresents(self, nicks): """Set the users presents in the contact list for a group chat @param nicks: list of nicknames @@ -107,7 +111,9 @@ error (_("[INTERNAL] trying to set presents nicks for a non group chat window")) return for nick in nicks: - self.present_panel.presents.replace(nick) + self.present_panel.presents.replace(nick) + if nick != self.nick: + self.occupants.add(nick) def replaceUser(self, nick): @@ -117,6 +123,8 @@ error (_("[INTERNAL] trying to replace user for a non group chat window")) return self.present_panel.presents.replace(nick) + if nick != self.nick: + self.occupants.add(nick) def removeUser(self, nick): """Remove a user from the group list""" @@ -125,6 +133,7 @@ error (_("[INTERNAL] trying to remove user for a non group chat window")) return self.present_panel.presents.remove(nick) + self.occupants.remove(nick) def setSubject(self, subject): """Set title for a group chat""" @@ -153,6 +162,18 @@ #events wx.EVT_MENU(self, idSEND, self.onSendFile) + def __createMenus_group(self): + """create menu bar for group chat""" + info("Creating menus") + self.__eraseMenus() + menuBar = self.GetMenuBar() + actionMenu = wx.Menu() + actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp + menuBar.Append(actionMenu,_("&Games")) + + #events + wx.EVT_MENU(self, idTAROT, self.onStartTarot) + def __del__(self): wx.Frame.__del__(self) @@ -200,3 +221,7 @@ id = self.host.bridge.sendFile(full_jid, filename) self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename)) + def onStartTarot(self, e): + debug (_("Starting Tarot game")) + warning (_("FIXME: temporary menu, must be changed")) + self.host.bridge.createTarotGame(self.id, list(self.occupants), self.host.profile) diff -r 7471ffcda33b -r fc7583282d40 frontends/wix/main_window.py --- a/frontends/wix/main_window.py Thu May 06 20:47:48 2010 +0930 +++ b/frontends/wix/main_window.py Fri May 07 17:09:30 2010 +0930 @@ -111,8 +111,8 @@ #self.profile_pan.Hide() #gof: self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND) - Tarot = CardGame(self) - Tarot.Show()#gof: temp for test + #Tarot = CardGame(self) + #Tarot.Show()#gof: temp for test self.Show()