Compare commits

..

2 Commits

Author SHA1 Message Date
11423d86e5 Document GridSet, fix resource hot reload on every frame. 2025-11-15 17:20:22 +01:00
828ec4973f Add docs to UIInputContext. 2025-07-04 19:13:52 +02:00
4 changed files with 49 additions and 12 deletions

View File

@@ -115,7 +115,7 @@ public class TestGame : Game
{
if (Input.IsActionPressed("reload"))
{
ResourceManager.Reload();
// ResourceManager.Reload();
// _particleSystem!.RestartEmitter(_emitterId);
}
}

View File

@@ -7,15 +7,23 @@ namespace Voile;
public class GridSet<T>
{
public float GridSize { get; }
public GridSet(float gridSize = 32.0f)
/// <summary>
/// The size of a cell of this <see cref="GridSet"/>.
/// </summary>
public float CellSize { get; }
public GridSet(float cellSize = 32.0f)
{
GridSize = gridSize;
CellSize = cellSize;
}
/// <summary>
/// Add an element to this <see cref="GridSet"/>.
/// </summary>
/// <param name="position">Position of the element in this <see cref="GridSet"/>.</param>
/// <param name="child">Element to add.</param>
public void Add(Vector2 position, T child)
{
var snap = Vector2.One * GridSize;
var snap = Vector2.One * CellSize;
position = position.Snapped(snap);
if (_values.TryGetValue(position, out var list))
@@ -28,10 +36,11 @@ public class GridSet<T>
}
}
public void Remove(T child)
{
}
/// <summary>
/// Removes an element from this <see cref="GridSet"/>.
/// </summary>
/// <param name="child">Element to remove.</param>
public void Remove(T child) => throw new NotImplementedException();
private Dictionary<Vector2, List<T>> _values = new();
}

View File

@@ -269,7 +269,6 @@ namespace Voile.Resources
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size;

View File

@@ -3,19 +3,48 @@ using Voile.Input;
namespace Voile.UI;
/// <summary>
/// Input information for UI elements.
/// </summary>
public class UIInputContext
{
/// <summary>
/// Current action handled by this <see cref="UIElement"/>.
/// </summary>
public IInputAction Action { get; }
/// <summary>
/// Current mouse position.
/// </summary>
public Vector2 MousePosition { get; }
/// <summary>
/// Determines if a mouse button was pressed.
/// </summary>
public bool MousePressed { get; set; }
/// <summary>
/// Determines if a mouse button was released.
/// </summary>
public bool MouseReleased { get; set; }
/// <summary>
/// Determines if a mouse button is currently held.
/// </summary>
public bool MouseDown { get; set; }
/// <summary>
/// Name of the current <see cref="IInputAction"/>.
/// </summary>
public string ActionName { get; }
/// <summary>
/// Keycode of a currently pressed character.
/// </summary>
public int CharPressed { get; }
/// <summary>
/// Determines if this <see cref="UIInputContext"/> registered any character input from keyboard.
/// </summary>
public bool HasCharInput => CharPressed != 0;
/// <summary>
/// Determines if this context's input was already handled and no longer needs to be processed.
/// </summary>
public bool Handled => _handled;
/// <summary>