Пример #1
0
/**
 * \brief Calls the on_update() method of the menus associated to a context.
 * \param context_index Index of an object with menus.
 */
void LuaContext::menus_on_update(int context_index) {

  const void* context;
  if (lua_type(l, context_index) == LUA_TUSERDATA) {
    ExportableToLuaPtr* userdata = static_cast<ExportableToLuaPtr*>(
        lua_touserdata(l, context_index));
    context = userdata->get();
  }
  else {
    context = lua_topointer(l, context_index);
  }

  for (LuaMenuData& menu: menus) {
    if (menu.context == context) {
      menu_on_update(menu.ref);
    }
  }
}
Пример #2
0
/**
 * @brief Calls the on_update() method of the menus associated to a context.
 * @param context_index Index of an object with menus.
 */
void LuaContext::menus_on_update(int context_index) {

  const void* context;
  if (lua_type(l, context_index) == LUA_TUSERDATA) {
    ExportableToLua** userdata = (ExportableToLua**) lua_touserdata(l, context_index);
    context = *userdata;
  }
  else {
    context = lua_topointer(l, context_index);
  }

  std::list<LuaMenuData>::iterator it;
  for (it = menus.begin(); it != menus.end(); ++it) {
    int menu_ref = it->ref;
    if (it->context == context) {
      menu_on_update(menu_ref);
    }
  }
}