moved utilities for rhythmbullet to separate project for a better custom content loaders for the monogame pipeline as well as for future projects and of course learning how things work.

This commit is contained in:
2018-11-29 20:41:06 -06:00
parent b61f390121
commit 698dd9d2f0
26 changed files with 1787 additions and 3 deletions

View File

@@ -0,0 +1,62 @@
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.UI.Modular;
using RhythmBullet.Utilities.DataTypes;
using RhythmBullet.Utilities.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
{
public delegate bool Clicked();
public class Button : UIModule
{
private NinePatch background;
public event Clicked Listeners;
public Button(NinePatch background = null)
{
this.background = background;
}
public override void Draw(SpriteBatch batch)
{
background?.Draw(batch, bounds);
base.Draw(batch);
}
public sealed override bool MouseStateChanged(MouseState state)
{
if (InputUtilities.MouseWithinBoundries(bounds))
{
if (InputUtilities.MouseClicked())
{
OnClick();
}
Highlighted = true;
}
else
{
Highlighted = false;
}
return base.MouseStateChanged(state);
}
public sealed override bool KeyboardStateChanged(KeyboardState state)
{
return base.KeyboardStateChanged(state);
}
protected void OnClick()
{
Listeners?.Invoke();
}
public bool Highlighted { get; private set; }
}
}

View File

@@ -0,0 +1,37 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.UI.Modular.Modules;
using RhythmBullet.Utilities.DataTypes;
using RhythmBullet.Utilities.UI.Modular.Modules.Interactive;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
{
internal class TextButton : Button
{
private TextLabel label;
internal TextButton(string text, SpriteFont font, NinePatch background) : base(background)
{
label = new TextLabel(font, text);
label.autoScale = true;
}
public override void Update(GameTime gameTime)
{
label.bounds = bounds;
label.Update(gameTime);
base.Update(gameTime);
}
public override void Draw(SpriteBatch batch)
{
label.Draw(batch);
base.Draw(batch);
}
}
}