void NeoScript::Init(lua_State* lua_State)
{
	if (lua_State != 0)
		setLuaState(lua_State);
	else
	{
		//code copy from cegui, manually initialize, cause they have bug i can't fix
		static const luaL_Reg lualibs[] =
		{
		{ "", luaopen_base },
		{
		LUA_LOADLIBNAME, luaopen_package },
		{ LUA_TABLIBNAME, luaopen_table },
		{
		LUA_IOLIBNAME, luaopen_io },
		{ LUA_OSLIBNAME, luaopen_os },
		{
		LUA_STRLIBNAME, luaopen_string },
		{ LUA_MATHLIBNAME, luaopen_math },
		{ 0, 0 } };

		// create a lua state
		lua_S = luaL_newstate();

		// init all standard libraries
		const luaL_Reg *lib = lualibs;
		for (; lib->func; lib++)
		{
			lua_pushcfunction(lua_S, lib->func);
			lua_pushstring(lua_S, lib->name);
			lua_call(lua_S, 1, 0);
		}
		createExtraBindings();
	}
}
Beispiel #2
0
 Rocket::Core::Context* RenderSystemWrapper::createContext(const std::string& name, unsigned int width, unsigned int height)
 {
   if(!mInitialized) {
     mInitialized = true;
     setUpInterfaces(width, height);
     Rocket::Core::Initialise();
     Rocket::Controls::Initialise();
     if(mLuaState) {
       setLuaState(mLuaState);
     }
   }
   mContexts[name] = Rocket::Core::CreateContext(name.c_str(), Rocket::Core::Vector2i(width, height));
   mEngine->fireEvent(RocketContextEvent(RocketContextEvent::CREATE, name));
   LOG(INFO) << "Created context " << name << ", initial size: " << width << "x" << height;
   return mContexts[name];
 }
Beispiel #3
0
  void RocketUIManager::setUp()
  {
    if(mIsSetUp)
      return;

    EngineSystem* render = mEngine->getSystem("render");
    if(render == 0) {
      return;
    }

    const std::string type = render->getSystemInfo().get("type", "unknown");
    bool initialized = false;
#ifdef OGRE_INTERFACE
    if(type == "ogre") {
      LOG(INFO) << "Initialize for render system ogre3d";
      mRenderSystemWrapper = new RocketOgreWrapper(mEngine);
      initialized = true;
    }

    setLuaState(mLuaState);
#endif

    if(!initialized) {
      LOG(ERROR) << "Failed to initialize rocket ui manager with the render system of type \"" << type << "\"";
      return;
    }
    // mouse events
    addEventListener(mEngine, MouseEvent::MOUSE_DOWN, &RocketUIManager::handleMouseEvent, -100);
    addEventListener(mEngine, MouseEvent::MOUSE_UP, &RocketUIManager::handleMouseEvent, -100);
    addEventListener(mEngine, MouseEvent::MOUSE_MOVE, &RocketUIManager::handleMouseEvent, -100);
    // keyboard events
    addEventListener(mEngine, KeyboardEvent::KEY_DOWN, &RocketUIManager::handleKeyboardEvent, -100);
    addEventListener(mEngine, KeyboardEvent::KEY_UP, &RocketUIManager::handleKeyboardEvent, -100);
    // text input event
    addEventListener(mEngine, TextInputEvent::INPUT, &RocketUIManager::handleInputEvent, -100);
    mIsSetUp = true;
  }