1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-24 21:48:35 +01:00

Compare commits

..

No commits in common. "01bec459de1d01955cba9b3be1ba19682fd801b0" and "e53d30e5ca14c2ec597da9a73de566f522215f7b" have entirely different histories.

7 changed files with 35 additions and 24 deletions

View file

@ -26,11 +26,9 @@ Additions
Improvements Improvements
- Removed LINQ Any and All usage in various methods to improve memory usage - Removed LINQ Any and All usage in various methods to improve memory usage
- Explicitly disallow creating Paragraphs without fonts to make starting out with MLEM.Ui less confusing
Fixes Fixes
- Fixed a crash if a paragraph has a link formatting code, but no font - Fixed a crash if a paragraph has a link formatting code, but no font
- Fixed tooltips with custom text scale not snapping to the mouse correctly in their first displayed frame
### MLEM.Extended ### MLEM.Extended
Improvements Improvements

View file

@ -48,10 +48,7 @@ namespace Demos {
RadioTexture = new NinePatch(new TextureRegion(this.testTexture, 16, 0, 8, 8), 3), RadioTexture = new NinePatch(new TextureRegion(this.testTexture, 16, 0, 8, 8), 3),
RadioCheckmark = new TextureRegion(this.testTexture, 32, 0, 8, 8) RadioCheckmark = new TextureRegion(this.testTexture, 32, 0, 8, 8)
}; };
var untexturedStyle = new UntexturedStyle(this.SpriteBatch) { var untexturedStyle = new UntexturedStyle(this.SpriteBatch);
TextScale = style.TextScale,
Font = style.Font
};
// set the defined style as the current one // set the defined style as the current one
this.UiSystem.Style = style; this.UiSystem.Style = style;
// scale every ui up by 5 // scale every ui up by 5
@ -76,7 +73,7 @@ namespace Demos {
}); });
this.root.AddChild(new VerticalSpace(3)); this.root.AddChild(new VerticalSpace(3));
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Note that the default style does not contain any textures and, as such, is quite bland. However, the default style is quite easy to override, as can be seen in the code for this demo.")); this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Note that the default style does not contain any textures or font files and, as such, is quite bland. However, the default style is quite easy to override, as can be seen in the code for this demo."));
this.root.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), "Change Style") { this.root.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), "Change Style") {
OnPressed = element => this.UiSystem.Style = this.UiSystem.Style == untexturedStyle ? style : untexturedStyle, OnPressed = element => this.UiSystem.Style = this.UiSystem.Style == untexturedStyle ? style : untexturedStyle,
PositionOffset = new Vector2(0, 1), PositionOffset = new Vector2(0, 1),
@ -188,7 +185,7 @@ namespace Demos {
CoroutineHandler.Start(WobbleProgressBar(bar2)); CoroutineHandler.Start(WobbleProgressBar(bar2));
var bar3 = this.root.AddChild(new ProgressBar(Anchor.AutoLeft, new Vector2(8, 30), Direction2.Down, 10) {PositionOffset = new Vector2(0, 1)}); var bar3 = this.root.AddChild(new ProgressBar(Anchor.AutoLeft, new Vector2(8, 30), Direction2.Down, 10) {PositionOffset = new Vector2(0, 1)});
CoroutineHandler.Start(WobbleProgressBar(bar3)); CoroutineHandler.Start(WobbleProgressBar(bar3));
var bar4 = this.root.AddChild(new ProgressBar(Anchor.AutoInline, new Vector2(8, 30), Direction2.Up, 10) {PositionOffset = new Vector2(1, 0)}); var bar4 = this.root.AddChild(new ProgressBar(Anchor.AutoInline, new Vector2(8, 30), Direction2.Up, 10) {PositionOffset = new Vector2(1, 1)});
CoroutineHandler.Start(WobbleProgressBar(bar4)); CoroutineHandler.Start(WobbleProgressBar(bar4));
this.root.AddChild(new VerticalSpace(3)); this.root.AddChild(new VerticalSpace(3));

View file

@ -1,4 +1,4 @@
<img src="../Media/Logo.svg" width="25%" alt="The MLEM logo"> <img src="../Media/Logo.svg" width="25%" >
**MLEM Library for Extending MonoGame** is an addition to the game framework [MonoGame](https://www.monogame.net/) that provides extension methods, quality of life improvements and additional features like a ui system and easy input handling. **MLEM Library for Extending MonoGame** is an addition to the game framework [MonoGame](https://www.monogame.net/) that provides extension methods, quality of life improvements and additional features like a ui system and easy input handling.
@ -20,17 +20,16 @@ If you created a game with the help of MLEM, you can get it added to this list b
# Gallery # Gallery
Here are some images that show a couple of MLEM's features. Here are some images that show a couple of MLEM's features.
The [MLEM.Ui](https://mlem.ellpeck.de/articles/ui) demo in action: MLEM.Ui in action:
<img src="../Media/Ui.gif">
<img src="../Media/Ui.gif" alt="A gif showing various user interface elements from the MLEM.Ui demo"> MLEM's text formatting system:
<img src="../Media/Formatting.png">
MLEM's [text formatting system](https://mlem.ellpeck.de/articles/text_formatting), which is compatible with both MLEM.Ui and regular sprite batch rendering:
<img src="../Media/Formatting.png" alt="An image showing text with various colors and other formatting">
# Friends of MLEM # Friends of MLEM
There are several other NuGet packages and tools that work well in combination with MonoGame and MLEM. Here are some of them: There are several other NuGet packages and tools that work well in combination with MonoGame and MLEM. Here are some of them:
- [Contentless](https://github.com/Ellpeck/Contentless), a tool that removes the need to add assets to the MonoGame Content Pipeline manually - [Contentless](https://github.com/Ellpeck/Contentless), a tool that removes the need to add assets to the MonoGame Content Pipeline manually
- [GameBundle](https://github.com/Ellpeck/GameBundle), a tool that packages MonoGame and other .NET Core applications into several distributable formats - [GameBundle](https://github.com/Ellpeck/GameBundle), a tool that packages MonoGame and other .NET Core applications into several distributable formats
- [ButlerDotNet](https://github.com/Ellpeck/ButlerDotNet), a tool that automatically downloads and invokes itch.io's butler
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame - [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project - [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project

View file

@ -151,8 +151,8 @@ namespace MLEM.Ui.Elements {
/// <inheritdoc /> /// <inheritdoc />
protected override void InitStyle(UiStyle style) { protected override void InitStyle(UiStyle style) {
base.InitStyle(style); base.InitStyle(style);
this.RegularFont.SetFromStyle(style.Font ?? throw new NotSupportedException("Paragraphs cannot use ui styles that don't have a font. Please supply a custom font by setting UiStyle.Font."));
this.TextScale.SetFromStyle(style.TextScale); this.TextScale.SetFromStyle(style.TextScale);
this.RegularFont.SetFromStyle(style.Font);
this.TextColor.SetFromStyle(style.TextColor); this.TextColor.SetFromStyle(style.TextColor);
} }

View file

@ -67,7 +67,6 @@ namespace MLEM.Ui.Elements {
if (this.Parent != null) if (this.Parent != null)
throw new NotSupportedException($"A tooltip shouldn't be the child of another element ({this.Parent})"); throw new NotSupportedException($"A tooltip shouldn't be the child of another element ({this.Parent})");
base.ForceUpdateArea(); base.ForceUpdateArea();
this.SnapPositionToMouse();
} }
/// <inheritdoc /> /// <inheritdoc />

View file

@ -37,6 +37,25 @@ namespace MLEM.Ui.Style {
this.ProgressBarColor = Color.White; this.ProgressBarColor = Color.White;
this.ProgressBarProgressPadding = new Vector2(1); this.ProgressBarProgressPadding = new Vector2(1);
this.ProgressBarProgressColor = Color.Red; this.ProgressBarProgressColor = Color.Red;
this.Font = new EmptyFont();
}
private class EmptyFont : GenericFont {
public override GenericFont Bold => this;
public override GenericFont Italic => this;
public override float LineHeight => 1;
protected override Vector2 MeasureChar(char c) {
return Vector2.Zero;
}
public override void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
}
public override void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
}
} }
} }

View file

@ -1,4 +1,4 @@
<img src="Media/Logo.png" width="25%" alt="The MLEM logo"> <img src="Media/Logo.png" width="25%" >
**MLEM Library for Extending MonoGame** is an addition to the game framework [MonoGame](https://www.monogame.net/) that provides extension methods, quality of life improvements and additional features like a ui system and easy input handling. **MLEM Library for Extending MonoGame** is an addition to the game framework [MonoGame](https://www.monogame.net/) that provides extension methods, quality of life improvements and additional features like a ui system and easy input handling.
@ -20,17 +20,16 @@ If you created a game with the help of MLEM, you can get it added to this list b
# Gallery # Gallery
Here are some images that show a couple of MLEM's features. Here are some images that show a couple of MLEM's features.
The [MLEM.Ui](https://mlem.ellpeck.de/articles/ui) demo in action: MLEM.Ui in action:
<img src="Media/Ui.gif">
<img src="Media/Ui.gif" alt="A gif showing various user interface elements from the MLEM.Ui demo"> MLEM's text formatting system:
<img src="Media/Formatting.png">
MLEM's [text formatting system](https://mlem.ellpeck.de/articles/text_formatting), which is compatible with both MLEM.Ui and regular sprite batch rendering:
<img src="Media/Formatting.png" alt="An image showing text with various colors and other formatting">
# Friends of MLEM # Friends of MLEM
There are several other NuGet packages and tools that work well in combination with MonoGame and MLEM. Here are some of them: There are several other NuGet packages and tools that work well in combination with MonoGame and MLEM. Here are some of them:
- [Contentless](https://github.com/Ellpeck/Contentless), a tool that removes the need to add assets to the MonoGame Content Pipeline manually - [Contentless](https://github.com/Ellpeck/Contentless), a tool that removes the need to add assets to the MonoGame Content Pipeline manually
- [GameBundle](https://github.com/Ellpeck/GameBundle), a tool that packages MonoGame and other .NET Core applications into several distributable formats - [GameBundle](https://github.com/Ellpeck/GameBundle), a tool that packages MonoGame and other .NET Core applications into several distributable formats
- [ButlerDotNet](https://github.com/Ellpeck/ButlerDotNet), a tool that automatically downloads and invokes itch.io's butler
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame - [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project - [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project