From f09ee4d1a3e3922d96d7f125dd1974de8a94f419 Mon Sep 17 00:00:00 2001 From: Darkyenus Date: Fri, 24 Jul 2015 22:46:33 +0200 Subject: [PATCH] Added IgnoreTask --- .../resourcepacker/tasks/FlattenTask.scala | 2 +- .../resourcepacker/tasks/IgnoreTask.scala | 27 +++++++++++++++++++ .../resourcepacker/tasks/package.scala | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/darkyenus/resourcepacker/tasks/IgnoreTask.scala diff --git a/src/darkyenus/resourcepacker/tasks/FlattenTask.scala b/src/darkyenus/resourcepacker/tasks/FlattenTask.scala index 5e0198a..ee07bc2 100644 --- a/src/darkyenus/resourcepacker/tasks/FlattenTask.scala +++ b/src/darkyenus/resourcepacker/tasks/FlattenTask.scala @@ -14,7 +14,7 @@ object FlattenTask extends Task { override def operate(directory: ResourceDirectory): Boolean = { if (directory.flags.contains("flatten")) { flatten(directory) - Log.info("Directory flattened. (" + directory + ")") + Log.info(Name, "Directory flattened. (" + directory + ")") true } else false } diff --git a/src/darkyenus/resourcepacker/tasks/IgnoreTask.scala b/src/darkyenus/resourcepacker/tasks/IgnoreTask.scala new file mode 100644 index 0000000..7b811d0 --- /dev/null +++ b/src/darkyenus/resourcepacker/tasks/IgnoreTask.scala @@ -0,0 +1,27 @@ +package darkyenus.resourcepacker.tasks + +import com.esotericsoftware.minlog.Log +import darkyenus.resourcepacker.{ResourceFile, ResourceDirectory, Task} + +/** + * Removes all files and directories marked with `.ignore.` + * @author Darkyen + */ +object IgnoreTask extends Task { + + override def operate(file: ResourceFile): Boolean = { + if(file.flags.contains("ignore")){ + file.removeFromParent() + Log.info(Name, "File ignored. (" + file + ")") + true + }else false + } + + override def operate(directory: ResourceDirectory): Boolean = { + if(directory.flags.contains("ignore")){ + directory.parent.removeChild(directory) + Log.info(Name, "Directory ignored. (" + directory + ")") + true + }else false + } +} diff --git a/src/darkyenus/resourcepacker/tasks/package.scala b/src/darkyenus/resourcepacker/tasks/package.scala index 43fe509..f9b122e 100644 --- a/src/darkyenus/resourcepacker/tasks/package.scala +++ b/src/darkyenus/resourcepacker/tasks/package.scala @@ -8,5 +8,5 @@ package object tasks { /** * Collection of all tasks from this package in logical order. */ - val DefaultTasks: Seq[Task] = Seq(CreateFontsTask, ConvertModelsTask, FlattenTask, ResizeTask, RasterizeTask, PreBlendTask, PackTask, RemoveEmptyDirectoriesTask) + val DefaultTasks: Seq[Task] = Seq(IgnoreTask, CreateFontsTask, ConvertModelsTask, FlattenTask, ResizeTask, RasterizeTask, PreBlendTask, PackTask, RemoveEmptyDirectoriesTask) }