Introduction
FlatRedBall supports wildcard files in the .gluj file. At the time of this writing wildcard files are only supported in Global Content, but future versions of FlatRedBall may expand this.
Wildcard enable the automatic adding of files to your FlatRedBall project based in their location on disk. This can make managing a large number of files much easier than manually managing the files.
Example: Using Wildcards to Add Texture PNG Files
The easiest way to add a Wildcard entry in the FlatRedBall is to first add a single file to your project which has all of the desired settings.
For example, consider the following project which has a single file added to Global Content Files named TextureFile.png:
Currently, wildcard entries must be manually added to the glue project (.gluj). To do this:
- Open the folder location of the project
- Open your game’s .gluj file in a text editor such as Visual Studio Code
- Locate the file entry of the file in your project. It should appear under the GlobalFiles section.
- Change the file’s Name property to be a wildcard file.
- Save the file in the text editor
After you save the file the FlatRedBall Editor displays the file with a wildcard (*) icon to indicate that it is added as a wildcard file.
Now you can add new files to disk and they will automatically appear in the FlatRedBall Editor (assuming they match the wildcard pattern.
Wildcards and Valid Names
Be careful – wildcard files are added automatically even if their name violates the naming convention of FlatRedBall. In other words, normally files cannot contain spaces or dashes, but FlatRedBall will add these files to your project even if the file names contain invalid characters. For example, if you copy and paste a file, Windows automatically appends ” – Copy” to the name of the file, and this will appear in the FlatRedBall Editor.
The code generator will attempt to remove invalid characters when generating the GlobalContent code.
Of course, since characters are either removed (such as spaces) or converted to valid C# property characters (such as underscores), it is possible to have multiple properties with the same name which would result in a compile error. We recommend keeping your file names named as valid C# properties.
Valid Wildcard Patterns
FlatRedBall supports a number of wildcard patterns for adding files to your projects. The following examples explain the possible wildcard patterns:
- “Name”: “GlobalContent/*.png” – Add all files in the GlobalContent folder with the PNG extension
- “Name”: “GlobalContent/*.*” – Add all files in the GlobalContent folder with any extension
- “Name”: “GlobalContent/*” – Add all files in the GlobalContent folder with any extension. Note that this is the same as “Name”: “GlobalContent/*.*”.
- “Name”: “GlobalContent/**/*.png” – Add all files in the GlobalContent folder and any subfolder of GlobalContent with the PNG extension
- “Name”: “GlobalContent/**/*.*” – Add all files in the GlobalContent folder and any subfolder of GlobalContent with any extension