diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index df82e29..a02f5aa 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -24,4 +24,10 @@ /processorParam:MakeSquare=False /processorParam:TextureFormat=Color /build:wall.jpg +#begin Font.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Font.spritefont diff --git a/DangerousD/Content/Font.spritefont b/DangerousD/Content/Font.spritefont new file mode 100644 index 0000000..4cffaf7 --- /dev/null +++ b/DangerousD/Content/Font.spritefont @@ -0,0 +1,64 @@ + + + + + + + Arial + + + 12 + + + 0 + + + true + + + + + + + + + + + + ~ + + + а + я + + + + diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs index 755f1cc..45b231a 100644 --- a/DangerousD/GameCore/GUI/AbstractGui.cs +++ b/DangerousD/GameCore/GUI/AbstractGui.cs @@ -11,21 +11,23 @@ public abstract class AbstractGui : IDrawableObject protected UIManager Manager = new(); protected List Elements = new(); + public AbstractGui() { } protected abstract void CreateUI(); - + private GraphicsDevice graphicsDevice; public virtual void Initialize(GraphicsDevice graphicsDevice) { - Manager.Initialize("", graphicsDevice); + this.graphicsDevice = graphicsDevice; + Manager.Initialize(graphicsDevice); CreateUI(); } public virtual void LoadContent() { - Manager.LoadContent(AppManager.Instance.Content); + Manager.LoadContent(AppManager.Instance.Content, "Font"); } public virtual void Update(GameTime gameTime) diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs index 2103562..e9a5c0e 100644 --- a/DangerousD/GameCore/GUI/MenuGUI.cs +++ b/DangerousD/GameCore/GUI/MenuGUI.cs @@ -15,5 +15,7 @@ internal class MenuGUI : AbstractGui { AppManager.Instance.ChangeGameState(GameState.Game); }; + Elements.Add(new Button(Manager) { rectangle = new Rectangle(0, 10, 790, 50) }); + Elements.Add(new Label(Manager) { rectangle = new Rectangle(100, 10, 50, 50), text = "DA" }); } } \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 68cd6c6..4bcd14b 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -41,7 +41,7 @@ namespace DangerousD.GameCore base.Initialize(); } - protected override void LoadContent() + protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); MenuGUI.LoadContent(); diff --git a/MonogameLibrary/UI/Base/UIManager.cs b/MonogameLibrary/UI/Base/UIManager.cs index 96d72fc..505d012 100644 --- a/MonogameLibrary/UI/Base/UIManager.cs +++ b/MonogameLibrary/UI/Base/UIManager.cs @@ -16,16 +16,10 @@ namespace MonogameLibrary.UI.Base Dictionary> layerCollection = new(); public GraphicsDevice GraphicsDevice { get; private set; } public SpriteFont BaseFont { get; private set; } - public void Initialize(string font, GraphicsDevice graphicsDevice) + public void Initialize(GraphicsDevice graphicsDevice) { GraphicsDevice = graphicsDevice; - try - { - //BaseFont = _content.Load(font); - } - catch - { - } + for (int i = -10; i < 11; i++) { layerCollection.Add(i, new List()); @@ -35,8 +29,16 @@ namespace MonogameLibrary.UI.Base static MouseState mouseState, prevmouseState; static KeyboardState keyboardState; - public void LoadContent(ContentManager content) + public void LoadContent(ContentManager content, string font) { + + try + { + BaseFont = content.Load(font); + } + catch + { + } foreach (var collection in layerCollection) { foreach (var item in collection.Value)