Crossfire Server, Trunk  R21246
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 
30 CREMapPanel::CREMapPanel(ScriptFileManager* manager, QWidget* parent) : CRETPanel(parent)
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  layout->addWidget(new QLabel(tr("Background music:"), this), 4, 0);
54  myBackgroundMusic = new QLabel();
55  layout->addWidget(myBackgroundMusic, 4, 1);
56 
57  fillEvents();
58 }
59 
61 {
62 }
63 
65 {
66  myName->setText(map->name());
67 
68  myExitsFrom->clear();
69  foreach(QString path, map->accessedFrom())
70  myExitsFrom->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
71 
72  myExitsTo->clear();
73  foreach(QString path, map->exitsTo())
74  myExitsTo->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
75 
76  myScripts->clear();
77  foreach(ScriptFile* script, myManager->scriptsForMap(map))
78  {
79  foreach(HookInformation* hook, script->hooks())
80  {
81  if (hook->map() == map)
82  {
83  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())));
84 
85  archt* arch = events[hook->eventName().toLower()];
86  if (arch != NULL && arch->clone.face != NULL)
87  {
88  child->setIcon(0, CREPixmap::getIcon(arch->clone.face->number));
89  }
90 
91  myScripts->addTopLevelItem(child);
92  }
93  }
94  }
95 
96  myBackgroundMusic->setText(map->backgroundMusic());
97 }
QString eventName() const
Definition: ScriptFile.cpp:95
const QString & path() const
Definition: ScriptFile.cpp:36
QLabel * myBackgroundMusic
Definition: CREMapPanel.h:25
const QString & backgroundMusic()
QStringList exitsTo() const
int y() const
Definition: ScriptFile.cpp:80
static QHash< QString, archetype * > events
Definition: CREMapPanel.cpp:12
CREMapPanel(ScriptFileManager *manager, QWidget *parent)
Definition: CREMapPanel.cpp:30
QTreeWidget * myScripts
Definition: CREMapPanel.h:24
Definition: object.h:465
QLabel * myName
Definition: CREMapPanel.h:21
const CREMapInformation * map() const
Definition: ScriptFile.cpp:70
virtual void setItem(CREMapInformation *map)
Definition: CREMapPanel.cpp:64
virtual ~CREMapPanel()
Definition: CREMapPanel.cpp:60
QString pluginName() const
Definition: ScriptFile.cpp:90
QStringList accessedFrom() const
static void fillEvents()
Definition: CREMapPanel.cpp:14
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:31
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
QTreeWidget * myExitsTo
Definition: CREMapPanel.h:22
int x() const
Definition: ScriptFile.cpp:75
static QIcon getIcon(int faceNumber)
Definition: CREPixmap.cpp:27
struct archt * next
Definition: object.h:467
QString itemName() const
Definition: ScriptFile.cpp:85
QTreeWidget * myExitsFrom
Definition: CREMapPanel.h:23
ScriptFileManager * myManager
Definition: CREMapPanel.h:20
EXTERN archetype * first_archetype
Definition: global.h:122
Definition: main.c:88