forked from yvt/terravox
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathluaengine.cpp
More file actions
90 lines (74 loc) · 1.9 KB
/
luaengine.cpp
File metadata and controls
90 lines (74 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "luaengine.h"
#include "luaengine_p.h"
#include <QApplication>
#include <QStandardPaths>
#include <QHash>
#include <QDir>
#include <QDebug>
#ifdef HAS_LUAJIT
LuaEngine::LuaEngine(QObject *parent) :
QObject(parent),
d_ptr(new LuaEnginePrivate(this))
{
}
LuaEngine::~LuaEngine()
{
delete d_ptr;
}
void LuaEngine::initialize(LuaInterface *i)
{
Q_D(LuaEngine);
d->initialize(i);
}
QStringList LuaEngine::pluginDirectories(bool writable)
{
QStringList ret;
QHash<QString, bool> included;
if (writable) {
QString path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
if (!path.isEmpty()) {
QString p = path + "/Scripts";
p = p.replace(QRegExp("\\/+"), "/");
ret.push_back(p);
}
} else {
foreach(const QString &path, QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation))
{
QString p = path + "/Scripts";
if (included.contains(p)) {
continue;
}
p = p.replace(QRegExp("\\/+"), "/");
ret.push_back(p);
included[p] = true;
}
#ifdef Q_OS_DARWIN
// Add bundled script
// (actually QStandardPaths::AppLocalDataLocation contains it, but strangely it's
// percent encoded.)
{
QString p = QApplication::applicationDirPath() + "/../Resources/scripts";
p = QDir(p).absolutePath();
if (!included.contains(p)) {
p = p.replace(QRegExp("\\/+"), "/");
ret.push_back(p);
included[p] = true;
}
}
#endif
}
return ret;
}
#else
LuaEngine::LuaEngine(QObject *parent) :
QObject(parent)
{
}
LuaEngine::~LuaEngine()
{
}
void LuaEngine::initialize(LuaInterface *)
{
qDebug() << "LuaEngine was not initialized: disabled by compilation option.";
}
#endif