mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
started fixing relative path issues with bitmap fonts
This commit is contained in:
@@ -10,6 +10,7 @@ namespace MonoGame.Extended.BitmapFonts
|
||||
{
|
||||
protected override BitmapFont Read(ContentReader reader, BitmapFont existingInstance)
|
||||
{
|
||||
var relativeAssetFolder = GetRelativeAssetFolder(reader.AssetName);
|
||||
var textureAssetCount = reader.ReadInt32();
|
||||
var assets = new List<string>();
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace MonoGame.Extended.BitmapFonts
|
||||
}
|
||||
|
||||
var textures = assets
|
||||
.Select(i => reader.ContentManager.Load<Texture2D>(i))
|
||||
.Select(assetName => reader.ContentManager.Load<Texture2D>(relativeAssetFolder + assetName))
|
||||
.ToArray();
|
||||
|
||||
var lineHeight = reader.ReadInt32();
|
||||
@@ -44,5 +45,15 @@ namespace MonoGame.Extended.BitmapFonts
|
||||
|
||||
return new BitmapFont(regions, lineHeight);
|
||||
}
|
||||
|
||||
private string GetRelativeAssetFolder(string assetPath)
|
||||
{
|
||||
var pathNodes = assetPath.Split(new[] {'\\', '/'});
|
||||
|
||||
if (pathNodes.Length > 1)
|
||||
return string.Join("/", pathNodes.Take(pathNodes.Length - 1).ToArray()) + "/";
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
/platform:Windows
|
||||
/config:
|
||||
/profile:Reach
|
||||
/compress:False
|
||||
|
||||
#-------------------------------- References --------------------------------#
|
||||
|
||||
@@ -26,23 +25,6 @@
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:hills.png
|
||||
|
||||
#begin courier-new-32.fnt
|
||||
/importer:BitmapFontImporter
|
||||
/processor:BitmapFontProcessor
|
||||
/build:courier-new-32.fnt
|
||||
|
||||
#begin courier-new-32_0.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:courier-new-32_0.png
|
||||
|
||||
#begin desert.tmx
|
||||
/copy:desert.tmx
|
||||
|
||||
@@ -158,3 +140,20 @@
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:zombie.png
|
||||
|
||||
#begin Fonts/courier-new-32.fnt
|
||||
/importer:BitmapFontImporter
|
||||
/processor:BitmapFontProcessor
|
||||
/build:Fonts/courier-new-32.fnt
|
||||
|
||||
#begin Fonts/courier-new-32_0.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Fonts/courier-new-32_0.png
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@@ -51,14 +51,14 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Content\courier-new-32.fnt" />
|
||||
<None Include="Content\desert.tmx" />
|
||||
<None Include="Content\Fonts\courier-new-32.fnt" />
|
||||
<None Include="Content\free-tileset.json" />
|
||||
<None Include="Content\free-tileset.tps" />
|
||||
<None Include="Content\level01.tmx" />
|
||||
<None Include="Content\read-me.md" />
|
||||
<Content Include="Content\courier-new-32_0.png" />
|
||||
<Content Include="Content\fireball.png" />
|
||||
<Content Include="Content\Fonts\courier-new-32_0.png" />
|
||||
<Content Include="Content\free-tileset.png" />
|
||||
<Content Include="Content\hills.png" />
|
||||
<Content Include="Content\Hills_1.png" />
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Sandbox
|
||||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
_bitmapFont = Content.Load<BitmapFont>("courier-new-32");
|
||||
_bitmapFont = Content.Load<BitmapFont>("Fonts/courier-new-32");
|
||||
_tiledMap = Content.Load<TiledMap>("level01");
|
||||
|
||||
var fireballTexture = Content.Load<Texture2D>("fireball");
|
||||
|
||||
Reference in New Issue
Block a user