-
Notifications
You must be signed in to change notification settings - Fork 1
/
xeh_postinit.sqf
247 lines (213 loc) · 13.9 KB
/
xeh_postinit.sqf
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
//by BlackHawk
UO_loadoutIndex = {
private _newIndex = player createDiarySubject ["GearIndex","Loadouts"];
private _playerSide = side player;
private _grpArray = [];
{
private _grpText = "";
if (side _x isEqualto _playerSide) then {
private _group = _x;
private _show = false;
private _textToDisplay = "";
{
private _unit = _x;
if ((alive _unit) && {((isMultiplayer) && (_unit in playableUnits)) || ((!isMultiplayer) && (_unit in switchableUnits))}) then {
private _getPicture = {
params ["_name", "_dimensions", ["_type", "CfgWeapons"]];
if (_name isEqualto "") exitwith {""};
if !(isText(configFile >> _type >> _name >> "picture")) exitwith {""};
private _image = getText(configFile >> _type >> _name >> "picture");
if (_image isEqualto "") then {_image = "\A3\ui_f\data\map\markers\military\unknown_CA.paa";};
if ((_image find ".paa") isEqualto -1) then {_image = _image + ".paa";};
format ["<img image='%1' width='%2' height='%3'/>", _image, _dimensions select 0, _dimensions select 1]
};
private _lobbyName = if !(((roleDescription _x) find "@") isEqualto -1) then {((roleDescription _x) splitString "@") select 0} else {roleDescription _x};
if (_lobbyName isEqualto "") then {_lobbyName = getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName")};
// Creating briefing text
_textToDisplay = _textToDisplay + format ["", rank _unit];
_textToDisplay = _textToDisplay +
format ["<img image='\A3\Ui_f\data\GUI\Cfg\Ranks\%4_gs.paa' width='16' height='16'/> <font size='14' color='%5'>%1 - %2</font> - %3kg<br/>",
name _unit,
_lobbyName,
round ((loadAbs _unit) *0.1 * 0.45359237 * 10) / 10,
toLower rank _unit,
if (_unit isEqualto player) then {"#5555FF"} else {"#FFFFFF"}
];
private _getApparelPicture = {
if !(_this isEqualto "") then {
private _name = getText(configFile >> "CfgWeapons" >> _this >> "displayName");
if (_name isEqualto "") then {
_name = getText(configFile >> "CfgVehicles" >> _this >> "displayName");
};
private _pic = [_this, [40, 40]] call _getPicture;
if (_pic isEqualto "") then {
_pic = [_this, [40, 40], "CfgVehicles"] call _getPicture;
};
_pic + format ["<execute expression='systemChat ""%1""'>*</execute> ", _name]
} else {
""
};
};
{_textToDisplay = _textToDisplay + (_x call _getApparelPicture)} forEach [uniform _unit, vest _unit, backpack _unit, headgear _unit];
_textToDisplay = _textToDisplay + "<br/>";
//display both weapon and it's attachments
private _getWeaponPicture = {
params ["_weaponName", "_weaponItems"];
private _str = "";
if !(_weaponName isEqualto "") then {
_str = _str + ([_weaponName, [80, 40]] call _getPicture);
{
if !(_x isEqualto "") then {
_str = _str + ([_x, [40, 40]] call _getPicture);
};
} forEach _weaponItems;
};
_str
};
//display array of magazines
private _displayMags = {
_textToDisplay = _textToDisplay + " ";
{
private _name = _x;
private _itemCount = {_x isEqualto _name} count _allMags;
private _displayName = getText(configFile >> "CfgMagazines" >> _name >> "displayName");
_textToDisplay = _textToDisplay + ([_name, [32,32], "CfgMagazines"] call _getPicture) + format ["<execute expression='systemChat ""%2""'>x%1</execute> ", _itemCount, _displayName];
} forEach _this;
_textToDisplay = _textToDisplay + "<br/>";
};
//get magazines for a weapon and it's muzzles (grenade launchers etc.)
private _getMuzzleMags = {
private _result = getArray(configFile >> "CfgWeapons" >> _this >> "magazines");
{
if (!(_x isEqualto "this") && {!(_x isEqualto "SAFE")}) then {
{_result pushBackUnique _x} forEach getArray (configFile >> "CfgWeapons" >> _this >> _x >> "magazines");
};
} forEach getArray (configFile >> "CfgWeapons" >> _this >> "muzzles");
_result = _result apply {toLower _x};
_result
};
private _sWeaponName = secondaryWeapon _unit;
private _hWeaponName = handgunWeapon _unit;
private _weaponName = primaryWeapon _unit;
// Primary weapon
if !(_weaponName isEqualto "") then {
private _name = getText(configFile >> "CfgWeapons" >> _weaponName >> "displayName");
_textToDisplay = _textToDisplay + format ["<font color='#FFFF00'>Primary: </font>%1<br/>", _name] + ([_weaponName, primaryWeaponItems _unit] call _getWeaponPicture);
};
private _allMags = magazines _unit;
_allMags = _allMags apply {toLower _x};
private _primaryMags = _allMags arrayIntersect (_weaponName call _getMuzzleMags);
_primaryMags call _displayMags;
// Secondary
private _secondaryMags = [];
if !(_sWeaponName isEqualto "") then {
private _name = getText(configFile >> "CfgWeapons" >> _sWeaponName >> "displayName");
_textToDisplay = _textToDisplay + format ["<font color='#FFFF00'>Launcher: </font>%1<br/>", _name];
_textToDisplay = _textToDisplay + ([_sWeaponName, secondaryWeaponItems _unit] call _getWeaponPicture);
_secondaryMags = _allMags arrayIntersect (_sWeaponName call _getMuzzleMags);
_secondaryMags call _displayMags;
};
// Handgun
private _handgunMags = [];
if !(_hWeaponName isEqualto "") then {
private _name = getText(configFile >> "CfgWeapons" >> _hWeaponName >> "displayName");
_textToDisplay = _textToDisplay + format ["<font color='#FFFF00'>Sidearm: </font>%1<br/>", _name];
_textToDisplay = _textToDisplay + ([_hWeaponName, handgunItems _unit] call _getWeaponPicture);
_handgunMags = _allMags arrayIntersect (_hWeaponName call _getMuzzleMags);
_handgunMags call _displayMags;
};
_allMags = _allMags - _primaryMags;
_allMags = _allMags - _secondaryMags;
_allMags = _allMags - _handgunMags;
private _radios = [];
private _allItems = items _unit;
{
if !((toLower _x) find "acre_" isEqualto -1) then {
_radios pushBack _x;
};
} forEach _allItems;
_allItems = _allItems - _radios;
_textToDisplay = _textToDisplay + format ["<font color='#FFFF00'>Magazines and items: </font>(Click count for info.)<br/>", _x];
//display radios, then magazines, inventory items and assigned items
{
_x params ["_items", "_cfgType"];
while {count _items > 0} do {
private _name = _items select 0;
private _itemCount = {_x isEqualto _name} count _items;
private _displayName = getText(configFile >> _cfgType >> _name >> "displayName");
_textToDisplay = _textToDisplay + ([_name, [32,32], _cfgType] call _getPicture) + format ["<execute expression='systemChat ""%2""'>x%1</execute> ", _itemCount, _displayName];
_items = _items - [_name];
};
} forEach [[_radios, "CfgWeapons"], [_allMags, "CfgMagazines"], [_allItems, "CfgWeapons"], [assignedItems _unit, "CfgWeapons"]];
_textToDisplay = _textToDisplay + "<br/>============================================================<br/>";
_show = true;
};
} foreach units _group;
if _show then {
_grpText = _grpText + _textToDisplay;
};
if !(_grpText isEqualto "") then {_grpArray set [count _grpArray,["GearIndex", [groupID _group, _grpText]]]};
};
} foreach allGroups;
reverse _grpArray;
{
player createDiaryRecord _x;
} foreach _grpArray;
UO_showOrbat = {
private _text = "<br/><execute expression='[] call UO_showOrbat'>Refresh</execute> (click to show JIPs)<br/><br/>";
private _getPicture = {
params ["_name", "_dimensions", ["_type", "CfgWeapons"]];
if (_name isEqualto "") exitwith {""};
if !(isText(configFile >> _type >> _name >> "picture")) exitwith {""};
private _image = getText(configFile >> _type >> _name >> "picture");
if (_image isEqualto "") then {_image = "\A3\ui_f\data\map\markers\military\unknown_CA.paa";};
if ((_image find ".paa") isEqualto -1) then {_image = _image + ".paa";};
format ["<img image='%1' width='%2' height='%3'/>", _image, _dimensions select 0, _dimensions select 1]
};
{
if (((side _x) isEqualto (side player)) && {!isNull leader _x} && {(isPlayer leader _x) || !(isMultiplayer)}) then {
_text = _text + format ["<font size='20' color='#FFFF00'>%1</font>", groupID _x] + "<br/>";
{
private _unit = _x;
private _radios = "";
{
if !((toLower _x) find "acre_" isEqualto -1) then {
_radios = _radios + ([_x, [28,28]] call _getPicture);
};
} forEach items _unit;
private _optics = "";
private _opticsClasses = ["UK3CB_BAF_Soflam_Laserdesignator","Laserdesignator","Laserdesignator_01_khk_F","Laserdesignator_02","Laserdesignator_02_ghex_F","Laserdesignator_03","rhsusf_bino_lerca_1200_black","rhsusf_bino_lerca_1200_tan","ACE_VectorDay","ACE_Vector","rhs_pdu4","rhsusf_bino_lrf_Vector21","Rangefinder","ACE_Yardage450","ACE_MX2A","Binocular","rhsusf_bino_m24_ARD","rhsusf_bino_m24","rhsusf_bino_leopold_mk4"];
{
private _class = _x;
if (_class in (items _unit + assignedItems _unit)) exitwith {
_optics = ([_class, [28,28]] call _getPicture);
};
} foreach _opticsClasses;
private _lobbyName = if !(((roleDescription _unit) find "@") isEqualto -1) then {((roleDescription _unit) splitString "@") select 0} else {roleDescription _unit};
if (_lobbyName isEqualto "") then {_lobbyName = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "displayName")};
_text = _text +
format ["%1<img image='\A3\Ui_f\data\GUI\Cfg\Ranks\%2_gs.paa' width='15' height='15'/> <font size='16' color='%3'>%4 | %5</font> %6 | %7kg<br/>%8 %9 %10 %11<br/>",
if (_forEachIndex isEqualto 0) then {""} else {" "},
rank _unit,
if (_unit isEqualto player) then {"#5555FF"} else {"#FFFFFF"},
name _unit,
_lobbyName,
_radios,
((round ((loadAbs _unit) * 0.45359237)) / 10),
if !(primaryWeapon _unit isEqualto "") then {[primaryWeapon _unit, [56,28]] call _getPicture} else {if !(handgunWeapon _unit isEqualto "") then {[handgunWeapon _unit, [56,28]] call _getPicture} else {""}},
if !(secondaryWeapon _unit isEqualto "") then {[secondaryWeapon _unit, [56,28]] call _getPicture} else {""},
if !(backpack _unit isEqualto "") then {[backpack _unit, [28,28], "CfgVehicles"] call _getPicture} else {""},
_optics
];
} forEach [leader _x] + (units _x - [leader _x]);
};
} forEach allGroups;
_text = _text + "<br/>============================================================";
_text = _text + "<br/>============================================================";
player createDiaryRecord ["GearIndex", ["ORBAT", _text]];
};
call UO_showOrbat;
};
if !(getMissionConfigValue ["UO_FW_Core_Enabled",false]) then {
[] call UO_loadoutIndex;
};