playersdiagram.h
1 //------------------------------------------------------------------------------
2 // playerdiagram.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #ifndef __PLAYERS_DIAGRAM_H_
24 #define __PLAYERS_DIAGRAM_H_
25 
26 #include "serverapi/serverptr.h"
27 #include "serverapi/player.h"
28 #include <QPixmap>
29 
30 class Server;
31 class QImage;
32 
33 #define NUM_SLOTSTYLES 2
34 
36 {
37  public:
43  static void loadImages(int style);
44 
45  PlayersDiagram(ServerCPtr server);
46 
47  ~PlayersDiagram();
48 
49  QPixmap pixmap() const { return diagram; }
50 
51  protected:
52  enum PlayerType
53  {
54  Bot,
55  Human
56  };
57 
58  static void deleteImages();
59  static bool isStyleNumberValid(int style);
60 
61  static const char* slotStyles[NUM_SLOTSTYLES];
62  static const QImage *openImage, *openSpecImage, *botImage, *playerImage, *spectatorImage;
63 
72  const QImage* colorizePlayer(const QImage *image, const QColor &color);
73 
74  void draw();
75  void drawTeam(PlayerType playerType, int team, int howMany);
76  void drawPictures(const QImage* image, int howMany);
77 
78  void obtainPlayerNumbers();
79 
80  int numBotsOnTeam[MAX_TEAMS];
81  int numBotsWithoutTeam;
82  int numFreeJoinSlots;
83  int numFreeSpectatorSlots;
84  int numHumansWithoutTeam;
85  int numHumansOnTeam[MAX_TEAMS];
86  int numSpectators;
87 
88  private:
89  ServerCPtr server;
90  QPixmap diagram;
91  QPainter* painter;
92  int position;
93  int slotSize;
94  QImage *tmp;
95 };
96 
97 #endif
static void loadImages(int style)
A representation of a server for a given game.
Definition: server.h:93
const QImage * colorizePlayer(const QImage *image, const QColor &color)