Commit cc153314 authored by Jan Möbius's avatar Jan Möbius

Added a startup scripting dir



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6370 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ed19248a
......@@ -528,7 +528,8 @@ Core::init() {
scenegraphCheckTimer_->start ();
}
QTimer::singleShot(100, this, SLOT(slotCommandLineOpen()));
QTimer::singleShot(100, this, SLOT(slotExecuteAfterStartup()));
}
......
......@@ -418,7 +418,7 @@ private:
private slots:
/// Executed after loading core completly
void slotCommandLineOpen();
void slotExecuteAfterStartup();
private:
std::vector< std::pair < const char* , bool > > commandLineFileNames_;
......
......@@ -85,7 +85,26 @@ void Core::commandLineScript(const char* _filename ) {
commandLineScriptNames_.push_back(_filename);
}
void Core::slotCommandLineOpen() {
void Core::slotExecuteAfterStartup() {
//check if we have scripting support:
bool scriptingSupport = false;
slotPluginExists("scripting",scriptingSupport);
if ( ! scriptingSupport ) {
emit log(LOGERR ,"No scripting support available, please check if we load a scripting plugin .. Skipping script execution on startup");
}
// Collect all script files from the scripting subdirectory and execute them if possible
if ( scriptingSupport ) {
QDir scriptDir = OpenFlipper::Options::scriptDir();
QStringList scriptFiles = scriptDir.entryList(QDir::Files,QDir::Name);
for ( int i = 0 ; i < scriptFiles.size(); ++i )
emit executeFileScript(scriptDir.path() + QDir::separator() + scriptFiles[i]);
}
for ( uint i = 0 ; i < commandLineFileNames_.size() ; ++i ) {
if (commandLineFileNames_[i].second)
loadObject(DATA_POLY_MESH, commandLineFileNames_[i].first);
......@@ -93,17 +112,9 @@ void Core::slotCommandLineOpen() {
loadObject(commandLineFileNames_[i].first);
}
for ( uint i = 0 ; i < commandLineScriptNames_.size() ; ++i ) {
//check if we have scripting support:
bool ok = false;
slotPluginExists("scripting",ok);
if ( ! ok ) {
emit log(LOGERR ,"No scripting support available, please check if we load a scripting plugin");
return;
}
emit executeFileScript(commandLineScriptNames_[i]);
}
if ( scriptingSupport )
for ( uint i = 0 ; i < commandLineScriptNames_.size() ; ++i )
emit executeFileScript(commandLineScriptNames_[i]);
if ( !OpenFlipper::Options::gui() && !OpenFlipper::Options::remoteControl())
exitApplication();
......
......@@ -221,6 +221,14 @@ void Core::setupOptions() {
tempDir.cd("Textures");
OpenFlipper::Options::textureDir(tempDir.absolutePath());
// Set the Path to the Scripts
tempDir = QDir(OpenFlipper::Options::applicationDir());
#ifdef OPENFLIPPER_DATADIR
tempDir.cd(OPENFLIPPER_DATADIR);
#endif
tempDir.cd("Scripts");
OpenFlipper::Options::scriptDir(tempDir.absolutePath());
// Set the Path to the Icons
tempDir = QDir(OpenFlipper::Options::applicationDir());
#ifdef OPENFLIPPER_DATADIR
......
......@@ -64,6 +64,9 @@ static QDir shaderDir_;
/// Stores the Path to the Textures
static QDir textureDir_;
/// Stores the Path to the Scripts
static QDir scriptDir_;
/// Stores the Path to the Icons
static QDir iconDir_;
......@@ -278,6 +281,7 @@ QDir configDir() { return configDir_; }
QDir pluginDir() { return pluginDir_; }
QDir shaderDir() { return shaderDir_; }
QDir textureDir() { return textureDir_; }
QDir scriptDir() { return scriptDir_; }
QDir iconDir() { return iconDir_; }
QDir fontsDir() { return fontsDir_; }
QDir helpDir() { return helpDir_; }
......@@ -290,6 +294,7 @@ QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
QString textureDirStr() { return textureDir_.absolutePath(); }
QString scriptDirStr() { return scriptDir_.absolutePath(); }
QString iconDirStr() { return iconDir_.absolutePath(); }
QString fontsDirStr() { return fontsDir_.absolutePath(); }
QString helpDirStr() { return helpDir_.absolutePath(); }
......@@ -303,9 +308,10 @@ void applicationDir(QDir _dir) { applicationDir_ = _dir; }
void pluginDir(QDir _dir) { pluginDir_ = _dir; }
void shaderDir(QDir _dir) { shaderDir_ = _dir; }
void textureDir(QDir _dir) { textureDir_ = _dir; }
void scriptDir(QDir _dir) { scriptDir_ = _dir; }
void iconDir(QDir _dir) { iconDir_ = _dir; }
void fontsDir(QDir _dir) { fontsDir_ = _dir;}
void helpDir(QDir _dir) { helpDir_ = _dir;}
void helpDir(QDir _dir) { helpDir_ = _dir;}
void configDir(QDir _dir) { configDir_ = _dir; }
void currentDir(QDir _dir) { currentDir_ = _dir; }
void currentScriptDir(QDir _dir) { currentScriptDir_ = _dir; }
......@@ -349,6 +355,15 @@ bool textureDir(QString _dir) {
return false;
}
bool scriptDir(QString _dir) {
QDir tmp(_dir);
if (tmp.exists()) {
scriptDir_ = tmp;
return true;
}
return false;
}
bool iconDir(QString _dir) {
QDir tmp(_dir);
if (tmp.exists()) {
......
......@@ -68,6 +68,10 @@ QDir pluginDir();
DLLEXPORT
QDir textureDir();
/// Returns the Path to the Scripts
DLLEXPORT
QDir scriptDir();
/// Returns the Path to the shaders
DLLEXPORT
QDir shaderDir();
......@@ -96,6 +100,10 @@ QString shaderDirStr();
DLLEXPORT
QString textureDirStr();
/// Returns the Path to the Scripts
DLLEXPORT
QString scriptDirStr();
/// Returns the Path to the Icons
DLLEXPORT
QString iconDirStr();
......@@ -128,6 +136,10 @@ void shaderDir(QDir _dir);
DLLEXPORT
void textureDir(QDir _dir);
/// Sets the Path to the Scripts
DLLEXPORT
void scriptDir( QDir _dir);
/// Sets the Path to the Icons
DLLEXPORT
void iconDir(QDir _dir);
......@@ -156,6 +168,10 @@ bool shaderDir(QString _dir);
DLLEXPORT
bool textureDir(QString _dir);
/// Sets the Path to the Scripts
DLLEXPORT
bool scriptDir(QString _dir);
/// Sets the Path to the Icons
DLLEXPORT
bool iconDir(QString _dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment