Crossfire Server, Trunk  R20513
ScriptFile.cpp
Go to the documentation of this file.
1 #include "ScriptFile.h"
2 #include "CREMapInformation.h"
3 
4 ScriptFile::ScriptFile(const QString& path)
5 {
6  myPath = path;
7 }
8 
10 {
11  qDeleteAll(myHooks);
12 }
13 
15 {
16  myHooks.append(hook);
17 }
18 
20 {
21  foreach(HookInformation* hook, myHooks)
22  {
23  if (hook->map() == map)
24  {
25  return true;
26  }
27  }
28  return false;
29 }
30 
31 QList<HookInformation*> ScriptFile::hooks() const
32 {
33  return myHooks;
34 }
35 
36 const QString& ScriptFile::path() const
37 {
38  return myPath;
39 }
40 
42 {
43  QList<HookInformation*>::iterator hook = myHooks.begin();
44  while (hook != myHooks.end())
45  {
46  if ((*hook)->map() == map)
47  {
48  HookInformation* h = *hook;
49  hook = myHooks.erase(hook);
50  delete h;
51  }
52  else
53  {
54  hook++;
55  }
56  }
57  return myHooks.empty();
58 }
59 
60 HookInformation::HookInformation(CREMapInformation* map, int x, int y, const QString& itemName, const QString& pluginName, const QString& eventName)
61 {
62  myMap = map;
63  myX = x;
64  myY = y;
65  myItemName = itemName;
66  myPluginName = pluginName;
67  myEventName = eventName;
68 }
69 
71 {
72  return myMap;
73 }
74 
75 int HookInformation::x() const
76 {
77  return myX;
78 }
79 
80 int HookInformation::y() const
81 {
82  return myY;
83 }
84 
86 {
87  return myItemName;
88 }
89 
91 {
92  return myPluginName;
93 }
94 
96 {
97  return myEventName;
98 }
int x() const
Definition: ScriptFile.cpp:75
QString itemName() const
Definition: ScriptFile.cpp:85
ScriptFile(const QString &path)
Definition: ScriptFile.cpp:4
void addHook(HookInformation *hook)
Definition: ScriptFile.cpp:14
QString myPath
Definition: ScriptFile.h:49
const QString & path() const
Definition: ScriptFile.cpp:36
int y() const
Definition: ScriptFile.cpp:80
virtual ~ScriptFile()
Definition: ScriptFile.cpp:9
bool removeMap(CREMapInformation *map)
Remove hooks linked to a map.
Definition: ScriptFile.cpp:41
QString eventName() const
Definition: ScriptFile.cpp:95
HookInformation(CREMapInformation *map, int x, int y, const QString &itemName, const QString &pluginName, const QString &eventName)
Definition: ScriptFile.cpp:60
QString pluginName() const
Definition: ScriptFile.cpp:90
const CREMapInformation * map() const
Definition: ScriptFile.cpp:70
Information about an event hook, linked to a script file.
Definition: ScriptFile.h:9
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:31
bool forMap(CREMapInformation *map) const
Definition: ScriptFile.cpp:19
QList< HookInformation * > myHooks
Definition: ScriptFile.h:50