00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef GLUONENGINE_SCRIPTINGCOMPONENT_H 00021 #define GLUONENGINE_SCRIPTINGCOMPONENT_H 00022 00023 #include <engine/gluon_engine_export.h> 00024 #include <engine/component.h> 00025 00026 #include "scriptingasset.h" 00027 00028 class QScriptValue; 00029 namespace GluonEngine 00030 { 00031 class GLUON_ENGINE_EXPORT ScriptingComponent : public Component 00032 { 00033 Q_OBJECT 00034 GLUON_OBJECT( GluonEngine::ScriptingComponent ) 00035 Q_INTERFACES( GluonEngine::Component ) 00036 00037 Q_PROPERTY( GluonEngine::ScriptingAsset* script READ script WRITE setScript ) 00038 public: 00039 Q_INVOKABLE ScriptingComponent( QObject* parent = 0 ); 00040 ScriptingComponent( const ScriptingComponent& other ); 00041 virtual ~ScriptingComponent(); 00042 00043 virtual QString category() const; 00044 00045 virtual void initialize(); 00046 virtual void start(); 00047 virtual void update( int elapsedMilliseconds ); 00048 virtual void draw( int timeLapse = 0 ); 00049 virtual void stop(); 00050 virtual void cleanup(); 00051 00052 ScriptingAsset* script() const; 00053 public Q_SLOTS: 00054 void setScript( GluonEngine::ScriptingAsset* newAsset ); 00055 void scriptAssetUpdated(); 00056 00057 QScriptValue scriptObject(); 00058 00059 private: 00060 class ScriptingComponentPrivate; 00061 QSharedDataPointer<ScriptingComponentPrivate> d; 00062 }; 00063 } 00064 00065 Q_DECLARE_METATYPE( GluonEngine::ScriptingComponent ) 00066 Q_DECLARE_METATYPE( GluonEngine::ScriptingComponent* ) 00067 00068 #endif // GLUONENGINE_SCRIPTINGCOMPONENT_H