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 <QObject>
00024 #include <QtScript>
00025 #include <QStringList>
00026 #include <QFile>
00027 #include <QTime>
00028 #include <QTimer>
00029
00030 class StelMainScriptAPI;
00031
00032 #ifdef ENABLE_SCRIPT_CONSOLE
00033 class ScriptConsole;
00034 #endif
00035
00037 class StelScriptMgr : public QObject
00038 {
00039 Q_OBJECT
00040
00041 #ifdef ENABLE_SCRIPT_CONSOLE
00042 friend class ScriptConsole;
00043 #endif
00044
00045 public:
00046 StelScriptMgr(QObject *parent=0);
00047 ~StelScriptMgr();
00048
00049 QStringList getScriptList();
00050
00053 bool scriptIsRunning();
00057 QString runningScriptId();
00058
00059 public slots:
00066 const QString getName(const QString& s);
00067
00074 const QString getAuthor(const QString& s);
00075
00082 const QString getLicense(const QString& s);
00083
00091 const QString getDescription(const QString& s);
00092
00101 bool runScript(const QString& fileName, const QString& includePath="");
00102
00105 void stopScript();
00106
00112 void setScriptRate(float r);
00113
00116 double getScriptRate();
00117
00120 void debug(const QString& msg);
00121
00122 private slots:
00124 void scriptEnded();
00125
00126 signals:
00128 void scriptRunning();
00130 void scriptStopped();
00132 void scriptDebug(const QString&);
00133
00134 private:
00135
00136 QMap<QString, QString> mappify(const QStringList& args, bool lowerKey=false);
00137 bool strToBool(const QString& str);
00138
00139 bool preprocessScript(QFile& input, QString& output, const QString& scriptDir);
00140
00141 #ifdef ENABLE_STRATOSCRIPT_COMPAT
00142 bool preprocessStratoScript(QFile& input, QString& output, const QString& scriptDir);
00143 #endif
00144
00151 const QString getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText="");
00152 QScriptEngine engine;
00153
00155 StelMainScriptAPI *mainAPI;
00156
00157 QString scriptFileName;
00158
00159 };
00160
00161 #endif // _STELSCRIPTMGR_HPP_