Crossfire Server, Branch 1.12  R12190
CREPixmap.cpp
Go to the documentation of this file.
00001 #include <Qt>
00002 #include "CREPixmap.h"
00003 
00004 extern "C" {
00005 #include "global.h"
00006 #include "face.h"
00007 #include "image.h"
00008 }
00009 
00010 QHash<int, QIcon> CREPixmap::allFaces;
00011 QIcon* CREPixmap::myTreasureIcon;
00012 QIcon* CREPixmap::myTreasureOneIcon;
00013 QIcon* CREPixmap::myTreasureYesIcon;
00014 QIcon* CREPixmap::myTreasureNoIcon;
00015 int CREPixmap::faceset;
00016 
00017 void CREPixmap::init()
00018 {
00019     myTreasureIcon = new QIcon(":resources/treasure_list.png");
00020     myTreasureOneIcon = new QIcon(":resources/treasureone_list.png");
00021     myTreasureYesIcon = new QIcon(":resources/treasure_yes.png");
00022     myTreasureNoIcon = new QIcon(":resources/treasure_no.png");
00023 
00024     faceset = 0;
00025 }
00026 
00027 QIcon CREPixmap::getIcon(int faceNumber)
00028 {
00029     if (!allFaces.contains(faceNumber))
00030     {
00031         QPixmap face;
00032 
00033         if (facesets[faceset].faces[faceNumber].datalen > 0)
00034         {
00035             if (face.loadFromData((uchar*)facesets[faceset].faces[faceNumber].data, facesets[faceset].faces[faceNumber].datalen))
00036             {
00037                 QIcon icon(face.scaled(32, 32, Qt::KeepAspectRatio));
00038                 allFaces[faceNumber] = icon;
00039             }
00040         }
00041     }
00042     return allFaces[faceNumber];
00043 }
00044 
00045 QIcon CREPixmap::getTreasureIcon()
00046 {
00047     Q_ASSERT(myTreasureIcon);
00048     return *myTreasureIcon;
00049 }
00050 
00051 QIcon CREPixmap::getTreasureOneIcon()
00052 {
00053     Q_ASSERT(myTreasureOneIcon);
00054     return *myTreasureOneIcon;
00055 }
00056 
00057 QIcon CREPixmap::getTreasureYesIcon()
00058 {
00059     Q_ASSERT(myTreasureYesIcon);
00060     return *myTreasureYesIcon;
00061 }
00062 
00063 QIcon CREPixmap::getTreasureNoIcon()
00064 {
00065     Q_ASSERT(myTreasureNoIcon);
00066     return *myTreasureNoIcon;
00067 }