Crossfire Server, Trunk  R22047
CREPixmap.cpp
Go to the documentation of this file.
1 #include <Qt>
2 #include "CREPixmap.h"
3 
4 extern "C" {
5 #include "global.h"
6 #include "face.h"
7 #include "image.h"
8 }
9 
10 #include "assets.h"
11 #include "AssetsManager.h"
12 
13 QHash<int, QIcon> CREPixmap::allFaces;
19 
21 {
22  myTreasureIcon = new QIcon(":resources/treasure_list.png");
23  myTreasureOneIcon = new QIcon(":resources/treasureone_list.png");
24  myTreasureYesIcon = new QIcon(":resources/treasure_yes.png");
25  myTreasureNoIcon = new QIcon(":resources/treasure_no.png");
26 
27  faceset = getManager()->facesets()->get("base");
28 }
29 
30 QIcon CREPixmap::getIcon(int faceNumber)
31 {
32  if (!allFaces.contains(faceNumber))
33  {
34  QPixmap face;
35 
36  if (faceset->allocated >= faceNumber && faceset->faces[faceNumber].datalen > 0)
37  {
38  if (face.loadFromData((uchar*)faceset->faces[faceNumber].data, faceset->faces[faceNumber].datalen))
39  {
40  QIcon icon(face.scaled(32, 32, Qt::KeepAspectRatio));
41  allFaces[faceNumber] = icon;
42  }
43  }
44  }
45  return allFaces[faceNumber];
46 }
47 
49 {
50  Q_ASSERT(myTreasureIcon);
51  return *myTreasureIcon;
52 }
53 
55 {
56  Q_ASSERT(myTreasureOneIcon);
57  return *myTreasureOneIcon;
58 }
59 
61 {
62  Q_ASSERT(myTreasureYesIcon);
63  return *myTreasureYesIcon;
64 }
65 
67 {
68  Q_ASSERT(myTreasureNoIcon);
69  return *myTreasureNoIcon;
70 }
static QIcon * myTreasureOneIcon
Definition: CREPixmap.h:22
face_info * faces
Definition: image.h:26
T * get(const Key &name)
static QIcon getTreasureIcon()
Definition: CREPixmap.cpp:48
Facesets * facesets()
Definition: AssetsManager.h:64
static QIcon getTreasureYesIcon()
Definition: CREPixmap.cpp:60
static QIcon getTreasureNoIcon()
Definition: CREPixmap.cpp:66
AssetsManager * getManager()
Definition: assets.cpp:304
size_t allocated
Definition: image.h:25
static QIcon * myTreasureIcon
Definition: CREPixmap.h:21
uint8_t * data
Definition: image.h:11
static QIcon getIcon(int faceNumber)
Definition: CREPixmap.cpp:30
uint16_t datalen
Definition: image.h:12
static face_sets * faceset
Definition: CREPixmap.h:11
static QIcon * myTreasureYesIcon
Definition: CREPixmap.h:23
static QIcon * myTreasureNoIcon
Definition: CREPixmap.h:24
static void init()
Definition: CREPixmap.cpp:20
#define uchar
Definition: re-cmp.h:49
static QHash< int, QIcon > allFaces
Definition: CREPixmap.h:20
static QIcon getTreasureOneIcon()
Definition: CREPixmap.cpp:54