added input system to basic button; code cleanup;

This commit is contained in:
Harrison Deng 2018-11-08 23:49:42 -06:00
parent fcd2278796
commit 17e59397a5
4 changed files with 47 additions and 10 deletions

View File

@ -49,14 +49,17 @@
<ItemGroup>
<Compile Include="Zer01HD\Game\Screens\Transitions\FadeAwayTransition.cs" />
<Compile Include="Zer01HD\Utilities\ContentSystem\NormalContentResolver.cs" />
<Compile Include="Zer01HD\Utilities\Input\IInputListener.cs" />
<Compile Include="Zer01HD\Utilities\Input\InputListener.cs" />
<Compile Include="Zer01HD\Utilities\Input\InputUtilities.cs" />
<Compile Include="Zer01HD\Utilities\Persistence\Preferences.cs" />
<Compile Include="Zer01HD\Utilities\Renderer\ScaledRenderer.cs" />
<Compile Include="Zer01HD\Utilities\UI\Interactive\BasicButton.cs" />
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\ITransition.cs" />
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\LoadingScreen.cs" />
<Compile Include="Zer01HD\Game\Screens\MainScreen.cs" />
<Compile Include="Zer01HD\Utilities\UI\Modular\Module.cs" />
<Compile Include="Zer01HD\Utilities\UI\Modular\ModuleGroup.cs" />
<Compile Include="Zer01HD\Utilities\UI\Modular\UIModule.cs" />
<Compile Include="Zer01HD\Utilities\UI\Modular\UIModuleGroup.cs" />
<Compile Include="RhythmBulletGame.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -11,11 +11,11 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
{
public delegate void ContentUpdate(String fileName, float completed);
public delegate void ContentSystemUpdate(String fileName, float completed);
public class ContentSystem
{
public event ContentUpdate UpdateEvent;
public event ContentSystemUpdate ContentSystemListeners;
Thread thread;
readonly ContentManager contentManager;
readonly Queue<LoadableContent> queue;
@ -44,7 +44,6 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
Debug.WriteLine("Loaded asset: " + assetName);
}
public T Get<T>(string assetName)
{
lock (queue)
@ -150,7 +149,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
protected virtual void OnProgress(string fileName, float progress)
{
UpdateEvent?.Invoke(fileName, progress);
ContentSystemListeners?.Invoke(fileName, progress);
}
public float Progress

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.UI.Book
{
class Page : ModuleGroup
class Page : UIModuleGroup
{
private readonly int pageX, pageY;

View File

@ -1,4 +1,7 @@
using System;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.Zer01HD.UI.Modular;
using RhythmBullet.Zer01HD.Utilities.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,8 +9,40 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive
{
class BasicButton
public delegate bool Clicked();
public class BasicButton : UIModuleGroup
{
public event Clicked Listeners;
public BasicButton()
{
}
public sealed override bool MouseStateChanged(MouseState state)
{
if (InputUtilities.MouseWithinBoundries(Bounds))
{
if (InputUtilities.MouseClicked())
{
OnClick();
}
Highlighted = true;
} else
{
Highlighted = false;
}
return base.MouseStateChanged(state);
}
protected void OnClick()
{
Listeners?.Invoke();
}
public bool Highlighted { get; private set; }
}
}