Crossfire Server, Trunk  R20513
CREMapPanel.cpp
Go to the documentation of this file.
1 #include "CREMapPanel.h"
2 #include "CREMapInformation.h"
3 #include "CREMainWindow.h"
4 #include "ScriptFileManager.h"
5 #include "ScriptFile.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  Q_ASSERT(manager != NULL);
33  myManager = manager;
34  QGridLayout* layout = new QGridLayout(this);
35 
36  layout->addWidget(new QLabel(tr("Name:"), this), 0, 0);
37  myName = new QLabel();
38  layout->addWidget(myName, 0, 1);
39 
40  myExitsFrom = new QTreeWidget(this);
41  myExitsFrom->setHeaderLabel(tr("Exits from this map"));
42  layout->addWidget(myExitsFrom, 1, 0, 1, 2);
43 
44  myExitsTo = new QTreeWidget(this);
45  myExitsTo->setHeaderLabel(tr("Exits leading to this map"));
46  layout->addWidget(myExitsTo, 2, 0, 1, 2);
47 
48  myScripts = new QTreeWidget(this);
49  myScripts->setHeaderLabel(tr("Scripts on this map"));
50  myScripts->setIconSize(QSize(32, 32));
51  layout->addWidget(myScripts, 3, 0, 1, 2);
52 
53  fillEvents();
54 }
55 
57 {
58 }
59 
61 {
62  myName->setText(map->name());
63 
64  myExitsFrom->clear();
65  foreach(QString path, map->accessedFrom())
66  myExitsFrom->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
67 
68  myExitsTo->clear();
69  foreach(QString path, map->exitsTo())
70  myExitsTo->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
71 
72  myScripts->clear();
73  foreach(ScriptFile* script, myManager->scriptsForMap(map))
74  {
75  foreach(HookInformation* hook, script->hooks())
76  {
77  if (hook->map() == map)
78  {
79  QTreeWidgetItem* child = new QTreeWidgetItem(QStringList(QString("%1 [%2, %3], %4, %5, %6").arg(hook->itemName()).arg(hook->x()).arg(hook->y()).arg(hook->eventName()).arg(hook->pluginName()).arg(script->path())));
80 
81  archt* arch = events[hook->eventName().toLower()];
82  if (arch != NULL && arch->clone.face != NULL)
83  {
84  child->setIcon(0, CREPixmap::getIcon(arch->clone.face->number));
85  }
86 
87  myScripts->addTopLevelItem(child);
88  }
89  }
90  }
91 }
QStringList exitsTo() const
int x() const
Definition: ScriptFile.cpp:75
Manage scripts for items.
Information about a script file.
Definition: ScriptFile.h:31
static QHash< QString, archetype * > events
Definition: CREMapPanel.cpp:12
QTreeWidget * myScripts
Definition: CREMapPanel.h:24
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
QLabel * myName
Definition: CREMapPanel.h:21
QString itemName() const
Definition: ScriptFile.cpp:85
CREMapPanel(ScriptFileManager *manager)
Definition: CREMapPanel.cpp:30
virtual void setItem(CREMapInformation *map)
Definition: CREMapPanel.cpp:60
virtual ~CREMapPanel()
Definition: CREMapPanel.cpp:56
static void fillEvents()
Definition: CREMapPanel.cpp:14
const QString & path() const
Definition: ScriptFile.cpp:36
int y() const
Definition: ScriptFile.cpp:80
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
QStringList accessedFrom() const
QString eventName() const
Definition: ScriptFile.cpp:95
QTreeWidget * myExitsTo
Definition: CREMapPanel.h:22
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
QTreeWidget * myExitsFrom
Definition: CREMapPanel.h:23
ScriptFileManager * myManager
Definition: CREMapPanel.h:20
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.