Crossfire Server, Trunk  R20513
CREArchetypePanel.cpp
Go to the documentation of this file.
1 #include <Qt>
2 #include "CREMapInformation.h"
4 
5 extern "C" {
6 #include "global.h"
7 }
8 
9 #include "CREArchetypePanel.h"
10 #include "CREUtils.h"
11 
13 {
14  Q_ASSERT(store);
15  myStore = store;
16 
17  QGridLayout* layout = new QGridLayout(this);
18 
19  myDisplay = new QTextEdit(this);
20  layout->addWidget(myDisplay, 1, 1);
21 
22  myUsing = new QTreeWidget(this);
23  myUsing->setHeaderLabel(tr("Used by"));
24  myUsing->setIconSize(QSize(32, 32));
25  myUsing->setSortingEnabled(true);
26  myUsing->sortByColumn(0, Qt::AscendingOrder);
27  layout->addWidget(myUsing, 2, 1);
28 }
29 
31 {
34  object_dump(&myArchetype->clone, dump);
35  char* final = stringbuffer_finish(dump);
36  myDisplay->setText(final);
37  free(final);
38 
39  myUsing->clear();
40  QTreeWidgetItem* root = NULL;
41 
42  const archt* arch;
43 
44  for (arch = first_archetype; arch; arch = (arch->more ? arch->more : arch->next))
45  {
46  if (arch->clone.other_arch == myArchetype)
47  {
48  if (root == NULL)
49  {
50  root = CREUtils::archetypeNode(NULL);
51  myUsing->addTopLevelItem(root);
52  root->setExpanded(true);
53  }
54  CREUtils::archetypeNode(arch, root);
55  }
56  }
57 
58  root = NULL;
59 
60  const treasurelist* list;
61  const treasure* t;
62 
63  for (list = first_treasurelist; list; list = list->next)
64  {
65  for (t = list->items; t; t = t->next)
66  {
67  if (t->item == myArchetype)
68  {
69  if (root == NULL)
70  {
71  root = CREUtils::treasureNode(NULL);
72  myUsing->addTopLevelItem(root);
73  root->setExpanded(true);
74  }
75  CREUtils::treasureNode(list, root);
76  }
77  }
78  }
79 
80  QList<CREMapInformation*> mapuse = myStore->getArchetypeUse(myArchetype);
81  if (mapuse.size() > 0)
82  {
83  root = new QTreeWidgetItem(myUsing, QStringList(QTreeWidget::tr("Maps [%1]").arg(mapuse.size())));
84  root->setExpanded(true);
85 
86  foreach(CREMapInformation* information, mapuse)
87  {
88  CREUtils::mapNode(information, root);
89  }
90  }
91 }
CREMapInformationManager * myStore
treasureliststruct represents one logical group of items to be generated together.
Definition: treasure.h:82
static QTreeWidgetItem * archetypeNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:15
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Definition: stringbuffer.c:57
object clone
An object from which to do object_copy()
Definition: object.h:470
struct treasureliststruct * next
Next treasure-item in linked list.
Definition: treasure.h:89
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
Global type definitions and header inclusions.
struct archt * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:413
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
struct archt * item
Which item this link can be.
Definition: treasure.h:64
QTreeWidget * myUsing
void object_dump(const object *op, StringBuffer *sb)
Dumps an object.
Definition: object.c:394
QList< CREMapInformation * > getArchetypeUse(const archetype *arch)
static char root[500]
Path to store generated files.
Definition: mapper.c:365
struct archt * more
Next part of a linked object.
Definition: object.h:469
EXTERN treasurelist * first_treasurelist
First treasure.
Definition: global.h:120
virtual void setItem(const archt *archetype)
struct treasurestruct * items
Items in this list, linked.
Definition: treasure.h:90
const archt * myArchetype
CREArchetypePanel(CREMapInformationManager *store)
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
static QTreeWidgetItem * treasureNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:83
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.c:25
struct treasurestruct * next
Next treasure-item in a linked list.
Definition: treasure.h:66
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.c:76
struct archt archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
static QTreeWidgetItem * mapNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:202
Definition: main.c:88