Crossfire Server, Trunk
CREMapPanel.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "CREMapPanel.h"
14 #include "CREMapInformation.h"
15 #include "CREMainWindow.h"
17 #include "scripts/ScriptFile.h"
18 #include "CREPixmap.h"
19 
20 #include "define.h"
21 #include "assets.h"
22 #include "AssetsManager.h"
23 
24 static QHash<QString, archetype*> events;
25 
26 void static fillEvents()
27 {
28  if (!events.isEmpty())
29  {
30  return;
31  }
32 
34  {
35  if (arch->clone.type == EVENT_CONNECTOR)
36  {
37  events.insert(arch->name, arch);
38  }
39  });
40 }
41 
43 {
44  Q_ASSERT(manager != NULL);
46 
47  myLayout->addWidget(new QLabel(tr("Name:"), this), 0, 0);
48  myName = new QLabel();
49  myLayout->addWidget(myName, 0, 1);
50 
51  myExitsFrom = new QTreeWidget(this);
52  myExitsFrom->setHeaderLabel(tr("Exits from this map"));
53  myLayout->addWidget(myExitsFrom, 1, 0, 1, 2);
54 
55  myExitsTo = new QTreeWidget(this);
56  myExitsTo->setHeaderLabel(tr("Exits leading to this map"));
57  myLayout->addWidget(myExitsTo, 2, 0, 1, 2);
58 
59  myScripts = new QTreeWidget(this);
60  myScripts->setHeaderLabel(tr("Scripts on this map"));
61  myScripts->setIconSize(QSize(32, 32));
62  myLayout->addWidget(myScripts, 3, 0, 1, 2);
63 
64  myLayout->addWidget(new QLabel(tr("Background music:"), this), 4, 0);
65  myBackgroundMusic = new QLabel();
66  myLayout->addWidget(myBackgroundMusic, 4, 1);
67 
68  fillEvents();
69 }
70 
72 {
73 }
74 
76 {
77  myName->setText(myItem->name());
78 
79  myExitsFrom->clear();
80  foreach(QString path, myItem->accessedFrom())
81  myExitsFrom->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
82 
83  myExitsTo->clear();
84  foreach(QString path, myItem->exitsTo())
85  myExitsTo->addTopLevelItem(new QTreeWidgetItem(QStringList(path)));
86 
87  myScripts->clear();
88  foreach(ScriptFile* script, myManager->scriptsForMap(myItem))
89  {
90  foreach(HookInformation* hook, script->hooks())
91  {
92  if (hook->map() == myItem)
93  {
94  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())));
95 
96  archetype* arch = events[hook->eventName().toLower()];
97  if (arch != NULL && arch->clone.face != NULL)
98  {
99  child->setIcon(0, CREPixmap::getIcon(arch->clone.face->number));
100  }
101 
102  myScripts->addTopLevelItem(child);
103  }
104  }
105  }
106 
108 }
ScriptFileManager
Definition: ScriptFileManager.h:26
HookInformation::x
int x() const
Definition: ScriptFile.cpp:86
CREMapPanel::myBackgroundMusic
QLabel * myBackgroundMusic
Definition: CREMapPanel.h:41
EVENT_CONNECTOR
@ EVENT_CONNECTOR
Definition: object.h:232
ScriptFileManager.h
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
AssetsManager.h
CREMapInformation.h
CREMapInformation::exitsTo
QStringList exitsTo() const
Definition: CREMapInformation.cpp:135
HookInformation::map
const CREMapInformation * map() const
Definition: ScriptFile.cpp:81
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
fillEvents
static void fillEvents()
Definition: CREMapPanel.cpp:26
AssetSWrapperPanel< CREMapInformation >::myItem
CREMapInformation * myItem
Definition: AssetWrapperPanel.h:126
CREMapPanel::myName
QLabel * myName
Definition: CREMapPanel.h:37
HookInformation::itemName
QString itemName() const
Definition: ScriptFile.cpp:96
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
CREMapInformation::name
QString name
Definition: CREMapInformation.h:32
HookInformation::y
int y() const
Definition: ScriptFile.cpp:91
CREMapPanel::CREMapPanel
CREMapPanel(ScriptFileManager *manager, QWidget *parent)
Definition: CREMapPanel.cpp:42
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition: AssetWrapperPanel.h:56
ScriptFile::path
const QString & path() const
Definition: ScriptFile.cpp:47
CREMapPanel::~CREMapPanel
virtual ~CREMapPanel()
Definition: CREMapPanel.cpp:71
ScriptFile.h
ScriptFileManager::scriptsForMap
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:26
HookInformation::pluginName
QString pluginName() const
Definition: ScriptFile.cpp:101
python_init.path
path
Definition: python_init.py:8
CREMapPanel::myScripts
QTreeWidget * myScripts
Definition: CREMapPanel.h:40
CREMapInformation::accessedFrom
QStringList accessedFrom() const
Definition: CREMapInformation.cpp:146
events
static QHash< QString, archetype * > events
Definition: CREMapPanel.cpp:24
archetype
Definition: object.h:483
CREMapPanel::myExitsTo
QTreeWidget * myExitsTo
Definition: CREMapPanel.h:38
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:158
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
AssetSWrapperPanel
Definition: AssetWrapperPanel.h:113
ScriptFile
Definition: ScriptFile.h:48
CREMapPanel::myExitsFrom
QTreeWidget * myExitsFrom
Definition: CREMapPanel.h:39
CREMapInformation::backgroundMusic
QString backgroundMusic
Definition: CREMapInformation.h:37
define.h
assets.h
CREMapPanel::myManager
ScriptFileManager * myManager
Definition: CREMapPanel.h:36
CREMainWindow.h
ScriptFile::hooks
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:42
HookInformation
Definition: ScriptFile.h:25
CREMapPanel.h
CREPixmap.h
manager
static AssetsManager * manager
Definition: assets.cpp:60
CREMapPanel::updateItem
virtual void updateItem() override
Definition: CREMapPanel.cpp:75
HookInformation::eventName
QString eventName() const
Definition: ScriptFile.cpp:106