Beispiel #1
0
_MEMBER_FUNCTION_IMPL(xml, constructor)
{
	const char * filename;
	script_getstring(pVM, -1, &filename);

	if(filename)
	{
		CXML * pXML = new CXML();
		String strFileName(filename);
		SharedUtility::RemoveIllegalCharacters(strFileName);
		String strPath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get()));
		pXML->load(strPath);

		if(!pXML || script_setinstance(pVM, pXML, &_CLASS_DECL(xml)) != 0 )
		{
			CLogFile::Print("Failed to load the xml.");
			SAFE_DELETE(pXML);
			script_pushnull(pVM);
			return 1;
		}

		//_SET_RELEASE_HOOK(xml);
		//script_pushbool(pVM, true);
		return 1;
	}

	script_pushnull(pVM);
	return 1;
}
Beispiel #2
0
_MEMBER_FUNCTION_IMPL(Audio, constructor)
{
	bool sqbIsOnlineStream;
	script_getbool(pVM, -3, &sqbIsOnlineStream);
	bool bIsOnlineStream = (sqbIsOnlineStream != 0);

	bool sqbReplay;
	script_getbool(pVM, -2, &sqbReplay);
	bool bReplay = (sqbReplay != 0);

	const char * szSoundName;
	script_getstring(pVM, -1, &szSoundName);

	CAudio * pAudio = new CAudio(szSoundName, bReplay, bIsOnlineStream);

	///SQ metatable = null
	if(!pAudio || !pAudio->Load() || script_setinstance(pVM, pAudio, &_CLASS_DECL(Audio)) != 0)
	{
		CLogFile::Printf("Failed to load audio from file %s",szSoundName);
		SAFE_DELETE(pAudio);
		script_pushnull(pVM);
		return 1;
	}

	g_pClient->GetAudioManager()->Add(pAudio);
	//script_pushbool(pVM, true);
	return 1;
}
Beispiel #3
0
_MEMBER_FUNCTION_IMPL(db, constructor)
{
	const char * filename;
	script_getstring(pVM, -1, &filename);

	if(filename)
	{
		CSQLite * pSQLite = new CSQLite();
		String strFileName(filename);
		SharedUtility::RemoveIllegalCharacters(strFileName);
		String strPath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get()));
		pSQLite->open(strPath);

		if(script_setinstance(pVM, pSQLite, &_CLASS_DECL(db)) == 0)
		{
			return 1;
		}
		else
		{
			CLogFile::Print("Failed to set the database instance.");
			SAFE_DELETE(pSQLite);
		}
	}

	script_pushnull(pVM);
	return 1;
}
CClientScriptManager::CClientScriptManager()
{
	m_pScripting = new CScriptingManager();
	g_pScriptingManager = m_pScripting;
	m_pGUIManager = new CClientScriptGUIManager();
	g_pScriptTimerManager = new CScriptTimerManager();

	// Register the client natives
	RegisterClientNatives(m_pScripting);

	// Register the world natives
	CWorldNatives::Register(m_pScripting);

	// Register the GUI natives
	RegisterGUINatives(m_pScripting);

	// Register the event natives
	CEventNatives::Register(m_pScripting);

	// Register the player natives
	CPlayerNatives::Register(m_pScripting);

	// Register the vehicle natives
	CVehicleNatives::Register(m_pScripting);

	// Register the area natives
	CAreaNatives::Register(m_pScripting);

	// Register the hash natives
	CHashNatives::Register(m_pScripting);

	// Register the script natives
	RegisterScriptNatives(m_pScripting);

	// Register the XML natives
	RegisterXMLNatives(m_pScripting);

	// Register the timer natives
	RegisterTimerNatives(m_pScripting);

	// Register the default constants
	m_pScripting->RegisterDefaultConstants();

	// GUI
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIFont));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIElement));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIWindow));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIText));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIButton));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIEditBox));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIMultiLineEditBox));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUICheckBox));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIImage));
	m_pScripting->RegisterClass(&_CLASS_DECL(GUIProgressBar));
	m_pScripting->RegisterClass(&_CLASS_DECL(Audio));

	#ifdef IVMP_WEBKIT
		//m_pScripting->RegisterClass(&_CLASS_DECL(GUIWebView));
	#endif
}
Beispiel #5
0
void RegisterAudioNatives(CScriptingManager * pScriptingManager)
{
	// GUI
	pScriptingManager->RegisterClass(&_CLASS_DECL(Audio));
}
Beispiel #6
0
void RegisterSQLiteNatives(CScriptingManager * pScriptingManager)
{
	pScriptingManager->RegisterClass(&_CLASS_DECL(db));
}
Beispiel #7
0
void RegisterXMLNatives(CScriptingManager * pScriptingManager)
{
	pScriptingManager->RegisterClass(&_CLASS_DECL(xml));
}
Beispiel #8
0
void CXMLNatives::Register( CScriptingManager * pScriptingManager )
{
    pScriptingManager->NewClass( &_CLASS_DECL(xml) );
}
Beispiel #9
0
void CTimerNatives::Register( CScriptingManager * pScriptingManager )
{
	pScriptingManager->NewClass( &_CLASS_DECL(timer) );
}
void RegisterTimerNatives(CScriptingManager * pScriptingManager)
{
	pScriptingManager->RegisterClass(&_CLASS_DECL(timer));
}