mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
fixed some bugs in the T4 file
This commit is contained in:
parent
5a2508550d
commit
65cf0df366
@ -20,29 +20,28 @@ namespace Nez
|
|||||||
// loop through all of our sourceFolders
|
// loop through all of our sourceFolders
|
||||||
foreach( var sourceFolder in sourceFolders )
|
foreach( var sourceFolder in sourceFolders )
|
||||||
{
|
{
|
||||||
var directories = Directory.GetDirectories( sourceFolder );
|
WriteLine( $"\t\t// folder: {sourceFolder}" );
|
||||||
|
|
||||||
|
// handle any files in the root sourceFolder
|
||||||
|
printContentFiles( sourceFolder, 2, sourceFolder );
|
||||||
|
|
||||||
// loop through all the directories in our sourceFolder
|
// loop through all the directories in our sourceFolder
|
||||||
|
var directories = Directory.GetDirectories( sourceFolder );
|
||||||
foreach( var dir in directories )
|
foreach( var dir in directories )
|
||||||
{
|
{
|
||||||
var dirName = new DirectoryInfo( dir ).Name.ToLower();
|
var dirName = new DirectoryInfo( dir ).Name.ToLower();
|
||||||
if( dirName == "bin" || dirName == "obj" || dirName == "content" )
|
if( dirName == "bin" || dirName == "obj" || dirName == "content" )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// dont delve into directories that don't contan xnb files
|
// dont delve into directories that don't contan xnb files if this is the CompiledContent folder
|
||||||
var xnbFiles = Directory.GetFiles( dir, "*.xnb", SearchOption.AllDirectories );
|
if( !shouldTraverseSubfolders( dir ) )
|
||||||
if( xnbFiles.Length == 0 )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// start off the recursive directory printing
|
// start off the recursive directory printing
|
||||||
printDirectoryClass( dir, 2, sourceFolder );
|
printDirectoryClass( dir, 2, sourceFolder );
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle any files in the root sourceFolder
|
|
||||||
printContentFiles( sourceFolder, 2, sourceFolder );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +61,16 @@ namespace Nez
|
|||||||
"throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
|
"throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool shouldTraverseSubfolders( string path )
|
||||||
|
{
|
||||||
|
if( !path.Contains( "/bin/" ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Directory.GetFiles( path, "*.xnb", SearchOption.AllDirectories ).Length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
// recursively creates a class for each directory
|
// recursively creates a class for each directory
|
||||||
void printDirectoryClass( string dir, int depth, string sourceFolder )
|
void printDirectoryClass( string dir, int depth, string sourceFolder )
|
||||||
{
|
{
|
||||||
@ -93,7 +102,14 @@ namespace Nez
|
|||||||
// clear out all of the path up to the sourceFolder so we get just the relative path to the Content folder
|
// clear out all of the path up to the sourceFolder so we get just the relative path to the Content folder
|
||||||
var finalPath = file.Substring( file.IndexOf( sourceFolder ) + sourceFolder.Length );
|
var finalPath = file.Substring( file.IndexOf( sourceFolder ) + sourceFolder.Length );
|
||||||
var fileInfo = new FileInfo( file );
|
var fileInfo = new FileInfo( file );
|
||||||
var fileName = fileInfo.Name.Replace( ".xnb", string.Empty );
|
var fileName = fileInfo.Name;
|
||||||
|
|
||||||
|
// clean the extension
|
||||||
|
foreach( var extension in fileExtensionsToCopy )
|
||||||
|
{
|
||||||
|
fileName = fileName.Replace( extension, string.Empty );
|
||||||
|
}
|
||||||
|
|
||||||
var className = generateClassName( fileName, false );
|
var className = generateClassName( fileName, false );
|
||||||
|
|
||||||
if( finalPath[0] == '/' || finalPath[0] == '\\' )
|
if( finalPath[0] == '/' || finalPath[0] == '\\' )
|
||||||
@ -105,6 +121,11 @@ namespace Nez
|
|||||||
|
|
||||||
WriteLine( "{0}public const string {1} = @\"{2}\";", firstIndent, className, finalPath );
|
WriteLine( "{0}public const string {1} = @\"{2}\";", firstIndent, className, finalPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( files.Count() > 0 )
|
||||||
|
{
|
||||||
|
WriteLine( "" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user