displaygame.h

Go to the documentation of this file.
00001 #ifndef DISPLAY_GAME_H
00002 #define DISPLAY_GAME_H
00003 /*
00004    This file is part of the KDE games kwin4 program
00005    Copyright (c) 2006 Martin Heni <kde@heni-online.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 // Qt includes
00024 #include <QWidget>
00025 #include <QGraphicsScene>
00026 #include <QGraphicsView>
00027 #include <QHash>
00028 #include <QList>
00029 #include <QTimer>
00030 
00031 // Local includes
00032 #include "thememanager.h"
00033 
00034 // Forward declaration
00035 class ThemeManager;
00036 class PieceSprite;
00037 class SpriteNotify;
00038 class PixmapSprite;
00039 class ScoreSprite;
00040 
00044 class DisplayGame : public QObject, public virtual Themable
00045 {
00046   Q_OBJECT
00047 
00048   public:
00055     DisplayGame(int advancePeriod, QGraphicsScene* scene, ThemeManager* theme,  QGraphicsView* parent = 0);
00056     
00059     ~DisplayGame();
00060 
00063     void start();
00064 
00068     virtual void changeTheme();
00069 
00079     SpriteNotify* displayPiece(int x,int y,int color,int no,bool animation);
00080     
00085     void displayArrow(int x, int color);
00086     
00093     void displayHint(int x, int y, bool show);
00094     
00101     void displayStar(int x,int y,int no);
00102     
00108     int mapMouseToMove(QPoint pos);
00109     
00112     void displayEnd();
00113 
00117     ScoreSprite* score();
00118 
00119    protected slots:  
00122     void advance();
00123 
00124   
00125   private:
00126     // The theme manager
00127     ThemeManager* mTheme;
00128     
00129     // The grapics scene used for display
00130     QGraphicsScene* mScene;
00131     
00132     // The graphics view used for display
00133     QGraphicsView* mView;
00134     
00135     // The advance period of the scene [ms]
00136     int mAdvancePeriod;
00137     
00138     // List of all sprites used
00139     QList<QGraphicsItem*> mSprites;
00140     
00141     // List of all game pieces used #=42
00142     QList<PieceSprite*> mPieces;
00143 
00144     // The game boad sprite
00145     PixmapSprite* mBoard;
00146     
00147     // All board hole sprites
00148     QList<PixmapSprite*> mBoardHoles;
00149     
00150     // All arrow sprites
00151     QList<PixmapSprite*> mArrows;
00152     
00153     // The score sprite
00154     ScoreSprite*  mScoreBoard;
00155     
00156     // The winning indicator sprites
00157     QList<PixmapSprite*> mStars;
00158     
00159     // The hint sprite
00160     PixmapSprite* mHint;
00161     
00162     // The game over sprite
00163     PixmapSprite* mGameOver;
00164     
00165     // The time used for advance()
00166     QTimer* mTimer;
00167 };
00168 
00169 #endif

Generated on Sun Mar 4 10:56:43 2007 for KWin4 by  doxygen 1.4.6