File indexing completed on 2024-02-18 04:03:26

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef INFOOVERLAY_H
0008 #define INFOOVERLAY_H
0009 
0010 #include <QObject>
0011 #include <QMap>
0012 #include <QList>
0013 
0014 class QGraphicsTextItem;
0015 class QGraphicsRectItem;
0016 class Game;
0017 class GameScene;
0018 class Player;
0019 class KGameRenderedItem;
0020 
0021 /**
0022  * @brief This class the game info if paused or a round is over.
0023  */
0024 class InfoOverlay : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 private:
0029     GameScene* m_gameScene;
0030     Game* m_game;
0031 
0032     QMap <Player*, QList<KGameRenderedItem*> > m_mapScore;
0033     QMap <Player*, QGraphicsTextItem*> m_mapPlayerNames;
0034     QGraphicsTextItem* m_continueLabel;
0035     QGraphicsTextItem* m_newGameLabel;
0036     QGraphicsTextItem* m_gameOverLabel;
0037 
0038     QGraphicsTextItem* m_getReadyLabel;
0039     QGraphicsTextItem* m_startGameLabel;
0040 
0041     QGraphicsTextItem* m_pauseLabel;
0042     QGraphicsTextItem* m_continueAfterPauseLabel;
0043 
0044     QGraphicsRectItem* m_dimmOverlay;
0045 
0046     qreal m_svgScaleFactor;
0047 
0048 public:
0049 
0050     /**
0051       * Creates a new InfoOverlay instance.
0052       * @param p_game the game instance
0053       * @param p_scene the gamescene instance
0054       */
0055     InfoOverlay (Game* p_game, GameScene* p_scene);
0056 
0057     /**
0058       * Deletes the InfoOverlay instance.
0059       */
0060     ~InfoOverlay() override;
0061 
0062     /**
0063       * Shows the get ready info.
0064       */
0065     void showGetReady();
0066 
0067     /**
0068       * Shows the pause info.
0069       */
0070     void showPause();
0071 
0072     /**
0073       * Shows the score info.
0074       */
0075     void showScore();
0076 
0077     /**
0078       * Hides the info items.
0079       */
0080     void hideItems();
0081 
0082     /**
0083       * Resize dimm overlay.
0084       * @param x the new left position
0085       * @param y the new top position
0086       * @param width the new width
0087       * @param height the new height
0088       */
0089     void resizeDimmOverlay(qreal x, qreal y, qreal width, qreal height);
0090 
0091     /**
0092      * Handles theme changes
0093      */
0094     void themeChanged();
0095 
0096 public Q_SLOTS:
0097     /**
0098      * Updates the graphics after a resize
0099      * @param svgScaleFactor the scaling factor between svg and rendered pixmap
0100      */
0101     virtual void updateGraphics(qreal svgScaleFactor);
0102 };
0103 
0104 #endif
0105