• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames/libkdegamesprivate/kgame

  • sources
  • kde-4.14
  • kdegames
  • libkdegames
  • libkdegamesprivate
  • kgame
kgameio.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Martin Heni (kde at heni-online.de)
4  Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KGAMEIO_H__
22 #define __KGAMEIO_H__
23 
24 #include <QtCore/QString>
25 #include <QtCore/QObject>
26 
27 #include "../libkdegamesprivate_export.h"
28 
29 class QEvent;
30 class QGraphicsScene;
31 class QKeyEvent;
32 class QMouseEvent;
33 class KPlayer;
34 class KGame;
35 class KGameIOPrivate;
36 class KGameKeyIOPrivate;
37 class KGameMouseIOPrivate;
38 class KGameProcessIOPrivate;
39 class KGameComputerIOPrivate;
40 
65 class KDEGAMESPRIVATE_EXPORT KGameIO : public QObject
66 {
67  Q_OBJECT
68 
69 public:
73  KGameIO();
74  KGameIO(KPlayer*);
75  virtual ~KGameIO();
76 
80  void Debug();
81 
85  enum IOMode {GenericIO=1,KeyIO=2,MouseIO=4,ProcessIO=8,ComputerIO=16};
92  virtual int rtti() const = 0; // Computer, network, local, ...
93 
99  KPlayer *player() const;
100 
105  KGame* game() const;
106 
114  void setPlayer(KPlayer *p);
115 
125  virtual void initIO(KPlayer *p);
126 
136  virtual void notifyTurn(bool b);
137 
141  bool sendInput(QDataStream& stream, bool transmit = true, quint32 sender = 0);
142 
143 Q_SIGNALS:
175  void signalPrepareTurn(QDataStream & stream, bool turn, KGameIO *io, bool * send);
176 
177 
178 private:
179  friend class KGameIOPrivate;
180  KGameIOPrivate *const d;
181 
182  Q_DISABLE_COPY(KGameIO)
183 };
184 
192 class KDEGAMESPRIVATE_EXPORT KGameKeyIO : public KGameIO
193 {
194  Q_OBJECT
195 
196 public:
217  KGameKeyIO(QWidget *parent);
218  virtual ~KGameKeyIO();
219 
225  virtual int rtti() const;
226 
227 Q_SIGNALS:
249  void signalKeyEvent(KGameIO *io,QDataStream &stream,QKeyEvent *m,bool *eatevent);
250 
251 protected:
255  bool eventFilter( QObject *o, QEvent *e );
256 
257 private:
258  friend class KGameKeyIOPrivate;
259  KGameKeyIOPrivate *const d;
260 
261  Q_DISABLE_COPY(KGameKeyIO)
262 };
263 
271 class KDEGAMESPRIVATE_EXPORT KGameMouseIO : public KGameIO
272 {
273  Q_OBJECT
274 
275 public:
291  explicit KGameMouseIO(QWidget *parent,bool trackmouse=false);
292  explicit KGameMouseIO(QGraphicsScene *parent,bool trackmouse=false);
293  virtual ~KGameMouseIO();
294 
300  void setMouseTracking(bool b);
306  virtual int rtti() const;
307 
308 Q_SIGNALS:
328  void signalMouseEvent(KGameIO *io,QDataStream &stream,QMouseEvent *m,bool *eatevent);
329 
330 protected:
334  bool eventFilter( QObject *o, QEvent *e );
335 
336 private:
337  friend class KGameMouseIOPrivate;
338  KGameMouseIOPrivate *const d;
339 
340  Q_DISABLE_COPY(KGameMouseIO)
341 };
342 
343 
353 class KDEGAMESPRIVATE_EXPORT KGameProcessIO : public KGameIO
354 {
355  Q_OBJECT
356 
357 public:
373  KGameProcessIO(const QString& name);
374 
378  virtual ~KGameProcessIO();
379 
385  int rtti() const;
386 
397  void sendMessage(QDataStream &stream,int msgid, quint32 receiver, quint32 sender);
398 
409  void sendSystemMessage(QDataStream &stream, int msgid, quint32 receiver, quint32 sender);
410 
419  void initIO(KPlayer *p);
420 
430  virtual void notifyTurn(bool turn);
431 
432  protected:
436  void sendAllMessages(QDataStream &stream,int msgid, quint32 receiver, quint32 sender, bool usermsg);
437 
438  protected Q_SLOTS:
442  void receivedMessage(const QByteArray& receiveBuffer);
443 
444 
445 Q_SIGNALS:
469  void signalProcessQuery(QDataStream &stream,KGameProcessIO *me);
470 
481  void signalIOAdded(KGameIO *game,QDataStream &stream,KPlayer *p,bool *send);
482 
486  void signalReceivedStderr(QString msg);
487 
488 private:
489  friend class KGameProcessIOPrivate;
490  KGameProcessIOPrivate *const d;
491 
492  Q_DISABLE_COPY(KGameProcessIO)
493 };
494 
513 class KDEGAMESPRIVATE_EXPORT KGameComputerIO : public KGameIO
514 {
515  Q_OBJECT
516 
517 public:
522  KGameComputerIO();
523  KGameComputerIO(KPlayer* player);
524  ~KGameComputerIO();
525 
526  int rtti() const;
527 
532  void setReactionPeriod(int advanceCalls);
533  int reactionPeriod() const;
534 
538  void setAdvancePeriod(int ms);
539 
540  void stopAdvancePeriod();
541 
554  void pause(int calls = -1);
555 
560  void unpause();
561 
562 public Q_SLOTS:
578  virtual void advance();
579 
580 Q_SIGNALS:
585  void signalReaction();
586 
587 protected:
591  virtual void reaction();
592 
593 private:
594  friend class KGameComputerIOPrivate;
595  KGameComputerIOPrivate *const d;
596 
597  Q_DISABLE_COPY(KGameComputerIO)
598 };
599 
600 
601 #endif
KGameIO::rtti
virtual int rtti() const =0
Run time idendification.
QEvent
QWidget
QGraphicsScene
KGameIO::notifyTurn
virtual void notifyTurn(bool b)
Notifies the IO device that the player's setTurn had been called Called by KPlayer.
Definition: kgameio.cpp:96
QByteArray
QDataStream
QMouseEvent
KGameProcessIO
The KGameProcessIO class.
Definition: kgameio.h:353
KGameMouseIO
The KGameMouseIO class.
Definition: kgameio.h:271
KGameIO::IOMode
IOMode
Identifies the KGameIO via the rtti function.
Definition: kgameio.h:85
QObject
QObject::eventFilter
virtual bool eventFilter(QObject *watched, QEvent *event)
QString
KGameIO::initIO
virtual void initIO(KPlayer *p)
Init this device by setting the player and e.g.
Definition: kgameio.cpp:91
KPlayer
Base class for a game player.
Definition: kplayer.h:69
QKeyEvent
KGame
The main KDE game object.
Definition: kgame.h:60
KGameComputerIO
KGameIO variant for real-time games.
Definition: kgameio.h:513
KGameKeyIO
The KGameKeyIO class.
Definition: kgameio.h:192
KGameIO
Base class for IO devices for games.
Definition: kgameio.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames/libkdegamesprivate/kgame

Skip menu "libkdegames/libkdegamesprivate/kgame"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal