void LandscapeEditorDrawSystem::SaveTileMaskTexture()
{
	if (!baseLandscape)
	{
		return;
	}

	if (!GetLandscapeProxy()->IsTilemaskChanged())
	{
		return;
	}

	Texture* texture = baseLandscape->GetTexture(Landscape::TEXTURE_TILE_MASK);

	if (texture)
	{
		FilePath texturePathname = baseLandscape->GetTextureName(Landscape::TEXTURE_TILE_MASK);

		if (texturePathname.IsEmpty())
		{
			return;
		}

		texturePathname.ReplaceExtension(".png");

		eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
		eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
		RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
		Image *image = texture->CreateImageFromMemory();
		RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);

		if(image)
		{
			ImageLoader::Save(image, texturePathname);
			SafeRelease(image);
		}

		FilePath descriptorPathname = TextureDescriptor::GetDescriptorPathname(texturePathname);
		TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(descriptorPathname);
		if(!descriptor)
		{
			descriptor = new TextureDescriptor();
			descriptor->pathname = descriptorPathname;
			descriptor->Save();
		}

		SafeRelease(descriptor);

		GetLandscapeProxy()->ResetTilemaskChanged();
	}
}
Ejemplo n.º 2
0
void CustomColorsSystem::SaveTexture(const DAVA::FilePath &filePath)
{
	if(filePath.IsEmpty())
		return;

	Sprite* customColorsSprite = drawSystem->GetCustomColorsProxy()->GetSprite();
	Texture* customColorsTexture = customColorsSprite->GetTexture();

	Image* image = customColorsTexture->CreateImageFromMemory(RenderState::RENDERSTATE_2D_BLEND);
    ImageSystem::Instance()->Save(filePath, image);
	SafeRelease(image);

	StoreSaveFileName(filePath);
	drawSystem->GetCustomColorsProxy()->ResetChanges();
}
void LandscapeEditorHeightmap::CreateCopyPasteUndo()
{
	if (oldHeightmap && oldTilemap)
	{
		workingLandscape->UpdateFullTiledTexture();
		Texture* texture = tilemaskTexture;
		Image* image = texture->CreateImageFromMemory();

		CommandsManager::Instance()->ExecuteAndRelease(new CommandCopyPasteHeightmap(currentTool->copyHeightmap,
																					 currentTool->copyTilemask,
																					 oldHeightmap,
																					 GetHeightmap(),
																					 oldTilemap,
																					 image,
																					 tilemaskPathname));
		SafeRelease(oldHeightmap);
		SafeRelease(oldTilemap);
		SafeRelease(image);
	}
}