Crossfire Server, Trunk
CREUtils.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include <QtWidgets>
14 #include "CREUtils.h"
15 #include "CREPixmap.h"
16 #include "CREMapInformation.h"
17 #include "MessageFile.h"
18 #include "scripts/ScriptFile.h"
19 
20 #include "global.h"
21 #include "recipe.h"
22 #include "libproto.h"
23 
24 QTreeWidgetItem* CREUtils::archetypeNode(const archetype* arch, QTreeWidgetItem* parent)
25 {
26  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(arch->name));
27  item->setIcon(0, CREPixmap::getIcon(arch->clone.face ? arch->clone.face->number : 0));
28  return item;
29 }
30 
31 QTreeWidgetItem* CREUtils::objectNode(const object* op, QTreeWidgetItem* parent)
32 {
33  char name[500];
34  query_name(op, name, sizeof(name));
35  QString n;
36  if (op->nrof > 1)
37  n.append(QString::number(op->nrof)).append(" ");
38  n.append(name);
39  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(n));
40  item->setIcon(0, CREPixmap::getIcon(op->face->number));
41  return item;
42 }
43 
44 QTreeWidgetItem* CREUtils::faceNode(QTreeWidgetItem* parent)
45 {
46  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(QTreeWidget::tr("Faces")));
47  return item;
48 }
49 
50 QTreeWidgetItem* CREUtils::faceNode(const Face* face, QTreeWidgetItem* parent)
51 {
52  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(face->name));
53  item->setIcon(0, CREPixmap::getIcon(face->number));
54  return item;
55 }
Face::name
sstring name
Definition: face.h:19
Face
Definition: face.h:14
global.h
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
CREMapInformation.h
CREUtils::faceNode
static QTreeWidgetItem * faceNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:44
CREUtils.h
recipe.h
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
CREUtils::archetypeNode
static QTreeWidgetItem * archetypeNode(const archetype *arch, QTreeWidgetItem *parent)
Definition: CREUtils.cpp:24
ScriptFile.h
query_name
void query_name(const object *op, char *buf, size_t size)
Definition: item.cpp:585
Face::number
uint16_t number
Definition: face.h:15
archetype
Definition: object.h:472
MessageFile.h
item
Definition: item.py:1
CREUtils::objectNode
static QTreeWidgetItem * objectNode(const object *op, QTreeWidgetItem *parent)
Definition: CREUtils.cpp:31
give.op
op
Definition: give.py:33
say.item
dictionary item
Definition: say.py:149
CREPixmap.h
libproto.h
give.name
name
Definition: give.py:27