RionKillikus

script_in_question

May 25th, 2019
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_weaponShopFilter.sqf
  4. Author: Bryan "Tonic" Boardwine
  5. Edit: Added level checks - BoGuu
  6.  
  7. Description:
  8. Applies the filter selected and changes the list.
  9. */
  10.  
  11. private _index = (lbCurSel 38402);
  12. private _shop = uiNamespace getVariable ["Weapon_Shop",""];
  13.  
  14. if (_index isEqualTo -1 || {_shop isEqualTo ""}) exitWith {systemChat "Bad Data Filter"; closeDialog 0;}; //Bad data passing.
  15.  
  16. uiNamespace setVariable ["Weapon_Shop_Filter",_index];
  17. //Setup List Control & Purge it.
  18.  
  19. private _priceTag = ((findDisplay 38400) displayCtrl 38404);
  20. _priceTag ctrlSetStructuredText parseText "";
  21.  
  22. private _itemList = ((findDisplay 38400) displayCtrl 38403);
  23. lbClear _itemList;
  24.  
  25. private "_config";
  26.  
  27. if ((uiNamespace getVariable ["Weapon_Magazine",0]) isEqualTo 1 || {(uiNamespace getVariable ["Weapon_Accessories",0]) isEqualTo 1}) then {
  28.  
  29. if ((uiNamespace getVariable ["Weapon_Magazine",0]) isEqualTo 1) then {
  30.  
  31. _config = M_CONFIG(getArray,"WeaponShops",_shop,"mags");
  32. {
  33. _bool = [_x] call life_fnc_levelCheck;
  34. if (_bool) then {
  35. _x params ["_var"];
  36. _count = {_x == _var} count (uiNamespace getVariable ["Magazine_Array",[]]);
  37. if (_count > 0) then {
  38. _itemInfo = [(_x select 0)] call life_fnc_fetchCfgDetails;
  39. _itemList lbAdd format ["%1",if (!((_x select 1) isEqualTo "")) then {(_x select 1)} else {(_itemInfo select 1)}];
  40. _itemList lbSetData[(lbSize _itemList)-1,(_itemInfo select 0)];
  41. _itemList lbSetPicture[(lbSize _itemList)-1,(_itemInfo select 2)];
  42. _itemList lbSetValue[(lbSize _itemList)-1,(_x select 2)];
  43. };
  44. };
  45. true
  46. } count _config;
  47.  
  48. ((findDisplay 38400) displayCtrl 38406) ctrlSetText localize "STR_Global_Weapons";
  49.  
  50. ctrlShow [38406,true];
  51. ctrlShow [38407,false];
  52.  
  53. } else {
  54.  
  55. _config = M_CONFIG(getArray,"WeaponShops",_shop,"accs");
  56. {
  57. _bool = [_x] call life_fnc_levelCheck;
  58. if (_bool) then {
  59. _x params ["_var"];
  60. _count = {_x == _var} count (uiNamespace getVariable ["Accessories_Array",[]]);
  61. if (_count > 0) then {
  62. _itemInfo = [(_x select 0)] call life_fnc_fetchCfgDetails;
  63. _itemList lbAdd format ["%1",if (!((_x select 1) isEqualTo "")) then {(_x select 1)} else {(_itemInfo select 1)}];
  64. _itemList lbSetData[(lbSize _itemList)-1,(_itemInfo select 0)];
  65. _itemList lbSetPicture[(lbSize _itemList)-1,(_itemInfo select 2)];
  66. _itemList lbSetValue[(lbSize _itemList)-1,(_x select 2)];
  67. };
  68. };
  69. true
  70. } count _config;
  71.  
  72. ((findDisplay 38400) displayCtrl 38407) ctrlSetText localize "STR_Global_Weapons";
  73.  
  74. ctrlShow [38406,false];
  75. ctrlShow [38407,true];
  76. };
  77.  
  78. ((findDisplay 38400) displayCtrl 38405) ctrlSetText localize "STR_Global_Buy";
  79. ctrlShow [38402,false];
  80.  
  81. } else {
  82.  
  83. switch (_index) do {
  84.  
  85. case 0: {
  86. _config = M_CONFIG(getArray,"WeaponShops",_shop,"items");
  87. {
  88. _bool = [_x] call life_fnc_levelCheck;
  89. if (_bool) then {
  90. _itemInfo = [_x select 0] call life_fnc_fetchCfgDetails;
  91. _itemList lbAdd format ["%1",if (!((_x select 1) isEqualTo "")) then {_x select 1} else {_itemInfo select 1}];
  92. _itemList lbSetData[(lbSize _itemList)-1,_itemInfo select 0];
  93. _itemList lbSetPicture[(lbSize _itemList)-1,_itemInfo select 2];
  94. _itemList lbSetValue[(lbSize _itemList)-1,_x select 2];
  95. };
  96. true
  97. } count _config;
  98.  
  99. ((findDisplay 38400) displayCtrl 38405) ctrlSetText localize "STR_Global_Buy";
  100. ((findDisplay 38400) displayCtrl 38406) ctrlSetText localize "STR_Global_Mags";
  101. ((findDisplay 38400) displayCtrl 38407) ctrlSetText localize "STR_Global_Accs";
  102.  
  103. ctrlShow [38402,true];
  104. ctrlShow [38406,true];
  105. ctrlShow [38407,true];
  106. };
  107.  
  108. case 1: {
  109. _config = [];
  110. private _listedItems = [];
  111. //Go through weapons
  112. if (primaryWeapon player != "") then {_config pushBack primaryWeapon player;};
  113. if (secondaryWeapon player != "") then {_config pushBack secondaryWeapon player;};
  114. if (handgunWeapon player != "") then {_config pushBack handgunWeapon player;};
  115.  
  116. //Go through items
  117. _config = _config + primaryWeaponItems player;
  118. _config = _config + (assignedItems player);
  119. _config = _config + (uniformItems player);
  120. _config = _config + (vestItems player);
  121. _config = _config + (backpackItems player);
  122.  
  123. ((findDisplay 38400) displayCtrl 38405) ctrlSetText localize "STR_Global_Sell";
  124. ctrlShow [38402,true];
  125. ctrlShow [38406,false];
  126. ctrlShow [38407,false];
  127.  
  128. private _itemArray = [];
  129. _itemArray pushBack M_CONFIG(getArray,"WeaponShops",_shop,"items");
  130. _itemArray pushBack M_CONFIG(getArray,"WeaponShops",_shop,"mags");
  131. _itemArray pushBack M_CONFIG(getArray,"WeaponShops",_shop,"accs");
  132. {
  133. _y = _x;
  134. {
  135. if (!(_x in _listedItems) && _x != "") then {
  136. _iS = [_x,_y] call TON_fnc_index;
  137. if !(_iS isEqualTo -1) then {
  138. _z = _y select _iS;
  139. if (!((_z select 3) isEqualTo -1)) then {
  140.  
  141. _bool = [_z] call life_fnc_levelCheck;
  142. if (_bool) then {
  143.  
  144. _itemInfo = [_x] call life_fnc_fetchCfgDetails;
  145. _listedItems pushBack _x;
  146.  
  147. _itemCount = {_x == (_itemInfo select 0)} count _config;
  148. if (_itemCount > 1) then {
  149. _itemList lbAdd format ["[%2] %1",_itemInfo select 1,_itemCount];
  150. } else {
  151. _itemList lbAdd format ["%1",_itemInfo select 1];
  152. };
  153. _itemList lbSetData[(lbSize _itemList)-1,_itemInfo select 0];
  154. _itemList lbSetPicture[(lbSize _itemList)-1,_itemInfo select 2];
  155.  
  156.  
  157. };
  158. };
  159. };
  160. };
  161. true
  162. } count _config;
  163. true
  164. } count _itemArray;
  165. };
  166. };
  167. };
  168.  
  169. ((findDisplay 38400) displayCtrl 38403) lbSetCurSel 0;
Add Comment
Please, Sign In to add comment