Crossfire Server, Trunk  R20513
CREScriptPanel.cpp
Go to the documentation of this file.
1 #include <QtGui>
2 #include "CREScriptPanel.h"
3 #include "ScriptFile.h"
4 #include "ScriptFile.h"
5 #include "CREMapInformation.h"
6 #include "CREPixmap.h"
7 
8 extern "C" {
9 #include "define.h"
10 }
11 
12 static QHash<QString, archetype*> events;
13 
14 void static fillEvents()
15 {
16  if (!events.isEmpty())
17  {
18  return;
19  }
20 
21  for (archt* arch = first_archetype; arch != NULL; arch = arch->next)
22  {
23  if (arch->clone.type == EVENT_CONNECTOR)
24  {
25  events.insert(arch->name, arch);
26  }
27  }
28 }
29 
31 {
32  QGridLayout* layout = new QGridLayout(this);
33  myMaps = new QTreeWidget(this);
34  layout->addWidget(myMaps, 1, 1, 1, 1);
35  myMaps->setHeaderLabel("Maps using this script");
36  myMaps->setIconSize(QSize(32, 32));
37  myMaps->setRootIsDecorated(true);
38 
39  fillEvents();
40 }
41 
43 {
44  myMaps->clear();
45 
46  QHash<QString, QTreeWidgetItem*> maps;
47 
48  foreach(const HookInformation* hook, script->hooks())
49  {
50  if (!maps.contains(hook->map()->path()))
51  {
52  QTreeWidgetItem* r = new QTreeWidgetItem(myMaps, QStringList(hook->map()->path()));
53  maps[hook->map()->path()] = r;
54  myMaps->addTopLevelItem(r);
55  r->setExpanded(true);
56  }
57 
58  QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("%1 (%2, %3), %4, %5").arg(hook->itemName()).arg(hook->x()).arg(hook->y()).arg(hook->eventName()).arg(hook->pluginName())));
59 
60  archt* arch = events[hook->eventName().toLower()];
61  if (arch != NULL && arch->clone.face != NULL)
62  {
63  child->setIcon(0, CREPixmap::getIcon(arch->clone.face->number));
64  }
65 
66  maps[hook->map()->path()]->addChild(child);
67  }
68 }
69 
QTreeWidget * myMaps
virtual void setItem(ScriptFile *script)
int x() const
Definition: ScriptFile.cpp:75
Information about a script file.
Definition: ScriptFile.h:31
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
QString itemName() const
Definition: ScriptFile.cpp:85
static QHash< QString, archetype * > events
static void fillEvents()
int y() const
Definition: ScriptFile.cpp:80
QString eventName() const
Definition: ScriptFile.cpp:95
static QIcon getIcon(int faceNumber)
Definition: CREPixmap.cpp:27
QString pluginName() const
Definition: ScriptFile.cpp:90
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
Lauwenmark: an invisible object holding a plugin event hook.
Definition: object.h:227
const CREMapInformation * map() const
Definition: ScriptFile.cpp:70
Information about an event hook, linked to a script file.
Definition: ScriptFile.h:9
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:31
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
Definition: main.c:88
Core defines: object types, flags, etc.