Beispiel #1
0
CommandCopyPasteHeightmap::CommandCopyPasteHeightmap(bool copyHeightmap, bool copyTilemap, Heightmap* originalHeightmap, Heightmap* newHeightmap, Image* originalTilemap, Image* newTilemap, const String& tilemapSavedPath)
:	HeightmapModificationCommand(COMMAND_UNDO_REDO)
,	heightmap(copyHeightmap)
,	tilemap(copyTilemap)
{
	commandName = "Heightmap Copy/Paste";

	heightmapUndoFilename = "";
	heightmapRedoFilename = "";
	tilemapUndoImage = NULL;
	tilemapRedoImage = NULL;

	if (copyHeightmap && originalHeightmap && newHeightmap)
	{
		heightmapUndoFilename = SaveHeightmap(originalHeightmap);
		heightmapRedoFilename = SaveHeightmap(newHeightmap);

		updatedRect = GetDifferenceRect(originalHeightmap, newHeightmap);
	}

	if (copyTilemap && originalTilemap && newTilemap)
	{
		tilemapSavedPathname = FileSystem::Instance()->ReplaceExtension(tilemapSavedPath, ".png");;
		tilemapUndoImage = SafeRetain(originalTilemap);
		tilemapRedoImage = SafeRetain(newTilemap);
	}
}
Beispiel #2
0
CommandDrawHeightmap::CommandDrawHeightmap(Heightmap* originalHeightmap, Heightmap* newHeightmap, const Rect& updatedRect)
    :	HeightmapModificationCommand(COMMAND_UNDO_REDO, updatedRect, CommandList::ID_COMMAND_DRAW_HEIGHTMAP)
{
    commandName = "Heightmap Change";

    if (originalHeightmap && newHeightmap)
    {
        undoFilename = SaveHeightmap(originalHeightmap);
        redoFilename = SaveHeightmap(newHeightmap);
    }
}
CommandDrawHeightmap::CommandDrawHeightmap(Heightmap* originalHeightmap, Heightmap* newHeightmap)
:	HeightmapModificationCommand(COMMAND_UNDO_REDO)
{
	commandName = "Heightmap Change";
	redoFilename = "";

	if (originalHeightmap && newHeightmap)
	{
		undoFilename = SaveHeightmap(originalHeightmap);
		redoFilename = SaveHeightmap(newHeightmap);
	}
}
CommandDrawHeightmap::CommandDrawHeightmap()
:	Command(COMMAND_UNDO_REDO)
{
	redoFilename = "";

	LandscapeEditorHeightmap* editor = GetEditor();
	if (editor)
	{
		Heightmap* heightmap;
		editor->GetHeightmap(&heightmap);
		undoFilename = SaveHeightmap(heightmap, "_" + GetRandomString(10));
	}
}
Beispiel #5
0
CommandCopyPasteHeightmap::CommandCopyPasteHeightmap(bool copyHeightmap, bool copyTilemap, Heightmap* originalHeightmap, Heightmap* newHeightmap, Image* originalTilemap, Image* newTilemap, const FilePath& tilemapSavedPath, const Rect& updatedRect)
    :	HeightmapModificationCommand(COMMAND_UNDO_REDO, updatedRect, CommandList::ID_COMMAND_COPY_PASTE_HEIGHTMAP)
    ,	heightmap(copyHeightmap)
    ,	tilemap(copyTilemap)
{
    commandName = "Heightmap Copy/Paste";

    tilemapUndoImage = NULL;
    tilemapRedoImage = NULL;

    if (copyHeightmap && originalHeightmap && newHeightmap)
    {
        heightmapUndoFilename = SaveHeightmap(originalHeightmap);
        heightmapRedoFilename = SaveHeightmap(newHeightmap);
    }

    if (copyTilemap && originalTilemap && newTilemap)
    {
        tilemapSavedPathname = FilePath::CreateWithNewExtension(tilemapSavedPath, ".png");

        tilemapUndoImage = SafeRetain(originalTilemap);
        tilemapRedoImage = SafeRetain(newTilemap);
    }
}
void CommandDrawHeightmap::Execute()
{
	LandscapeEditorHeightmap* editor = GetEditor();
	if (editor == NULL)
	{
		SetState(STATE_INVALID);
		return;
	}

	Heightmap* heightmap;
	editor->GetHeightmap(&heightmap);

	if (redoFilename == "")
	{
		redoFilename = SaveHeightmap(heightmap, "_" + GetRandomString(10));
	}
	else
	{
		
		heightmap->Load(redoFilename);
		editor->UpdateHeightmap(heightmap);
	}
}