Crossfire Server, Trunk  R20513
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 QHash<int, QIcon> CREPixmap::allFaces;
16 
18 {
19  myTreasureIcon = new QIcon(":resources/treasure_list.png");
20  myTreasureOneIcon = new QIcon(":resources/treasureone_list.png");
21  myTreasureYesIcon = new QIcon(":resources/treasure_yes.png");
22  myTreasureNoIcon = new QIcon(":resources/treasure_no.png");
23 
24  faceset = 0;
25 }
26 
27 QIcon CREPixmap::getIcon(int faceNumber)
28 {
29  if (!allFaces.contains(faceNumber))
30  {
31  QPixmap face;
32 
33  if (facesets[faceset].faces[faceNumber].datalen > 0)
34  {
35  if (face.loadFromData((uchar*)facesets[faceset].faces[faceNumber].data, facesets[faceset].faces[faceNumber].datalen))
36  {
37  QIcon icon(face.scaled(32, 32, Qt::KeepAspectRatio));
38  allFaces[faceNumber] = icon;
39  }
40  }
41  }
42  return allFaces[faceNumber];
43 }
44 
46 {
47  Q_ASSERT(myTreasureIcon);
48  return *myTreasureIcon;
49 }
50 
52 {
53  Q_ASSERT(myTreasureOneIcon);
54  return *myTreasureOneIcon;
55 }
56 
58 {
59  Q_ASSERT(myTreasureYesIcon);
60  return *myTreasureYesIcon;
61 }
62 
64 {
65  Q_ASSERT(myTreasureNoIcon);
66  return *myTreasureNoIcon;
67 }
static QIcon * myTreasureOneIcon
Definition: CREPixmap.h:22
face_info * faces
images in this faceset
Definition: image.h:24
static QIcon getTreasureIcon()
Definition: CREPixmap.cpp:45
static int faceset
Definition: CREPixmap.h:11
static QIcon getTreasureYesIcon()
Definition: CREPixmap.cpp:57
Global type definitions and header inclusions.
static QIcon getTreasureNoIcon()
Definition: CREPixmap.cpp:63
Image-related structures.
static QIcon * myTreasureIcon
Definition: CREPixmap.h:21
uint8_t * data
Image data.
Definition: image.h:11
Face-related structures.
face_sets facesets[MAX_FACE_SETS]
All facesets.
Definition: image.c:47
static QIcon getIcon(int faceNumber)
Definition: CREPixmap.cpp:27
uint16_t datalen
Length of data.
Definition: image.h:12
static QIcon * myTreasureYesIcon
Definition: CREPixmap.h:23
static QIcon * myTreasureNoIcon
Definition: CREPixmap.h:24
static void init()
Definition: CREPixmap.cpp:17
#define uchar
Definition: re-cmp.h:49
static QHash< int, QIcon > allFaces
Definition: CREPixmap.h:20
static QIcon getTreasureOneIcon()
Definition: CREPixmap.cpp:51