Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType","_key_colors","_ownerKeyId","_itemsPlayer","_hasKey","_objects","_ownerID","_i"];
  2. disableSerialization;
  3. _control = _this select 0;
  4. _button = _this select 1;
  5. _parent = findDisplay 106;
  6.  
  7. //if ((time - dayzClickTime) < 1) exitWith {};
  8. if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {};
  9. if (_button == 1) then {
  10. //dayzClickTime = time;
  11. _group = _parent displayCtrl 6902;
  12.  
  13. _pos = ctrlPosition _group;
  14. _pos set [0,((_this select 2) + 0.48)];
  15. _pos set [1,((_this select 3) + 0.07)];
  16.  
  17. _item = gearSlotData _control;
  18.  
  19. _conf = configFile >> "cfgMagazines" >> _item;
  20. if (!isClass _conf) then {
  21. _conf = configFile >> "cfgWeapons" >> _item;
  22. };
  23. _name = getText(_conf >> "displayName");
  24.  
  25. _cfgActions = _conf >> "ItemActions";
  26. _numActions = (count _cfgActions);
  27. _height = 0;
  28.  
  29. //Populate Menu
  30. for "_i" from 0 to (_numActions - 1) do
  31. {
  32. _menu = _parent displayCtrl (1600 + _i);
  33. _menu ctrlShow true;
  34. _config = (_cfgActions select _i);
  35. _type = getText (_config >> "text");
  36. _script = getText (_config >> "script");
  37. _outputOriented = getNumber (_config >> "outputOriented") == 1;
  38. _height = _height + (0.025 * safezoneH);
  39. _compile = format["_id = '%2' %1;",_script,_item];
  40. uiNamespace setVariable ['uiControl', _control];
  41. if (_outputOriented) then {
  42. /*
  43. This flag means that the action is output oriented
  44. the output class will then be transferred to the script
  45. && the type used for the name
  46. */
  47. _array = getArray (_config >> "output");
  48. _outputClass = _array select 0;
  49. _outputType = _array select 1;
  50. _name = getText (configFile >> _outputType >> _outputClass >> "displayName");
  51. _compile = format["_id = ['%2',%3] %1;",_script,_item,_array];
  52. };
  53.  
  54. _menu ctrlSetText format[_type,_name];
  55. _menu ctrlSetEventHandler ["ButtonClick",_compile];
  56. };
  57. _erc_cfgActions = (missionConfigFile >> "ExtraRc" >> _item);
  58. _erc_numActions = (count _erc_cfgActions);
  59. if (isClass _erc_cfgActions) then {
  60. for "_j" from 0 to (_erc_numActions - 1) do
  61. {
  62. _menu = _parent displayCtrl (1600 + _j + _numActions);
  63. _menu ctrlShow true;
  64. _config = (_erc_cfgActions select _j);
  65. _text = getText (_config >> "text");
  66. _script = getText (_config >> "script");
  67. _height = _height + (0.025 * safezoneH);
  68. uiNamespace setVariable ['uiControl', _control];
  69. _menu ctrlSetText _text;
  70. _menu ctrlSetEventHandler ["ButtonClick",_script];
  71. };
  72. };
  73. // Add extra context menus
  74. _erc_cfgActions = (missionConfigFile >> "ExtraRc" >> _item);
  75. _erc_numActions = (count _erc_cfgActions);
  76. if (isClass _erc_cfgActions) then {
  77. for "_j" from 0 to (_erc_numActions - 1) do
  78. {
  79. _menu = _parent displayCtrl (1600 + _j + _numActions);
  80. _menu ctrlShow true;
  81. _config = (_erc_cfgActions select _j);
  82. _text = getText (_config >> "text");
  83. _script = getText (_config >> "script");
  84. _height = _height + (0.025 * safezoneH);
  85. uiNamespace setVariable ['uiControl', _control];
  86. _menu ctrlSetText _text;
  87. _menu ctrlSetEventHandler ["ButtonClick",_script];
  88. };
  89. };
  90. //### BEGIN MODIFIED CODE: extra click actions
  91. {
  92. private["_classname","_text","_execute","_condition"];
  93. _classname = _x select 0;
  94. _text = _x select 1;
  95. _execute = _x select 2;
  96. _condition = _x select 3;
  97. // if the clicked item matches, then assign the script call and display text
  98. if(_item == _classname && (call compile _condition)) then {
  99. _menu = _parent displayCtrl (1600 + _numActions);
  100. _menu ctrlShow true;
  101. _height = _height + (0.025 * safezoneH);
  102. uiNamespace setVariable ['uiControl', _control];
  103. _menu ctrlSetText _text;
  104. _menu ctrlSetEventHandler ["ButtonClick",_execute];
  105. _numActions = _numActions + 1;
  106. };
  107. } forEach DZE_CLICK_ACTIONS;
  108. //### END MODIFIED CODE: extra click actions
  109. /*
  110. Begin: Vehicle remote lock/unlock
  111. */
  112. _itemsPlayer = items player;
  113.  
  114. _temp_keys = [];
  115. _temp_keys_names = [];
  116. // find available keys
  117. _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
  118. if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _key_colors) then {
  119. _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
  120. _ownerKeyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");
  121. _temp_keys_names set [_ownerKeyId,_ownerKeyName];
  122.  
  123. _objects = nearestObjects [getPos player, ["LandVehicle","Helicopter","Plane","Ship"], 50];
  124. _i = 0;
  125. {
  126. if (alive _x) then {
  127. _ownerID = _x getVariable ["CharacterID", "0"];
  128. _hasKey = (_ownerID == str(_ownerKeyId));
  129. _oldOwner = (_ownerID == dayz_playerUID);
  130.  
  131. if(_hasKey or _oldOwner) then {
  132. if(locked _x) then {
  133. //Unlock
  134. _menu = _parent displayCtrl (1600 + _numActions);
  135. _menu ctrlShow true;
  136. _text = "Unlock";
  137. _script = "[""" + _ownerID + """] execVM ""scripts\remote_unlock.sqf""";
  138. _height = _height + (0.025 * safezoneH);
  139. uiNamespace setVariable ['uiControl', _control];
  140. _menu ctrlSetText _text;
  141. _menu ctrlSetEventHandler ["ButtonClick",_script];
  142. } else {
  143. //Lock
  144. _menu = _parent displayCtrl (1600 + _numActions);
  145. _menu ctrlShow true;
  146. _text = "Lock";
  147. _script = "[""" + _ownerID + """] execVM ""scripts\remote_lock.sqf""";
  148. _height = _height + (0.025 * safezoneH);
  149. uiNamespace setVariable ['uiControl', _control];
  150. _menu ctrlSetText _text;
  151. _menu ctrlSetEventHandler ["ButtonClick",_script];
  152. };
  153. //Engine start
  154. _menu = _parent displayCtrl (1600 + _numActions + 1);
  155. _menu ctrlShow true;
  156. _text = "Engine";
  157. _script = "[""" + _ownerID + """] execVM ""scripts\remote_engine.sqf""";
  158. _height = _height + (0.025 * safezoneH);
  159. uiNamespace setVariable ['uiControl', _control];
  160. _menu ctrlSetText _text;
  161. _menu ctrlSetEventHandler ["ButtonClick",_script];
  162. };
  163.  
  164. _i = _i + 1;
  165. };
  166. } forEach _objects;
  167. };
  168.  
  169. /*
  170. End: Vehicle remote lock/unlock
  171. */
  172. _pos set [3,_height];
  173. //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];
  174.  
  175. _group ctrlShow true;
  176. ctrlSetFocus _group;
  177. _group ctrlSetPosition _pos;
  178. _group ctrlCommit 0;
  179. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement