void UIScript::ini()
{
	LOG_ENTER;

	CEGUI::System::getSingleton().executeScriptFile("globlefunc.lua");

	CEGUI::LuaScriptModule * ls = (CEGUI::LuaScriptModule*)CEGUI::System::getSingleton().getScriptingModule();
	lua_State* L = ls->getLuaState();
	lua_tinker::def(L, "GetWheelName", lua_GetWheelName);
	lua_tinker::def(L, "GetWheelNum", lua_GetWheelNum);
	lua_tinker::def(L, "GetStatus", lua_GetStatus);
	lua_tinker::def(L, "SetStatus", lua_SetStatus);
	lua_tinker::def(L, "OnFindEnd", lua_OnFindEnd);
	lua_tinker::def(L, "GetCustomValue", lua_GetCustomValue);
	lua_tinker::def(L, "SetCustomValue", lua_SetCustomValue);
	lua_tinker::def(L, "GetFindDir", lua_GetFindDir);
	lua_tinker::def(L, "GetFindName", lua_GetFindName);
	lua_tinker::def(L, "GetFindNum", lua_GetFindNum);
	lua_tinker::def(L, "PlayMusic", lua_PlayMusic);
	lua_tinker::def(L, "RandomShuffleMusic", lua_RandomShuffleMusic);
	lua_tinker::def(L, "SetMusicVolume", lua_SetMusicVolume);
	lua_tinker::def(L, "IsPlaying", lua_IsPlaying);
	
	LOG_LEAVE;
}
void UIScript::heartbeat(double elapsed)
{
	CEGUI::LuaScriptModule * ls = (CEGUI::LuaScriptModule*)CEGUI::System::getSingleton().getScriptingModule();
	lua_State* L = ls->getLuaState();

	lua_tinker::call<double>(L, "UIScript_Heartbeat", elapsed);
}
void GUIManager::initialise()
{
    guiRenderer = &CEGUI::OgreRenderer::bootstrapSystem();
    CEGUI::LuaScriptModule *scriptModule = &CEGUI::LuaScriptModule::create();
    scriptModule->setDefaultResourceGroup("Scripts");
    luaState = scriptModule->getLuaState();
    tolua_Interface_open(luaState);
    guiSystem = CEGUI::System::getSingletonPtr();
    guiSystem->setScriptingModule(scriptModule);
    guiSystem->executeScriptFile("init.lua");
}