-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkarounds.cs
161 lines (147 loc) · 4.66 KB
/
workarounds.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// =================
// EventScript Client
// Author: McTwist (9845)
// Date: 2018-03-02
//
// Workaround fixes to solve issues regarding strange phenomena
// on either platform
// =================
// Mac keybind workaround
// Enabled for all platforms for convenience
// Creates buttons for copy, paste and editor
// =================
if (isObject(EventScriptWrenchButtons))
EventScriptWrenchButtons.delete();
new GuiSwatchCtrl(EventScriptWrenchButtons) {
profile = "GuiDefaultProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "700 3";
extent = "61 19";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
color = "0 104 176 4";
new GuiBitmapButtonCtrl() {
profile = "BlockButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "16 19";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
command = "EventScriptClient_copy(true);";
text = "C";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "base/client/ui/button2";
lockAspectRatio = "0";
alignLeft = "0";
alignTop = "0";
overflowImage = "0";
mKeepCached = "0";
mColor = "255 255 255 255";
};
new GuiBitmapButtonCtrl() {
profile = "BlockButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "20 0";
extent = "16 19";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
command = "EventScriptClient_paste(true);";
text = "P";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "base/client/ui/button2";
lockAspectRatio = "0";
alignLeft = "0";
alignTop = "0";
overflowImage = "0";
mKeepCached = "0";
mColor = "255 255 255 255";
};
new GuiBitmapButtonCtrl() {
profile = "BlockButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "40 0";
extent = "16 19";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
command = "EventScriptClient_openEditor(false);";
text = "E";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "base/client/ui/button2";
lockAspectRatio = "0";
alignLeft = "0";
alignTop = "0";
overflowImage = "0";
mKeepCached = "0";
mColor = "255 255 255 255";
};
};
WrenchEvents_Window.add(EventScriptWrenchButtons);
// =================
// Mac keybind workaround v2
// Force global key
// =================
package EventScriptPackage_Keybind
{
// Event window is open
function wrenchEventsDlg::onWake(%this)
{
Parent::onWake(%this);
%map = GlobalActionMap.getId();
// Get possible binding
%copy = MoveMap.getbinding(EventScriptClient_copy);
%paste = MoveMap.getbinding(EventScriptClient_paste);
%editor = MoveMap.getbinding(EventScriptClient_openEditor);
$EventScript::bind::copy = (%copy !$= "") ? %copy : (isWindows() ? "keyboard ctrl-shift c" : "keyboard cmd-shift c");
$EventScript::bind::paste = (%paste !$= "") ? %paste : (isWindows() ? "keyboard ctrl-shift v" : "keyboard cmd-shift v");
$EventScript::bind::editor = (%editor !$= "") ? %editor : (isWindows() ? "keyboard ctrl-shift e" : "keyboard cmd-shift e");
GlobalActionMap.pushBind(firstWord($EventScript::bind::copy), restWords($EventScript::bind::copy), EventScriptClient_copy);
GlobalActionMap.pushBind(firstWord($EventScript::bind::paste), restWords($EventScript::bind::paste), EventScriptClient_paste);
GlobalActionMap.pushBind(firstWord($EventScript::bind::editor), restWords($EventScript::bind::editor), EventScriptClient_openEditor);
}
// Event window is closed
function wrenchEventsDlg::onSleep(%this)
{
Parent::onSleep(%this);
GlobalActionMap.popUnbind(firstWord($EventScript::bind::copy), restWords($EventScript::bind::copy));
GlobalActionMap.popUnbind(firstWord($EventScript::bind::paste), restWords($EventScript::bind::paste));
GlobalActionMap.popUnbind(firstWord($EventScript::bind::editor), restWords($EventScript::bind::editor));
}
};
activatePackage(EventScriptPackage_Keybind);
// Push a new command to be used instead of current
function ActionMap::pushBind(%map, %device, %action, %command)
{
if (%map.getCommand(%device, %action) !$= "")
{
%map.stackBind[%device, %action] |= 0;
%map.stackBind[%device, %action, %map.stackBind[%device, %action]] = %map.getCommand(%device, %action);
%map.stackBind[%device, %action]++;
}
%map.bind(%device, %action, %command);
}
// Pop current command in favor for previous one, if there is one
function ActionMap::popUnbind(%map, %device, %action)
{
if (%map.stackBind[%device, %action] !$= "")
{
%map.stackBind[%device, %action]--;
%map.bind(%device, %action, %map.stackBind[%device, %action, %map.stackBind[%device, %action]]);
if (%map.stackBind[%device, %action] == 0)
%map.stackBind[%device, %action] = "";
}
}