From 525275f9b299ff5aa0d8fcc35e754814020bd12b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 8 Oct 2019 19:27:42 +0200 Subject: [PATCH] document the config --- Contentless/Config.cs | 13 +++++++++++++ Contentless/Program.cs | 6 ++++-- README.md | 16 ++++++++++++++-- Test/Content/Content.mgcb | 6 ------ Test/Content/Contentless.json | 3 ++- 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 Contentless/Config.cs diff --git a/Contentless/Config.cs b/Contentless/Config.cs new file mode 100644 index 0000000..734e76b --- /dev/null +++ b/Contentless/Config.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Contentless { + public class Config { + + [JsonProperty(PropertyName = "exclude")] + public string[] ExcludedFiles = {"bin/", "obj/"}; + + [JsonProperty(PropertyName = "logSkipped")] + public bool LogSkipped = true; + + } +} \ No newline at end of file diff --git a/Contentless/Program.cs b/Contentless/Program.cs index 2f9d991..bd28dfb 100644 --- a/Contentless/Program.cs +++ b/Contentless/Program.cs @@ -69,13 +69,15 @@ namespace Contentless { // is the file in an excluded directory? if (excluded.Any(e => e.IsMatch(relative))) { - Console.WriteLine($"Skipping excluded file {relative}"); + if (config.LogSkipped) + Console.WriteLine($"Skipping excluded file {relative}"); continue; } // is the file already in the content file? if (HasEntry(content, relative)) { - Console.WriteLine($"Skipping file {relative} as it is already part of the content file"); + if (config.LogSkipped) + Console.WriteLine($"Skipping file {relative} as it is already part of the content file"); continue; } diff --git a/README.md b/README.md index 342059a..bc8141c 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,22 @@ Next, add Contentless to your build process by adding the following task to your ``` -Contentless will now automatically add any content files from your `Content` directory and subdirectories (excluding `bin` and `obj`) to your `Content.mgcb` file if they haven't already been added either manually or by Contentless. No existing items' configurations will be overridden, so you can still use the Content Pipeline tool to modify any settings as well. +Contentless will now automatically add any content files from your `Content` directory and subdirectories to your `Content.mgcb` file if they haven't already been added either manually or by Contentless. No existing items' configurations will be overridden, so you can still use the Content Pipeline tool to modify any settings as well. + +# Configuring +To add a configuration file to Contentless, simply create a file named `Contentless.json` in the same directory as your `Content.mgcb` file. You can use the config to change several options. For reference, here is a configuration file with the default values that are used if no config is supplied: +```json +{ + "exclude": [ + "obj/", + "bin/" + ], + "logSkipped": true +} +``` # What it does -When running Contentless and supplying the location of a MonoGame Content Pipeline project (`Content.mgcb`), it scans all of the files in the project's directory as well as its subdirectories (excluding `bin` and `obj`). For each file, it checks if the `Content.mgcb` file already contains any references to that file. If no references are found, then a new reference to the file is added. +When running Contentless and supplying the location of a MonoGame Content Pipeline project (`Content.mgcb`), it scans all of the files in the project's directory as well as its subdirectories. For each file, it checks if the `Content.mgcb` file already contains any references to that file. If no references are found, then a new reference to the file is added. Contentless figures out which importer and processor to register for any given file by generating a list of all of the importers and processors that are available, both inside of MonoGame, and inside of References added to the `Content.mgcb` file. This process is similar to what occurs when adding an existing file through MonoGame's Content Pipeline tool. If Contentless sets the wrong importer or processor for any file, the user can simply open `Content.mgcb` in MonoGame's Content Pipeline tool and edit it manually. diff --git a/Test/Content/Content.mgcb b/Test/Content/Content.mgcb index e34014a..05e810d 100644 --- a/Test/Content/Content.mgcb +++ b/Test/Content/Content.mgcb @@ -64,9 +64,3 @@ /importer:TiledMapTilesetImporter /processor:TiledMapTilesetProcessor /build:Tiled/Tileset.tsx - -#begin Contentless.json -/importer:TexturePackerJsonImporter -/processor:TexturePackerProcessor -/build:Contentless.json - diff --git a/Test/Content/Contentless.json b/Test/Content/Contentless.json index 00b87f0..e878528 100644 --- a/Test/Content/Contentless.json +++ b/Test/Content/Contentless.json @@ -3,5 +3,6 @@ "obj/", "bin/", "Ex*.png" - ] + ], + "logSkipped": false } \ No newline at end of file