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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
/* Important, use +array if you plan to use Setters */
private ["_inRange","_sideID","_nObjects","_nObject","_unitList","_text","_amount","_val","_val2",
"_ainumber","_txt","_type","_check","_updateFiller","_list","_id","_changed","_get","_currentMags",
"_currentRow","_currentData","_currentValue","_currentItem","_skip","_get2","_oldMags","_currentMagazines",
"_slist","_index","_currentWeapons","_displayInv","_zt","_currentSpecialCost","_u",
"_currentSpecials","_currentItems","_currentPrimary","_currentPrimaryCost","_currentSecondary",
"_currentSecondaryCost","_currentSidearm","_currentSidearmCost","_cwep","_x","_tempWeapons",
"_tempItems","_tempMags","_tempSpecs","_currentMagValue","_currentMag","_currentUnit","_updateUnit",
"_sideGear","_found","_data","_inventorySlots","_sidearmInventorySlots","_miscItemSlots","_currentCost",
"_cost","_slot","_upgradeCost","_funds","_template","_templateCosts","_templatePictures","_templateNames",
"_templateMags","_templateItems","_templateSpecs","_templateUpgrades","_templateAllowed",
"_cAllow","_temp","_desc","_pict","_upgr","_filler","_mainAction","_inventoryClick","_unitSwap",
"_actionSE","_lastFiller","_primary","_secondary","_sidearm","_misc","_magazine","_all","_lb",
"_lbm","_primaryIDC","_secondaryIDC","_sidearmIDC","_specialIDC","_display","_totalWeapons",
"_fillerIDC","_fillerTypes","_old","_disp","_buildings","_getpp","_isPrimAllowTwo","_getss","_isSecoAllowTwo",
"_sskip","_query","_tfil","_pallow","_sallow"];
_primary = +(WF_Logic getVariable 'primaryClasses');
_secondary = +(WF_Logic getVariable 'secondaryClasses');
_sidearm = +(WF_Logic getVariable 'sidearmClasses');
_misc = +(WF_Logic getVariable 'miscClasses');
_magazine = +(WF_Logic getVariable 'magazineClasses');
_template = +(WF_Logic getVariable 'templateClasses');
_templateCosts = +(WF_Logic getVariable 'templateCosts');
_templatePictures = +(WF_Logic getVariable 'templatePictures');
_templateNames = +(WF_Logic getVariable 'templateNames');
_templateMags = +(WF_Logic getVariable 'templateMags');
_templateItems = +(WF_Logic getVariable 'templateItems');
_templateSpecs = +(WF_Logic getVariable 'templateSpecs');
_templateUpgrades = +(WF_Logic getVariable 'templateUpgrades');
_templateAllowed = +(WF_Logic getVariable 'templateAllowed');
_all = _primary + _secondary + _sidearm + _misc;
WF_Logic setVariable ['lbChange',false];
WF_Logic setVariable ['lbMainAction',''];
WF_Logic setVariable ['InventoryClick',-1];
WF_Logic setVariable ['WF_GEAR_Swap',false];
WF_Logic setVariable ['WF_Gear_Action',''];
ctrlShow[3802,false];
primClicked = false;
secoClicked = false;
sideClicked = false;
deleteLoadout = false;
saveLoadout = false;
buyLoadout = false;
_displayInv = false;
_updateUnit = true;
_updateFiller = false;
disableSerialization;
_lb = 3700;
_lbm = 3701;
_primaryIDC = 3500;
_secondaryIDC = 3501;
_sidearmIDC = 3502;
_specialIDC = 3535;
_display = _this select 0;
_totalWeapons = count _primary + count _secondary + count _sidearm;
_fillerIDC = [3400,3401,3402,3403,3404,3405];
_fillerTypes = ['template','all','primary','secondary','sidearm','misc'];
_inventorySlots = [];
_lastFiller = 'nil';
_id = _fillerTypes find 'primary';
_list = [];
_miscItemSlots = [];
_sidearmInventorySlots = [];
(_display DisplayCtrl (_fillerIDC select _id)) ctrlSetTextColor [1, 1, 1, 1];
_currentItem = '';
_currentMags = [];
_currentData = '';
_currentValue = '';
_currentCost = 0;
_cost = 0;
_currentPrimary = '';
_currentSecondary = '';
_currentSidearm = '';
_currentPrimaryCost = 0;
_currentSecondaryCost = 0;
_currentSidearmCost = 0;
_currentSpecialCost = 0;
_old = '';
_currentWeapons = [];
_currentSpecials = [];
_currentItems = [];
_currentMagazines = [];
_disp = (findDisplay 16000) displayAddEventHandler ['KeyDown','_this Call WF_Gear_Hotkeys'];
_buygearfrom = missionNamespace getVariable "WFBE_TOWNGEAR";
//--- Fill the available units list.
_unitList = [];
_buildings = (sideJoinedText) Call GetSideStructures;
_i = 0;
{
_check = ['BARRACKSTYPE',_buildings,'WFBE_PURCHASEGEARRANGE' Call GetNamespace,sideJoined,_x] Call BuildingInRange;
_inRange = if (isNull _check) then {false} else {true};
if (!_inRange && _buygearfrom in [1,2,3]) then {
_lookfor = switch (_buygearfrom) do { case 1:{WFCAMP}; case 2:{WFDEPOT}; case 3:{WFCAMP + WFDEPOT}; default{[]}};
_nObjects = nearestObjects [_x, _lookfor, 25];
_nObject = if (count _nObjects > 0) then {_nObjects select 0} else {objNull};
if !(isNull _nObject) then {
_sideID = _nObject getVariable "sideID";
if !(isNil "_sideID") then {
if (_sideID == sideID) then {_inRange = true};
};
};
};
if (_inRange) then {
_txt = (_x) Call GetAIDigit;
_unitList = _unitList + [_x];
_type = [typeOf _x, 'displayName'] Call GetConfigInfo;
lbAdd [3854,Format["[%1] %2 (%3)",_txt,name _x,_type]];
if (_currentUnit == _x) then {lbSetCurSel[3854,_i]};
_i = _i + 1;
};
} forEach units(group player);
_currentUnit = player;
while {alive player && dialog} do {
if (Side player != sideJoined) exitWith {closeDialog 0};
if (!dialog) exitWith {};
//--- Something changed since the last time?
_filler = WF_Logic getVariable 'filler';
_changed = WF_Logic getVariable 'lbChange';
_mainAction = WF_Logic getVariable 'lbMainAction';
_inventoryClick = WF_Logic getVariable 'InventoryClick';
_unitSwap = WF_Logic getVariable 'WF_GEAR_Swap';
_actionSE = WF_Logic getVariable 'WF_Gear_Action';
//--- Filter Changed.
if (_filler != _lastFiller || _updateFiller) then {
_updateFiller = false;
_list = Call Compile Format ['_%1',_filler];
lnbClear _lb;
if (_filler != 'template') then {
[_list,_filler,_lb] Call UIGearFillList;
} else {
[_templateCosts,_templateNames,_templatePictures,_templateUpgrades,_templateAllowed,_filler,_lb] Call UIGearFillTemplateList;
};
_id = _fillerTypes find _filler;
{(_display displayCtrl _x) ctrlSetTextColor [0.7490, 0.7490, 0.7490, 0.7]} forEach _fillerIDC;
(_display displayCtrl (_fillerIDC select _id)) ctrlSetTextColor [1, 1, 1, 1];
//--- Update the list since the filler changed.
_changed = true;
};
//--- List Selection Changed.
if (_changed) then {
WF_Logic setVariable ['lbChange',false];
_currentRow = lnbCurSelRow _lb;
_currentData = lnbData[_lb,[_currentRow,0]];
_currentValue = lnbValue[_lb,[_currentRow,0]];
_currentItem = _list select _currentValue;
lnbClear _lbm;
_get = [];
/* Get */
if (_filler != 'template') then {
if (_filler == 'secondary' || _filler == 'all') then {
_get = (_currentItem+'_W') Call GetNamespace;
if (isNil '_get') then {
_get = _currentItem Call GetNamespace;
};
} else {
_get = _currentItem Call GetNamespace;
};
if !(isNil '_get') then {
_currentMags = _get select QUERYGEARMAGAZINES;
if (typeName _currentMags != 'SCALAR') then {
if (count _currentMags > 0) then {
[_currentMags,'magazine',_lbm] Call UIGearFillList;
};
};
};
};
};
//--- Player have clicked on one of the listbox.
if (_mainAction != '') then {
switch (_mainAction) do {
case 'addWeapon': {
_skip = true;
_sskip = false;
_get = [];
if (_filler != 'template') then {
_get = (_currentItem+"_W") Call GetNamespace;
if (isNil '_get') then {
_get = _currentItem Call GetNamespace;
};
};
if (_filler == 'primary' || _filler == 'secondary' || _filler == 'sidearm' || _filler == 'all') then {
if (_currentItem in _misc) then {_skip = false;_currentValue = _currentValue - _totalWeapons};
if (_skip) then {
_slist = Call Compile Format ['_%1',_currentData];
_index = _slist find _currentItem;
if (_index != -1) then {
if (_filler == 'all') then {
if (_currentItem in _primary) then {_currentData = 'primary'} else {
if (_currentItem in _secondary) then {_currentData = 'secondary'} else {
if (_currentItem in _sidearm) then {_currentData = 'sidearm'};
};
};
};
/* Handle the extended inventory system if disabled */
_isSecoAllowTwo = true;
_isPrimAllowTwo = true;
if (paramExtendedInventory && (_filler == 'primary' || _filler == 'secondary' || _filler == 'all')) then {
_getpp = [];
_getss = [];
_query = if (_currentData == 'primary') then {_currentItem} else {_currentPrimary};
if (_query != '') then {
_getpp = (_query+"_W") Call GetNamespace;
if (isNil '_getpp') then {
_getpp = _query Call GetNamespace;
};
};
if (_query != '') then {_isPrimAllowTwo = _getpp select QUERYGEARALLOWTWO};
_query = if (_currentData == 'secondary') then {_currentItem} else {_currentSecondary};
if (_query != '') then {
_getss = (_query+"_W") Call GetNamespace;
if (isNil '_getss') then {
_getss = _query Call GetNamespace;
};
};
if (_query != '') then {_isSecoAllowTwo = _getss select QUERYGEARALLOWTWO};
if (!_isSecoAllowTwo && !_isPrimAllowTwo) then {
_sskip = true;
hint parseText (localize 'STR_WF_INFO_Gear_AllowTwo');
};
};
if (!_sskip) then {
Call Compile Format ['_old = _current%1;_currentWeapons = _currentWeapons - [_current%1]; _current%1Cost = %2; _current%1 = "%3";ctrlSetText[_%1IDC,"%4"]',_currentData,_get select QUERYGEARCOST,_currentItem,_get select QUERYGEARPICTURE];
//--- New Magazines.
_currentMags = _get select QUERYGEARMAGAZINES;
//--- Old Magazines.
_get2 = (_old+"_W") Call GetNamespace;
if (isNil '_get2') then {
_get2 = _old Call GetNamespace;
};
if !(isNil '_get2') then {
_oldMags = _get2 select QUERYGEARMAGAZINES;
_use = "";
_currentUpgrades = (sideJoinedText) Call GetSideUpgrades;
{
_upgr = (missionNamespace getVariable _x) select QUERYGEARUPGRADE;
if ((_currentUpgrades select 13) >= _upgr) exitWith {_use = _x};
} forEach _currentMags;
_currentMagazines = [_use,_oldMags,_currentMagazines] Call ReplaceInventoryAmmo;
};
};
if !(isNil '_get2') then {
_oldMags = _get2 select QUERYGEARMAGAZINES;
_currentMagazines = [_currentMags select 0,_oldMags,_currentMagazines] Call ReplaceInventoryAmmo;
};
};
};
if (!_sskip) then {
_currentWeapons = _currentWeapons + [_currentItem];
_displayInv = true;
};
};
};
if (_filler == 'misc' || !_skip) then {
_type = _get select QUERYGEARTYPE;
if (_type == 'CfgMagazines') then {
_currentMagazines = [_currentMagazines,_currentItem] Call UIAddMagazine;
_displayInv = true;
};
if (_type == 'Special' && count _currentSpecials < 3 && !(_currentItem in _currentSpecials)) then {
_currentSpecials = _currentSpecials + [_currentItem];
_currentSpecialCost = 0;
_u = 0;
{
_zt = _x Call GetNamespace;
ctrlSetText[_specialIDC + _u,_zt select QUERYGEARPICTURE];
_currentSpecialCost = _currentSpecialCost + (_zt select QUERYGEARCOST);
_u = _u + 1;
} forEach _currentSpecials;
_displayInv = true;
};
if (_type == 'Item') then {
if (!(_currentItem in _currentItems)) then {
_currentItems = [_currentItems,_currentItem] Call UIAddItem;
_displayInv = true;
};
};
};
/* TODO */
if (_filler == 'template') then {
_tempWeapons = _template select _currentValue;
_tempItems = _templateItems select _currentValue;
_tempMags = _templateMags select _currentValue;
_tempSpecs = _templateSpecs select _currentValue;
_currentPrimary = '';
_currentSecondary = '';
_currentSidearm = '';
_currentPrimaryCost = 0;
_currentSecondaryCost = 0;
_currentSidearmCost = 0;
_currentWeapons = [];
_currentItems = _tempItems;
{
_cwep = _x;
_get = (_x+"_W") Call GetNamespace;
if (isNil '_get') then {
_get = _x Call GetNamespace;
};
if (({_x == _cwep} count _primary) > 0) then {_currentWeapons = _currentWeapons + [_x];_currentPrimary = _x;_currentPrimaryCost = _get select QUERYGEARCOST;ctrlSetText[_primaryIDC,_get select QUERYGEARPICTURE]} else {
if (({_x == _cwep} count _secondary) > 0) then {_currentWeapons = _currentWeapons + [_x];_currentSecondary = _x;_currentSecondaryCost = _get select QUERYGEARCOST;ctrlSetText[_secondaryIDC,_get select QUERYGEARPICTURE]} else {
if (({_x == _cwep} count _sidearm) > 0) then {_currentWeapons = _currentWeapons + [_x];_currentSidearm = _x;_currentSidearmCost = _get select QUERYGEARCOST;ctrlSetText[_sidearmIDC,_get select QUERYGEARPICTURE]};
};
};
} forEach _tempWeapons;
if (_currentPrimary == '') then {ctrlSetText [_primaryIDC,'\ca\ui\data\ui_gear_gun_gs.paa']};
if (_currentSecondary == '') then {ctrlSetText [_secondaryIDC,'\ca\ui\data\ui_gear_sec_gs.paa']};
if (_currentSidearm == '') then {ctrlSetText [_sidearmIDC,'\ca\ui\data\ui_gear_hgun_gs.paa']};
_currentMagazines = _tempMags;
_currentSpecials = _tempSpecs;
_currentSpecialCost = 0;
for [{_x = 0},{_x < 2},{_x = _x + 1}] do {ctrlSetText[_specialIDC + _x,'\Ca\UI\Data\ui_gear_eq_gs.paa']};
_u = 0;
{
_get = _x Call GetNamespace;
_currentSpecialCost = _currentSpecialCost + (_get select QUERYGEARCOST);
ctrlSetText[_specialIDC + _u,_get select QUERYGEARPICTURE];
_u = _u + 1;
} forEach _currentSpecials;
_displayInv = true;
};
};
case 'addMagazine': {
_currentMagValue = lnbValue[_lbm,[lnbCurSelRow _lbm,0]];
_currentMag = _currentMags select _currentMagValue;
_currentMagazines = [_currentMagazines,_currentMag] Call UIAddMagazine;
_displayInv = true;
};
};
WF_Logic setVariable ['lbMainAction',''];
};
//--- Remove a weapon by clicking on it.
if (primClicked) then {primClicked = false;if (_currentPrimary != '') then {ctrlSetText [_primaryIDC,'\ca\ui\data\ui_gear_gun_gs.paa'];_index = _primary find _currentPrimary;_currentPrimaryCost = 0;_currentWeapons = _currentWeapons - [_currentPrimary];_currentPrimary = '';_displayInv = true}};
if (secoClicked) then {secoClicked = false;if (_currentSecondary != '') then {ctrlSetText [_secondaryIDC,'\ca\ui\data\ui_gear_sec_gs.paa'];_index = _secondary find _currentSecondary;_currentSecondaryCost = 0;_currentWeapons = _currentWeapons - [_currentSecondary];_currentSecondary = '';_displayInv = true}};
if (sideClicked) then {sideClicked = false;if (_currentSidearm != '') then {ctrlSetText [_sidearmIDC,'\ca\ui\data\ui_gear_hgun_gs.paa'];_index = _sidearm find _currentSidearm;_currentSidearmCost = 0;_currentWeapons = _currentWeapons - [_currentSidearm];_currentSidearm = '';_displayInv = true}};
if (_unitSwap) then {
WF_Logic setVariable ['WF_GEAR_Swap',false];
if (count _unitList > 0) then {_currentUnit = _unitList select (lbCurSel 3854)} else {_currentUnit = player};
_updateUnit = true;
};
if (_updateUnit) then {
_currentWeapons = weapons _currentUnit;
_currentSpecials = [];
_currentItems = [];
_currentMagazines = magazines _currentUnit;
_currentPrimary = '';
_currentSecondary = '';
_currentSidearm = '';
_sideGear = _currentWeapons;
{if (!(_x in _all)) then {_sideGear = _sideGear - [_x]}} forEach _currentWeapons;
_currentWeapons = _sideGear;
_sideGear = _currentMagazines;
{if (!(_x in _misc) && !(_x in _magazine)) then {_sideGear = _sideGear - [_x]}} forEach _currentMagazines;
_currentMagazines = _sideGear;
_currentPrimaryCost = 0;
_currentSecondaryCost = 0;
_currentSidearmCost = 0;
_currentSpecialCost = 0;
ctrlSetText [_primaryIDC,'\ca\ui\data\ui_gear_gun_gs.paa'];
ctrlSetText [_secondaryIDC,'\ca\ui\data\ui_gear_sec_gs.paa'];
ctrlSetText [_sidearmIDC,'\ca\ui\data\ui_gear_hgun_gs.paa'];
ctrlSetText [3535,'\Ca\UI\Data\ui_gear_eq_gs.paa'];
ctrlSetText [3536,'\Ca\UI\Data\ui_gear_eq_gs.paa'];
{
_cwep = _x;
_get = (_cwep+"_W") Call GetNamespace;
if (isNil '_get') then {
_get = _cwep Call GetNamespace;
};
if !(isNil '_get') then {
_found = false;
_index = {_x == _cwep} count _primary;
if (_index > 0) then {_currentPrimary = _cwep;_currentPrimaryCost = _get select QUERYGEARCOST;ctrlSetText[_primaryIDC,_get select QUERYGEARPICTURE];_found = true};
if !(_found) then {
_index = {_x == _cwep} count _secondary;
if (_index > 0) then {_currentSecondary = _cwep;_currentSecondaryCost = _get select QUERYGEARCOST;ctrlSetText[_secondaryIDC,_get select QUERYGEARPICTURE];_found = true};
if !(_found) then {
_index = {_x == _cwep} count _sidearm;
if (_index > 0) then {_currentSidearm = _cwep;_currentSidearmCost = _get select QUERYGEARCOST;ctrlSetText[_sidearmIDC,_get select QUERYGEARPICTURE];_found = true};
if !(_found) then {
_index = {_x == _cwep} count _misc;
if (_index > 0) then {
switch (_get select QUERYGEARTYPE) do {
case 'Special': {
_currentSpecials = _currentSpecials + [_x];
_currentSpecialCost = _currentSpecialCost + (_get select QUERYGEARCOST);
_u = 0;
{
_zt = _x Call GetNamespace;
ctrlSetText[_specialIDC + _u,_zt select QUERYGEARPICTURE];
_u = _u + 1;
} forEach _currentSpecials;
};
case 'Item': {
_currentItems = _currentItems + [_x];
};
};
};
};
};
};
};
} forEach _currentWeapons;
_currentWeapons = _currentWeapons - _misc;
_data = [_currentMagazines,_currentItems] Call DisplayInventory;
_inventorySlots = _data select 0;
_sidearmInventorySlots = _data select 1;
_miscItemSlots = _data select 2;
_currentCost = (_data select 3) + _currentPrimaryCost + _currentSecondaryCost + _currentSidearmCost + _currentSpecialCost;
_cost = 0;
_updateUnit = false;
};
//--- Remove a magazine by clicking on it.
if (_inventoryClick != -1) then {
//--- Main Inventory.
if (_inventoryClick > 3502 && _inventoryClick < 3515) then {
_slot = _inventoryClick - 3503;
if (_slot < Count _inventorySlots) then {
_index = _currentMagazines find (_inventorySlots select _slot);
if (_index != -1) then {_currentMagazines = [_currentMagazines,_index] Call ReplaceArray};
};
};
//--- Handgun Inventory
if (_inventoryClick > 3514 && _inventoryClick < 3523) then {
_slot = _inventoryClick - 3515;
if (_slot < Count _sidearmInventorySlots) then {
_index = _currentMagazines find (_sidearmInventorySlots select _slot);
if (_index != -1) then {_currentMagazines = [_currentMagazines,_index] Call ReplaceArray};
};
};
//--- Misc Inventory
if (_inventoryClick > 3522 && _inventoryClick < 3535) then {
_slot = _inventoryClick - 3523;
if (_slot < Count _miscItemSlots) then {
_index = _currentItems find (_miscItemSlots select _slot);
if (_index != -1) then {_currentItems = [_currentItems,_index] Call ReplaceArray};
};
};
//--- Remove a special item.
if (_inventoryClick == 3535 || _inventoryClick == 3536) then {
_slot = _inventoryClick - 3535;
if (_slot < Count _currentSpecials) then {
_currentSpecialCost = 0;
_currentSpecials = _currentSpecials - [_currentSpecials select _slot];
for [{_x = 0},{_x < 2},{_x = _x + 1}] do {ctrlSetText[_specialIDC + _x,'\Ca\UI\Data\ui_gear_eq_gs.paa']};
_u = 0;
{
_get = _x Call GetNamespace;
_currentSpecialCost = _currentSpecialCost + (_get select QUERYGEARCOST);
ctrlSetText[_specialIDC + _u,_get select QUERYGEARPICTURE];
_u = _u + 1;
} forEach _currentSpecials;
};
};
WF_Logic setVariable ['InventoryClick',-1];
_displayInv = true;
};
//--- Custom UA.
if (_actionSE != '') then {
switch (_actionSE) do {
case 'reload': {
if !(isNil 'respawnWeapons') then {
_currentPrimary = '';
_currentSecondary = '';
_currentSidearm = '';
_currentPrimaryCost = 0;
_currentSecondaryCost = 0;
_currentSidearmCost = 0;
_currentWeapons = [];
_currentItems = [];
_currentSpecials = [];
{
_cwep = _x;
_get = (_cwep+"_W") Call GetNamespace;
if (isNil '_get') then {
_get = _cwep Call GetNamespace;
};
if !(isNil '_get') then {
_index = {_x == _cwep} count _primary;
if (_index > 0) then {_currentWeapons = _currentWeapons + [_x];_currentPrimary = _x;_currentPrimaryCost = _get select QUERYGEARCOST;ctrlSetText[_primaryIDC,_get select QUERYGEARPICTURE]} else {
_index = {_x == _cwep} count _secondary;
if (_index > 0) then {_currentWeapons = _currentWeapons + [_x];_currentSecondary = _x;_currentSecondaryCost = _get select QUERYGEARCOST;ctrlSetText[_secondaryIDC,_get select QUERYGEARPICTURE]} else {
_index = {_x == _cwep} count _sidearm;
if (_index > 0) then {_currentWeapons = _currentWeapons + [_x];_currentSidearm = _x;_currentSidearmCost = _get select QUERYGEARCOST;ctrlSetText[_sidearmIDC,_get select QUERYGEARPICTURE]} else {
_index = {_x == _cwep} count _misc;
if (_index > 0) then {
switch (_get select QUERYGEARTYPE) do {
case 'Special': {
_currentSpecials = _currentSpecials + [_x];
};
case 'Item': {
_currentItems = _currentItems + [_x];
};
};
};
};
};
};
};
} forEach respawnWeapons;
if (_currentPrimary == '') then {ctrlSetText [_primaryIDC,'\ca\ui\data\ui_gear_gun_gs.paa']};
if (_currentSecondary == '') then {ctrlSetText [_secondaryIDC,'\ca\ui\data\ui_gear_sec_gs.paa']};
if (_currentSidearm == '') then {ctrlSetText [_sidearmIDC,'\ca\ui\data\ui_gear_hgun_gs.paa']};
_currentMagazines = respawnAmmo;
_currentSpecialCost = 0;
for [{_x = 0},{_x < 2},{_x = _x + 1}] do {ctrlSetText[_specialIDC + _x,'\Ca\UI\Data\ui_gear_eq_gs.paa']};
_u = 0;
{
_get = _x Call GetNamespace;
_currentSpecialCost = _currentSpecialCost + (_get select QUERYGEARCOST);
ctrlSetText[_specialIDC + _u,_get select QUERYGEARPICTURE];
_u = _u + 1;
} forEach _currentSpecials;
_displayInv = true;
};
};
case 'clear': {
_currentPrimary = '';
_currentSecondary = '';
_currentSidearm = '';
_currentPrimaryCost = 0;
_currentSecondaryCost = 0;
_currentSidearmCost = 0;
_currentSpecialCost = 0;
_currentWeapons = [];
_currentItems = [];
_currentSpecials = [];
_currentMagazines = [];
ctrlSetText [_primaryIDC,'\ca\ui\data\ui_gear_gun_gs.paa'];
ctrlSetText [_secondaryIDC,'\ca\ui\data\ui_gear_sec_gs.paa'];
ctrlSetText [_sidearmIDC,'\ca\ui\data\ui_gear_hgun_gs.paa'];
for [{_x = 0},{_x < 2},{_x = _x + 1}] do {ctrlSetText[_specialIDC + _x,'\Ca\UI\Data\ui_gear_eq_gs.paa']};
_displayInv = true;
};
};
WF_Logic setVariable ['WF_Gear_Action',''];
};
//--- Show inventory (Icons).
if (_displayInv) then {
_displayInv = false;
_upgradeCost = _currentSpecialCost;
_data = [_currentMagazines,_currentItems] Call DisplayInventory;
_inventorySlots = _data select 0;
_sidearmInventorySlots = _data select 1;
_miscItemSlots = _data select 2;
_upgradeCost = _upgradeCost + (_data select 3);
if (_currentPrimary != '') then {_upgradeCost = _upgradeCost + _currentPrimaryCost};
if (_currentSecondary != '') then {_upgradeCost = _upgradeCost + _currentSecondaryCost};
if (_currentSidearm != '') then {_upgradeCost = _upgradeCost + _currentSidearmCost};
_cost = _upgradeCost - _currentCost;
};
//--- Buy a loadout.
if (buyLoadout) then {
buyLoadout = false;
_funds = Call GetPlayerFunds;
if (_funds >= _cost) then {
(-_cost) Call ChangePlayerFunds;
//--- Player's respawn loadout.
if (_currentUnit == player && (vehicleVarName player == clientIdentification)) then {
respawnWeapons = _currentWeapons + _currentSpecials + _currentItems;
respawnAmmo = _currentMagazines;
};
[_currentUnit,(_currentWeapons + _currentSpecials + _currentItems),_currentMagazines] Call EquipLoadout;
_data = [_currentMagazines,_currentItems] Call DisplayInventory;
_inventorySlots = _data select 0;
_sidearmInventorySlots = _data select 1;
_miscItemSlots = _data select 2;
_currentCost = (_data select 3) + _currentPrimaryCost + _currentSecondaryCost + _currentSidearmCost + _currentSpecialCost;
respawnGearCost = _currentCost;
_cost = 0;
} else {
hint parseText(Format [localize "STR_WF_INFO_Funds_Missing_Gear",_cost - _funds]);
};
};
//--- Remove an existing template.
if (deleteLoadout) then {
deleteLoadout = false;
//--- Behave only on template filler.
if (_filler == 'template') then {
_currentRow = lnbCurSelRow _lb;
_currentValue = lnbValue[_lb,[_currentRow,0]];
//--- Update the templates.
_template set [_currentValue, "DELETE"];
_template = _template - ["DELETE"];
WF_Logic setVariable["templateClasses",_template];
_templateCosts set [_currentValue, "DELETE"];
_templateCosts = _templateCosts - ["DELETE"];
WF_Logic setVariable["templateCosts",_templateCosts];
_templatePictures set [_currentValue, "DELETE"];
_templatePictures = _templatePictures - ["DELETE"];
WF_Logic setVariable["templatePictures",_templatePictures];
_templateNames set [_currentValue, "DELETE"];
_templateNames = _templateNames - ["DELETE"];
WF_Logic setVariable["templateNames",_templateNames];
_templateMags set [_currentValue, "DELETE"];
_templateMags = _templateMags - ["DELETE"];
WF_Logic setVariable["templateMags",_templateMags];
_templateItems set [_currentValue, "DELETE"];
_templateItems = _templateItems - ["DELETE"];
WF_Logic setVariable["templateItems",_templateItems];
_templateSpecs set [_currentValue, "DELETE"];
_templateSpecs = _templateSpecs - ["DELETE"];
WF_Logic setVariable["templateSpecs",_templateSpecs];
_templateUpgrades set [_currentValue, "DELETE"];
_templateUpgrades = _templateUpgrades - ["DELETE"];
WF_Logic setVariable["templateUpgrades",_templateUpgrades];
_templateAllowed set [_currentValue, "DELETE"];
_templateAllowed = _templateAllowed - ["DELETE"];
WF_Logic setVariable["templateAllowed",_templateAllowed];
_updateFiller = true;
};
};
//--- TODO
if (saveLoadout) then {
saveLoadout = false;
//--- Behave only on template filler.
if (_filler == 'template') then {
//--- Update the templates.
_desc = '';
_pict = '';
_temp = [];
_cAllow = true;
_upgr = 0;
_pallow = true;
_sallow = true;
if (_currentPrimary != '') then {
_get = _currentPrimary Call GetNamespace;
_temp = _temp + [_currentPrimary];
_desc = _desc + (_get select QUERYGEARLABEL);
_pict = (_get select QUERYGEARPICTURE);
if !(_get select QUERYGEARALLOWED) then {_cAllow = false};
_upgr = _get select QUERYGEARUPGRADE;
_pallow = _get select QUERYGEARALLOWTWO;
};
if (_currentSecondary != '') then {
_get = (_currentSecondary+"_W") Call GetNamespace;
if (isNil '_get') then {
_get = _currentSecondary Call GetNamespace;
};
_temp = _temp + [_currentSecondary];
if (_desc != '') then { _desc = _desc + "/"};
//--- Needless to check if the primary is prohibed.
_desc = _desc + (_get select QUERYGEARLABEL);
if (_pict == '') then {_pict = _get select QUERYGEARPICTURE};
if (_cAllow) then {if !(_get select QUERYGEARALLOWED) then {_cAllow = false}};
if ((_get select QUERYGEARUPGRADE) > _upgr) then {_upgr = (_get select QUERYGEARUPGRADE)};
_sallow = _get select QUERYGEARALLOWTWO;
};
if (_currentSidearm != '') then {
_get = _currentSidearm Call GetNamespace;
_temp = _temp + [_currentSidearm];
if (_desc != '') then { _desc = _desc + "/"};
//--- Needless to check if the secondary is prohibed.
_desc = _desc + (_get select QUERYGEARLABEL);
if (_pict == '') then {_pict = _get select QUERYGEARPICTURE};
if (_cAllow) then {if !(_get select QUERYGEARALLOWED) then {_cAllow = false}};
if ((_get select QUERYGEARUPGRADE) > _upgr) then {_upgr = (_get select QUERYGEARUPGRADE)};
};
if (_pallow || _sallow || !paramExtendedInventory) then {
_template = _template + [_temp];
WF_Logic setVariable["templateClasses",_template];
_templateCosts = _templateCosts + [(_cost + _currentCost)];
WF_Logic setVariable["templateCosts",_templateCosts];
_templatePictures = _templatePictures + [_pict];
WF_Logic setVariable["templatePictures",_templatePictures];
_templateNames = _templateNames + [_desc];
WF_Logic setVariable["templateNames",_templateNames];
_templateMags = _templateMags + [_currentMagazines];
WF_Logic setVariable["templateMags",_templateMags];
_templateItems = _templateItems + [_currentItems];
WF_Logic setVariable["templateItems",_templateItems];
_templateSpecs = _templateSpecs + [_currentSpecials];
WF_Logic setVariable["templateSpecs",_templateSpecs];
_templateUpgrades = _templateUpgrades + [_upgr];
WF_Logic setVariable["templateUpgrades",_templateUpgrades];
_templateAllowed = _templateAllowed + [_cAllow];
WF_Logic setVariable["templateAllowed",_templateAllowed];
_updateFiller = true;
} else {
hint parseText (localize 'STR_WF_INFO_Gear_AllowTwo');
};
};
};
//--- Loadout Cost.
ctrlSetText[3850,Format[localize 'STR_WF_GEAR_Cost',_cost]];
//--- Player's Cash.
//ctrlSetText[3851,Format["%1 $ %2.",localize 'STR_WF_GEAR_CashLabel',Call GetPlayerFunds]];
ctrlSetText[3851,Format["$%1",Call GetPlayerFunds]]; //---changed-MrNiceGuy
_lastFiller = _filler;
sleep 0.05;
//--- Back Button.
if (MenuAction == 1) exitWith { //---added-MrNiceGuy
MenuAction = -1;
closeDialog 0;
createDialog "WF_Menu";
};
};
//--- Variables destruction.
WF_Logic setVariable ['lbChange',nil];
WF_Logic setVariable ['lbMainAction',nil];
WF_Logic setVariable ['InventoryClick',nil];
WF_Gear_Hotkeys = nil;
primClicked = nil;
secoClicked = nil;
sideClicked = nil;
buyLoadout = nil;
saveLoadout = nil;
deleteLoadout = nil;
(findDisplay 16000) displayRemoveEventHandler ['KeyDown',_disp];
|