-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyBinds.cs
122 lines (118 loc) · 4.65 KB
/
KeyBinds.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using Raylib_cs;
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.KeyboardKey;
using static Raylib_cs.MouseButton;
using rbx.Puzzle;
namespace rbx{
public static class Keybinds {
public static bool CloseKey() {
return Control_Mod(KEY_W);
}
public static bool ScreenShotKey() {
return Control_Mod(KEY_S);
}
public static bool HelpKey() {
return Shift_Mod(KEY_SLASH);
}
public static bool FullScreenKey() {
return IsKeyPressed(KEY_F11);
}
public static bool UndoKey() {
return IsKeyDown(KEY_Z) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL));
}
public static bool CenterKey() => IsKeyPressed(KEY_ESCAPE);
public static bool PauseKey() => IsKeyDown(KEY_ENTER);
public static bool ShuffleKey() {
return IsKeyPressed(KEY_SPACE);
}
public static uint? NumKey() {
for(uint i = 0; i < 10; i++)
if(Any_NumPressed(i)) return i;
return null;
}
public static bool UpArrow() => IsKeyPressed(KEY_UP);
public static bool DownArrow() => IsKeyPressed(KEY_DOWN);
public static bool LeftArrow() => IsKeyPressed(KEY_LEFT);
public static bool RightArrow() => IsKeyPressed(KEY_RIGHT);
public static bool Alt_Mod(KeyboardKey key)
=> IsKeyPressed(key) && Any_Alt();
public static bool Control_Mod(KeyboardKey key)
=> IsKeyPressed(key) && Any_Control();
public static bool Shift_Mod(KeyboardKey key)
=> IsKeyPressed(key) && Any_Shift();
public static bool Any_NumPressed(uint num) {
switch(num) {
case 0: return IsKeyPressed(KEY_ZERO)
|| IsKeyPressed(KEY_KP_0);
case 1: return IsKeyPressed(KEY_ONE)
|| IsKeyPressed(KEY_KP_1);
case 2: return IsKeyPressed(KEY_TWO)
|| IsKeyPressed(KEY_KP_2);
case 3: return IsKeyPressed(KEY_THREE)
|| IsKeyPressed(KEY_KP_3);
case 4: return IsKeyPressed(KEY_FOUR)
|| IsKeyPressed(KEY_KP_4);
case 5: return IsKeyPressed(KEY_FIVE)
|| IsKeyPressed(KEY_KP_5);
case 6: return IsKeyPressed(KEY_SIX)
|| IsKeyPressed(KEY_KP_6);
case 7: return IsKeyPressed(KEY_SEVEN)
|| IsKeyPressed(KEY_KP_7);
case 8: return IsKeyPressed(KEY_EIGHT)
|| IsKeyPressed(KEY_KP_8);
case 9: return IsKeyPressed(KEY_NINE)
|| IsKeyPressed(KEY_KP_9);
default: return false;
}
}
public static bool Any_Alt()
=> IsKeyDown(KEY_LEFT_ALT)
|| IsKeyDown(KEY_RIGHT_ALT);
public static bool Any_Control()
=> IsKeyDown(KEY_LEFT_CONTROL)
|| IsKeyDown(KEY_RIGHT_CONTROL);
public static bool Any_Shift()
=> IsKeyDown(KEY_LEFT_SHIFT)
|| IsKeyDown(KEY_RIGHT_SHIFT);
public static Mvmt? InputMvmt() {
KeyboardKey[] MvmtKeys = new KeyboardKey[]{
KEY_X, KEY_Y, KEY_Z, KEY_F, KEY_R, KEY_U, KEY_D, KEY_B, KEY_L, KEY_M, KEY_E, KEY_S
};
for(int i = 0; i < 12; i++) {
if(IsKeyPressed(MvmtKeys[i])) {
if(Any_Shift())
return (Mvmt)(i * 2) + 1;
return (Mvmt)(i * 2);
}
}
return null;
}
public static Vector3 PanVector() {
if(IsMouseButtonUp(MOUSE_LEFT_BUTTON) || !IsCursorOnScreen())
return Vector3.Zero;
Vector2 mouseDelta = GetMouseDelta();
return new Vector3(-1*mouseDelta.X, -1*mouseDelta.Y, 0F);
}
public static Vector2 InputVector() {
Vector2 vec = new Vector2(0, 0);
if (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP)) {
vec = vec + new Vector2(0, -1);
}
if (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN)) {
vec = vec + new Vector2(0, 1);
}
if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) {
vec = vec + new Vector2(1, 0);
}
if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) {
vec = vec + new Vector2(-1, 0);
}
if (vec.Length() == 0) {
return vec;
}
return Vector2.Normalize(vec);
}
}
}