summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sigencore/CMakeLists.txt2
-rw-r--r--sigencore/RunScript.cpp37
-rw-r--r--sigencore/RunScript.h47
3 files changed, 86 insertions, 0 deletions
diff --git a/sigencore/CMakeLists.txt b/sigencore/CMakeLists.txt
index 08abb4e4..79413d08 100644
--- a/sigencore/CMakeLists.txt
+++ b/sigencore/CMakeLists.txt
@@ -10,6 +10,7 @@ SET(sigencore_HEADERS
Containment.h
Global.h
Player.h
+ RunScript.h
Team.h
TeamMember.h
)
@@ -18,6 +19,7 @@ SET(sigencore_SRCS
Client.cpp
Containment.cpp
Player.cpp
+ RunScript.cpp
Team.cpp
TeamMember.cpp
)
diff --git a/sigencore/RunScript.cpp b/sigencore/RunScript.cpp
new file mode 100644
index 00000000..bff6de3f
--- /dev/null
+++ b/sigencore/RunScript.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2009 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Header include
+#include "RunScript.h"
+
+// Sigcore includes
+#include "../sigcore/Script.h"
+
+// KDE includes
+#include <kross/core/action.h>
+#include <kross/core/actioncollection.h>
+
+Kross::Action* Sigencore::runScript(const QString& name, const Sigcore::Script& script, const ObjectMap& objects, Kross::ActionCollection* collection)
+{
+ Kross::Action* action = new Kross::Action(collection, name);
+ action->setInterpreter(script.interpreter());
+ action->setCode(script.script().toUtf8());
+ QStringList names = objects.keys();
+ foreach (const QString& name, names)
+ action->addObject(objects[name], name);
+ return action;
+}
diff --git a/sigencore/RunScript.h b/sigencore/RunScript.h
new file mode 100644
index 00000000..119f13a6
--- /dev/null
+++ b/sigencore/RunScript.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SIGENCORE_RUNSCRIPT
+#define SIGENCORE_RUNSCRIPT
+
+// Sigencore includes
+#include "Global.h"
+
+// Qt includes
+#include <QtCore/QMap>
+
+// Forward declarations
+namespace Sigcore
+{
+class Script;
+}
+namespace Kross
+{
+class Action;
+class ActionCollection;
+}
+class QObject;
+class QString;
+
+namespace Sigencore
+{
+typedef QMap<QString, QObject*> ObjectMap;
+
+SIGENCORE_EXPORT Kross::Action* runScript(const QString& name, const Sigcore::Script& script, const ObjectMap& objects, Kross::ActionCollection* collection);
+}
+
+#endif