Crossfire Server, Trunk
ScriptFileManager.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 "ScriptFileManager.h"
14 #include "scripts/ScriptFile.h"
15 #include <QVariant>
16 
18  setProperty(tipProperty, tr("Display all Python scripts used in maps."));
19 }
20 
22 {
23  qDeleteAll(myScripts.values());
24 }
25 
27 {
28  QList<ScriptFile*> list;
29  foreach(ScriptFile* script, myScripts.values())
30  {
31  if (script->forMap(map))
32  {
33  list.append(script);
34  }
35  }
36  return list;
37 }
38 
40 {
41  if (!myScripts.contains(path))
42  {
44  myScripts.insert(path, new ScriptFile(this, path));
46  }
47  return myScripts[path];
48 }
49 
51 {
52  QHash<QString, ScriptFile*>::iterator script = myScripts.begin();
53  while (script != myScripts.end())
54  {
55  if ((*script)->removeMap(map))
56  {
57  ScriptFile* s = *script;
58  script = myScripts.erase(script);
59  delete s;
60  }
61  else
62  {
63  script++;
64  }
65  }
66 }
67 
68 QList<ScriptFile*> ScriptFileManager::scripts() const
69 {
70  return myScripts.values();
71 }
72 
73 void ScriptFileManager::addHook(const QString &file, HookInformation *hook) {
74  getFile(file)->addHook(hook);
75 }
AssetWrapper::BeforeChildAdd
@ BeforeChildAdd
Definition: AssetWrapper.h:33
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:34
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
guildoracle.list
list
Definition: guildoracle.py:87
ScriptFileManager::~ScriptFileManager
virtual ~ScriptFileManager()
Definition: ScriptFileManager.cpp:21
mad_mage_user.file
file
Definition: mad_mage_user.py:15
ScriptFileManager::ScriptFileManager
ScriptFileManager(AssetWrapper *parent)
Definition: ScriptFileManager.cpp:17
ScriptFileManager.h
HookInformation
Definition: ScriptFile.h:25
ScriptFile.h
AssetWrapper
Definition: AssetWrapper.h:25
ScriptFile::addHook
void addHook(HookInformation *hook)
Definition: ScriptFile.cpp:25
disinfect.map
map
Definition: disinfect.py:4
ScriptFileManager::scriptsForMap
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:26
ScriptFile
Definition: ScriptFile.h:48
script
Install Bug reporting Credits but rather whatever guild name you are using *With the current map and server there are three they and GreenGoblin *Whatever name you give the folder should but it will still use GUILD_TEMPLATE *You can change what guild it uses by editing the map files Modify Map or objects if you want to use the optional Python based Guild Storage hall The first three are on the main the next two are in the guild_hq and the final one is in hallofjoining Withe the Storage three objects are found on the main floor and the last two are in the basement It s not that but you will need a map editor You find the object that has the script
Definition: README.txt:19
ScriptFileManager::getFile
ScriptFile * getFile(const QString &path)
Definition: ScriptFileManager.cpp:39
path
pluglist shows those as well as a short text describing each the list will simply appear empty The keyword for the Python plugin is Python plugout< keyword > Unloads a given identified by its _keyword_ So if you want to unload the Python you need to do plugout Python plugin< libname > Loads a given whose _filename_ is libname So in the case of you d have to do a plugin cfpython so Note that all filenames are relative to the default plugin path(SHARE/plugins). Console messages. ----------------- When Crossfire starts
CREMapInformation
Definition: CREMapInformation.h:27
ScriptFileManager::addHook
void addHook(const QString &file, HookInformation *hook)
Definition: ScriptFileManager.cpp:73
ScriptFileManager::myScripts
QHash< QString, ScriptFile * > myScripts
Definition: ScriptFileManager.h:59
AssetWrapper::AfterChildAdd
@ AfterChildAdd
Definition: AssetWrapper.h:33
ScriptFileManager::scripts
QList< ScriptFile * > scripts() const
Definition: ScriptFileManager.cpp:68
ScriptFileManager::removeMap
void removeMap(CREMapInformation *map)
Definition: ScriptFileManager.cpp:50