forked from Friedchicken-42/KeyOverlay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKey.cs
More file actions
60 lines (54 loc) · 1.51 KB
/
Key.cs
File metadata and controls
60 lines (54 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using SFML.Graphics;
using SFML.Window;
namespace KeyOverlay
{
public class Key
{
public int Hold { get; set; }
public List<RectangleShape> BarList = new();
public string KeyLetter = "";
public readonly Keyboard.Key KeyboardKey;
public readonly Mouse.Button MouseButton;
public int Counter = 0;
public readonly bool isKey = true;
public Color _color;
public Color _colorPressed;
public uint _size = 1;
public Key(string key)
{
setColor(Color.White);
KeyLetter = key;
if (!Enum.TryParse(key, out KeyboardKey))
{
if (KeyLetter[0] == 'm')
{
KeyLetter = KeyLetter.Remove(0, 1);
}
if (Enum.TryParse(key.Substring(1), out MouseButton))
{
isKey = false;
}
else
{
string exceptName = "Invalid key " + key;
throw new InvalidOperationException(exceptName);
}
}
}
public void setKeyLetter(string key)
{
KeyLetter = key;
}
public void setColor(Color c)
{
_color = c;
_colorPressed = new Color(c.R, c.G, c.B, (byte)(c.A / 1.618));
}
public void setSize(uint size)
{
_size = size;
}
}
}