1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 14:08:34 +01:00

Compare commits

..

3 commits

29 changed files with 64 additions and 150 deletions

View file

@ -24,15 +24,11 @@ Improvements
- Allow comparing Keybind and Combination based on the amount of modifiers they have
- Allow using multiple textures in a StaticSpriteBatch
- Added GenericInput support for Buttons.None
- Improved the way terminating formatting codes work by introducing SimpleEndCode
Removals
- **Moved Input namespace into MLEM.Input**
- Marked AStar.InfiniteCost as obsolete
### MLEM.Input
Additions
- Added Input namespace that was originally a part of MLEM
### MLEM.Ui
Additions
- Added Element.AutoNavGroup which allows forming groups for auto-navigation

View file

@ -87,10 +87,6 @@
<Project>{1bc4682b-aa14-4937-b5c7-707e20fe88ff}</Project>
<Name>Demos</Name>
</ProjectReference>
<ProjectReference Include="..\MLEM.Input\MLEM.Input.csproj">
<Project>{34c0707b-1b0a-437e-9536-39ec7012c1b5}</Project>
<Name>MLEM.Input</Name>
</ProjectReference>
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.csproj">
<Project>{997f4739-7bec-4621-b9ca-68deb2d74412}</Project>
<Name>MLEM.Startup</Name>

View file

@ -12,7 +12,7 @@ namespace Demos {
private const string Text =
"MLEM's text formatting system allows for various <b>formatting codes</b> to be applied in the middle of a string. Here's a demonstration of some of them.\n\n" +
"You can write in <b>bold</i>, <i>italics</i>, <u>with an underline</u>, <st>strikethrough</st>, or with a <s #000000 4>drop shadow</s> whose <s #ff0000 4>color</s> and <s #000000 10>offset</s> you can modify in each application of the code.\n\n" +
"You can write in <b>bold</i>, <i>italics</i>, <u>with an underline</u>, <st>strikethrough</st>, with a <s #000000 4>drop shadow</s> whose <s #ff0000 4>color</s> and <s #000000 10>offset</s> you can modify in each application of the code, or with various types of <b>combined <c Pink>formatting</c> codes</b>.\n\n" +
"You can apply <c CornflowerBlue>custom</c> <c Yellow>colors</c> to text, including all default <c Orange>MonoGame colors</c> and <c #aabb00>inline custom colors</c>.\n\n" +
"You can also use animations like <a wobbly>a wobbly one</a>, as well as create custom ones using the <a wobbly>Code class</a>.\n\n" +
"You can also display <i grass> icons in your text!\n\n" +

View file

@ -11,9 +11,8 @@
- See [the changelog](https://mlem.ellpeck.de/CHANGELOG.html) for information on updates
# Packages
- **MLEM** is the base package, which provides extension methods and additional features for MonoGame and FNA
- **MLEM.Input** features simple input handling, including a unified way to query mouse, keyboard, gamepad and touch input, a simple keybind system, and a text input field abstraction
- **MLEM.Ui** includes a mouse, keyboard, gamepad and touch ready Ui system that features automatic anchoring, sizing and several ready-to-use element types
- **MLEM** is the base package, which provides extension methods and additional features for MonoGame and FNA, including a text formatting system and simple input handling
- **MLEM.Ui** features a mouse, keyboard, gamepad and touch ready Ui system that features automatic anchoring, sizing and several ready-to-use element types
- **MLEM.Extended** ties in with MonoGame.Extended and other MonoGame and FNA libraries
- **MLEM.Data** provides simple loading and processing of textures and other data, including the ability to load non-XNB content files easily
- **MLEM.Startup** combines MLEM with some other useful libraries into a quick Game startup class

View file

@ -20,8 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA.Core", "FNA\FNA.Core.cs
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FontStashSharp.FNA.Core", "FontStashSharp\src\XNA\FontStashSharp.FNA.Core.csproj", "{0B410591-3AED-4C82-A07A-516FF493709B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Input.FNA", "MLEM.Input\MLEM.Input.FNA.csproj", "{AB5EEA09-6373-4742-B809-2A348CDDB869}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -68,9 +66,5 @@ Global
{0B410591-3AED-4C82-A07A-516FF493709B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B410591-3AED-4C82-A07A-516FF493709B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B410591-3AED-4C82-A07A-516FF493709B}.Release|Any CPU.Build.0 = Release|Any CPU
{AB5EEA09-6373-4742-B809-2A348CDDB869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB5EEA09-6373-4742-B809-2A348CDDB869}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB5EEA09-6373-4742-B809-2A348CDDB869}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB5EEA09-6373-4742-B809-2A348CDDB869}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -1,34 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<RootNamespace>MLEM.Input</RootNamespace>
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>Simple input handling for FNA, including a unified way to query mouse, keyboard, gamepad and touch input, a simple keybind system, and a text input field abstraction.</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG</PackageReleaseNotes>
<PackageTags>fna input handler keybind mouse keyboard gamepad touch ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM\MLEM.FNA.csproj" />
<ProjectReference Include="..\FNA\FNA.Core.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../Docs/index.md" Pack="true" PackagePath="README.md" />
</ItemGroup>
</Project>

View file

@ -1,32 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>Simple input handling for MonoGame, including a unified way to query mouse, keyboard, gamepad and touch input, a simple keybind system, and a text input field abstraction.</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG</PackageReleaseNotes>
<PackageTags>monogame input handler keybind mouse keyboard gamepad touch ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM\MLEM.csproj" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../Docs/index.md" Pack="true" PackagePath="README.md" />
</ItemGroup>
</Project>

View file

@ -23,6 +23,7 @@
<ItemGroup>
<PackageReference Include="Coroutine" Version="2.1.3" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.FNA.csproj" />
<ProjectReference Include="..\MLEM\MLEM.FNA.csproj" />
<ProjectReference Include="..\FNA\FNA.Core.csproj">
<PrivateAssets>all</PrivateAssets>

View file

@ -21,6 +21,7 @@
<ItemGroup>
<PackageReference Include="Coroutine" Version="2.1.3" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.csproj" />
<ProjectReference Include="..\MLEM\MLEM.csproj" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
<PrivateAssets>all</PrivateAssets>

View file

@ -21,7 +21,7 @@
<ItemGroup>
<PackageReference Include="TextCopy" Version="6.1.0" />
<ProjectReference Include="..\MLEM.Input\MLEM.Input.FNA.csproj" />
<ProjectReference Include="..\MLEM\MLEM.FNA.csproj" />
<ProjectReference Include="..\FNA\FNA.Core.csproj">
<PrivateAssets>all</PrivateAssets>

View file

@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="TextCopy" Version="6.1.0" />
<ProjectReference Include="..\MLEM.Input\MLEM.Input.csproj" />
<ProjectReference Include="..\MLEM\MLEM.csproj" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
<PrivateAssets>all</PrivateAssets>

View file

@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "Demos.Andr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{53D52C3F-67FB-4F32-A794-EAB140BBFC11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Input", "MLEM.Input\MLEM.Input.csproj", "{34C0707B-1B0A-437E-9536-39EC7012C1B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -74,9 +72,5 @@ Global
{53D52C3F-67FB-4F32-A794-EAB140BBFC11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53D52C3F-67FB-4F32-A794-EAB140BBFC11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53D52C3F-67FB-4F32-A794-EAB140BBFC11}.Release|Any CPU.Build.0 = Release|Any CPU
{34C0707B-1B0A-437E-9536-39EC7012C1B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34C0707B-1B0A-437E-9536-39EC7012C1B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34C0707B-1B0A-437E-9536-39EC7012C1B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34C0707B-1B0A-437E-9536-39EC7012C1B5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -39,13 +39,25 @@ namespace MLEM.Formatting.Codes {
/// <summary>
/// Returns whether this formatting code should end when the passed formatting code starts.
/// If this method returns true, a new <see cref="Token"/> is started at its position.
/// This is the opposite version of <see cref="EndsOther"/>.
/// </summary>
/// <param name="other">The code that is started here</param>
/// <returns>If this code should end</returns>
/// <param name="other">The code that is started here.</param>
/// <returns>If this code should end here.</returns>
public virtual bool EndsHere(Code other) {
return other.GetType() == this.GetType();
}
/// <summary>
/// Returns whether the <paramref name="other"/> <see cref="Code"/> should end when this formatting code starts.
/// If this method returns true, a new <see cref="Token"/> is started at this code's position.
/// This is the opposite version of <see cref="EndsHere"/>.
/// </summary>
/// <param name="other">The code that could end here.</param>
/// <returns>Whether the <paramref name="other"/> code should end here.</returns>
public virtual bool EndsOther(Code other) {
return false;
}
/// <inheritdoc cref="Formatting.Token.GetColor"/>
public virtual Color? GetColor(Color defaultPick) {
return null;

View file

@ -18,10 +18,5 @@ namespace MLEM.Formatting.Codes {
return this.font?.Invoke(defaultPick);
}
/// <inheritdoc />
public override bool EndsHere(Code other) {
return other is FontCode;
}
}
}

View file

@ -1,16 +0,0 @@
using System.Text.RegularExpressions;
namespace MLEM.Formatting.Codes {
/// <inheritdoc />
public class ResetFormattingCode : Code {
/// <inheritdoc />
public ResetFormattingCode(Match match, Regex regex) : base(match, regex) {}
/// <inheritdoc />
public override bool EndsHere(Code other) {
return true;
}
}
}

View file

@ -24,10 +24,5 @@ namespace MLEM.Formatting.Codes {
return false;
}
/// <inheritdoc />
public override bool EndsHere(Code other) {
return other is ShadowCode || other is ResetFormattingCode;
}
}
}

View file

@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
namespace MLEM.Formatting.Codes {
/// <inheritdoc />
public class SimpleEndCode : Code {
private readonly Regex codeToEnd;
/// <inheritdoc />
public SimpleEndCode(Match match, Regex regex, string codeNameToEnd) : base(match, regex) {
this.codeToEnd = new Regex($@"<{codeNameToEnd}(\W.*)?>");
}
/// <inheritdoc />
public override bool EndsOther(Code other) {
return this.codeToEnd.IsMatch(other.Regex.ToString());
}
}
}

View file

@ -29,10 +29,5 @@ namespace MLEM.Formatting.Codes {
return false;
}
/// <inheritdoc />
public override bool EndsHere(Code other) {
return other is UnderlineCode || other is ResetFormattingCode;
}
}
}

View file

@ -40,8 +40,6 @@ namespace MLEM.Formatting {
new Vector2(float.TryParse(m.Groups[2].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var offset) ? offset : 2)));
this.Codes.Add(new Regex("<u>"), (f, m, r) => new UnderlineCode(m, r, 1 / 16F, 0.85F));
this.Codes.Add(new Regex("<st>"), (f, m, r) => new UnderlineCode(m, r, 1 / 16F, 0.55F));
this.Codes.Add(new Regex("</(s|u|st|l)>"), (f, m, r) => new ResetFormattingCode(m, r));
this.Codes.Add(new Regex("</(b|i|f)>"), (f, m, r) => new FontCode(m, r, null));
// color codes
foreach (var c in typeof(Color).GetProperties()) {
@ -51,13 +49,14 @@ namespace MLEM.Formatting {
}
}
this.Codes.Add(new Regex(@"<c #([0-9\w]{6,8})>"), (f, m, r) => new ColorCode(m, r, ColorHelper.FromHexString(m.Groups[1].Value)));
this.Codes.Add(new Regex("</c>"), (f, m, r) => new ColorCode(m, r, null));
// animation codes
this.Codes.Add(new Regex(@"<a wobbly(?: ([+-.0-9]*) ([+-.0-9]*))?>"), (f, m, r) => new WobblyCode(m, r,
float.TryParse(m.Groups[1].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var mod) ? mod : 5,
float.TryParse(m.Groups[2].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var heightMod) ? heightMod : 1 / 8F));
this.Codes.Add(new Regex("</a>"), (f, m, r) => new AnimatedCode(m, r));
// control codes
this.Codes.Add(new Regex(@"</(\w+)>"), (f, m, r) => new SimpleEndCode(m, r, m.Groups[1].Value));
// macros
this.Macros.Add(new Regex("~"), (f, m, r) => GenericFont.Nbsp.ToCachedString());
@ -101,7 +100,7 @@ namespace MLEM.Formatting {
index += strippedRet.Length;
// remove all codes that are incompatible with the next one and apply it
codes.RemoveAll(c => c.EndsHere(next));
codes.RemoveAll(c => c.EndsHere(next) || next.EndsOther(c));
codes.Add(next);
}
return new TokenizedString(font, alignment, s, TextFormatter.StripFormatting(font, s, tokens.SelectMany(t => t.AppliedCodes)), tokens.ToArray());

View file

@ -9,7 +9,7 @@
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>MLEM Library for Extending FNA provides extension methods and additional features for FNA</Description>
<Description>The MLEM base package, which provides extension methods and additional features for FNA, including a text formatting system and simple input handling</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG</PackageReleaseNotes>
<PackageTags>fna ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>

View file

@ -7,7 +7,7 @@
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>MLEM Library for Extending MonoGame provides extension methods and additional features for MonoGame</Description>
<Description>The MLEM base package, which provides extension methods and additional features for MonoGame, including a text formatting system and simple input handling</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG</PackageReleaseNotes>
<PackageTags>monogame ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>

View file

@ -11,9 +11,8 @@
- See [the changelog](https://github.com/Ellpeck/MLEM/blob/main/CHANGELOG.md) for information on updates
# Packages
- **MLEM** is the base package, which provides extension methods and additional features for MonoGame and FNA
- **MLEM.Input** features simple input handling, including a unified way to query mouse, keyboard, gamepad and touch input, a simple keybind system, and a text input field abstraction
- **MLEM.Ui** includes a mouse, keyboard, gamepad and touch ready Ui system that features automatic anchoring, sizing and several ready-to-use element types
- **MLEM** is the base package, which provides extension methods and additional features for MonoGame and FNA, including a text formatting system and simple input handling
- **MLEM.Ui** features a mouse, keyboard, gamepad and touch ready Ui system that features automatic anchoring, sizing and several ready-to-use element types
- **MLEM.Extended** ties in with MonoGame.Extended and other MonoGame and FNA libraries
- **MLEM.Data** provides simple loading and processing of textures and other data, including the ability to load non-XNB content files easily
- **MLEM.Startup** combines MLEM with some other useful libraries into a quick Game startup class