Example #1
0
/**
 * \brief Calls the on_draw() method of the menus associated to a context.
 * \param context_index Index of an object with menus.
 * \param dst_surface The destination surface to draw.
 */
void LuaContext::menus_on_draw(int context_index, const SurfacePtr& dst_surface) {

  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_draw(menu.ref, dst_surface);
    }
  }
}
Example #2
0
/**
 * @brief Calls the on_draw() method of the menus associated to a context.
 * @param context_index Index of an object with menus.
 * @param dst_surface The destination surface to draw.
 */
void LuaContext::menus_on_draw(int context_index, Surface& dst_surface) {

  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_draw(menu_ref, dst_surface);
    }
  }
}