kgamechat.h
00001 /* 00002 This file is part of the KDE games library 00003 Copyright (C) 2001-2002 Andreas Beckermann (b_mann@gmx.de) 00004 Copyright (C) 2001 Martin Heni (martin@heni-online.de) 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __KGAMECHAT_H__ 00022 #define __KGAMECHAT_H__ 00023 00024 #include <tqstring.h> 00025 00026 #include "kchatbase.h" 00027 #include <kdemacros.h> 00028 class KPlayer; 00029 class KGame; 00030 class KGamePropertyBase; 00031 00032 class KGameChatPrivate; 00033 00043 class KDE_EXPORT KGameChat : public KChatBase 00044 { 00045 Q_OBJECT 00046 TQ_OBJECT 00047 public: 00053 KGameChat(KGame* game, int msgid, KPlayer* fromPlayer, TQWidget * parent); 00054 00060 KGameChat(KGame* game, int msgId, TQWidget* parent); 00061 00068 KGameChat(TQWidget* parent); 00069 00070 virtual ~KGameChat(); 00071 00072 enum SendingIds { 00073 SendToGroup = 1 00074 }; 00075 00082 void setFromPlayer(KPlayer* player); 00083 00084 KPlayer* fromPlayer() const; 00085 00093 void setKGame(KGame* g); 00094 00095 KGame* game() const; 00096 00101 int messageId() const; 00102 00112 void setMessageId(int msgid); 00113 00118 virtual const TQString& fromName() const; 00119 00120 00121 public slots: 00122 virtual void addMessage(const TQString& fromName, const TQString& text) { KChatBase::addMessage(fromName, text);} 00123 virtual void addMessage(int fromId, const TQString& text); 00124 00125 void slotReceiveMessage(int, const TQByteArray&, TQ_UINT32 receiver, TQ_UINT32 sender); 00126 00127 protected: 00133 bool isSendToAllMessage(int id) const; 00134 00144 bool isToGroupMessage(int id) const; 00145 00146 00159 bool isToPlayerMessage(int id) const; 00160 00170 int playerId(int id) const; 00171 00177 int sendingId(int playerId) const; 00178 00183 bool hasPlayer(int id) const; 00184 00191 virtual TQString sendToPlayerEntry(const TQString& name) const; 00192 00193 00194 protected slots: 00200 void slotUnsetKGame(); 00201 00202 00203 void slotPropertyChanged(KGamePropertyBase*, KPlayer*); 00204 void slotAddPlayer(KPlayer*); 00205 void slotRemovePlayer(KPlayer*); 00206 00212 void slotReceivePrivateMessage(int msgid, const TQByteArray& buffer, TQ_UINT32 sender, KPlayer* me); 00213 00214 protected: 00215 virtual void returnPressed(const TQString& text); 00216 00217 private: 00218 void init(KGame* g, int msgid); 00219 00220 private: 00221 KGameChatPrivate* d; 00222 }; 00223 00224 #endif