StelScriptMgr.hpp   StelScriptMgr.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELSCRIPTMGR_HPP_ #ifndef _STELSCRIPTMGR_HPP_
#define _STELSCRIPTMGR_HPP_ #define _STELSCRIPTMGR_HPP_
#include "VecMath.hpp"
#include <QObject> #include <QObject>
#include <QtScript> #include <QtScript>
#include <QStringList> #include <QStringList>
#include <QFile> #include <QFile>
#include <QTime> #include <QTime>
#include <QTimer>
class StelMainScriptAPI; class StelMainScriptAPI;
#ifdef ENABLE_SCRIPT_CONSOLE #ifdef ENABLE_SCRIPT_CONSOLE
class ScriptConsole; class ScriptConsole;
#endif #endif
//! Manage scripting in Stellarium //! Manage scripting in Stellarium
class StelScriptMgr : public QObject class StelScriptMgr : public QObject
{ {
Q_OBJECT Q_OBJECT
#ifdef ENABLE_SCRIPT_CONSOLE #ifdef ENABLE_SCRIPT_CONSOLE
friend class ScriptConsole; friend class ScriptConsole;
#endif #endif
public: public:
StelScriptMgr(QObject *parent=0); StelScriptMgr(QObject *parent=0);
~StelScriptMgr(); ~StelScriptMgr();
QStringList getScriptList(void); QStringList getScriptList();
//! Find out if a script is running //! Find out if a script is running
//! @return true if a script is running, else false //! @return true if a script is running, else false
bool scriptIsRunning(void); bool scriptIsRunning();
//! Get the ID (filename) of the currently running script //! Get the ID (filename) of the currently running script
//! @return Empty string if no script is running, else the //! @return Empty string if no script is running, else the
//! ID of the script which is running. //! ID of the script which is running.
QString runningScriptId(void); QString runningScriptId();
public slots: public slots:
//! Gets a single line name of the script. //! Gets a single line name of the script.
//! @param s the file name of the script whose name is to be returne d. //! @param s the file name of the script whose name is to be returne d.
//! @return text following a comment with Name: at the start. If no //! @return text following a comment with Name: at the start. If no
//! such comment is found, the file name will be returned. If the f ile //! such comment is found, the file name will be returned. If the f ile
//! is not found or cannot be opened for some reason, an Empty strin g //! is not found or cannot be opened for some reason, an Empty strin g
//! will be returned. //! will be returned.
const QString getName(const QString& s); const QString getName(const QString& s);
skipping to change at line 106 skipping to change at line 105
//! @param includePath the directory to use when searching for inclu de files //! @param includePath the directory to use when searching for inclu de files
//! in the SSC preprocessor. Usually this will be the same as the //! in the SSC preprocessor. Usually this will be the same as the
//! script file itself, but if you're running a generated script fro m //! script file itself, but if you're running a generated script fro m
//! a temp directory, but want to include a file from elsewhere, it //! a temp directory, but want to include a file from elsewhere, it
//! can be usetul to set it to something else (e.g. in ScriptConsole ). //! can be usetul to set it to something else (e.g. in ScriptConsole ).
//! @return false if the named script could not be run, true otherwi se //! @return false if the named script could not be run, true otherwi se
bool runScript(const QString& fileName, const QString& includePath=" "); bool runScript(const QString& fileName, const QString& includePath=" ");
//! Stops any running script. //! Stops any running script.
//! @return false if no script was running, true otherwise. //! @return false if no script was running, true otherwise.
bool stopScript(void); void stopScript();
void setScriptRate(double r); //! Changes the rate at which the script executes as a multiple of r
double getScriptRate(void); eal time.
//! Note that this is not the same as the rate at which simulation t
ime passes
//! because the script running at normal rate might set the simulati
on time rate
//! to be non-real time.
//! @param r rate, e.g. 2.0 = script runs at twice the normal rate
void setScriptRate(float r);
//! Get the rate at which the script is running as a multiple of the
normal
//! execution rate.
double getScriptRate();
//! cause the emission of the scriptDebug signal. This is so that f unctions in //! cause the emission of the scriptDebug signal. This is so that f unctions in
//! StelMainScriptAPI can explicitly send information to the ScriptC onsole //! StelMainScriptAPI can explicitly send information to the ScriptC onsole
void debug(const QString& msg); void debug(const QString& msg);
private slots: private slots:
//! Called at the end of the running thread //! Called at the end of the running threa
void scriptEnded(); void scriptEnded();
signals: signals:
//! Notification when a script starts running //! Notification when a script starts running
void scriptRunning(); void scriptRunning();
//! Notification when a script has stopped running //! Notification when a script has stopped running
void scriptStopped(); void scriptStopped();
//! Notification of a script event - warnings, current execution lin e etc. //! Notification of a script event - warnings, current execution lin e etc.
void scriptDebug(const QString&); void scriptDebug(const QString&);
private: private:
// Utility functions for preprocessor // Utility functions for preprocessor
QMap<QString, QString> mappify(const QStringList& args, bool lowerKe y=false); QMap<QString, QString> mappify(const QStringList& args, bool lowerKe y=false);
bool strToBool(const QString& str); bool strToBool(const QString& str);
// Pre-processor functions // Pre-processor functions
bool preprocessScript(QFile& input, QFile& output, const QString& sc riptDir); bool preprocessScript(QFile& input, QString& output, const QString& scriptDir);
#ifdef ENABLE_STRATOSCRIPT_COMPAT #ifdef ENABLE_STRATOSCRIPT_COMPAT
bool preprocessStratoScript(QFile& input, QFile& output, const QStri ng& scriptDir); bool preprocessStratoScript(QFile& input, QString& output, const QSt ring& scriptDir);
#endif #endif
//! This function is for use with getName, getAuthor and getLicense. //! This function is for use with getName, getAuthor and getLicense.
//! @param s the script id //! @param s the script id
//! @param id the command line id, e.g. "Name" //! @param id the command line id, e.g. "Name"
//! @param notFoundText the text to be returned if the key is not fo und //! @param notFoundText the text to be returned if the key is not fo und
//! @return the text following the id and : on a comment line near t he top of //! @return the text following the id and : on a comment line near t he top of
//! the script file (i.e. before there is a non-comment line). //! the script file (i.e. before there is a non-comment line).
const QString getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText=""); const QString getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText="");
QScriptEngine engine; QScriptEngine engine;
//! The thread in which scripts are run //! The thread in which scripts are run
class StelScriptThread* thread;
StelMainScriptAPI *mainAPI; StelMainScriptAPI *mainAPI;
QString scriptFileName;
float savedTimeRate;
}; };
#endif // _STELSCRIPTMGR_HPP_ #endif // _STELSCRIPTMGR_HPP_
 End of changes. 12 change blocks. 
12 lines changed or deleted 26 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/