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() { ...@@ -528,7 +528,8 @@ Core::init() {
scenegraphCheckTimer_->start (); scenegraphCheckTimer_->start ();
} }
QTimer::singleShot(100, this, SLOT(slotCommandLineOpen()));
QTimer::singleShot(100, this, SLOT(slotExecuteAfterStartup()));
} }
......
...@@ -418,7 +418,7 @@ private: ...@@ -418,7 +418,7 @@ private:
private slots: private slots:
/// Executed after loading core completly /// Executed after loading core completly
void slotCommandLineOpen(); void slotExecuteAfterStartup();
private: private:
std::vector< std::pair < const char* , bool > > commandLineFileNames_; std::vector< std::pair < const char* , bool > > commandLineFileNames_;
......
...@@ -85,7 +85,26 @@ void Core::commandLineScript(const char* _filename ) { ...@@ -85,7 +85,26 @@ void Core::commandLineScript(const char* _filename ) {
commandLineScriptNames_.push_back(_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 ) { for ( uint i = 0 ; i < commandLineFileNames_.size() ; ++i ) {
if (commandLineFileNames_[i].second) if (commandLineFileNames_[i].second)
loadObject(DATA_POLY_MESH, commandLineFileNames_[i].first); loadObject(DATA_POLY_MESH, commandLineFileNames_[i].first);
...@@ -93,17 +112,9 @@ void Core::slotCommandLineOpen() { ...@@ -93,17 +112,9 @@ void Core::slotCommandLineOpen() {
loadObject(commandLineFileNames_[i].first); loadObject(commandLineFileNames_[i].first);
} }
for ( uint i = 0 ; i < commandLineScriptNames_.size() ; ++i ) { if ( scriptingSupport )
//check if we have scripting support: for ( uint i = 0 ; i < commandLineScriptNames_.size() ; ++i )
bool ok = false; emit executeFileScript(commandLineScriptNames_[i]);
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 ( !OpenFlipper::Options::gui() && !OpenFlipper::Options::remoteControl()) if ( !OpenFlipper::Options::gui() && !OpenFlipper::Options::remoteControl())
exitApplication(); exitApplication();
......
...@@ -221,6 +221,14 @@ void Core::setupOptions() { ...@@ -221,6 +221,14 @@ void Core::setupOptions() {
tempDir.cd("Textures"); tempDir.cd("Textures");
OpenFlipper::Options::textureDir(tempDir.absolutePath()); 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 // Set the Path to the Icons
tempDir = QDir(OpenFlipper::Options::applicationDir()); tempDir = QDir(OpenFlipper::Options::applicationDir());
#ifdef OPENFLIPPER_DATADIR #ifdef OPENFLIPPER_DATADIR
......
...@@ -64,6 +64,9 @@ static QDir shaderDir_; ...@@ -64,6 +64,9 @@ static QDir shaderDir_;
/// Stores the Path to the Textures /// Stores the Path to the Textures
static QDir textureDir_; static QDir textureDir_;
/// Stores the Path to the Scripts
static QDir scriptDir_;
/// Stores the Path to the Icons /// Stores the Path to the Icons
static QDir iconDir_; static QDir iconDir_;
...@@ -278,6 +281,7 @@ QDir configDir() { return configDir_; } ...@@ -278,6 +281,7 @@ QDir configDir() { return configDir_; }
QDir pluginDir() { return pluginDir_; } QDir pluginDir() { return pluginDir_; }
QDir shaderDir() { return shaderDir_; } QDir shaderDir() { return shaderDir_; }
QDir textureDir() { return textureDir_; } QDir textureDir() { return textureDir_; }
QDir scriptDir() { return scriptDir_; }
QDir iconDir() { return iconDir_; } QDir iconDir() { return iconDir_; }
QDir fontsDir() { return fontsDir_; } QDir fontsDir() { return fontsDir_; }
QDir helpDir() { return helpDir_; } QDir helpDir() { return helpDir_; }
...@@ -290,6 +294,7 @@ QString configDirStr() { return configDir_.absolutePath(); } ...@@ -290,6 +294,7 @@ QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); } QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); } QString shaderDirStr() { return shaderDir_.absolutePath(); }
QString textureDirStr() { return textureDir_.absolutePath(); } QString textureDirStr() { return textureDir_.absolutePath(); }
QString scriptDirStr() { return scriptDir_.absolutePath(); }
QString iconDirStr() { return iconDir_.absolutePath(); } QString iconDirStr() { return iconDir_.absolutePath(); }
QString fontsDirStr() { return fontsDir_.absolutePath(); } QString fontsDirStr() { return fontsDir_.absolutePath(); }
QString helpDirStr() { return helpDir_.absolutePath(); } QString helpDirStr() { return helpDir_.absolutePath(); }
...@@ -303,9 +308,10 @@ void applicationDir(QDir _dir) { applicationDir_ = _dir; } ...@@ -303,9 +308,10 @@ void applicationDir(QDir _dir) { applicationDir_ = _dir; }
void pluginDir(QDir _dir) { pluginDir_ = _dir; } void pluginDir(QDir _dir) { pluginDir_ = _dir; }
void shaderDir(QDir _dir) { shaderDir_ = _dir; } void shaderDir(QDir _dir) { shaderDir_ = _dir; }
void textureDir(QDir _dir) { textureDir_ = _dir; } void textureDir(QDir _dir) { textureDir_ = _dir; }
void scriptDir(QDir _dir) { scriptDir_ = _dir; }
void iconDir(QDir _dir) { iconDir_ = _dir; } void iconDir(QDir _dir) { iconDir_ = _dir; }
void fontsDir(QDir _dir) { fontsDir_ = _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 configDir(QDir _dir) { configDir_ = _dir; }
void currentDir(QDir _dir) { currentDir_ = _dir; } void currentDir(QDir _dir) { currentDir_ = _dir; }
void currentScriptDir(QDir _dir) { currentScriptDir_ = _dir; } void currentScriptDir(QDir _dir) { currentScriptDir_ = _dir; }
...@@ -349,6 +355,15 @@ bool textureDir(QString _dir) { ...@@ -349,6 +355,15 @@ bool textureDir(QString _dir) {
return false; return false;
} }
bool scriptDir(QString _dir) {
QDir tmp(_dir);
if (tmp.exists()) {
scriptDir_ = tmp;
return true;
}
return false;
}
bool iconDir(QString _dir) { bool iconDir(QString _dir) {
QDir tmp(_dir); QDir tmp(_dir);
if (tmp.exists()) { if (tmp.exists()) {
......
...@@ -68,6 +68,10 @@ QDir pluginDir(); ...@@ -68,6 +68,10 @@ QDir pluginDir();
DLLEXPORT DLLEXPORT
QDir textureDir(); QDir textureDir();
/// Returns the Path to the Scripts
DLLEXPORT
QDir scriptDir();
/// Returns the Path to the shaders /// Returns the Path to the shaders
DLLEXPORT DLLEXPORT
QDir shaderDir(); QDir shaderDir();
...@@ -96,6 +100,10 @@ QString shaderDirStr(); ...@@ -96,6 +100,10 @@ QString shaderDirStr();
DLLEXPORT DLLEXPORT
QString textureDirStr(); QString textureDirStr();
/// Returns the Path to the Scripts
DLLEXPORT
QString scriptDirStr();
/// Returns the Path to the Icons /// Returns the Path to the Icons
DLLEXPORT DLLEXPORT
QString iconDirStr(); QString iconDirStr();
...@@ -128,6 +136,10 @@ void shaderDir(QDir _dir); ...@@ -128,6 +136,10 @@ void shaderDir(QDir _dir);
DLLEXPORT DLLEXPORT
void textureDir(QDir _dir); void textureDir(QDir _dir);
/// Sets the Path to the Scripts
DLLEXPORT
void scriptDir( QDir _dir);
/// Sets the Path to the Icons /// Sets the Path to the Icons
DLLEXPORT DLLEXPORT
void iconDir(QDir _dir); void iconDir(QDir _dir);
...@@ -156,6 +168,10 @@ bool shaderDir(QString _dir); ...@@ -156,6 +168,10 @@ bool shaderDir(QString _dir);
DLLEXPORT DLLEXPORT
bool textureDir(QString _dir); bool textureDir(QString _dir);
/// Sets the Path to the Scripts
DLLEXPORT
bool scriptDir(QString _dir);
/// Sets the Path to the Icons /// Sets the Path to the Icons
DLLEXPORT DLLEXPORT
bool iconDir(QString _dir); 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