-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandCard.eps
More file actions
104 lines (88 loc) · 2.94 KB
/
CommandCard.eps
File metadata and controls
104 lines (88 loc) · 2.94 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
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
import ETK.ETKUnit as Unit;
import ETK.ETKConstants as Const;
const DYNAMIC_BUTTON_SET = 249;
const BUTTON_TOOLTIP_STRING_FIRST = 1539;
const BUTTON_FIRST_UNIT_TYPE = Const.Unit_DarkTemplar_Hero;
const Screen = StringBuffer(256);
function setupUnit(unit) {
Unit.setCommandCard(unit, DYNAMIC_BUTTON_SET);
}
function getButtonIndexFromBuildQueue(unit) {
return Unit.getBuildQueue1(unit) - BUTTON_FIRST_UNIT_TYPE;
}
function setButtonIconWithState(position, iconID, title, enabled, actionType) {
// Must be executed for localCP
if (IsUserCP()) {
const stringID = BUTTON_TOOLTIP_STRING_FIRST + position;
const buttonStringValue = stringID + (65536 * stringID);
settblf(stringID, 0, "{:s}", title);
// setcurpl(P1); Screen.printf("setButtonIconWithState {} {} {:s} ({})", position, iconID, title, stringID);
var conditionValue;
if (enabled) {
conditionValue = 4358864; //Always display
} else {
conditionValue = 4359904; //Has interceptors
}
var action;
var actionPrefix;
if (actionType == 1) { // create unit
// 3 is Create Unit
action = 3 + (BUTTON_FIRST_UNIT_TYPE + position) * 65536;
actionPrefix = 4338864; //Unknown but write anyway
} else if (actionType == 2) { // cancel
action = Const.Unit_None * 65536;
actionPrefix = 4561648; //Unknown but write anyway
}
iconID = (iconID * 65536) + position + 1;
const btnPtr = EPD(0x5187EC) + DYNAMIC_BUTTON_SET * 3;
var btnPos = 5 * position;
dwadd_epd(btnPtr, 0);
btnPos += epdread_epd(btnPtr);
const oldCP = getcurpl();
DoActions(list(
SetMemory(0x6509B0, SetTo, btnPos),
SetDeaths(CurrentPlayer, SetTo, iconID, 0),
SetMemory(0x6509B0, Add, 1),
SetDeaths(CurrentPlayer, SetTo, conditionValue, 0),
SetMemory(0x6509B0, Add, 1),
SetDeaths(CurrentPlayer, SetTo, actionPrefix, 0),
SetMemory(0x6509B0, Add, 1),
SetDeaths(CurrentPlayer, SetTo, action, 0),
SetMemory(0x6509B0, Add, 1),
SetDeaths(CurrentPlayer, SetTo, buttonStringValue, 0),
SetMemory(0x6509B0, SetTo, oldCP)
));
}
}
function setButtonIcon(position, iconID, title) {
setButtonIconWithState(position, iconID, title, true, 1);
}
function setDisabledButtonIcon(position, iconID, title) {
setButtonIconWithState(position, iconID, title, false, 1);
}
function setButtonIconCancel(position, iconID, title) {
setButtonIconWithState(position, iconID, title, true, 2);
}
function hideButtonIcon(position) {
if (IsUserCP()) {
const btnPtr = EPD(0x5187EC) + DYNAMIC_BUTTON_SET * 3;
var btnPos = 5 * position;
dwadd_epd(btnPtr, 0);
btnPos += epdread_epd(btnPtr);
const oldCP = getcurpl();
DoActions(list(
SetMemory(0x6509B0, SetTo, btnPos),
SetMemory(0x6509B0, Add, 1),
SetDeaths(CurrentPlayer, SetTo, 5106496, 0),
SetMemory(0x6509B0, Add, 1),
SetMemory(0x6509B0, Add, 1),
SetMemory(0x6509B0, Add, 1),
SetMemory(0x6509B0, SetTo, oldCP)
));
}
}
function hideAllButtonIcons() {
for (var position = 0; position < 9; position++) {
hideButtonIcon(position);
}
}