00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELSCRIPTMGR_HPP_
00021 #define _STELSCRIPTMGR_HPP_
00022
00023 #include "VecMath.hpp"
00024
00025 #include <QObject>
00026 #include <QtScript>
00027 #include <QStringList>
00028 #include <QFile>
00029 #include <QTime>
00030
00031 class StelMainScriptAPI;
00032
00033 #ifdef ENABLE_SCRIPT_CONSOLE
00034 class ScriptConsole;
00035 #endif
00036
00038 class StelScriptMgr : public QObject
00039 {
00040 Q_OBJECT
00041
00042 #ifdef ENABLE_SCRIPT_CONSOLE
00043 friend class ScriptConsole;
00044 #endif
00045
00046 public:
00047 StelScriptMgr(QObject *parent=0);
00048 ~StelScriptMgr();
00049
00050 QStringList getScriptList(void);
00051
00054 bool scriptIsRunning(void);
00058 QString runningScriptId(void);
00059
00060 public slots:
00067 const QString getName(const QString& s);
00068
00075 const QString getAuthor(const QString& s);
00076
00083 const QString getLicense(const QString& s);
00084
00092 const QString getDescription(const QString& s);
00093
00102 bool runScript(const QString& fileName, const QString& includePath="");
00103
00106 bool stopScript(void);
00107
00108 void setScriptRate(double r);
00109 double getScriptRate(void);
00110
00113 void debug(const QString& msg);
00114
00115 private slots:
00117 void scriptEnded();
00118
00119 signals:
00121 void scriptRunning();
00123 void scriptStopped();
00125 void scriptDebug(const QString&);
00126
00127 private:
00128
00129 QMap<QString, QString> mappify(const QStringList& args, bool lowerKey=false);
00130 bool strToBool(const QString& str);
00131
00132 bool preprocessScript(QFile& input, QFile& output, const QString& scriptDir);
00133
00134 #ifdef ENABLE_STRATOSCRIPT_COMPAT
00135 bool preprocessStratoScript(QFile& input, QFile& output, const QString& scriptDir);
00136 #endif
00137
00144 const QString getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText="");
00145 QScriptEngine engine;
00146
00148 class StelScriptThread* thread;
00149 StelMainScriptAPI *mainAPI;
00150 };
00151
00152 #endif // _STELSCRIPTMGR_HPP_