Skip to content

Commit

Permalink
Merge pull request #38 from eviltwo/add-summary
Browse files Browse the repository at this point in the history
Add summary
  • Loading branch information
eviltwo committed Jul 8, 2024
2 parents cf1d233 + 832c939 commit f2d544e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public static class DisplayGlyphTextureGenerator
{
private static List<Texture2D> _textureBuffer = new List<Texture2D>();

/// <summary>
/// Generates glyph texture for the specified inputLayoutPaths and writes it to the texture. The glyph textures are arranged according to the layout.
/// </summary>
public static bool GenerateGlyphTexture(Texture2D texture, IReadOnlyList<InputDevice> activeDevices, IReadOnlyList<string> inputLayoutPaths, GlyphsLayout layout)
{
if (texture == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace InputGlyphs
{
public interface IInputGlyphLoader
{
/// <summary>
/// Load glyphs for the given device and layout path and writes it to texture.
/// </summary>
/// <param name="texture">Texture onto which glyphs are written.</param>
/// <param name="activeDevices">Active devices</param>
/// <param name="inputLayoutPath">example: &lt;gamepad&gt;/dpad/left</param>
/// <returns>Return true if the load was success.</returns>
bool LoadGlyph(Texture2D texture, IReadOnlyList<InputDevice> activeDevices, string inputLayoutPath);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

namespace InputGlyphs
{
/// <summary>
/// Manages GlyphLoaders and load Glyph images from registered GlyphLoaders.
/// Register GlyphLoaders when you start the game.
/// </summary>
public static class InputGlyphManager
{
private static List<IInputGlyphLoader> _loaders = new List<IInputGlyphLoader>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ public class GamepadGlyphInitializer : MonoBehaviour
[SerializeField]
private InputGlyphTextureMap _switchProControllerTextureMap = null;

private static bool _initialized;

private void Awake()
{
if (_initialized)
{
return;
}

var gamepadGlyphLoader = new GamepadGlyphLoader(
_fallbackTextureMap,
_xboxTextureMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace InputGlyphs.Loaders.Utils
{
/// <summary>
/// General implementation of the <see cref="IInputGlyphLoader"/>.
/// It is recommended to use the <see cref="DeviceGlyphLoaderInitializer{T}"/> to generate the loader instead of inheriting and implementing this class.
/// </summary>
public class DeviceGlyphLoader<T> : IInputGlyphLoader
where T : InputDevice
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace InputGlyphs.Loaders.Utils
{
/// <summary>
/// A general initialization class that creates glyph loader for various <see cref="InputDevice"/>, handles the transfer of <see cref="InputGlyphTextureMap"/>, and registers loader with the Manager.
/// If you want to easily create a glyph loader for custom devices, it is recommended to inherit from this class.
/// </summary>
public class DeviceGlyphLoaderInitializer<T> : MonoBehaviour
where T : InputDevice
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace InputGlyphs.Loaders.Utils
{
/// <summary>
/// A map that associates control paths of input devices with glyph textures.
/// </summary>
[CreateAssetMenu(fileName = "InputGlyphTextureMap", menuName = "InputGlyphs/InputGlyphTextureMap")]
public class InputGlyphTextureMap : ScriptableObject
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ namespace InputGlyphs.Utils
{
public static class GlyphTextureUtility
{
/// <summary>
/// Combines multiple textures into a single texture arranged in a horizontal row.
/// </summary>
/// <param name="texture">texture to write the results to.</param>
/// <param name="sourceTextures">Original textures. They can be of different sizes.</param>
/// <returns>Return true if the load was success.</returns>
public static bool MergeTexturesHorizontal(Texture2D texture, IReadOnlyList<Texture2D> sourceTextures)
{
var width = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ namespace InputGlyphs.Utils
{
public static class InputActionRebindingExtensions
{
/// <summary>
/// Gets the indexes of all bindings in the action's bindings that match the specified binding mask.
/// This function just changes the number of results of <see cref="InputActionRebindingExtensions.GetBindingIndex()"/> .
/// </summary>
public static void GetBindingIndexes(this InputAction action, InputBinding bindingMask, List<int> results)
{
results.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public static string GetLocalPath(string inputLayoutPath)
return _stringBuilder.ToString();
}

/// <summary>
/// Searches for bindings within actions that match the control scheme and returns the effective paths.
/// </summary>
/// <param name="action">Target action</param>
/// <param name="controlScheme">Control scheme for masks</param>
/// <param name="results">Effective paths of detected bindings</param>
public static bool TryGetActionBindingPath(InputAction action, string controlScheme, List<string> results)
{
results.Clear();
Expand Down

0 comments on commit f2d544e

Please sign in to comment.