Advertisement
Leonardo01

ui_selectslot

Dec 9th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.84 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"];
  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.         _menu ctrlSetText format[_type,_name];
  54.         _menu ctrlSetEventHandler ["ButtonClick",_compile];
  55.     };
  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.    
  74.     _pos set [3,_height];
  75.     //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];      
  76.  
  77.     _group ctrlShow true;
  78.     ctrlSetFocus _group;
  79.     _group ctrlSetPosition _pos;
  80.     _group ctrlCommit 0;
  81. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement