Crossfire Server, Branches 1.12  R18729
CREFacePanel.cpp
Go to the documentation of this file.
1 #include <Qt>
2 
3 extern "C" {
4 #include "global.h"
5 #include "face.h"
6 #include "image.h"
7 }
8 
9 #include "CREFacePanel.h"
10 #include "CREUtils.h"
11 
13 static const char *const colorname[] = {
14  "black", /* 0 */
15  "white", /* 1 */
16  "blue", /* 2 */
17  "red", /* 3 */
18  "orange", /* 4 */
19  "light_blue", /* 5 */
20  "dark_orange", /* 6 */
21  "green", /* 7 */
22  "light_green", /* 8 */
23  "grey", /* 9 */
24  "brown", /* 10 */
25  "yellow", /* 11 */
26  "khaki" /* 12 */
27 };
28 
29 
31 {
32  myFace = 0;
33 
34  QGridLayout* layout = new QGridLayout(this);
35 
36  myUsing = new QTreeWidget(this);
37  myUsing->setColumnCount(1);
38  myUsing->setHeaderLabel(tr("Used by"));
39  myUsing->setIconSize(QSize(32, 32));
40  layout->addWidget(myUsing, 1, 1, 3, 2);
41 
42  myColor = new QComboBox(this);
43  layout->addWidget(myColor, 4, 2);
44  layout->addWidget(new QLabel("Magicmap color: "), 4, 1);
45 
46  for(uint color = 0; color < sizeof(colorname) / sizeof(*colorname); color++)
47  myColor->addItem(colorname[color], color);
48 
49  myFile = new QLineEdit(this);
50  myFile->setReadOnly(true);
51  layout->addWidget(myFile, 5, 2);
52  layout->addWidget(new QLabel("Original file: "), 5, 1);
53 
54  mySave = new QPushButton(tr("Save face"));
55  layout->addWidget(mySave, 6, 1);
56 
57  connect(mySave, SIGNAL(clicked(bool)), this, SLOT(saveClicked(bool)));
58 }
59 
61 {
62  Q_ASSERT(face);
63  myFace = face;
64 
65  myUsing->clear();
66 
67  QTreeWidgetItem* root = NULL;
68 
69  const archt* arch;
70 
71  for (arch = first_archetype; arch; arch = arch->more ? arch->more : arch->next)
72  {
73  if (arch->clone.face == myFace)
74  {
75  if (root == NULL)
76  {
77  root = CREUtils::archetypeNode(NULL);
78  myUsing->addTopLevelItem(root);
79  root->setExpanded(true);
80  }
81  CREUtils::archetypeNode(arch, root);
82  }
83  }
84 
85  root = NULL;
86 
87  const Animations* anim;
88 
89  // "bug" animation is zero, don't forget that shift
90  for (int a = 0; a <= num_animations; a++)
91  {
92  anim = &animations[a];
93  for (int face = 0; face < anim->num_animations; face++)
94  {
95  if (anim->faces[face] == myFace->number)
96  {
97  if (root == NULL)
98  {
99  root = CREUtils::animationNode(NULL);
100  myUsing->addTopLevelItem(root);
101  root->setExpanded(true);
102  }
103  CREUtils::animationNode(anim, root);
104  break;
105  }
106  }
107  }
108 
109  root = NULL;
110 
111  const artifactlist* list;
112  const typedata* data;
113  const artifact* arti;
114 
115  for (list = first_artifactlist; list; list = list->next)
116  {
117  data = get_typedata(list->type);
118 
119 // item = new QTreeWidgetItem(root, QStringList(data ? data->name : tr("type %1").arg(type)));
120 
121  for (arti = list->items; arti; arti = arti->next)
122  {
123  if (arti->item->face == myFace)
124  {
125  if (!root)
126  {
127  root = CREUtils::artifactNode(NULL);
128  myUsing->addTopLevelItem(root);
129  root->setExpanded(true);
130  }
131 
132  CREUtils::artifactNode(arti, root);
133  }
134  }
135  }
136 
137  myColor->setCurrentIndex(myFace->magicmap);
138 }
140 {
141 }
QTreeWidget * myUsing
Definition: CREFacePanel.h:22
static QTreeWidgetItem * animationNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:142
static QTreeWidgetItem * archetypeNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:11
static QTreeWidgetItem * artifactNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:25
EXTERN int num_animations
Definition: global.h:242
struct artifactstruct * items
Definition: artifact.h:52
object clone
Definition: object.h:326
void saveClicked(bool)
Fontindex * faces
Definition: face.h:59
Definition: object.h:321
const typedata * get_typedata(int itemtype)
Definition: item.c:352
uint16 number
Definition: face.h:43
struct artifactliststruct * next
Definition: artifact.h:51
static const char *const colorname[]
static char root[500]
Definition: mapper.c:361
void setFace(const New_Face *face)
struct archt * more
Definition: object.h:325
const New_Face * myFace
Definition: CREFacePanel.h:20
EXTERN Animations * animations
Definition: global.h:241
uint8 num_animations
Definition: face.h:56
EXTERN artifactlist * first_artifactlist
Definition: global.h:194
QComboBox * myColor
Definition: CREFacePanel.h:23
QLineEdit * myFile
Definition: CREFacePanel.h:24
struct archt * next
Definition: object.h:323
object * item
Definition: artifact.h:38
New_Face * face
Definition: object.h:183
QPushButton * mySave
Definition: CREFacePanel.h:25
uint8 magicmap
Definition: face.h:46
EXTERN archetype * first_archetype
Definition: global.h:195
struct artifactstruct * next
Definition: artifact.h:41