mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
Merge changes from upstream
This commit is contained in:
commit
5b31d71eaa
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@ -15,8 +15,8 @@
|
||||
"osx":{
|
||||
"env": {
|
||||
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
@ -28,7 +28,7 @@
|
||||
"osx":{
|
||||
"env": {
|
||||
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -38,12 +38,7 @@
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
|
||||
"cwd": "${workspaceFolder}/project_name",
|
||||
"preLaunchTask": "Build (Debug)",
|
||||
"osx":{
|
||||
"env": {
|
||||
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
|
||||
},
|
||||
}
|
||||
"preLaunchTask": "Build (Debug)"
|
||||
},
|
||||
|
||||
{
|
||||
@ -51,12 +46,7 @@
|
||||
"type": "clr",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"osx":{
|
||||
"env": {
|
||||
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
|
||||
},
|
||||
}
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -10,8 +10,7 @@
|
||||
"files.exclude": {
|
||||
"**/.[^v]*": true, // hide any files that start with a '.' but keep the .vscode folder
|
||||
".vs": true, // Visual Studio settings
|
||||
"getFNA.sh": true,
|
||||
"getFNA.ps1": true,
|
||||
"getFNA.*": true,
|
||||
"imgui.ini": true,
|
||||
"MonoGameContent.targets": true,
|
||||
"**/obj": true,
|
||||
|
||||
47
.vscode/tasks.json
vendored
47
.vscode/tasks.json
vendored
@ -49,7 +49,6 @@
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": "$msCompile",
|
||||
"dependsOn": "Build Content",
|
||||
},
|
||||
|
||||
{
|
||||
@ -77,7 +76,6 @@
|
||||
"command": "start",
|
||||
"args": [
|
||||
"/wait",
|
||||
"${workspaceFolder}/project_name/bin/Debug/project_name.exe",
|
||||
"${workspaceFolder}/project_name/bin/Debug/project_name.exe"
|
||||
]
|
||||
},
|
||||
@ -96,7 +94,6 @@
|
||||
"command": "start",
|
||||
"args": [
|
||||
"/wait",
|
||||
"${workspaceFolder}/project_name/bin/Release/project_name.exe",
|
||||
"${workspaceFolder}/project_name/bin/Release/project_name.exe"
|
||||
]
|
||||
},
|
||||
@ -120,51 +117,7 @@
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build Content",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"command": "msbuild /t:BuildContent",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/project_name"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Force Build Content",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"osx": {
|
||||
"command": "mono /Applications/Pipeline.app/Contents/MonoBundle/MGCB.exe /@:Content.mgcb -r",
|
||||
},
|
||||
"windows": {
|
||||
"command":"C:/Program Files (x86)/MSBuild/MonoGame/v3.0/Tools/MGCB.exe",
|
||||
"args": [
|
||||
"/@:Content.mgcb",
|
||||
"-r"
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/project_name/CompiledContent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Open Pipeline Tool",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"osx": {
|
||||
"command": "export MONOGAME_PIPELINE_PROJECT=${workspaceFolder}/project_name/CompiledContent/Content.mgcb && /Applications/Pipeline.app/Contents/MacOS/Pipeline"
|
||||
},
|
||||
"windows": {
|
||||
"command": "${workspaceFolder}/project_name/CompiledContent/Content.mgcb"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Process T4 Templates",
|
||||
"type": "shell",
|
||||
|
||||
@ -10,13 +10,13 @@ Start new FNA projects with Nez quickly and easily with handy setup scripts, a v
|
||||
|
||||
|
||||
## Prerequisites ##
|
||||
- [Visual Studio Code](https://code.visualstudio.com) or [Visual Studio](https://visualstudio.microsoft.com/) (recommended to use Visual Studio Code because it has some custom tasks but either will work fine.)
|
||||
- [Visual Studio Code](https://code.visualstudio.com) or [Visual Studio](https://visualstudio.microsoft.com/) (recommended to use Visual Studio Code because it has some custom tasks but either will work fine)
|
||||
- [Mono Debugger Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) (required for macOS debugging)
|
||||
- [MonoGame](http://www.monogame.net/downloads/) (required for compiling content with the Pipeline tool)
|
||||
- (optional) [.NET Core](https://dotnet.microsoft.com/download) (required for compiling T4 templates)
|
||||
- (optional) [Microsoft DirectX SDK (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=6812) (required for building effects, [you can use Wine to run this](https://github.com/AndrewRussellNet/FNA-Template#linuxmacos-installing-the-directx-sdk-on-wine))
|
||||
- (windows only) [7zip](https://www.7-zip.org) (if intending to use fnalibs, the filetype is unsupported for windows and requires 7zip to be installed to decompress/unzip)
|
||||
- (windows only) [Build tools for Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)(these build tools are required for all Visual Studio Code build tasks. if you intend to use the full Visual Studio, these are already included. be sure to include .NET Core Build Tools in the installation)
|
||||
- (windows only) [Build tools for Visua Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)(these build tools are required for all Visual Studio Code build tasks. if you intend to use the full Visual Studio, these are already included. be sure to include .NET Core Build Tools in the installation)
|
||||
|
||||
|
||||
## Setup Instructions ##
|
||||
@ -26,11 +26,11 @@ Start new FNA projects with Nez quickly and easily with handy setup scripts, a v
|
||||
|
||||
That's it! Now you're ready to build and run the base project. If you get missing DLL errors (pointing at SDL) when running in Visual Studio copy the FNA libs into your `/usr/local/lib` folder. With Visual Studio Code, `DYLD_LIBRARY_PATH` is set automatically so it won't run into the DLL not found error. Nez is setup as a submodule so you can update it in the normal fashion.
|
||||
|
||||
When developing, raw content (files not processed by the Pipeline tool) should be placed in the `Content` folder and anything that needs processing should go in the `CompiledContent` folder and added to the Pipeline tool.
|
||||
When developing, raw content (files not processed by the Pipeline tool) should be placed in the `Content` folders subfolders and anything that needs processing should go in the `CompiledContent` folder and added to the Pipeline tool.
|
||||
|
||||
The setup process will also init a git repo for you with Nez added as a submodule.
|
||||
|
||||
If you want to see the output of `Debug.*` calls in the VS Code Debug Console, you have to install a listener by adding this somewhere in your code (Game1 by default has one for you): `System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(System.Console.Out));`
|
||||
If you want to see the output of `Debug.*` calls in the VS Code Debug Console, you have to install a listener by adding this somewhere in your code (Game1 by default has one for you): `System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(System.Console.Out));` Pixel art games should also uncomment a line in the Game1.cs file setting the `FNA_OPENGL_BACKBUFFER_SCALE_NEAREST` environment variable when using FNA.
|
||||
|
||||
|
||||
## Build Tasks ##
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#-------------------------------- References --------------------------------#
|
||||
|
||||
/reference:../../Nez/Nez.PipelineImporter/bin/Debug/Ionic.ZLib.dll
|
||||
/reference:../../Nez/Nez.PipelineImporter/bin/Debug/Newtonsoft.Json.dll
|
||||
/reference:../../Nez/Nez.PipelineImporter/bin/Debug/Nez.PipelineImporter.dll
|
||||
/reference:../../Nez/Nez.PipelineImporter/bin/Debug/Nez.dll
|
||||
|
||||
0
project_name/Content/Audio/.keep
Normal file
0
project_name/Content/Audio/.keep
Normal file
0
project_name/Content/Fonts/.keep
Normal file
0
project_name/Content/Fonts/.keep
Normal file
0
project_name/Content/Materials/.keep
Normal file
0
project_name/Content/Materials/.keep
Normal file
0
project_name/Content/Shaders/.keep
Normal file
0
project_name/Content/Shaders/.keep
Normal file
0
project_name/Content/Textures/.keep
Normal file
0
project_name/Content/Textures/.keep
Normal file
0
project_name/Content/Tilemaps/.keep
Normal file
0
project_name/Content/Tilemaps/.keep
Normal file
@ -1,27 +1,25 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Nez;
|
||||
using Nez.ImGuiTools;
|
||||
using Nez.Sprites;
|
||||
|
||||
namespace project_name
|
||||
{
|
||||
public class DefaultScene : Scene
|
||||
public class DefaultScene : Scene
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetDesignResolution(Screen.Width, Screen.Height, Scene.SceneResolutionPolicy.None);
|
||||
|
||||
AddRenderer(new DefaultRenderer());
|
||||
|
||||
CreateEntity("demo imgui draw commands")
|
||||
.SetPosition(new Vector2(150, 150))
|
||||
.AddComponent<DemoComponent>()
|
||||
.AddComponent(new PrototypeSprite(20, 20));
|
||||
|
||||
var Logo = Content.Load<Texture2D>("nez-logo-black");
|
||||
var logo = Content.Load<Texture2D>("nez-logo-black");
|
||||
CreateEntity("logo")
|
||||
.SetPosition(Screen.Center)
|
||||
.AddComponent(new Nez.Sprites.Sprite(Logo));
|
||||
.AddComponent(new SpriteRenderer(logo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,17 +11,13 @@ namespace project_name
|
||||
public override void OnAddedToEntity()
|
||||
{
|
||||
// register with the ImGuiMangaer letting it know we want to render some IMGUI
|
||||
#if DEBUG
|
||||
Core.GetGlobalManager<ImGuiManager>().RegisterDrawCommand(ImGuiDraw);
|
||||
#endif
|
||||
Core.GetGlobalManager<ImGuiManager>()?.RegisterDrawCommand(ImGuiDraw);
|
||||
}
|
||||
|
||||
public override void OnRemovedFromEntity()
|
||||
{
|
||||
// remove ourselves when we are removed from the Scene
|
||||
#if DEBUG
|
||||
Core.GetGlobalManager<ImGuiManager>().UnregisterDrawCommand(ImGuiDraw);
|
||||
#endif
|
||||
Core.GetGlobalManager<ImGuiManager>()?.UnregisterDrawCommand(ImGuiDraw);
|
||||
}
|
||||
|
||||
void ImGuiDraw()
|
||||
|
||||
@ -6,21 +6,27 @@ namespace project_name
|
||||
class Game1 : Core
|
||||
{
|
||||
public Game1() : base()
|
||||
{}
|
||||
{
|
||||
// uncomment this line for scaled pixel art games
|
||||
// System.Environment.SetEnvironmentVariable("FNA_OPENGL_BACKBUFFER_SCALE_NEAREST", "1");
|
||||
}
|
||||
|
||||
override protected void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
|
||||
Scene = new DefaultScene();
|
||||
|
||||
#if DEBUG
|
||||
System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(System.Console.Out));
|
||||
|
||||
// render Nez in the imgui window in debug mode
|
||||
// optionally render Nez in an ImGui window
|
||||
var imGuiManager = new ImGuiManager();
|
||||
Core.RegisterGlobalManager(imGuiManager);
|
||||
#endif
|
||||
|
||||
Scene = new DefaultScene();
|
||||
// optionally load up ImGui DLL if not using the above setup so that its command gets loaded in the DebugConsole
|
||||
//System.Reflection.Assembly.Load("Nez.ImGui")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,48 +8,75 @@
|
||||
<#@ import namespace="System.Globalization" #>
|
||||
<#@ import namespace="System.Text.RegularExpressions" #>
|
||||
|
||||
<# var sourceFolders = new string[] { "CompiledContent/bin/DesktopGL", "Content" }; #>
|
||||
|
||||
|
||||
namespace Nez
|
||||
{
|
||||
public static class Content
|
||||
{
|
||||
<#
|
||||
|
||||
// loop through all of our sourceFolders
|
||||
foreach( var sourceFolder in sourceFolders )
|
||||
{
|
||||
WriteLine( $"\t\t// folder: {sourceFolder}" );
|
||||
|
||||
// handle any files in the root sourceFolder
|
||||
PrintContentFiles( sourceFolder, 2, sourceFolder );
|
||||
|
||||
// loop through all the directories in our sourceFolder
|
||||
var directories = Directory.GetDirectories( sourceFolder );
|
||||
foreach( var dir in directories )
|
||||
public static class Nez
|
||||
{
|
||||
var dirName = new DirectoryInfo( dir ).Name.ToLower();
|
||||
if( dirName == "bin" || dirName == "obj" || dirName == "content" )
|
||||
continue;
|
||||
|
||||
// dont delve into directories that don't contan xnb files if this is the CompiledContent folder
|
||||
if( !ShouldTraverseSubfolders( dir ) )
|
||||
continue;
|
||||
|
||||
// start off the recursive directory printing
|
||||
PrintDirectoryClass( dir, 2, sourceFolder );
|
||||
<# PrintNezContent(); #>
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
||||
public static class Audio
|
||||
{
|
||||
<# PrintAudio(); #>
|
||||
}
|
||||
|
||||
public static class Fonts
|
||||
{
|
||||
<# PrintFonts(); #>
|
||||
}
|
||||
|
||||
public static class Materials
|
||||
{
|
||||
<# PrintMaterials(); #>
|
||||
}
|
||||
|
||||
public static class Particles
|
||||
{
|
||||
<# PrintParticles(); #>
|
||||
}
|
||||
|
||||
public static class Shaders
|
||||
{
|
||||
<# PrintShaders(); #>
|
||||
}
|
||||
|
||||
public static class Tilemaps
|
||||
{
|
||||
<# PrintTilemaps(); #>
|
||||
}
|
||||
|
||||
public static class Textures
|
||||
{
|
||||
<# PrintTextures(); #>
|
||||
}
|
||||
|
||||
public static class Atlases
|
||||
{
|
||||
<# PrintAtlases(); #>
|
||||
}
|
||||
|
||||
public static class Compiled
|
||||
{
|
||||
<# PrintCompiledContent(); #>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
<#+
|
||||
// all the valid file extensions we should add to the output file
|
||||
private string[] fileExtensionsToCopy = new string[] { ".xnb", ".png", ".ogg", ".wav", ".fxb" };
|
||||
// all the valid file extensions we should copy for each root folder
|
||||
private string[] validAudioExtensions = new string[] { ".ogg", ".wav" };
|
||||
private string[] validFontExtensions = new string[] { ".fnt" };
|
||||
private string[] validMaterialExtensions = new string[] { ".mat" };
|
||||
private string[] validParticleExtensions = new string[] { ".pex" };
|
||||
private string[] validShaderExtensions = new string[] { ".fxb" };
|
||||
private string[] validTilemapExtensions = new string[] { ".tmx" };
|
||||
private string[] validTextureExtensions = new string[] { ".png", ".jpg" };
|
||||
private string[] validAtlasExtensions = new string[] { ".atlas" };
|
||||
|
||||
// C# reserved keywords
|
||||
private System.Collections.Generic.List<string> keywords = new System.Collections.Generic.List<string>
|
||||
@ -61,101 +88,170 @@ namespace Nez
|
||||
"throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
|
||||
};
|
||||
|
||||
bool ShouldTraverseSubfolders( string path )
|
||||
void PrintNezContent()
|
||||
{
|
||||
if( !path.Contains( "/bin/" ) )
|
||||
PrintSpecialFolderAndSubfolders("../Nez/DefaultContent", new string[] { ".xnb", ".fxb" }, true);
|
||||
}
|
||||
|
||||
void PrintAudio()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Audio", validAudioExtensions);
|
||||
}
|
||||
|
||||
void PrintFonts()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Fonts", validFontExtensions);
|
||||
}
|
||||
|
||||
void PrintMaterials()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Materials", validMaterialExtensions);
|
||||
}
|
||||
|
||||
void PrintParticles()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Particles", validParticleExtensions);
|
||||
}
|
||||
|
||||
void PrintShaders()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Shaders", validShaderExtensions);
|
||||
}
|
||||
|
||||
void PrintTextures()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Textures", validTextureExtensions);
|
||||
}
|
||||
|
||||
void PrintAtlases()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Atlases", validAtlasExtensions);
|
||||
}
|
||||
|
||||
void PrintTilemaps()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("Content/Tilemaps", validTilemapExtensions);
|
||||
}
|
||||
|
||||
void PrintCompiledContent()
|
||||
{
|
||||
PrintSpecialFolderAndSubfolders("CompiledContent/bin/DesktopGL", new string[] { ".xnb" }, true);
|
||||
}
|
||||
|
||||
void PrintSpecialFolderAndSubfolders(string source, string[] validExtensions, bool isCompiledFolder = false)
|
||||
{
|
||||
var stripPath = isCompiledFolder ? source : "";
|
||||
PrintContentFiles(source, 3, stripPath, validExtensions);
|
||||
|
||||
// loop through all the directories in our sourceFolder
|
||||
foreach (var dir in Directory.GetDirectories(source))
|
||||
{
|
||||
return true;
|
||||
var dirName = new DirectoryInfo(dir).Name.ToLower();
|
||||
PrintDirectoryClass(dir, 3, stripPath, validExtensions, isCompiledFolder);
|
||||
}
|
||||
|
||||
return Directory.GetFiles( path, "*.xnb", SearchOption.AllDirectories ).Length > 0;
|
||||
}
|
||||
|
||||
// recursively creates a class for each directory
|
||||
void PrintDirectoryClass( string dir, int depth, string sourceFolder )
|
||||
void PrintDirectoryClass(string dir, int depth, string sourceFolder, string[] validFileExtensions, bool isCompiledFolder)
|
||||
{
|
||||
var dirInfo = new DirectoryInfo( dir );
|
||||
var firstIndent = new string( ' ', depth * 4 );
|
||||
var className = GenerateClassName( dirInfo.Name );
|
||||
WriteLine( "{0}public static class {1}\n{2}{{", firstIndent, className, firstIndent );
|
||||
var dirInfo = new DirectoryInfo(dir);
|
||||
var firstIndent = new string(' ', depth * 4);
|
||||
var className = GenerateClassName(dirInfo.Name, true);
|
||||
|
||||
if (!FolderHasContent(dir, validFileExtensions))
|
||||
return;
|
||||
|
||||
// fix our class name if this is the FNAEffects folder
|
||||
if (dir.Contains("Nez/DefaultContent") && className == "FNAEffects")
|
||||
className = "Effects";
|
||||
WriteLine("{0}public static class {1}\n{2}{{", firstIndent, className, firstIndent);
|
||||
|
||||
// handle subdirectories
|
||||
foreach( var subdir in Directory.GetDirectories( dir ) )
|
||||
PrintDirectoryClass( subdir, depth + 1, sourceFolder );
|
||||
foreach (var subdir in Directory.GetDirectories(dir))
|
||||
PrintDirectoryClass(subdir, depth + 1, sourceFolder, validFileExtensions, isCompiledFolder);
|
||||
|
||||
// handle files
|
||||
PrintContentFiles( dir, depth + 1, sourceFolder );
|
||||
PrintContentFiles(dir, depth + 1, sourceFolder, validFileExtensions);
|
||||
|
||||
WriteLine( "{0}}}\n", firstIndent );
|
||||
WriteLine("{0}}}\n", firstIndent);
|
||||
}
|
||||
|
||||
|
||||
// prints a const string for each file in the directory
|
||||
void PrintContentFiles( string dir, int depth, string sourceFolder )
|
||||
void PrintContentFiles(string dir, int depth, string sourceFolder, string[] validFileExtensions)
|
||||
{
|
||||
var firstIndent = new string( ' ', depth * 4 );
|
||||
var firstIndent = new string('\t', depth);
|
||||
|
||||
var files = Directory.EnumerateFiles( dir )
|
||||
.Where( s => Array.IndexOf( fileExtensionsToCopy, Path.GetExtension( s ) ) >= 0 );
|
||||
foreach( var file in files )
|
||||
var files = Directory.EnumerateFiles(dir)
|
||||
.Where( s => Array.IndexOf(validFileExtensions, Path.GetExtension(s)) >= 0);
|
||||
foreach (var file in files)
|
||||
{
|
||||
// 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 fileInfo = new FileInfo( file );
|
||||
var finalPath = file.Substring(file.IndexOf(sourceFolder) + sourceFolder.Length);
|
||||
var fileInfo = new FileInfo(file);
|
||||
var fileName = fileInfo.Name;
|
||||
|
||||
// clean the extension
|
||||
foreach( var extension in fileExtensionsToCopy )
|
||||
foreach (var extension in validFileExtensions)
|
||||
fileName = fileName.Replace(extension, string.Empty);
|
||||
|
||||
var className = GenerateClassName(fileName, false);
|
||||
|
||||
if (finalPath[0] == '/' || finalPath[0] == '\\')
|
||||
finalPath = finalPath.Substring(1);
|
||||
|
||||
// remove xnb extensions to avoid issues with loading
|
||||
finalPath = finalPath.Replace(".xnb", string.Empty);
|
||||
|
||||
// deal with built-in Nez content pathing
|
||||
if (dir.Contains("Nez/DefaultContent"))
|
||||
{
|
||||
fileName = fileName.Replace( extension, string.Empty );
|
||||
if (dir.Contains("FNAEffects"))
|
||||
{
|
||||
finalPath = finalPath.Replace("FNAEffects", "Effects");
|
||||
finalPath = "Content/Nez/" + finalPath;
|
||||
}
|
||||
else if(dir.Contains("Textures"))
|
||||
{
|
||||
finalPath = "Nez/" + finalPath;
|
||||
}
|
||||
}
|
||||
|
||||
var className = GenerateClassName( fileName );
|
||||
|
||||
if( finalPath[0] == '/' || finalPath[0] == '\\' )
|
||||
finalPath = finalPath.Substring( 1 );
|
||||
|
||||
// if file name is reserved insert a leading '@'
|
||||
if( keywords.Contains( className ) )
|
||||
if (keywords.Contains(className))
|
||||
className = className.Insert( 0, "@" );
|
||||
|
||||
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( "" );
|
||||
}
|
||||
if (files.Count() > 0)
|
||||
WriteLine("");
|
||||
}
|
||||
|
||||
|
||||
string StripInvalidPathChars( string input )
|
||||
{
|
||||
var invalidChars = Path.GetInvalidPathChars();
|
||||
return new string( input.Where( m => !invalidChars.Contains( m ) ).ToArray<char>() );
|
||||
}
|
||||
|
||||
|
||||
string StripInvalidFilenameChars( string input )
|
||||
{
|
||||
var invalidChars = Path.GetInvalidFileNameChars();
|
||||
return new string( input.Where( m => !invalidChars.Contains( m ) ).ToArray<char>() );
|
||||
}
|
||||
|
||||
|
||||
// attempts to generate a proper path name
|
||||
string GenerateClassName( string className )
|
||||
string GenerateClassName(string className, bool uppercaseFirstChar)
|
||||
{
|
||||
className = char.ToUpper( className[0] ) + className.Substring( 1 );
|
||||
// handle upper or lower casing the first char in the className
|
||||
if (uppercaseFirstChar && char.IsLower(className[0]))
|
||||
className = char.ToUpper(className[0]) + className.Substring(1);
|
||||
|
||||
className = className.Replace("-", "_");
|
||||
|
||||
// remove invalid characters
|
||||
var regex = new Regex( @"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]" );
|
||||
className = regex.Replace( className, "" );
|
||||
var regex = new Regex(@"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]");
|
||||
className = regex.Replace(className, "");
|
||||
|
||||
// class name doesn't begin with a letter, insert an underscore
|
||||
if( !char.IsLetter( className, 0 ) )
|
||||
className = className.Insert( 0, "_" );
|
||||
if (!char.IsLetter(className, 0))
|
||||
className = className.Insert(0, "_");
|
||||
|
||||
return className.Replace( " ", string.Empty );
|
||||
return className.Replace(" ", string.Empty);
|
||||
}
|
||||
|
||||
// returns true if the folder or any subfolder has some content with a valid file extension
|
||||
bool FolderHasContent(string dir, string[] validFileExtensions)
|
||||
{
|
||||
var files = Directory.EnumerateFiles(dir)
|
||||
.Where( s => Array.IndexOf(validFileExtensions, Path.GetExtension(s)) >= 0);
|
||||
return files.Count() > 0;
|
||||
}
|
||||
#>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<AssemblyName>project_name</AssemblyName>
|
||||
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Reference FNA, Nez, ImGui and Persistence projects. Optionally add a Farseer reference here and in the .sln file -->
|
||||
@ -39,26 +39,6 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Include the CompiledContent bin (MGCB output). Copy it to the Content folder in the build. -->
|
||||
<ItemGroup>
|
||||
<Content Include="CompiledContent/bin/DesktopGL/**/*.xnb">
|
||||
<Link>Content/%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<!-- cleanup so VS looks clean -->
|
||||
<None Remove="CompiledContent\obj\**"/>
|
||||
<None Remove="CompiledContent\bin\**"/>
|
||||
<None Remove="CompiledContent\.*"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- MonoGames content pipeline needs this defined -->
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="CompiledContent\Content.mgcb"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="../MonoGameContent.targets"/>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
|
||||
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user