Stellarium
0.21.3
|
Manage scripting in Stellarium.
#include <StelScriptMgr.hpp>
Public Slots | |
QString | getHtmlDescription (const QString &s, bool generateDocumentTags=true) const |
Returns a HTML description of the specified script. More... | |
QString | getName (const QString &s) const |
Gets a single line name of the script. More... | |
QString | getAuthor (const QString &s) const |
Gets the name of the script Author. More... | |
QString | getLicense (const QString &s) const |
Gets the licensing terms for the script. More... | |
QString | getVersion (const QString &s) const |
Gets the version of the script. More... | |
QString | getDescription (const QString &s) const |
Gets a description of the script. More... | |
QString | getShortcut (const QString &s) const |
Gets the default shortcut of the script. More... | |
bool | runScript (const QString &fileName, const QString &includePath="") |
Run the script located in the given file. More... | |
bool | runScriptDirect (const QString scriptId, const QString &scriptCode, int &errLoc, const QString &includePath=QString()) |
Runs the script code given. More... | |
bool | runScriptDirect (const QString &scriptCode, const QString &includePath=QString()) |
Convenience method similar to runScriptDirect(const QString scriptId, const QString& scriptCode, int &errLoc, const QString &includePath = QString()); when scriptId and errLoc are not relevant. More... | |
bool | runPreprocessedScript (const QString &preprocessedScript, const QString &scriptId) |
Runs preprocessed script code which has been generated using runPreprocessedScript(). More... | |
bool | prepareScript (QString &script, const QString &fileName, const QString &includePath="") |
Loads a script file and does all preparatory steps except for actually executing the script in the engine. More... | |
void | stopScript () |
Stops any running script. More... | |
void | setScriptRate (double r) |
Changes the rate at which the script executes as a multiple of real time. More... | |
double | getScriptRate () const |
Get the rate at which the script is running as a multiple of the normal execution rate. | |
void | debug (const QString &msg) |
cause the emission of the scriptDebug signal. More... | |
void | output (const QString &msg) |
cause the emission of the scriptOutput signal. More... | |
void | resetOutput (void) |
Reset output file and cause the emission of an (empty) scriptOutput signal. | |
void | saveOutputAs (const QString &filename) |
Save output file to new file. More... | |
void | pauseScript () |
Pause a running script. | |
void | resumeScript () |
Resume a paused script. | |
Signals | |
void | runningScriptIdChanged (const QString &id) |
Emitted when the running script id changes (also on start/stop) | |
void | scriptRunning () |
Notification when a script starts running. | |
void | scriptPaused () |
Notification when a script has paused running. | |
void | scriptStopped () |
Notification when a script has stopped running. | |
void | scriptDebug (const QString &) const |
Notification of a script event - warnings, current execution line etc. | |
void | scriptOutput (const QString &) const |
Notification of a script event - output line. | |
Public Member Functions | |
StelScriptMgr (QObject *parent=Q_NULLPTR) | |
QStringList | getScriptList () const |
bool | scriptIsRunning () const |
Find out if a script is running. More... | |
QString | runningScriptId () const |
Get the ID (usually filename) of the currently running script. More... | |
bool | preprocessScript (const QString fileName, const QString &input, QString &output, const QString &scriptDir, int &errLoc) |
Preprocess script, esp. More... | |
bool | preprocessFile (const QString fileName, QFile &input, QString &output, const QString &scriptDir) |
void | addModules () |
Add all the StelModules into the script engine. | |
const QMetaObject * | getMetaOfStelMainScriptAPI () |
Permit access to StelScriptMainAPI's methods. | |
QEventLoop * | getWaitEventLoop () |
Accessor to QEventLoop. | |
Static Public Member Functions | |
static void | defVecClasses (QScriptEngine *engine) |
Define JS classes Vec3f, Vec3d. | |
Properties | |
QString | runningScriptId |
|
slot |
This is so that functions in StelMainScriptAPI can explicitly send information to the ScriptConsole
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
Includes name, author, description...
s | the file name of the script whose HTML description is to be returned. |
generateDocumentTags | if true, the main wrapping document tags (<html><body>...</body></html>) are also generated |
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
s | the file name of the script whose name is to be returned. |
|
slot |
This is so that functions in StelMainScriptAPI can explicitly send information to the ScriptConsole
|
slot |
Use runPreprocessedScript to execute the script. It should be safe to call this method from another thread.
script | returns the preprocessed script text |
fileName | the location of the file containing the script. |
includePath | the directory to use when searching for include files in the SSC preprocessor. Usually this will be the same as the script file itself, but if you're running a generated script from 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). |
bool StelScriptMgr::preprocessScript | ( | const QString | fileName, |
const QString & | input, | ||
QString & | output, | ||
const QString & | scriptDir, | ||
int & | errLoc | ||
) |
process include instructions. if the command line option –verbose has been given, this dumps the preprocessed script with line numbers attached to log. This helps to understand the line number given by the usual error message.
QString StelScriptMgr::runningScriptId | ( | ) | const |
|
slot |
In general, you do not want to use this method, use runScript() or runScriptDirect() instead.
preprocessedScript | the string containing the preprocessed script. |
scriptId | The name of the script. Usually should correspond to the file name. |
|
slot |
In essence, this calls prepareScript and runPreprocessedScript.
fileName | the location of the file containing the script. |
includePath | the directory to use when searching for include files in the SSC preprocessor. If empty, this will be the same as the directory where the script file resides. If you're running a generated script from 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). |
|
slot |
(Required e.g. in RemoteControl)
|
slot |
This can be used for quick script executions, without having to create a temporary file first.
scriptId | path name, if available, or something helpful |
scriptCode | The script to execute |
errLoc | offset of erroneous include line, or -1 |
includePath | If a null string (the default), no pre-processing is done. If an empty string, the default script directories are used (script/ in both user and install directory). Otherwise, the given directory is used. |
|
slot |
This is required to allow reading with other program on Windows while output.txt is still open.
filename | new filename. If this is not an absolute path, it will be created in the same directory as output.txt |
bool StelScriptMgr::scriptIsRunning | ( | ) | const |
|
slot |
Note that this is not the same as the rate at which simulation time passes because the script running at normal rate might set the simulation time rate to be non-real time.
r | rate, e.g. 2.0 = script runs at twice the normal rate |
|
slot |