-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbind.cs
57 lines (52 loc) · 1.1 KB
/
bind.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
// Create a possible bind to a function. This will place it in respective division.
// If division and name is the same, it will replace the function.
function CreateBind(%division, %name, %cmd)
{
if (%name $= "" || %cmd $= "")
return;
%remapid = $remapCount;
%new = true;
if (%division !$= "")
{
// Find division
for (%i = 0; %i < $remapCount; %i++)
{
// Found division
if ($remapDivision[%i] $= %division || (%new == false && $remapDivision[%i] $= ""))
{
// Put it in the end
%remapid = %i+1;
%new = false;
// Replace function
if ($remapName[%i] $= %name)
{
$remapCmd[%i] = %cmd;
return;
}
}
// End of division
else if (%new == false)
{
break;
}
}
// Move binds
for (%i = $remapCount; %i > %remapid; %i--)
{
$remapDivision[%i] = $remapDivision[%i-1];
$remapName[%i] = $remapName[%i-1];
$remapCmd[%i] = $remapCmd[%i-1];
}
}
// Append bind
else
{
%new = false;
}
// Add new one
if (%new)
$remapDivision[%remapid] = %division;
$remapName[%remapid] = %name;
$remapCmd[%remapid] = %cmd;
$remapCount++;
}