1/*
2 * Copyright 2007-2009 Parker Coates <coates@kde.org>
3 *
4 * This file is part of Killbots.
5 *
6 * Killbots is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Killbots is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Killbots. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef KILLBOTS_SCENE_H
21#define KILLBOTS_SCENE_H
22
23#include "actions.h"
24#include "sprite.h"
25
26#include <QtGui/QGraphicsScene>
27
28
29namespace Killbots
30{
31 class NumericDisplayItem;
32
33 class Scene : public QGraphicsScene
34 {
35 Q_OBJECT
36
37 public: // functions
38 explicit Scene( QObject * parent = 0 );
39 virtual ~Scene();
40
41 void addNumericDisplay( NumericDisplayItem * displayItem );
42 void setGridSize( int rows, int columns );
43 void forgetHero();
44
45 Sprite * createSprite( SpriteType type, QPoint position );
46 void animateSprites( const QList<Sprite *> & newSprites,
47 const QList<Sprite *> & slidingSprites,
48 const QList<Sprite *> & teleportingSprites,
49 const QList<Sprite *> & destroyedSprites,
50 qreal value
51 ) const;
52
53 public slots:
54 void doLayout();
55
56 signals:
57 void clicked( int action );
58
59 protected: // functions
60 virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * mouseEvent );
61 virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * mouseEvent );
62
63 private: // functions
64 HeroAction getMouseDirection( QPointF cursorPosition ) const;
65 bool popupAtPosition( QPointF position ) const;
66 void updateSpritePos( Sprite * sprite, QPoint gridPosition ) const;
67
68 private: // data members
69 Sprite * m_hero;
70
71 QList<NumericDisplayItem *> m_numericDisplays;
72
73 QSize m_cellSize;
74 int m_rows;
75 int m_columns;
76 };
77}
78
79#endif
80