File indexing completed on 2023-10-01 08:05:26
0001 /* 0002 This file is part of the KDE games lskat program 0003 SPDX-FileCopyrightText: 2006 Martin Heni <kde@heni-online.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef SCORE_SPRITE_H 0009 #define SCORE_SPRITE_H 0010 0011 // Qt includes 0012 #include <QGraphicsPixmapItem> 0013 #include <QGraphicsTextItem> 0014 0015 // Local includes 0016 #include "pixmapsprite.h" 0017 #include "player.h" 0018 #include "thememanager.h" 0019 0020 /** 0021 * The sprite for a score board on the canvas. 0022 */ 0023 class ScoreSprite : public PixmapSprite 0024 { 0025 public: 0026 /** 0027 * Constructor for the score sprite. 0028 * @param id The theme id 0029 * @param theme The theme manager 0030 * @param advancePeriod The canvas advance period [ms] 0031 * @param no A used defined number (unused) 0032 * @param scene The graphics scene 0033 */ 0034 ScoreSprite(const QString &id, ThemeManager *theme, int advancePeriod, int no, QGraphicsScene *scene); 0035 0036 /** 0037 * Destructor 0038 */ 0039 ~ScoreSprite() override; 0040 0041 /** 0042 * Standard QGI advance function. 0043 * @param phase The advance phase 0044 */ 0045 void advance(int phase) override; 0046 0047 /** 0048 * Retrieve the type of QGI. This item is UserType+10 0049 * @return The type of item. 0050 */ 0051 int type() const override {return QGraphicsItem::UserType + 10;} 0052 0053 /** 0054 * Main theme change function. On call of this the item needs to redraw and 0055 * resize. 0056 */ 0057 void changeTheme() override; 0058 0059 /** 0060 * Store the player name. 0061 * @param s The name 0062 */ 0063 void setPlayerName(const QString &s); 0064 0065 /** 0066 * Store the amounts of points for a player. 0067 * @param points The amount of current points. 0068 */ 0069 void setPoints(int points); 0070 0071 /** 0072 * Store the score for a player. 0073 * @param score The score 0074 */ 0075 void setScore(int score); 0076 0077 /** 0078 * Store the amounts of games. 0079 * @param won The amount of won games 0080 * @param all The amount of all games 0081 */ 0082 void setGames(int won, int all); 0083 0084 /** 0085 * Store input device for a player. 0086 * @param device The device number [0-2] 0087 */ 0088 void setInput(int device); 0089 0090 /** 0091 * Store trump icon for a player. 0092 * @param suite The trump suite 0093 */ 0094 void setTrump(int suite); 0095 0096 private: 0097 // Text for name of player 0098 QGraphicsTextItem *mName; 0099 0100 // Text for current points 0101 QGraphicsTextItem *mPoints; 0102 0103 // Text for score 0104 QGraphicsTextItem *mScore; 0105 0106 // Text for games 0107 QGraphicsTextItem *mGames; 0108 0109 // Sprite for the input device 0110 PixmapSprite *mInput; 0111 0112 // Frame number of the input device sprite 0113 int mInputFrame; 0114 0115 // Sprite for the input device 0116 PixmapSprite *mTrump; 0117 0118 // Frame number of the input device sprite 0119 int mTrumpFrame; 0120 }; 0121 0122 #endif