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 INFOSIDEBAR_H
0008 #define INFOSIDEBAR_H
0009 
0010 #include "granatierglobals.h"
0011 
0012 #include <QObject>
0013 #include <QMap>
0014 
0015 class QGraphicsTextItem;
0016 class QGraphicsRectItem;
0017 class Game;
0018 class GameScene;
0019 class Player;
0020 class QRectF;
0021 class KGameRenderedItem;
0022 
0023 struct PlayerInfo
0024 {
0025     QGraphicsTextItem* name;
0026     KGameRenderedItem* icon;
0027     KGameRenderedItem* bonusShield;
0028     QGraphicsRectItem* bonusShieldDimm;
0029     KGameRenderedItem* bonusThrow;
0030     QGraphicsRectItem* bonusThrowDimm;
0031     KGameRenderedItem* bonusKick;
0032     QGraphicsRectItem* bonusKickDimm;
0033     KGameRenderedItem* badBonus;
0034     QGraphicsRectItem* badBonusDimm;
0035 };
0036 
0037 /**
0038  * @brief This class represents the game sidebar with game information about the player.
0039  */
0040 class InfoSidebar : public QObject
0041 {
0042 
0043     Q_OBJECT
0044 
0045 private:
0046     GameScene* m_gameScene;
0047     Game* m_game;
0048 
0049     QMap<Player*, PlayerInfo*> m_mapPlayerInfo;
0050 
0051     QGraphicsRectItem* m_background;
0052 
0053     qreal m_svgScaleFactor;
0054 
0055     QString m_badBonusSpriteKey;
0056 
0057 public:
0058 
0059     /**
0060       * Creates a new InfoSidebar instance.
0061       * @param p_game the game instance
0062       * @param p_scene the gamescene instance
0063       */
0064     explicit InfoSidebar (Game* p_game, GameScene* p_scene);
0065 
0066     /**
0067       * Deletes the InfoSidebar instance.
0068       */
0069     ~InfoSidebar() override;
0070 
0071     /**
0072       * Resets the player states
0073       */
0074     void reset();
0075 
0076     /**
0077       * Returns the background rect of the infoSidebar
0078       */
0079     QRectF rect();
0080 
0081     /**
0082       * Handles theme changes
0083       */
0084     void themeChanged();
0085 
0086 private Q_SLOTS:
0087     /**
0088       * sets the bonus info
0089       * @param player the player which info changed
0090       * @param bonusType the bonus that was taken
0091       * @param percentageElapsed the bad bonus time that has elapsed
0092       */
0093     void bonusInfoChanged(Player* player, Granatier::Bonus::Type bonusType, int percentageElapsed);
0094 
0095 public Q_SLOTS:
0096     /**
0097      * Updates the graphics after a resize
0098      * @param svgScaleFactor the scaling factor between svg and rendered pixmap
0099      */
0100     virtual void updateGraphics(qreal svgScaleFactor);
0101 };
0102 
0103 #endif
0104