1
This commit is contained in:
14
Src/Core/Hotkey/BITKit.Hotkey.asmdef
Normal file
14
Src/Core/Hotkey/BITKit.Hotkey.asmdef
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "BITKit.Hotkey",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": true
|
||||
}
|
7
Src/Core/Hotkey/BITKit.Hotkey.asmdef.meta
Normal file
7
Src/Core/Hotkey/BITKit.Hotkey.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3abaaefa7af558d44ba20cea1c43d602
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Src/Core/Hotkey/IHotkeyCollection.cs
Normal file
47
Src/Core/Hotkey/IHotkeyCollection.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BITKit.UX.Hotkey
|
||||
{
|
||||
public interface IHotkeyProvider
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
object Data { get; }
|
||||
bool Enabled { get; }
|
||||
Action OnPerform { get; }
|
||||
float HoldDuration => 0;
|
||||
}
|
||||
public struct HotkeyProvider : IHotkeyProvider
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public object Data { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public Action OnPerform { get; set; }
|
||||
|
||||
public float HoldDuration { get; set; }
|
||||
}
|
||||
public interface IHotkeyCollection
|
||||
{
|
||||
IEnumerable<IHotkeyProvider> Hotkeys { get; }
|
||||
void Register(IHotkeyProvider hotkey);
|
||||
void UnRegister(IHotkeyProvider hotkey);
|
||||
}
|
||||
|
||||
public class HotkeyCollection:IHotkeyCollection
|
||||
{
|
||||
private readonly HashSet<IHotkeyProvider> _hotkeys = new();
|
||||
public IEnumerable<IHotkeyProvider> Hotkeys => _hotkeys;
|
||||
public void Register(IHotkeyProvider hotkey)
|
||||
{
|
||||
_hotkeys.Add(hotkey);
|
||||
}
|
||||
|
||||
public void UnRegister(IHotkeyProvider hotkey)
|
||||
{
|
||||
_hotkeys.Remove(hotkey);
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Core/Hotkey/IHotkeyCollection.cs.meta
Normal file
11
Src/Core/Hotkey/IHotkeyCollection.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad36bc56dd5406418bf8ea67f4bc010
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user