Guest User

Untitled

a guest
May 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. // toggle: close old radar if present
  2. private _display = uiNamespace getVariable ["commy_SquadRadar", displayNull];
  3.  
  4. if (!isNull _display) exitWith {
  5. "commy_SquadRadar" cutText ["", "PLAIN"];
  6. false
  7. };
  8.  
  9. // otherwise create canvas
  10. "commy_SquadRadar" cutRsc ["RscTitleDisplayEmpty", "PLAIN", 0, false];
  11. _display = uiNamespace getVariable "RscTitleDisplayEmpty";
  12. uiNamespace setVariable ["commy_SquadRadar", _display];
  13.  
  14. // kill duplicate vignette
  15. private _vignette = _display displayCtrl 1202;
  16. _vignette ctrlShow false;
  17.  
  18. // radar control
  19. private _control = _display ctrlCreate ["RscPicture", -1];
  20. _display setVariable ["commy_SquadRadar", _control];
  21.  
  22. private _width = 8 * (((safezoneW / safezoneH) min 1.2) / 40);
  23. private _height = 8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25);
  24. private _left = (0.5 - _width/2);
  25. private _top = (safezoneY + safezoneH - 1.2 * _height);
  26.  
  27. _control ctrlSetPosition [_left, _top, _width, _height];
  28. _control ctrlCommit 0;
  29.  
  30. // squad member markers
  31. private _markers = [];
  32. _control setVariable ["commy_SquadRadarMarkers", _markers];
  33.  
  34. for "_i" from 1 to 20 do {
  35. private _marker = _display ctrlCreate ["RscPicture", -1];
  36. _marker ctrlSetText "\a3\ui_f\data\IGUI\Cfg\SquadRadar\SquadRadarOtherGroupUnit_ca.paa";
  37. _marker ctrlShow false;
  38. _markers pushBack _marker;
  39. };
  40.  
  41. // draw script
  42. private _script = _display ctrlCreate ["RscMapControl", -1];
  43.  
  44. _script ctrlSetPosition [0,0,0,0];
  45. _script ctrlCommit 0;
  46.  
  47. _script ctrlAddEventHandler ["Draw", {
  48. params ["_script"];
  49. private _display = ctrlParent _script;
  50.  
  51. private _control = _display getVariable "commy_SquadRadar";
  52. private _markers = _control getVariable "commy_SquadRadarMarkers";
  53.  
  54. private _unit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player];
  55. private _radius = 40;
  56. private _nearUnits = nearestObjects [_unit, ["CAManBase"], _radius] select {_unit knowsAbout _x >= 4};
  57.  
  58. // show or hide cardinal directions if unit owns compass
  59. if ("ItemCompass" in assignedItems _unit) then {
  60. _control ctrlSetText "\a3\ui_f\data\IGUI\Cfg\SquadRadar\SquadRadarCompassBackgroundTexture_ca.paa";
  61.  
  62. private _view = AGLToASL positionCameraToWorld [0,0,0] vectorFromTo AGLToASL positionCameraToWorld [0,0,1];
  63. private _viewHorizontal = vectorNormalized (_view vectorCrossProduct [0,0,1]);
  64.  
  65. private _dir = acos (_viewHorizontal select 0);
  66.  
  67. if (_viewHorizontal select 1 > 0) then {
  68. _dir = 360 - _dir;
  69. };
  70.  
  71. _control ctrlSetAngle [-_dir,0.5,0.5];
  72. } else {
  73. _control ctrlSetText "\a3\ui_f\data\IGUI\Cfg\SquadRadar\SquadRadarBackgroundTexture_ca.paa";
  74. };
  75.  
  76. // update positions of squad members
  77. ctrlPosition _control params ["_left", "_top", "_width", "_height"];
  78. private _center = [_left + _width/2, _top + _height/2];
  79.  
  80. {
  81. private _target = _nearUnits param [_forEachIndex, objNull];
  82.  
  83. if (isNull _target) then {
  84. _x ctrlShow false;
  85. } else {
  86. private _dir = _unit getRelDir _target;
  87. private _dist = (_unit distance2D _target) / (_radius*2);
  88.  
  89. _x ctrlSetPosition [
  90. (_center select 0) + _width * (sin _dir * _dist) - _width/8,
  91. (_center select 1) - _height * (cos _dir * _dist) - _height/8,
  92. _width/4,
  93. _height/4
  94. ];
  95. _x ctrlCommit 0;
  96. _x ctrlShow true;
  97. };
  98. } forEach _markers;
  99. }];
  100.  
  101. true
Add Comment
Please, Sign In to add comment