Crossfire Server, Trunk
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 #include "assets.h"
12 #include "AssetsManager.h"
13 
14 static QHash<QString, archetype*> events;
15 
16 void static fillEvents()
17 {
18  if (!events.isEmpty())
19  {
20  return;
21  }
22 
24  {
25  if (arch->clone.type == EVENT_CONNECTOR)
26  {
27  events.insert(arch->name, arch);
28  }
29  });
30 }
31 
33 {
34  Q_ASSERT(manager != NULL);
36  QGridLayout* layout = new QGridLayout(this);
37 
38  layout->addWidget(new QLabel(tr("Name:"), this), 0, 0);
39  myName = new QLabel();
40  layout->addWidget(myName, 0, 1);
41 
42  myExitsFrom = new QTreeWidget(this);
43  myExitsFrom->setHeaderLabel(tr("Exits from this map"));
44  layout->addWidget(myExitsFrom, 1, 0, 1, 2);
45 
46  myExitsTo = new QTreeWidget(this);
47  myExitsTo->setHeaderLabel(tr("Exits leading to this map"));
48  layout->addWidget(myExitsTo, 2, 0, 1, 2);
49 
50  myScripts = new QTreeWidget(this);
51  myScripts->setHeaderLabel(tr("Scripts on this map"));
52  myScripts->setIconSize(QSize(32, 32));
53  layout->addWidget(myScripts, 3, 0, 1, 2);
54 
55  layout->addWidget(new QLabel(tr("Background music:"), this), 4, 0);
56  myBackgroundMusic = new QLabel();
57  layout->addWidget(myBackgroundMusic, 4, 1);
58 
59  fillEvents();
60 }
61 
63 {
64 }
65 
67 {
68  myName->setText(map->name());
69 
70  myExitsFrom->clear();
71  foreach(QString path, map->accessedFrom())
72  myExitsFrom->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
73 
74  myExitsTo->clear();
75  foreach(QString path, map->exitsTo())
76  myExitsTo->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
77 
78  myScripts->clear();
79  foreach(ScriptFile* script, myManager->scriptsForMap(map))
80  {
81  foreach(HookInformation* hook, script->hooks())
82  {
83  if (hook->map() == map)
84  {
85  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())));
86 
87  archt* arch = events[hook->eventName().toLower()];
88  if (arch != NULL && arch->clone.face != NULL)
89  {
90  child->setIcon(0, CREPixmap::getIcon(arch->clone.face->number));
91  }
92 
93  myScripts->addTopLevelItem(child);
94  }
95  }
96  }
97 
98  myBackgroundMusic->setText(map->backgroundMusic());
99 }
ScriptFileManager
Definition: ScriptFileManager.h:10
HookInformation::x
int x() const
Definition: ScriptFile.cpp:75
CRETPanel
Definition: CREPanel.h:20
CREMapPanel::myBackgroundMusic
QLabel * myBackgroundMusic
Definition: CREMapPanel.h:25
layout
Definition: main.c:85
EVENT_CONNECTOR
@ EVENT_CONNECTOR
Definition: object.h:227
ScriptFileManager.h
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
AssetsManager.h
CREMapInformation.h
HookInformation::map
const CREMapInformation * map() const
Definition: ScriptFile.cpp:70
python_event.path
path
Definition: python_event.py:11
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:55
fillEvents
static void fillEvents()
Definition: CREMapPanel.cpp:16
CREMapPanel::myName
QLabel * myName
Definition: CREMapPanel.h:21
HookInformation::itemName
QString itemName() const
Definition: ScriptFile.cpp:85
getManager
AssetsManager * getManager()
Definition: assets.cpp:329
archt
Definition: object.h:468
HookInformation::y
int y() const
Definition: ScriptFile.cpp:80
CREMapInformation
Definition: CREMapInformation.h:13
CREMapPanel::CREMapPanel
CREMapPanel(ScriptFileManager *manager, QWidget *parent)
Definition: CREMapPanel.cpp:32
disinfect.map
map
Definition: disinfect.py:4
ScriptFile::path
const QString & path() const
Definition: ScriptFile.cpp:36
CREMapPanel::~CREMapPanel
virtual ~CREMapPanel()
Definition: CREMapPanel.cpp:62
ScriptFile.h
ScriptFileManager::scriptsForMap
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:13
CREMapPanel::setItem
virtual void setItem(CREMapInformation *map) override
Definition: CREMapPanel.cpp:66
HookInformation::pluginName
QString pluginName() const
Definition: ScriptFile.cpp:90
CREMapPanel::myScripts
QTreeWidget * myScripts
Definition: CREMapPanel.h:24
events
static QHash< QString, archetype * > events
Definition: CREMapPanel.cpp:14
CREMapPanel::myExitsTo
QTreeWidget * myExitsTo
Definition: CREMapPanel.h:22
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:135
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
ScriptFile
Definition: ScriptFile.h:31
CREMapPanel::myExitsFrom
QTreeWidget * myExitsFrom
Definition: CREMapPanel.h:23
define.h
assets.h
CREMapPanel::myManager
ScriptFileManager * myManager
Definition: CREMapPanel.h:20
CREMainWindow.h
ScriptFile::hooks
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:31
HookInformation
Definition: ScriptFile.h:9
CREMapPanel.h
CREPixmap.h
manager
static AssetsManager * manager
Definition: assets.cpp:63
HookInformation::eventName
QString eventName() const
Definition: ScriptFile.cpp:95