File indexing completed on 2024-10-06 03:45:28
0001 /* 0002 This file is part of the KDE games kwin4 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 // own 0012 #include "pixmapsprite.h" 0013 #include "thememanager.h" 0014 // Qt 0015 #include <QGraphicsPixmapItem> 0016 #include <QGraphicsTextItem> 0017 0018 /** 0019 * The sprite for a score board on the canvas. 0020 */ 0021 class ScoreSprite : public PixmapSprite 0022 { 0023 public: 0024 /** 0025 * Constructor for the score sprite. 0026 * @param id The theme id 0027 * @param theme The theme manager 0028 * @param no A used defined number (unused) 0029 * @param scene The graphics scene 0030 */ 0031 ScoreSprite(const QString &id, ThemeManager *theme, int no, QGraphicsScene *scene); 0032 0033 /** 0034 * Destructor 0035 */ 0036 ~ScoreSprite() override; 0037 0038 /** 0039 * Standard QGI advance function. 0040 * @param phase The advance phase 0041 */ 0042 void advance(int phase) override; 0043 0044 /** 0045 * Retrieve the type of QGI. This item is UserType+10 0046 * @return The type of item. 0047 */ 0048 int type() const override 0049 { 0050 return QGraphicsItem::UserType + 10; 0051 } 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 level of the AI. 0061 * @param level The level 0062 * @param no The player number [0,1] 0063 */ 0064 void setLevel(int level, int no); 0065 0066 /** 0067 * Store the player name. 0068 * @param s The name 0069 * @param no The player number [0,1] 0070 */ 0071 void setPlayerName(const QString &s, int no); 0072 0073 /** 0074 * Store the amounts of wins for a player. 0075 * @param s The amount of wins 0076 * @param no The player number [0,1] 0077 */ 0078 void setWon(const QString &s, int no); 0079 0080 /** 0081 * Store the amounts of draws for a player. 0082 * @param s The amount of draws 0083 * @param no The player number [0,1] 0084 */ 0085 void setDraw(const QString &s, int no); 0086 0087 /** 0088 * Store the amounts of losses for a player. 0089 * @param s The amount of losses 0090 * @param no The player number [0,1] 0091 */ 0092 void setLoss(const QString &s, int no); 0093 0094 /** 0095 * Store the amounts of aborted games for a player. 0096 * @param s The amount of aborted games 0097 * @param no The player number [0,1] 0098 */ 0099 void setBreak(const QString &s, int no); 0100 0101 /** 0102 * Define who's turn it is next 0103 * @param no The next player number [0,1] 0104 */ 0105 void setTurn(int no); 0106 0107 /** 0108 * Store input device for a player. 0109 * @param device The device number [0-3] 0110 * @param no The player number [0,1] 0111 */ 0112 void setInput(int device, int no); 0113 0114 private: 0115 // Text for won 0116 QGraphicsTextItem *mWon[2]; 0117 0118 // Text for draw 0119 QGraphicsTextItem *mDraw[2]; 0120 0121 // Text for loss 0122 QGraphicsTextItem *mLoss[2]; 0123 0124 // Text for aborted games 0125 QGraphicsTextItem *mBreak[2]; 0126 0127 // Text for name of player 0128 QGraphicsTextItem *mName[2]; 0129 0130 // Sprite for the input device 0131 PixmapSprite *mInput[2]; 0132 0133 // Frame number of the input device sprite 0134 int mInputFrame[2]; 0135 0136 // Whose' turn or -1 for nobody 0137 int mTurn; 0138 }; 0139 0140 #endif