예제 #1
0
void ScriptContainer::readScripts(const Aurora::GFF3Struct &gff) {
	clearScripts();

	for (size_t i = 0; i < ARRAYSIZE(kScriptNames); i++) {
		const Script script = kScriptNames[i].script;
		const char  *name   = kScriptNames[i].name;

		_scripts[script] = gff.getString(name, _scripts[script]);
	}
}
예제 #2
0
// Simple setting and getting of properties for scripts and the set command.
stError* cUObject::setProperty( const QString& name, const cVariant& value )
{
	changed( TOOLTIP );
	changed_ = true;
	// \rproperty object.serial This integer property contains the serial for this object.
	if ( name == "serial" )
	{
		if ( !value.canCast( cVariant::IntType ) )
		{
			PROPERTY_ERROR( -3, QString( "Invalid integer value: '%1'" ).arg( value.toString() ) );
		}
		setSerial( value.toInt() );
		return 0;
	}

	// \property object.free This boolean property indicates that the object has been freed and is awaiting deletion.
	else
		SET_BOOL_PROPERTY( "free", free )
		// \property object.name This string property contains the name of the object.
	else
		SET_STR_PROPERTY( "name", this->name_ )
		// \property object.pos This property is a <object id="coord">coord</object> object (Python) or a string representation (Show/Set) of the objects position.
	else if ( name == "pos" )
	{
		Coord pos;
		if ( !parseCoordinates( value.toString(), pos ) )
			PROPERTY_ERROR( -3, QString( "Invalid coordinate value: '%1'" ).arg( value.toString() ) )
			moveTo( pos );
		return 0;
	}

	// \property object.eventlist This string property contains a comma separated list of the names of the scripts that are assigned to this object.
	else if ( name == "scriptlist" )
	{
		clearScripts();
		QStringList list = value.toString().split( "," );
		for ( QStringList::const_iterator it( list.begin() ); it != list.end(); ++it )
		{
			cPythonScript* script = ScriptManager::instance()->find( ( *it ).toLatin1() );
			if ( script )
				addScript( script );
			else
				PROPERTY_ERROR( -3, QString( "Script not found: '%1'" ).arg( *it ) )
		}
		return 0;
	}
예제 #3
0
파일: module.cpp 프로젝트: Hellzed/xoreos
void Module::unloadModule() {
	runScript(kScriptExit, this, _pc);
	handleActions();

	_delayedActions.clear();

	TwoDAReg.clear();

	clearVariables();
	clearScripts();

	_tag.clear();

	_ifo.unload();

	ResMan.undo(_resModule);

	_newModule.clear();
	_hasModule = false;
}
예제 #4
0
파일: module.cpp 프로젝트: jbowtie/xoreos
void Module::unloadModule() {
	runScript(kScriptExit, this, _pc);
	handleActions();

	_eventQueue.clear();
	_delayedActions.clear();

	TwoDAReg.clear();

	clearVariables();
	clearScripts();

	_tag.clear();

	_ifo.unload();

	deindexResources(_resModule);

	_newModule.clear();
	_hasModule = false;
}
예제 #5
0
/**
 * Initializes the script list by creating RS_Script 
 * objects, one for each script that could be found.
 */
void RS_ScriptList::init() {

    RS_DEBUG->print("RS_ScriptList::initScripts");

    clearScripts();
    QStringList list = RS_SYSTEM->getScriptList();
    RS_Script* script;

    for ( QStringList::Iterator it = list.begin();
            it != list.end(); ++it ) {
        RS_DEBUG->print("script: %s:", (*it).toLatin1().data());

        QFileInfo fi(*it);
        script = new RS_Script(fi.baseName(), fi.absoluteFilePath());
        scripts.append(script);

        RS_DEBUG->print("base: %s", fi.baseName().toLatin1().data());
        RS_DEBUG->print("path: %s", fi.absoluteFilePath().toLatin1().data());
    }

    //RS_Script* f = new RS_Script("normal");
    //scripts.append(f);
}
예제 #6
0
/*!
	Removes an event handler from the object
*/
void cUObject::removeScript( const QByteArray& name )
{
	if ( isScriptChainFrozen() )
	{
		return;
	}

	bool found = false;
	if ( scriptChain )
	{
		size_t count = reinterpret_cast<size_t>( scriptChain[0] );

		for ( size_t i = 1; i <= count; ++i )
		{
			if ( scriptChain[i]->name() == name )
			{
				found = true;
				break;
			}
		}
	}

	if ( !found )
	{
		return;
	}

	cPythonScript* event = 0;

	if ( scriptChain )
	{
		size_t count = reinterpret_cast<size_t>( scriptChain[0] );

		if ( count == 1 )
		{
			clearScripts();
		}
		else
		{
			unsigned int pos = 1;

			cPythonScript** newScriptChain = new cPythonScript*[count];
			newScriptChain[0] = reinterpret_cast<cPythonScript*>( count - 1 );

			for ( size_t i = 1; i <= count; ++i )
			{
				if ( scriptChain[i]->name() != name )
				{
					newScriptChain[pos++] = scriptChain[i];
				}
				else
				{
					event = scriptChain[i];
				}
			}

			delete[] scriptChain;
			scriptChain = newScriptChain;
		}
	}

	changed_ = true;

	if ( event && event->canHandleEvent( EVENT_DETACH ) )
	{
		PyObject* args = Py_BuildValue( "(N)", getPyObject() );
		event->callEvent( EVENT_DETACH, args );
		Py_DECREF( args );
	}
}