void lua_player::run_require_slot(std::string file)
{
  try
  {
    QUrl url = player::create_url(file + ".lua", lua_path);

    activate_frame(file, url.toString ().toStdString ());

    QObject::connect(current_activation_frame (), SIGNAL(execution_finished ())
                     , this, SLOT(require_finished ()));

    assert(pending_download_file == 0);
    pending_download_file = new player::url_file(url, this);

    if(!pending_download_file->local())
    {
      QObject::connect(this, SIGNAL(download_lua_signal ()), this
                       , SLOT(download_require ()), Qt::QueuedConnection);
      QObject::connect(pending_download_file, SIGNAL(download_finished_signal()), this
                       , SLOT(download_lua()));
      QObject::connect(pending_download_file, SIGNAL(error_signal(std::string)), this
                       , SLOT(download_error(std::string)));
    }
    else
    {
      QObject::connect(this, SIGNAL(download_lua_signal ()), this
                       , SLOT(download_require ()), Qt::QueuedConnection);
      Q_EMIT download_lua_signal();
    }
  }
  catch(std::exception const& e)
  {
    std::string error = "Error loading file ";
    error += lua_path;
    error += '/';
    error += path;
    error += " with error: ";
    error += e.what();
    ncl_window->error_occurred(error);
  }
}
void lua_player::run_global_scope()
{
  QObject::disconnect(this, SIGNAL (started ()));

  luaL_openlibs(L);

  luabind::open(L);

  luabind::module(L, "ghtv")
  [
   luabind::class_<lua_player>("lua_player")
  ];

  init_sandbox();
  init_canvas();
  init_event();

  start_time = boost::posix_time::microsec_clock::universal_time();

  QObject::connect(this, SIGNAL(resume_current_frame_signal (int)), this
                   , SLOT(resume_current_frame (int)), Qt::QueuedConnection);
  QObject::connect(this, SIGNAL(run_require_signal (std::string)), this
                   , SLOT(run_require_slot (std::string)), Qt::QueuedConnection);

  try
  {
    main_file_url = player::create_url(path, root_path);
    lua_path = main_file_url.path ().toStdString ();

    {
      std::string::reverse_iterator
        iterator = std::find(lua_path.rbegin(), lua_path.rend(), '/')
        , iterator_backslash = std::find(lua_path.rbegin(), lua_path.rend(), '\\');
      iterator = (std::min)(iterator, iterator_backslash);
      if(iterator != lua_path.rend())
        lua_path.erase(boost::prior(iterator.base()), lua_path.end());
      else
      {
        std::string error_msg = "Couldn't create a absolute path from the path for the NCL file: ";
        error_msg += lua_path;
        ncl_window->error_occurred(error_msg);
        return;
      }
    }

    activate_frame(path, main_file_url.toString ().toStdString ());

    QObject::connect(current_activation_frame (), SIGNAL(execution_finished ())
                     , this, SLOT(global_scope_finished ()));
    QObject::connect(this, SIGNAL(signal_all_execution_finished ())
                     , this, SLOT(try_unqueue_events ()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(signal_try_unqueue_event ())
                     , this, SLOT(try_unqueue_event ()), Qt::QueuedConnection);

    assert(pending_download_file == 0);
    pending_download_file = new player::url_file(main_file_url, this);
    if(!pending_download_file->local())
    {
      QObject::connect(this, SIGNAL(download_lua_signal ()), this
                       , SLOT(download_global ()), Qt::QueuedConnection);
      QObject::connect(pending_download_file, SIGNAL(download_finished_signal()), this
                       , SLOT(download_lua()));
      QObject::connect(pending_download_file, SIGNAL(error_signal(std::string)), this
                       , SLOT(download_error(std::string)));
    }
    else
    {
      QObject::connect(this, SIGNAL(download_lua_signal ()), this
                       , SLOT(download_global ()), Qt::QueuedConnection);
      Q_EMIT download_lua_signal();
    }
  }
  catch(std::exception const& e)
  {
    std::string error = "Error loading file ";
    error += root_path;
    error += '/';
    error += path;
    error += " with error: ";
    error += e.what();
    ncl_window->error_occurred(error);
  }
}
예제 #3
0
파일: event.c 프로젝트: apenwarr/ion1
static void activate(WWindow *wwin)
{
	set_current_wswindow(wwin);
	if(WTHING_IS(wwin, WFrame))
		activate_frame((WFrame*)wwin);
}