public TextureRegionAtlas Load(AssetLoaderContext context, string assetName) { var data = context.Load <string>(assetName); #if MONOGAME || FNA || STRIDE return(TextureRegionAtlas.Load(data, name => context.Load <Texture2D>(name))); #else return(TextureRegionAtlas.Load(data, name => context.Load <Texture2DWrapper>(name).Texture)); #endif }
public SpriteFontBase Load(AssetLoaderContext context, string assetName) { if (assetName.Contains(".fnt")) { return(context.Load <StaticSpriteFont>(assetName)); } else if (assetName.Contains(".ttf")) { return(context.Load <DynamicSpriteFont>(assetName)); } throw new Exception(string.Format("Can't load font '{0}'", assetName)); }
public StaticSpriteFont Load(AssetLoaderContext context, string assetName) { var fontData = context.Load <string>(assetName); return(StaticSpriteFont.FromBMFont(fontData, name => TextureGetter(context, name))); }
public TextureRegion Load(AssetLoaderContext context, string assetName) { if (assetName.Contains(":")) { // First part is texture region atlas name // Second part is texture region name var parts = assetName.Split(':'); var textureRegionAtlas = context.Load <TextureRegionAtlas>(parts[0]); return(textureRegionAtlas[parts[1]]); } // Ordinary texture #if MONOGAME || FNA || STRIDE var texture = context.Load <Texture2D>(assetName); return(new TextureRegion(texture, new Rectangle(0, 0, texture.Width, texture.Height))); #else var texture = context.Load <Texture2DWrapper>(assetName); return(new TextureRegion(texture.Texture, new Rectangle(0, 0, texture.Width, texture.Height))); #endif }
public FontSystem Load(AssetLoaderContext context, string assetName) { var parts = assetName.Split(':'); var fontType = FontType.Regular; var amount = 1; if (parts.Length > 1) { fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]); if (fontType != FontType.Regular) { if (parts.Length < 3) { throw new Exception("Missing amount"); } amount = int.Parse(parts[2]); } } FontSystem fontSystem = null; switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(context.GraphicsDevice, 1024, 1024); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(context.GraphicsDevice, 1024, 1024, amount); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(context.GraphicsDevice, 1024, 1024, amount); break; } var data = context.Load <byte[]>(parts[0]); fontSystem.AddFont(data); return(fontSystem); }
public DynamicSpriteFont Load(AssetLoaderContext context, string assetName) { var parts = assetName.Split(':'); if (parts.Length < 2) { throw new Exception("Missing font size"); } var fontSize = int.Parse(parts[parts.Length - 1]); var partsWithoutSize = new List <string>(); for (var i = 0; i < parts.Length - 1; ++i) { partsWithoutSize.Add(parts[i]); } var fontSystem = context.Load <FontSystem>(string.Join(":", partsWithoutSize)); return(fontSystem.GetFont(fontSize)); }
public FontSystem Load(AssetLoaderContext context, string assetName) { var parts = assetName.Split(':'); var fontType = FontType.Regular; var amount = 1; if (parts.Length > 1) { fontType = (FontType)Enum.Parse(typeof(FontType), parts[1]); if (fontType != FontType.Regular) { if (parts.Length < 3) { throw new Exception("Missing amount"); } amount = int.Parse(parts[2]); } } FontSystem fontSystem = null; #if MONOGAME || FNA || STRIDE switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(MyraEnvironment.GraphicsDevice, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(MyraEnvironment.GraphicsDevice, amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; } #else switch (fontType) { case FontType.Regular: fontSystem = FontSystemFactory.Create(MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Blurry: fontSystem = FontSystemFactory.CreateBlurry(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; case FontType.Stroked: fontSystem = FontSystemFactory.CreateStroked(amount, MyraEnvironment.FontAtlasSize, MyraEnvironment.FontAtlasSize); break; } #endif var data = context.Load <byte[]>(parts[0]); fontSystem.AddFont(data); return(fontSystem); }
private TextureWithOffset TextureGetter(AssetLoaderContext context, string name) { var textureRegion = context.Load <TextureRegion>(name); return(new TextureWithOffset(textureRegion.Texture, textureRegion.Bounds.Location)); }