player2_dz

Untitled

Jan 27th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.84 KB | None | 0 0
  1. disableSerialization;
  2. private ["_control","_display","_temp","_event","_data","_x","_stopTheKey","_keyLeft","_i","_index","_size","_indices","_lbcontrol"];
  3. private ["_key","_keyRight","_keyTop","_keyBottom","_secondColumn","_activateControl","_output","_doFilter"];
  4. private ["_event","_data","_display","_control","_primaryWeaponControl","_IDCsArray","_lbIDC","_lbColumn","_sum"];
  5. /*
  6. IGUI_GEAR_filterPrimaryWeapon = (_activeFilter select 0);
  7. IGUI_GEAR_filterSecondaryWeapon = (_activeFilter select 1);
  8. IGUI_GEAR_filterAmmo = (_activeFilter select 2);
  9. IGUI_GEAR_filterBinocular = (_activeFilter select 3);
  10. IGUI_GEAR_filterInventory = (_activeFilter select 4);
  11. IGUI_GEAR_filterPistols = (_activeFilter select 5);
  12. IGUI_GEAR_filterPistolAmmo = (_activeFilter select 6); */
  13.  
  14. _filterSets = [
  15. //Primary Weapon, Secondary weapon, Ammo, Binocular, Inventory, Pistols, Pistols Ammo
  16. [false,false,false,false,false,false,false],
  17. [false,true,false,true,true,true,true],
  18. [true,false,false,true,true,true,true],
  19. [true,true,true,false,false,true,true], // all but pistol, pistols ammo
  20. [true,true,true,true,true,true,true]
  21. ];
  22.  
  23. _icons = [
  24. "\ca\ui\data\igui_buyUnit_filter_1_ca.paa",
  25. "\ca\ui\data\igui_buyUnit_filter_2_ca.paa",
  26. "\ca\ui\data\igui_buyUnit_filter_3_ca.paa",
  27. "\ca\ui\data\igui_buyUnit_filter_4_ca.paa",
  28. "\ca\ui\data\igui_buyUnit_filter_5_ca.paa"
  29. ];
  30.  
  31. _event = _this select 1;
  32. _data = _this select 0;
  33.  
  34. _dofilter = false;
  35.  
  36. /*-------------------------------------------*/
  37. if(typeName(_data select 0) == "DISPLAY")then
  38. {
  39. _display = (_data select 0);
  40. };
  41.  
  42. if(typeName(_data select 0) == "CONTROL")then
  43. {
  44. _control = (_data select 0);
  45. _display = ctrlParent _control;
  46. };
  47.  
  48.  
  49. /*-------------------------------------------*/
  50. _lbSelectedItem = {
  51. private ["_index","_selectedItem","_n"];
  52. _lbcontrol = _display displayctrl _lbIDC;
  53. _index = lbCurSel _lbcontrol;
  54. _selectedItem = "";
  55. _n = 0;
  56.  
  57. while {(_selectedItem == "")&&(_n<6)} do {
  58. _selectedItem = _lbcontrol lnbData [_index,1];
  59. uisleep 0.001;
  60. _n = _n + 1;
  61. };
  62.  
  63. _selectedItem;
  64. };
  65.  
  66. _arrowsEnable = {
  67. private ["_index","_selectedItem"];
  68.  
  69. _lbcontrol = _display displayctrl _lbIDC;
  70.  
  71. _controlLeftArrow = _display displayctrl 147;
  72. _controlRightArrow = _display displayctrl 146;
  73. _index = lbCurSel _lbcontrol;
  74. _selectedItemCountLeft = _lbcontrol lnbText [_index,0];
  75. _selectedItemCountRight = _lbcontrol lnbText [_index,2];
  76. };
  77.  
  78.  
  79. _isWeapon = {
  80. private ["_item","_return"];
  81. _item = _this select 0;
  82. _return = (str(configfile >> "cfgWeapons" >> _item) != "");
  83. _return;
  84. };
  85.  
  86. _isMagazine = {
  87. private ["_item","_return"];
  88. _item = _this select 0;
  89. _return = (str(configfile >> "cfgMagazines" >> _item) != "");
  90. _return;
  91. };
  92.  
  93.  
  94. _IDCsArray = [
  95. [107],
  96. [121],
  97. [108],
  98. [107],
  99. [122,123,124,125,126,127,128,129],
  100. [107],
  101. [107],
  102. [107],
  103. [109,110,111,112,113,114,115,116,117,118,119,120],
  104. [109,110,111,112,113,114,115,116,117,118,119,120],
  105. [108],
  106. [107],
  107. [130,131],
  108. [107],
  109. [107],
  110. [107],
  111. [107],
  112. [134,135,136,137,138,139,140,141,142,143,144,145],
  113. [107],
  114. [107],
  115. [107],
  116. [107]
  117. ];
  118.  
  119.  
  120. _showAllIDCs = {
  121. private ["_slotArray","_j","_i"];
  122. for [{_i=0},{_i<count(_IDCsArray)}, {_i = _i + 1} ] do {
  123. _slotArray = _IDCsArray select _i;
  124.  
  125. for [{_j=0},{_j<count(_slotArray)}, {_j = _j + 1} ] do {
  126. _primaryWeaponControl = _display displayctrl (_slotArray select _j);
  127. _primaryWeaponControl ctrlSetFade 0.5;
  128. _primaryWeaponControl ctrlCommit 0.0;
  129. };
  130. };
  131. };
  132.  
  133. _higlightIDCs = {
  134. private ["_slotArray","_j","_i"];
  135. for [{_i=0},{_i<count(_IDCsArray)}, {_i = _i + 1} ] do {
  136. _slotArray = _IDCsArray select _i;
  137. for [{_j=0},{_j<count(_slotArray)}, {_j = _j + 1} ] do {
  138. if (_selectedItemSlotIDCs find (_slotArray select _j)>-1 ) then {
  139. _itemSlot = _display displayctrl (_slotArray select _j);
  140. _itemSlot ctrlSetFade 0.0;
  141. _itemSlot ctrlCommit 0.3;
  142.  
  143. } else {
  144. _itemSlot = _display displayctrl (_slotArray select _j);
  145. _itemSlot ctrlSetFade 0.5;
  146. _itemSlot ctrlCommit 0.3;
  147. };
  148. };
  149. };
  150.  
  151.  
  152. /* for [{_i=0},{_i<count(_selectedItemSlotIDCs)}, {_i = _i + 1} ] do
  153. {
  154. _slotControl = _display displayctrl (_selectedItemSlotIDCs select _i);
  155. _slotControl ctrlSetFade 0;
  156. _slotControl ctrlCommit 0.3;
  157. }; */
  158. };
  159. _returnSlotIDCs = {
  160. _flags = (_this select 0);
  161. _outputArray = [];
  162. _sum = 0;
  163. for [{_i=0},{_i<count(_IDCsArray)}, {_i = _i + 1} ] do
  164. {
  165. _sum = _sum + (_flags select _i);
  166. if ((_flags select _i) == 1) then {
  167. _outputArray = _outputArray + (_IDCsArray select _i);
  168.  
  169. };
  170. };
  171. if (_sum == 0) then {
  172. _outputArray = (_IDCsArray select 2);
  173. };
  174. _outputArray;
  175. };
  176. _isPrimaryWeapon = {
  177. _flags = (_this select 0);
  178. if ( (_flags select 0) == 1) then {
  179. true;
  180. } else {
  181. false;
  182. };
  183. };
  184.  
  185. _isSecondaryWeapon = {
  186. _flags = (_this select 0);
  187. if ( (_flags select 0) == 1) then {
  188. true;
  189. } else {
  190. false;
  191. };
  192. };
  193.  
  194. _itemSlot = {
  195. private ["_item", "_return"];
  196. _item = _this select 0;
  197. _return = 0;
  198. if ([_item] call _isWeapon) then {
  199. _return = getNumber(configfile >> "cfgWeapons" >> _item >> "type");
  200. };
  201. if ([_item] call _isMagazine) then {
  202. _return = getNumber(configfile >> "cfgMagazines" >> _item >> "type");
  203. };
  204. _return;
  205. };
  206.  
  207. _highlightIDCs = {
  208. _hlIDCs = _this select 0;
  209. for [{_i=0},{_i<count(_hlIDCs)}, {_i = _i + 1} ] do {
  210. };
  211. };
  212.  
  213. _returnBitArray = {
  214. private ["_i","_bitArray","_valResult","_val","_n","_i"];
  215. _val = _this select 0;
  216. _bitArray = [0,0,0,0,0 ,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  217. _n = 524288;
  218. for [{_i=19},{_i>=0}, {_i = _i - 1} ] do
  219. {
  220.  
  221. _valResult = _val mod _n;
  222. if (_valResult != _val) then {
  223. _bitArray set [_i, 1];
  224. };
  225. _n = _n / 2;
  226. _val = _valResult;
  227. };
  228. _bitArray
  229. };
  230.  
  231. _highlightGearSlots ={
  232. // [] call _showAllIDCs;
  233. _selectedItem = [] call _lbSelectedItem;
  234. _selectedItemSlot = [_selectedItem] call _itemSlot;
  235. _selectedItemSlotFlags = [_selectedItemSlot] call _returnBitArray;
  236. _selectedItemSlotIDCs = [_selectedItemSlotFlags] call _returnSlotIDCs;
  237. [_selectedItemSlotIDCs] call _higlightIDCs;
  238. };
  239. _weaponsLBSetFocus = {
  240. _lbcontrol = _display displayctrl _lbIDC;
  241. /** Temporary disabled to prevent bug news:[email protected] **/
  242. //ctrlSetFocus _lbcontrol;
  243. };
  244. _setFilterIcon = {
  245. _ctrlIcon = _display displayctrl 148;
  246. _ctrlIcon ctrlSetText (_icons select IGUI_GEAR_activeFilter);
  247. };
  248.  
  249.  
  250. _keyActions = {
  251. _keyLeft = [203,327700,327686];
  252. _keyRight = [205,327696,327687];
  253. _keyTop = [200,327697,327684];
  254. _keyBottom = [208,327701,327685];
  255. _key = _data select 1;
  256. if((_keyLeft find _key)>=0)then {
  257. _control = _display displayctrl 146;
  258. ctrlActivate _control;
  259. _output = true;
  260. };
  261. if((_keyRight find _key)>=0)then {
  262. _control = _display displayctrl 147;
  263. ctrlActivate _control;
  264. _output = true;
  265. };
  266. if((_keyTop find _key)>=0)then {
  267.  
  268. };
  269. if((_keyBottom find _key)>=0)then {
  270.  
  271. };
  272. };
  273. //_bitArray = [0,0,0,0,0 ,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  274. /*
  275. #define WeaponNoSlot 0 // dummy weapons
  276. #define WeaponSlotPrimary 1 // primary weapons
  277. #define WeaponSlotSecondary 4 // secondary weapons
  278. #define WeaponSlotHandGun 2 // HandGun
  279. #define WeaponSlotHandGunItem 16 // HandGun magazines
  280. #define WeaponSlotItem 256 // items
  281. #define WeaponSlotBinocular 4096 // binocular
  282. #define WeaponHardMounted 65536
  283. #define WeaponSlotInventory 131072 // inventory items
  284. */
  285.  
  286. _setFilterGlobals = {
  287. _activeFilter = _this;
  288. IGUI_GEAR_filterPrimaryWeapon = (_activeFilter select 0);
  289. IGUI_GEAR_filterSecondaryWeapon = (_activeFilter select 1);
  290. IGUI_GEAR_filterAmmo = (_activeFilter select 2);
  291. IGUI_GEAR_filterBinocular = (_activeFilter select 3);
  292. IGUI_GEAR_filterInventory = (_activeFilter select 4);
  293. IGUI_GEAR_filterPistols = (_activeFilter select 5);
  294. IGUI_GEAR_filterPistolAmmo = (_activeFilter select 6);
  295. };
  296.  
  297. //1201
  298. _highlightFilterIcons = {
  299. for [{_i=0},{_i<6}, {_i = _i + 1} ] do
  300. {
  301. _control = _display displayctrl (1200 + _i);
  302. _control ctrlSetTextColor [0.6000,0.8392,0.4706,1.0];
  303. };
  304. _control = _display displayctrl (1200 + _this);
  305. _control ctrlSetTextColor [1,1,1,1];
  306. };
  307.  
  308. _matchesFilter = {
  309. private ["_itemValue","_itemBitArray"];
  310. _output = false;
  311.  
  312. _itemValue = _this select 0;
  313. _itemBitArray = [_itemValue] call _returnBitArray;
  314.  
  315.  
  316. if (_itemValue == 1 && IGUI_GEAR_filterPrimaryWeapon) then {
  317. _output = true;
  318. };
  319.  
  320. if (_itemValue == 5 && IGUI_GEAR_filterPrimaryWeapon) then {
  321. _output = true;
  322.  
  323. };
  324.  
  325. if (_itemValue == 4 && IGUI_GEAR_filterSecondaryWeapon) then {
  326. _output = true;
  327. };
  328.  
  329. if (_itemValue == 2 && IGUI_GEAR_filterPistols) then {
  330. _output = true;
  331. };
  332. if (_itemValue == 16 && IGUI_GEAR_filterPistolAmmo) then {
  333. _output = true;
  334. };
  335.  
  336. if (_itemValue == 131072 && IGUI_GEAR_filterInventory) then {
  337. _output = true;
  338. };
  339.  
  340. if (_itemValue == 512 && IGUI_GEAR_filterAmmo) then {
  341. _output = true;
  342. };
  343. if (_itemValue == 256 && IGUI_GEAR_filterAmmo) then {
  344. _output = true;
  345. };
  346.  
  347. if (_itemValue == 4096 && IGUI_GEAR_filterBinocular) then {
  348. _output = true;
  349. };
  350. _output;
  351. };
  352.  
  353. _filterItems = {
  354. private ["_n","_itemType"];
  355. _deleteIndexes = [];
  356. _lbcontrol = _display displayctrl _lbIDC;
  357. _n = (lnbSize _lbcontrol) select 0;
  358. _j = 0;
  359. for [{_i=_n},{_i>=0}, {_i = _i - 1} ] do
  360. {
  361. _item = _lbcontrol lnbData [_i,1];
  362. _itemType = [_item] call _itemSlot;
  363.  
  364. if ([_itemType] call _matchesFilter) then {
  365. _j = _j + 1;
  366. _deleteIndexes set [(_j-1), _i];
  367. };
  368. };
  369. LB_CTRL = _lbcontrol;
  370. {
  371. _lbcontrol lnbDeleteRow _x;
  372. } count _deleteIndexes;
  373. };
  374.  
  375. _itemPicture = {
  376. private ["_item"];
  377. _item = _this select 0;
  378.  
  379. _return = "";
  380.  
  381. if ([_item] call _isWeapon) then {
  382. _return = getText(configfile >> "cfgWeapons" >> _item >> "picture");
  383. };
  384. if ([_item] call _isMagazine) then {
  385. _return = getText(configfile >> "cfgMagazines" >> _item >> "picture");
  386. };
  387. _return;
  388. };
  389.  
  390. _itemDescription = {
  391. private ["_inputItem","_return"];
  392. _inputItem = _this select 0;
  393. _return = "";
  394. if ([_inputItem] call _isWeapon) then {
  395. _name = getText(configfile >> "cfgWeapons" >> _inputItem >> "descriptionShort");
  396. _return = (_name);
  397. };
  398.  
  399. if ([_inputItem] call _isMagazine) then {
  400. _name = getText(configfile >> "cfgMagazines" >> _inputItem >> "descriptionShort");
  401. _return = (_name);
  402. };
  403. _return;
  404. };
  405.  
  406. _itemName = {
  407. private ["_item"];
  408. _item = _this select 0;
  409.  
  410. _return = "";
  411.  
  412. if ([_item] call _isWeapon) then {
  413. _name = getText(configfile >> "cfgWeapons" >> _item >> "displayName");
  414. _return = ( _name);
  415. };
  416.  
  417. if ([_item] call _isMagazine) then {
  418. _name = getText(configfile >> "cfgMagazines" >> _item >> "displayName");
  419. _return = ( _name);
  420. };
  421.  
  422. _return;
  423. };
  424. _displayItemIcon = {
  425. private ["_selectedItem","_itemPicturePath"];
  426. _selectedItem = [] call _lbSelectedItem;
  427. _itemPicturePath = [_selectedItem] call _itemPicture;
  428. _pictureControl = _display displayctrl 1104;
  429. _pictureControl ctrlSetText _itemPicturePath;
  430. };
  431.  
  432. _displayItemDescription = {
  433. private ["_descriptionControl","_selectedItemDescription","_selectedItemN"];
  434. _selectedItemN = [] call _lbSelectedItem;
  435. _selectedItemDescription = [_selectedItemN] call _itemDescription;
  436. _descriptionControl = _display displayctrl 1106;
  437.  
  438. _descriptionControl ctrlSetStructuredText parseText(_selectedItemDescription);
  439. };
  440.  
  441. _displayItemName = {
  442. private ["_nameControl","_itemDescription"];
  443. _selectedItem = [] call _lbSelectedItem;
  444. _itemName = [_selectedItem] call _itemName;
  445. _nameControl = _display displayctrl 1101;
  446. _nameControl ctrlSetText _itemName;
  447. };
  448.  
  449.  
  450. _output = true;
  451. _lbIDC = 105;
  452.  
  453.  
  454. switch _event do {
  455. case "initDialog": {
  456. [] call _showAllIDCs;
  457. };
  458. case "onLoad": {
  459. [] call _weaponsLBSetFocus;
  460. [] call _arrowsEnable;
  461. [] call _displayItemIcon;
  462. [] call _displayItemName;
  463. [] call _displayItemDescription;
  464. [] call _showAllIDCs;
  465. //[] call _arrowsEnable;
  466. //[] call _highlightGearSlots;
  467. };
  468.  
  469. //used for buyUnits
  470. case "filter": {
  471. IGUI_GEAR_activeFilter = IGUI_GEAR_activeFilter + 1;
  472. if (IGUI_GEAR_activeFilter > ((count _filterSets)-1 )) then {
  473. IGUI_GEAR_activeFilter = 0;
  474. };
  475. _doFilter = true;
  476. };
  477.  
  478. //changing IGUI_GEAR_activeFilter, but not filter picture (used for buyGear)
  479. case "filterNotSet": {
  480. IGUI_GEAR_activeFilter = IGUI_GEAR_activeFilter + 1;
  481. if (IGUI_GEAR_activeFilter > ((count _filterSets)-1 )) then {
  482. IGUI_GEAR_activeFilter = 0;
  483. };
  484. //_doFilter = true;
  485. };
  486.  
  487. case "filter_left": {
  488. IGUI_GEAR_activeFilter = IGUI_GEAR_activeFilter - 1;
  489. if (IGUI_GEAR_activeFilter < 0) then {
  490. IGUI_GEAR_activeFilter = ((count _filterSets)-1 );
  491. };
  492. _doFilter = true;
  493. };
  494.  
  495.  
  496. case "onFocus": {
  497. [] call _weaponsLBSetFocus;
  498. //[] call _arrowsEnable;
  499. };
  500.  
  501. case "onKeyDown": {
  502. [] call _keyActions;
  503. };
  504. case "onLBSelChanged": {
  505. [] call _displayItemIcon;
  506. [] call _displayItemName;
  507. [] call _displayItemDescription;
  508. //[] call _arrowsEnable;
  509. [] call _highlightGearSlots;
  510. };
  511. case "onKillFocus": {
  512. [] call _weaponsLBSetFocus;
  513. };
  514. default {
  515.  
  516. };
  517. };
  518.  
  519. /* Filter removed, moving to engine */
  520. if _doFilter then {
  521. (_filterSets select IGUI_GEAR_activeFilter) call _setFilterGlobals;
  522. // [] call _filterItems;
  523. // [] call _setFilterIcon;
  524. };
  525.  
  526.  
  527. _output;
  528. false;
Advertisement
Add Comment
Please, Sign In to add comment