Ellpeck / MLEM

Libraries for MonoGame and FNA that provide abstractions, quality of life improvements and additional features like a ui system and easy input handling.
https://mlem.ellpeck.de/
MIT License
84 stars 6 forks source link

UiSystem.Draw throws System.MissingMethodException in FontStashSharp #21

Closed asik closed 8 months ago

asik commented 8 months ago

UiSystem.Draw throws

System.MissingMethodException: 'Method not found: 'Single FontStashSharp.SpriteFontBase.DrawText(Microsoft.Xna.Framework.Graphics.SpriteBatch, System.String, Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Color, System.Nullable`1, Single, Microsoft.Xna.Framework.Vector2, Single, Single, Single, FontStashSharp.TextStyle, FontStashSharp.FontSystemEffect, Int32)'.'

What I did:

_fontSystem = new FontSystem();
_fontSystem.AddFont(File.ReadAllBytes(@"Content/Fonts/12-post-antiqua-roman-05554.ttf"));

var style = new UntexturedStyle(_spriteBatch)
{
    Font = new GenericStashFont(_fontSystem.GetFont(18))
};
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
_uiSystem = new UiSystem(this, style);
var box = new Panel(Anchor.Center, new Vector2(100, 1), Vector2.Zero, setHeightBasedOnChildren: true);
box.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is some example text!"));
box.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.5F, 20), "Okay")
{
    OnPressed = element => _uiSystem.Remove("InfoBox"),
    PositionOffset = new Vector2(0, 1)
});
_uiSystem.Add("InfoBox", box);

The following code to Update:

_uiSystem.Update(gameTime);

And the following to Draw:

_uiSystem.Draw(gameTime, _spriteBatch);

FontStashSharp seems to be working on its own, I can do .DrawText and it works.

Ellpeck commented 8 months ago

Hi, thanks for your in-depth report!

This is unfortunately due to a recent-ish breaking change in FSS which I already addressed in-dev. You can either downgrade FSS, or use a prerelease version of MLEM from the private feed.

(Although MLEM is definitely overdue for another official release. 6.3.0 is pretty full of stuff already.)