File indexing completed on 2024-11-10 06:45:40
0001 /* 0002 This file is part of Killbots. 0003 0004 SPDX-FileCopyrightText: 2007-2009 Parker Coates <coates@kde.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KILLBOTS_SCENE_H 0010 #define KILLBOTS_SCENE_H 0011 0012 #include "actions.h" 0013 #include "sprite.h" 0014 0015 #include <QGraphicsScene> 0016 0017 namespace Killbots 0018 { 0019 class NumericDisplayItem; 0020 0021 class Scene : public QGraphicsScene 0022 { 0023 Q_OBJECT 0024 0025 public: // functions 0026 explicit Scene(QObject *parent = nullptr); 0027 ~Scene() override; 0028 0029 void addNumericDisplay(NumericDisplayItem *displayItem); 0030 void setGridSize(int rows, int columns); 0031 void forgetHero(); 0032 0033 Sprite *createSprite(SpriteType type, QPoint position); 0034 void animateSprites(const QList<Sprite *> &newSprites, 0035 const QList<Sprite *> &slidingSprites, 0036 const QList<Sprite *> &teleportingSprites, 0037 const QList<Sprite *> &destroyedSprites, 0038 qreal value 0039 ) const; 0040 0041 public Q_SLOTS: 0042 void doLayout(); 0043 0044 Q_SIGNALS: 0045 void clicked(int action); 0046 0047 protected: // functions 0048 void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override; 0049 void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) override; 0050 0051 private: // functions 0052 HeroAction getMouseDirection(QPointF cursorPosition) const; 0053 bool popupAtPosition(QPointF position) const; 0054 void updateSpritePos(Sprite *sprite, QPoint gridPosition) const; 0055 0056 private: // data members 0057 Sprite *m_hero; 0058 0059 QList<NumericDisplayItem *> m_numericDisplays; 0060 0061 QSize m_cellSize; 0062 int m_rows; 0063 int m_columns; 0064 }; 0065 } 0066 0067 #endif