Esempio n. 1
0
void ImagesCollector::collectFromLayer(Layer* layer)
{
  const Sprite* sprite = layer->getSprite();
  int frame = sprite->getCurrentFrame();

  if (!layer->is_readable())
    return;

  if (m_forWrite && !layer->is_writable())
    return;

  switch (layer->getType()) {

    case GFXOBJ_LAYER_IMAGE: {
      if (m_allFrames) {
	for (frame=0; frame<sprite->getTotalFrames(); frame++) {
	  Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
	  if (cel != NULL)
	    collectImage(layer, cel);
	}
      }
      else {
	Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
	if (cel != NULL)
	  collectImage(layer, cel);
      }
      break;
    }

    case GFXOBJ_LAYER_FOLDER: {
      LayerIterator it = static_cast<LayerFolder*>(layer)->get_layer_begin();
      LayerIterator end = static_cast<LayerFolder*>(layer)->get_layer_end();

      for (; it != end; ++it)
	collectFromLayer(*it);

      break;
    }

  }
}
void ImagesCollector::collectFromLayer(Layer* layer, FrameNumber frame)
{
  const Sprite* sprite = layer->sprite();

  if (!layer->isReadable())
    return;

  if (m_forWrite && !layer->isWritable())
    return;

  switch (layer->type()) {

    case ObjectType::LayerImage: {
      if (m_allFrames) {
        for (FrameNumber frame(0); frame<sprite->totalFrames(); ++frame) {
          Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
          if (cel != NULL)
            collectImage(layer, cel);
        }
      }
      else {
        Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
        if (cel != NULL)
          collectImage(layer, cel);
      }
      break;
    }

    case ObjectType::LayerFolder: {
      LayerIterator it = static_cast<LayerFolder*>(layer)->getLayerBegin();
      LayerIterator end = static_cast<LayerFolder*>(layer)->getLayerEnd();

      for (; it != end; ++it)
        collectFromLayer(*it, frame);

      break;
    }

  }
}