kgamedialogconfig.h
00001 /* 00002 This file is part of the TDE games library 00003 Copyright (C) 2001 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 // NAMING 00022 // please follow these naming rules if you add/change classes: 00023 // the main dialog is named KGameDialog and the base config widget 00024 // KGameDialogConfig. All config widgets are named KGameDialogXYZConfig (where 00025 // XYZ = the name of the config widget, like "general" or "network") and are 00026 // inherited from KGameDialogConfig. 00027 00028 #ifndef __KGAMEDIALOGCONFIG_H__ 00029 #define __KGAMEDIALOGCONFIG_H__ 00030 00031 #include <tqwidget.h> 00032 #include <kdemacros.h> 00033 00034 class TQGridLayout; 00035 class TQVBoxLayout; 00036 class TQListBoxItem; 00037 00038 class KGame; 00039 class KPlayer; 00040 class KGamePropertyBase; 00041 00042 class KGameDialogConfigPrivate; 00051 class KDE_EXPORT KGameDialogConfig : public TQWidget 00052 { 00053 Q_OBJECT 00054 00055 public: 00056 KGameDialogConfig(TQWidget* parent = 0); 00057 virtual ~KGameDialogConfig(); 00058 00066 virtual void submitToKGame(KGame* g, KPlayer* p) = 0; 00067 00079 virtual void setOwner(KPlayer* p); 00080 00089 virtual void setKGame(KGame* g); 00090 00105 virtual void setAdmin(bool admin); 00106 00113 KGame* game() const; 00114 00122 KPlayer* owner() const; 00123 00128 bool admin() const; 00129 00130 protected: 00131 00132 private: 00133 KGameDialogConfigPrivate* d; 00134 }; 00135 00144 class KGameDialogGeneralConfigPrivate; 00145 class KGameDialogGeneralConfig : public KGameDialogConfig 00146 { 00147 Q_OBJECT 00148 00149 public: 00165 KGameDialogGeneralConfig(TQWidget* parent = 0, bool initializeGUI = true); 00166 virtual ~KGameDialogGeneralConfig(); 00167 00175 virtual void submitToKGame(KGame* g, KPlayer* p); 00176 00183 virtual void setOwner(KPlayer* p); 00184 00191 virtual void setKGame(KGame* g); 00192 00198 virtual void setAdmin(bool admin); 00199 00200 protected slots: 00201 void slotPropertyChanged(KGamePropertyBase*, KPlayer*); 00202 00203 protected: 00204 void setPlayerName(const TQString& name); 00205 00206 TQString playerName() const; 00207 00208 private: 00209 KGameDialogGeneralConfigPrivate* d; 00210 }; 00211 00212 class KGameDialogNetworkConfigPrivate; 00213 class KDE_EXPORT KGameDialogNetworkConfig : public KGameDialogConfig 00214 { 00215 Q_OBJECT 00216 00217 public: 00218 KGameDialogNetworkConfig(TQWidget* parent = 0); 00219 virtual ~KGameDialogNetworkConfig(); 00220 00221 00222 void disableInitConnection(); 00223 00231 virtual void submitToKGame(KGame* g, KPlayer* p); 00232 00233 virtual void setKGame(KGame* g); 00234 00244 void setDefaultNetworkInfo(const TQString& host, unsigned short int port,bool server=true); 00245 00254 void setDiscoveryInfo(const TQString& type, const TQString& name=TQString()); 00255 00256 signals: 00263 void signalServerTypeChanged(int); 00264 00265 00266 protected: 00267 void setConnected(bool connected, bool master = false); 00268 00269 protected slots: 00270 void slotInitConnection(); 00271 void slotExitConnection(); 00272 void slotConnectionBroken(); 00273 00274 00275 private: 00276 KGameDialogNetworkConfigPrivate* d; 00277 }; 00278 00279 class KGameDialogMsgServerConfigPrivate; 00280 class KGameDialogMsgServerConfig : public KGameDialogConfig 00281 { 00282 Q_OBJECT 00283 00284 public: 00285 KGameDialogMsgServerConfig(TQWidget* parent = 0); 00286 virtual ~KGameDialogMsgServerConfig(); 00287 00288 virtual void submitToKGame(KGame*, KPlayer*) {} 00289 00290 void setHasMsgServer(bool); 00291 00292 virtual void setKGame(KGame* g); 00293 virtual void setAdmin(bool); 00294 00295 protected slots: 00296 void slotChangeMaxClients(); 00297 void slotChangeAdmin(); 00298 void slotRemoveClient(); 00299 00300 protected: 00301 void removeClient(TQ_UINT32 id); 00302 00303 private: 00304 KGameDialogMsgServerConfigPrivate* d; 00305 }; 00306 00307 class KGameDialogChatConfigPrivate; 00314 class KGameDialogChatConfig : public KGameDialogConfig 00315 { 00316 Q_OBJECT 00317 00318 public: 00319 KGameDialogChatConfig(int chatMsgId, TQWidget* parent = 0); 00320 virtual ~KGameDialogChatConfig(); 00321 00322 virtual void setKGame(KGame* g); 00323 virtual void setOwner(KPlayer* p); 00324 00325 virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); } 00326 00327 private: 00328 KGameDialogChatConfigPrivate* d; 00329 }; 00330 00335 class KGameDialogConnectionConfigPrivate; 00336 class KGameDialogConnectionConfig : public KGameDialogConfig 00337 { 00338 Q_OBJECT 00339 00340 public: 00341 KGameDialogConnectionConfig(TQWidget* parent = 0); 00342 virtual ~KGameDialogConnectionConfig(); 00343 00344 virtual void setKGame(KGame* g); 00345 virtual void setOwner(KPlayer* p); 00346 virtual void setAdmin(bool admin); 00347 00348 virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); } 00349 00350 protected: 00355 TQListBoxItem* item(KPlayer* p) const; 00356 00357 protected slots: 00358 void slotKickPlayerOut(TQListBoxItem* item); 00359 void slotPropertyChanged(KGamePropertyBase* prop, KPlayer* p); 00360 void slotPlayerLeftGame(KPlayer* p); 00361 void slotPlayerJoinedGame(KPlayer* p); 00362 void slotClearPlayers(); 00363 00364 private: 00365 KGameDialogConnectionConfigPrivate* d; 00366 00367 }; 00368 #endif