libkdegames Library API Documentation

kgameio.h

00001 /* 00002 This file is part of the KDE games library 00003 Copyright (C) 2001 Martin Heni (martin@heni-online.de) 00004 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 /* 00021 $Id: kgameio.h,v 1.28 2003/11/03 10:09:29 bhards Exp $ 00022 */ 00023 #ifndef __KGAMEIO_H__ 00024 #define __KGAMEIO_H__ 00025 00026 #include <qstring.h> 00027 #include <qobject.h> 00028 00029 class KPlayer; 00030 class KGame; 00031 class KProcess; 00032 00055 class KGameIO : public QObject 00056 { 00057 Q_OBJECT 00058 00059 public: 00063 KGameIO(); 00064 KGameIO(KPlayer*); 00065 virtual ~KGameIO(); 00066 00070 void Debug(); 00071 00075 enum IOMode {GenericIO=1,KeyIO=2,MouseIO=4,ProcessIO=8,ComputerIO=16}; 00082 virtual int rtti() const = 0; // Computer, network, local, ... 00083 00089 KPlayer *player() const {return mPlayer;} 00090 00095 KGame* game() const; 00096 00104 void setPlayer(KPlayer *p) {mPlayer=p;} 00105 00115 virtual void initIO(KPlayer *p); 00116 00126 virtual void notifyTurn(bool b); 00127 00131 bool sendInput(QDataStream& stream, bool transmit = true, Q_UINT32 sender = 0); 00132 00133 signals: 00165 void signalPrepareTurn(QDataStream & stream, bool turn, KGameIO *io, bool * send); 00166 00167 00168 private: 00169 KPlayer *mPlayer; 00170 }; 00171 00177 class KGameKeyIO : public KGameIO 00178 { 00179 Q_OBJECT 00180 00181 public: 00202 KGameKeyIO(QWidget *parent); 00203 virtual ~KGameKeyIO(); 00204 00210 virtual int rtti() const; 00211 00212 signals: 00234 void signalKeyEvent(KGameIO *io,QDataStream &stream,QKeyEvent *m,bool *eatevent); 00235 00236 protected: 00240 bool eventFilter( QObject *o, QEvent *e ); 00241 }; 00242 00248 class KGameMouseIO : public KGameIO 00249 { 00250 Q_OBJECT 00251 00252 public: 00268 KGameMouseIO(QWidget *parent,bool trackmouse=false); 00269 virtual ~KGameMouseIO(); 00270 00276 void setMouseTracking(bool b); 00282 virtual int rtti() const; 00283 00284 signals: 00304 void signalMouseEvent(KGameIO *io,QDataStream &stream,QMouseEvent *m,bool *eatevent); 00305 00306 protected: 00310 bool eventFilter( QObject *o, QEvent *e ); 00311 00312 }; 00313 00314 00323 class KGameProcessIO : public KGameIO 00324 { 00325 Q_OBJECT 00326 00327 public: 00343 KGameProcessIO(const QString& name); 00344 00348 virtual ~KGameProcessIO(); 00349 00355 int rtti() const; 00356 00367 void sendMessage(QDataStream &stream,int msgid, Q_UINT32 receiver, Q_UINT32 sender); 00368 00379 void sendSystemMessage(QDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender); 00380 00389 void initIO(KPlayer *p); 00390 00400 virtual void notifyTurn(bool turn); 00401 00402 protected: 00406 void sendAllMessages(QDataStream &stream,int msgid, Q_UINT32 receiver, Q_UINT32 sender, bool usermsg); 00407 00408 protected slots: 00412 void receivedMessage(const QByteArray& receiveBuffer); 00413 00414 00415 signals: 00439 void signalProcessQuery(QDataStream &stream,KGameProcessIO *me); 00440 00451 void signalIOAdded(KGameIO *game,QDataStream &stream,KPlayer *p,bool *send); 00452 00453 00454 protected: 00455 00456 private: 00457 class KGameProcessIOPrivate; 00458 KGameProcessIOPrivate* d; 00459 }; 00460 00477 class KGameComputerIO : public KGameIO 00478 { 00479 Q_OBJECT 00480 00481 public: 00486 KGameComputerIO(); 00487 KGameComputerIO(KPlayer* player); 00488 ~KGameComputerIO(); 00489 00490 int rtti() const; 00491 00496 void setReactionPeriod(int advanceCalls); 00497 int reactionPeriod() const; 00498 00502 void setAdvancePeriod(int ms); 00503 00504 void stopAdvancePeriod(); 00505 00518 void pause(int calls = -1); 00519 00524 void unpause(); 00525 00526 public slots: 00542 virtual void advance(); 00543 00544 signals: 00549 void signalReaction(); 00550 00551 protected: 00555 virtual void reaction(); 00556 00557 private: 00558 void init(); 00559 00560 private: 00561 class KGameComputerIOPrivate; 00562 KGameComputerIOPrivate* d; 00563 }; 00564 00565 00566 #endif
KDE Logo
This file is part of the documentation for libkdegames Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 12:48:54 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003