mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 01:39:32 +00:00
Feature label styling (#454)
* Added some basic tests for the ECS * Add test project for Nuclex Gui * Nuclex Gui project update * Added ability to style labels * Removed Nuclex Gui Test project for lack of tests
This commit is contained in:
@@ -52,3 +52,31 @@
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:TitleFont.spritefont
|
||||
|
||||
#begin Fonts/Heading1.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Heading1.spritefont
|
||||
|
||||
#begin Fonts/Heading2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Heading2.spritefont
|
||||
|
||||
#begin Fonts/Heading3.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Heading3.spritefont
|
||||
|
||||
#begin Fonts/Title.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Title.spritefont
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Corbel</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>16</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<DefaultCharacter>?</DefaultCharacter>
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Corbel</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>13</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<DefaultCharacter>?</DefaultCharacter>
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Corbel</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>12</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<DefaultCharacter>?</DefaultCharacter>
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Corbel</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>28</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<DefaultCharacter>?</DefaultCharacter>
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
||||
@@ -95,6 +95,10 @@
|
||||
<EmbeddedResource Include="Icon.bmp" />
|
||||
<EmbeddedResource Include="Icon.ico" />
|
||||
<None Include="app.config" />
|
||||
<None Include="Content\Fonts\Title.spritefont" />
|
||||
<None Include="Content\Fonts\Heading3.spritefont" />
|
||||
<None Include="Content\Fonts\Heading2.spritefont" />
|
||||
<None Include="Content\Fonts\Heading1.spritefont" />
|
||||
<None Include="Content\DefaultFont.spritefont" />
|
||||
<None Include="Content\logo-square-128.png" />
|
||||
<None Include="Content\TitleFont.spritefont" />
|
||||
@@ -132,4 +136,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
@@ -7,6 +8,7 @@ using MonoGame.Extended.Input.InputListeners;
|
||||
using MonoGame.Extended.Sprites;
|
||||
using MonoGame.Extended.ViewportAdapters;
|
||||
using MonoGame.Extended.NuclexGui;
|
||||
using MonoGame.Extended.NuclexGui.Controls;
|
||||
using MonoGame.Extended.NuclexGui.Controls.Desktop;
|
||||
|
||||
namespace Demo.NuclexGui
|
||||
@@ -65,14 +67,90 @@ namespace Demo.NuclexGui
|
||||
Bounds = new UniRectangle(new UniScalar(20), new UniScalar(80), new UniScalar(120), new UniScalar(50)),
|
||||
Text = "Open Window"
|
||||
};
|
||||
var button3 = new GuiButtonControl()
|
||||
{
|
||||
Name = "button3",
|
||||
Bounds = new UniRectangle(new UniScalar(20), new UniScalar(140), new UniScalar(120), new UniScalar(50)),
|
||||
Text = "Show Labels",
|
||||
};
|
||||
|
||||
// Attach relevant events
|
||||
button.Pressed += Button_Pressed;
|
||||
button2.Pressed += Button2_Pressed;
|
||||
button3.Pressed += Button3_Pressed;
|
||||
|
||||
// And finally, attach controls to the parent control. In this case, desktop screen.
|
||||
_gui.Screen.Desktop.Children.Add(button);
|
||||
_gui.Screen.Desktop.Children.Add(button2);
|
||||
_gui.Screen.Desktop.Children.Add(button3);
|
||||
}
|
||||
|
||||
private void Button3_Pressed(object sender, EventArgs e)
|
||||
{
|
||||
if (_gui.Screen.Desktop.Children.Any(i => i.Name == "window"))
|
||||
return;
|
||||
|
||||
var window = new GuiWindowControl
|
||||
{
|
||||
Name = "window",
|
||||
Bounds = new UniRectangle(new UniVector(new UniScalar(0.5f, -100), new UniScalar(0.5f, -60)), new UniVector(new UniScalar(200), new UniScalar(160))),
|
||||
Title = "Labels with Styles",
|
||||
EnableDragging = true
|
||||
};
|
||||
|
||||
var labelTitle = new GuiLabelControl
|
||||
{
|
||||
Name = "label-title",
|
||||
Bounds = new UniRectangle(new UniScalar(10), new UniScalar(45), new UniScalar(10), new UniScalar(10)),
|
||||
Text = "Title",
|
||||
Style = "label-title"
|
||||
};
|
||||
var label1 = new GuiLabelControl
|
||||
{
|
||||
Name = "label1",
|
||||
Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 70), new UniScalar(10), new UniScalar(10)),
|
||||
Text = "Heading 1",
|
||||
Style = "label-h1",
|
||||
};
|
||||
var label2 = new GuiLabelControl
|
||||
{
|
||||
Name = "label2",
|
||||
Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 90), new UniScalar(10), new UniScalar(10)),
|
||||
Text = "Heading 2",
|
||||
Style = "label-h2",
|
||||
};
|
||||
var label3 = new GuiLabelControl
|
||||
{
|
||||
Name = "label3",
|
||||
Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 105), new UniScalar(10), new UniScalar(10)),
|
||||
Text = "Heading 3",
|
||||
Style = "label-h3"
|
||||
};
|
||||
|
||||
var button1 = new GuiButtonControl
|
||||
{
|
||||
Name = "confirm",
|
||||
Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)),
|
||||
Text = "Confirm"
|
||||
};
|
||||
var button2 = new GuiButtonControl
|
||||
{
|
||||
Name = "cancel",
|
||||
Bounds = new UniRectangle(new UniScalar(1.0f, -90), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)),
|
||||
Text = "Cancel"
|
||||
};
|
||||
|
||||
button1.Pressed += DialogueConfirm_Pressed;
|
||||
button2.Pressed += DialogueCancel_Pressed;
|
||||
|
||||
window.Children.Add(labelTitle);
|
||||
window.Children.Add(label1);
|
||||
window.Children.Add(label2);
|
||||
window.Children.Add(label3);
|
||||
window.Children.Add(button1);
|
||||
window.Children.Add(button2);
|
||||
|
||||
_gui.Screen.Desktop.Children.Add(window);
|
||||
}
|
||||
|
||||
private void Button2_Pressed(object sender, System.EventArgs e)
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
/// <summary>Text to be rendered in the control's frame</summary>
|
||||
public string Text;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style to be used with this label when drawing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If you are using the FlatGuiVisualizer, this style
|
||||
/// corresponds to the 'Frames' used in
|
||||
/// <see cref="MonoGame.Extended.NuclexGui.Visuals.Flat.FlatGuiGraphics"/>
|
||||
/// The style can be customized in the skin's json file.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string Style { get; set; }
|
||||
|
||||
/// <summary>Initializes a new label control with an empty string</summary>
|
||||
public GuiLabelControl() : this(string.Empty)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,22 @@
|
||||
{
|
||||
"name": "default",
|
||||
"contentPath": "DefaultFont"
|
||||
},
|
||||
{
|
||||
"name": "heading1",
|
||||
"contentPath": "Fonts/Heading1"
|
||||
},
|
||||
{
|
||||
"name": "heading2",
|
||||
"contentPath": "Fonts/Heading2"
|
||||
},
|
||||
{
|
||||
"name": "heading3",
|
||||
"contentPath": "Fonts/Heading3"
|
||||
},
|
||||
{
|
||||
"name": "label-title",
|
||||
"contentPath": "Fonts/Title"
|
||||
}
|
||||
],
|
||||
"bitmap": [
|
||||
@@ -133,6 +149,54 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "label-h1",
|
||||
"text": [
|
||||
{
|
||||
"font": "heading1",
|
||||
"hplacement": "left",
|
||||
"vplacement": "center",
|
||||
"yoffset": 0,
|
||||
"color": "#3F3F3F"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "label-h2",
|
||||
"text": [
|
||||
{
|
||||
"font": "heading2",
|
||||
"hplacement": "left",
|
||||
"vplacement": "center",
|
||||
"yoffset": 0,
|
||||
"color": "#3F3F3F"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "label-h3",
|
||||
"text": [
|
||||
{
|
||||
"font": "heading3",
|
||||
"hplacement": "left",
|
||||
"vplacement": "center",
|
||||
"yoffset": 0,
|
||||
"color": "#3F3F3F"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "label-title",
|
||||
"text": [
|
||||
{
|
||||
"font": "label-title",
|
||||
"hplacement": "left",
|
||||
"vplacement": "center",
|
||||
"yoffset": 0,
|
||||
"color": "#3F3F3F"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "progress",
|
||||
"region": [
|
||||
|
||||
+6
-2
@@ -1,4 +1,5 @@
|
||||
using MonoGame.Extended.NuclexGui.Controls;
|
||||
using System;
|
||||
using MonoGame.Extended.NuclexGui.Controls;
|
||||
|
||||
namespace MonoGame.Extended.NuclexGui.Visuals.Flat.Renderers
|
||||
{
|
||||
@@ -14,7 +15,10 @@ namespace MonoGame.Extended.NuclexGui.Visuals.Flat.Renderers
|
||||
/// </param>
|
||||
public void Render(GuiLabelControl control, IFlatGuiGraphics graphics)
|
||||
{
|
||||
graphics.DrawString("label", control.GetAbsoluteBounds(), control.Text);
|
||||
var frameName = "label";
|
||||
if (control.Style != null) frameName = control.Style;
|
||||
|
||||
graphics.DrawString(frameName, control.GetAbsoluteBounds(), control.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26430.12
|
||||
VisualStudioVersion = 15.0.27130.2010
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended", "MonoGame.Extended\MonoGame.Extended.csproj", "{41724C52-3D50-45BB-81EB-3C8A247EAFD1}"
|
||||
EndProject
|
||||
@@ -107,6 +107,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Tests\Sandbox\Sa
|
||||
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Entities.Tests", "Tests\MonoGame.Extended.Entities.Tests\MonoGame.Extended.Entities.Tests.csproj", "{5B993DD9-A9B8-434C-B444-F1CFFB947F79}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -323,6 +325,14 @@ Global
|
||||
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -342,5 +352,9 @@ Global
|
||||
{57C47653-BC51-43BA-98F4-1D0EEE78782D} = {932F8931-4A8D-4205-BFCF-98E794207786}
|
||||
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78} = {932F8931-4A8D-4205-BFCF-98E794207786}
|
||||
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
|
||||
{5B993DD9-A9B8-434C-B444-F1CFFB947F79} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8ED5A62D-25EC-4331-9F99-BDD1E10C02A0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonoGame.Extended.Entities;
|
||||
using MonoGame.Extended.Gui.Tests.Implementation;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoGame.Extended.Gui.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class EntityTemplateTests
|
||||
{
|
||||
[Test]
|
||||
public void ECS_CreateEntityFromTemplate_Basic_Test()
|
||||
{
|
||||
// Seems to work with null.
|
||||
var ecs = new EntityComponentSystem(null);
|
||||
ecs.Scan(typeof(EntityTemplateBasic).Assembly);
|
||||
var manager = ecs.EntityManager;
|
||||
Entity entity = null;
|
||||
try
|
||||
{
|
||||
entity = manager.CreateEntityFromTemplate(EntityTemplateBasic.Name);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.Fail("Failed to create entity from template.\n" + e.StackTrace);
|
||||
}
|
||||
|
||||
Assert.NotNull(entity);
|
||||
Assert.NotNull(entity.Get<EntityComponentBasic>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ECS_CreateEntityFromTemplate_UsingManager_Test()
|
||||
{
|
||||
// Seems to work with null.
|
||||
var ecs = new EntityComponentSystem(null);
|
||||
ecs.Scan(typeof(EntityTemplateUsingManager).Assembly);
|
||||
var manager = ecs.EntityManager;
|
||||
Entity entity = null;
|
||||
try
|
||||
{
|
||||
entity = manager.CreateEntityFromTemplate(EntityTemplateUsingManager.Name);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.Fail("Failed to create entity from template.\n" + e.StackTrace);
|
||||
}
|
||||
|
||||
Assert.NotNull(entity);
|
||||
Assert.NotNull(entity.Get<EntityComponentBasic>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using MonoGame.Extended.Entities;
|
||||
|
||||
namespace MonoGame.Extended.Gui.Tests.Implementation
|
||||
{
|
||||
[EntityComponent]
|
||||
public class EntityComponentBasic : TransformComponent2D
|
||||
{
|
||||
public int Number { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using MonoGame.Extended.Entities;
|
||||
|
||||
namespace MonoGame.Extended.Gui.Tests.Implementation
|
||||
{
|
||||
[EntityTemplate(Name)]
|
||||
public class EntityTemplateBasic : EntityTemplate
|
||||
{
|
||||
public const string Name = nameof(EntityTemplateBasic);
|
||||
|
||||
protected override void Build(Entity entity)
|
||||
{
|
||||
entity.Attach<EntityComponentBasic>();
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using MonoGame.Extended.Entities;
|
||||
|
||||
namespace MonoGame.Extended.Gui.Tests.Implementation
|
||||
{
|
||||
[EntityTemplate(Name)]
|
||||
public class EntityTemplateUsingManager : EntityTemplate
|
||||
{
|
||||
public const string Name = nameof(EntityTemplateUsingManager);
|
||||
|
||||
protected override void Build(Entity entity)
|
||||
{
|
||||
var num = Manager.EntityManager.TotalEntitiesCount;
|
||||
entity.Attach<EntityComponentBasic>(c => c.Number = num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
# Implementation
|
||||
|
||||
This folder is for making a testable implementation using the ECS library.
|
||||
This implementation is used in the unit tests in this project.
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5B993DD9-A9B8-434C-B444-F1CFFB947F79}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MonoGame.Extended.Gui.Tests</RootNamespace>
|
||||
<AssemblyName>MonoGame.Extended.Gui.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework, Version=3.6.0.1625, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\MonoGame.Framework.WindowsDX.3.6.0.1625\lib\net40\MonoGame.Framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NSubstitute, Version=1.10.0.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EntityTemplateTests.cs" />
|
||||
<Compile Include="Implementation\EntityComponentBasic.cs" />
|
||||
<Compile Include="Implementation\EntityTemplateBasic.cs" />
|
||||
<Compile Include="Implementation\EntityTemplateUsingManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Implementation\README.md" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MonoGame.Extended.Entities\MonoGame.Extended.Entities.csproj">
|
||||
<Project>{35fd1f05-af04-469a-b37a-f9b36c34401c}</Project>
|
||||
<Name>MonoGame.Extended.Entities</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MonoGame.Extended.Entities.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MonoGame.Extended.Entities.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("EFE3C251-67A7-4BBF-A4B8-A7659F460920")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MonoGame.Framework.WindowsDX" version="3.6.0.1625" targetFramework="net452" />
|
||||
<package id="NSubstitute" version="1.10.0.0" targetFramework="net452" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net452" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user