Crossfire Server, Trunk
ScriptFile.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 "ScriptFile.h"
14 #include "CREMapInformation.h"
15 
16 ScriptFile::ScriptFile(AssetWrapper *parent, const QString& path) : AssetWrapper(parent, "Script") {
17  myPath = path;
18 }
19 
21 {
22  qDeleteAll(myHooks);
23 }
24 
26 {
27  myHooks.append(hook);
28 }
29 
31 {
32  foreach(HookInformation* hook, myHooks)
33  {
34  if (hook->map() == map)
35  {
36  return true;
37  }
38  }
39  return false;
40 }
41 
42 QList<HookInformation*> ScriptFile::hooks() const
43 {
44  return myHooks;
45 }
46 
47 const QString& ScriptFile::path() const
48 {
49  return myPath;
50 }
51 
53 {
54  QList<HookInformation*>::iterator hook = myHooks.begin();
55  while (hook != myHooks.end())
56  {
57  if ((*hook)->map() == map)
58  {
59  HookInformation* h = *hook;
60  hook = myHooks.erase(hook);
61  delete h;
62  }
63  else
64  {
65  hook++;
66  }
67  }
68  return myHooks.empty();
69 }
70 
71 HookInformation::HookInformation(CREMapInformation* map, int x, int y, const QString& itemName, const QString& pluginName, const QString& eventName)
72 {
73  myMap = map;
74  myX = x;
75  myY = y;
79 }
80 
82 {
83  return myMap;
84 }
85 
86 int HookInformation::x() const
87 {
88  return myX;
89 }
90 
91 int HookInformation::y() const
92 {
93  return myY;
94 }
95 
97 {
98  return myItemName;
99 }
100 
102 {
103  return myPluginName;
104 }
105 
107 {
108  return myEventName;
109 }
HookInformation::x
int x() const
Definition: ScriptFile.cpp:86
ScriptFile::removeMap
bool removeMap(CREMapInformation *map)
Definition: ScriptFile.cpp:52
diamondslots.x
x
Definition: diamondslots.py:15
CREMapInformation.h
ScriptFile::forMap
bool forMap(const CREMapInformation *map) const
Definition: ScriptFile.cpp:30
HookInformation::myMap
CREMapInformation * myMap
Definition: ScriptFile.h:37
HookInformation::myItemName
QString myItemName
Definition: ScriptFile.h:40
HookInformation::map
const CREMapInformation * map() const
Definition: ScriptFile.cpp:81
ScriptFile::myHooks
QList< HookInformation * > myHooks
Definition: ScriptFile.h:68
HookInformation::itemName
QString itemName() const
Definition: ScriptFile.cpp:96
HookInformation::myY
int myY
Definition: ScriptFile.h:39
HookInformation::y
int y() const
Definition: ScriptFile.cpp:91
CREMapInformation
Definition: CREMapInformation.h:27
disinfect.map
map
Definition: disinfect.py:4
ScriptFile::path
const QString & path() const
Definition: ScriptFile.cpp:47
ScriptFile.h
AssetWrapper
Definition: AssetWrapper.h:25
HookInformation::myEventName
QString myEventName
Definition: ScriptFile.h:42
HookInformation::pluginName
QString pluginName() const
Definition: ScriptFile.cpp:101
python_init.path
path
Definition: python_init.py:8
ScriptFile::ScriptFile
ScriptFile(AssetWrapper *parent, const QString &path)
Definition: ScriptFile.cpp:16
HookInformation::HookInformation
HookInformation(CREMapInformation *map, int x, int y, const QString &itemName, const QString &pluginName, const QString &eventName)
Definition: ScriptFile.cpp:71
ScriptFile::addHook
void addHook(HookInformation *hook)
Definition: ScriptFile.cpp:25
diamondslots.y
y
Definition: diamondslots.py:16
HookInformation::myX
int myX
Definition: ScriptFile.h:38
HookInformation::myPluginName
QString myPluginName
Definition: ScriptFile.h:41
ScriptFile::myPath
QString myPath
Definition: ScriptFile.h:67
ScriptFile::hooks
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:42
ScriptFile::~ScriptFile
virtual ~ScriptFile()
Definition: ScriptFile.cpp:20
HookInformation
Definition: ScriptFile.h:25
HookInformation::eventName
QString eventName() const
Definition: ScriptFile.cpp:106