added input system to basic button; code cleanup;
This commit is contained in:
parent
fcd2278796
commit
17e59397a5
@ -49,14 +49,17 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Zer01HD\Game\Screens\Transitions\FadeAwayTransition.cs" />
|
<Compile Include="Zer01HD\Game\Screens\Transitions\FadeAwayTransition.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\ContentSystem\NormalContentResolver.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\Persistence\Preferences.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\Renderer\ScaledRenderer.cs" />
|
<Compile Include="Zer01HD\Utilities\Renderer\ScaledRenderer.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\UI\Interactive\BasicButton.cs" />
|
<Compile Include="Zer01HD\Utilities\UI\Interactive\BasicButton.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\ITransition.cs" />
|
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\ITransition.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\LoadingScreen.cs" />
|
<Compile Include="Zer01HD\Utilities\UI\ScreenSystem\LoadingScreen.cs" />
|
||||||
<Compile Include="Zer01HD\Game\Screens\MainScreen.cs" />
|
<Compile Include="Zer01HD\Game\Screens\MainScreen.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\UI\Modular\Module.cs" />
|
<Compile Include="Zer01HD\Utilities\UI\Modular\UIModule.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\UI\Modular\ModuleGroup.cs" />
|
<Compile Include="Zer01HD\Utilities\UI\Modular\UIModuleGroup.cs" />
|
||||||
<Compile Include="RhythmBulletGame.cs" />
|
<Compile Include="RhythmBulletGame.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -11,11 +11,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
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 class ContentSystem
|
||||||
{
|
{
|
||||||
public event ContentUpdate UpdateEvent;
|
public event ContentSystemUpdate ContentSystemListeners;
|
||||||
Thread thread;
|
Thread thread;
|
||||||
readonly ContentManager contentManager;
|
readonly ContentManager contentManager;
|
||||||
readonly Queue<LoadableContent> queue;
|
readonly Queue<LoadableContent> queue;
|
||||||
@ -44,7 +44,6 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
|||||||
Debug.WriteLine("Loaded asset: " + assetName);
|
Debug.WriteLine("Loaded asset: " + assetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public T Get<T>(string assetName)
|
public T Get<T>(string assetName)
|
||||||
{
|
{
|
||||||
lock (queue)
|
lock (queue)
|
||||||
@ -150,7 +149,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
|||||||
|
|
||||||
protected virtual void OnProgress(string fileName, float progress)
|
protected virtual void OnProgress(string fileName, float progress)
|
||||||
{
|
{
|
||||||
UpdateEvent?.Invoke(fileName, progress);
|
ContentSystemListeners?.Invoke(fileName, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Progress
|
public float Progress
|
||||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.UI.Book
|
namespace RhythmBullet.Zer01HD.UI.Book
|
||||||
{
|
{
|
||||||
class Page : ModuleGroup
|
class Page : UIModuleGroup
|
||||||
{
|
{
|
||||||
private readonly int pageX, pageY;
|
private readonly int pageX, pageY;
|
||||||
|
|
||||||
|
@ -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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -6,8 +9,40 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive
|
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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user