fn_drawBftMarkers.sqf 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. Name: cTab_fnc_drawBftMarkers
  3. Author(s):
  4. Gundy, Riouken
  5. Description:
  6. Draw BFT markers
  7. List format:
  8. Index 0: Unit object
  9. Index 1: Path to icon A
  10. Index 2: Path to icon B (either group size or wingmen)
  11. Index 3: Text to display
  12. Index 4: String of group index
  13. Parameters:
  14. 0: OBJECT - Map control to draw BFT icons on
  15. 1: INTEGER - Mode, 0 = draw normal, 1 = draw for TAD, 2 = draw for MicroDAGR
  16. Returns:
  17. BOOLEAN - Always TRUE
  18. Example:
  19. [_ctrlScreen,0] call cTab_fnc_drawBftMarkers;
  20. */
  21. private ["_ctrlScreen","_mode","_veh","_iconB","_text","_groupID","_pos","_vehicles","_vehIndex","_mountedLabels","_mountedIndex","_drawText","_playerVehicle","_playerGroup","_teamColor"];
  22. _ctrlScreen = _this select 0;
  23. _mode = _this select 1;
  24. _vehicles = [];
  25. _playerVehicle = vehicle cTab_player;
  26. _playerGroup = group cTab_player;
  27. _mountedLabels = [];
  28. _drawText = cTabBFTtxt;
  29. // Anything but MicroDAGR
  30. if (_mode != 2) then {
  31. // ------------------ VEHICLES ------------------
  32. {
  33. _veh = _x select 0;
  34. _iconB = _x select 2;
  35. _text = if (_drawText) then {_x select 3} else {""};
  36. _groupID = _x select 4;
  37. _pos = getPosASL _veh;
  38. call {
  39. if (_mode == 1 && {_iconB != "" && {_veh != _playerVehicle}}) exitWith {
  40. // Drawing on TAD && vehicle is an air contact
  41. call {
  42. if (_groupID != "") exitWith {
  43. // air contact is in our group
  44. _ctrlScreen drawIcon [_iconB,cTabTADgroupColour,_pos,cTabAirContactSize,cTabAirContactSize,direction _veh,"",0,cTabTxtSize,"TahomaB","right"];
  45. _ctrlScreen drawIcon ["\A3\ui_f\data\map\Markers\System\dummy_ca.paa",cTabTADgroupColour,_pos,0,0,0,_groupID,0,cTabAirContactGroupTxtSize * 0.8,"TahomaB","center"];
  46. };
  47. // air contact is _not_ in our group
  48. _ctrlScreen drawIcon [_iconB,cTabTADfontColour,_pos,cTabAirContactSize,cTabAirContactSize,direction _veh,"",0,cTabTxtSize,"TahomaB","right"];
  49. if (_drawText) then {
  50. _ctrlScreen drawIcon ["\A3\ui_f\data\map\Markers\System\dummy_ca.paa",cTabTADfontColour,_pos,cTabAirContactDummySize,cTabAirContactDummySize,0,_text,0,cTabTxtSize,"TahomaB","right"];
  51. };
  52. };
  53. };
  54. // Draw on anything but TAD
  55. call {
  56. if (_veh != _playerVehicle) exitWith {
  57. // player is not sitting in this vehicle
  58. _ctrlScreen drawIcon [_x select 1,cTabColorBlue,_pos,cTabIconSize,cTabIconSize,0,_text,0,cTabTxtSize,"TahomaB","right"];
  59. };
  60. if (group _veh != _playerGroup) then {
  61. // player is not in the same group as this vehicle
  62. _ctrlScreen drawIcon ["\A3\ui_f\data\map\Markers\System\dummy_ca.paa",cTabColorBlue,_pos,cTabIconSize,cTabIconSize,0,_text,0,cTabTxtSize,"TahomaB","right"];
  63. };
  64. };
  65. };
  66. 0 = _vehicles pushBack _veh;
  67. } count cTabBFTvehicles;
  68. // ------------------ GROUPS ------------------
  69. {
  70. _veh = vehicle (_x select 0);
  71. call {
  72. // See if the group leader's vehicle is in the list of drawn vehicles
  73. _vehIndex = _vehicles find _veh;
  74. // Only do this if the vehicle has not been drawn yet, or the player is sitting in the same vehicle as the group leader
  75. if (_vehIndex != -1 || {_veh == _playerVehicle}) exitWith {
  76. if (_drawText) then {
  77. // we want to draw text and the group leader is in a vehicle that has already been drawn
  78. _text = _x select 3;
  79. // _vehIndex == -1 means that the player sits in the vehicle
  80. if (_vehIndex == -1 || {(groupID group _veh) != _text}) then {
  81. // group name is not the same as that of the vehicle the leader is sitting in
  82. _mountedIndex = _mountedLabels find _veh;
  83. if (_mountedIndex != -1) then {
  84. _mountedLabels set [_mountedIndex + 1,(_mountedLabels select (_mountedIndex + 1)) + "/" + (_text)];
  85. } else {
  86. 0 = _mountedLabels pushBack _veh;
  87. 0 = _mountedLabels pushBack _text;
  88. };
  89. };
  90. };
  91. };
  92. _text = if (_drawText) then {_x select 3} else {""};
  93. _pos = getPosASL _veh;
  94. _ctrlScreen drawIcon [_x select 1,cTabColorBlue,_pos,cTabIconSize,cTabIconSize,0,_text,0,cTabTxtSize,"TahomaB","right"];
  95. _ctrlScreen drawIcon [_x select 2,cTabColorBlue,_pos,cTabGroupOverlayIconSize,cTabGroupOverlayIconSize,0,"",0,cTabTxtSize,"TahomaB","right"];
  96. };
  97. } count cTabBFTgroups;
  98. };
  99. // ------------------ MEMBERS ------------------
  100. {
  101. _veh = vehicle (_x select 0);
  102. call {
  103. // make sure we are still in the same team
  104. if (group cTab_player != group (_x select 0)) exitWith {};
  105. // get the fire-team color
  106. _teamColor = cTabColorTeam select (["MAIN","RED","GREEN","BLUE","YELLOW"] find (assignedTeam (_x select 0)));
  107. if (_mode != 2 && {_veh == _playerVehicle || {_veh in _vehicles}}) exitWith {
  108. if (_drawText) then {
  109. // we want to draw text on anything but MicroDAGR and the unit sits in a vehicle that has already been drawn
  110. _mountedIndex = _mountedLabels find _veh;
  111. if (_mountedIndex != -1) then {
  112. _mountedLabels set [_mountedIndex + 1,(_mountedLabels select (_mountedIndex + 1)) + "/" + (_x select 4)];
  113. } else {
  114. 0 = _mountedLabels pushBack _veh;
  115. 0 = _mountedLabels pushBack (_x select 4);
  116. };
  117. };
  118. };
  119. if (_veh != (_x select 0)) exitWith {
  120. // the unit _does_ sit in a vehicle
  121. _mountedIndex = _mountedLabels find _veh;
  122. if (_mountedIndex != -1 && _drawText) then {
  123. _mountedLabels set [_mountedIndex + 1,(_mountedLabels select (_mountedIndex + 1)) + "/" + (_x select 4)];
  124. } else {
  125. 0 = _mountedLabels pushBack _veh;
  126. if (_drawText) then {
  127. 0 = _mountedLabels pushBack (_x select 4);
  128. };
  129. if (_veh != _playerVehicle) then {
  130. _ctrlScreen drawIcon ["\A3\ui_f\data\map\VehicleIcons\iconmanvirtual_ca.paa",cTabColorBlue,getPosASL _veh,cTabIconSize,cTabIconSize,direction _veh,"",0,cTabTxtSize,"TahomaB","right"];
  131. };
  132. };
  133. };
  134. _pos = getPosASL _veh;
  135. _ctrlScreen drawIcon [_x select 1,_teamColor,_pos,cTabIconManSize,cTabIconManSize,direction _veh,"",0,cTabTxtSize,"TahomaB","right"];
  136. if (_drawText) then {
  137. _ctrlScreen drawIcon ["\A3\ui_f\data\map\Markers\System\dummy_ca.paa",_teamColor,_pos,cTabIconManSize,cTabIconManSize,0,_x select 4,0,cTabTxtSize,"TahomaB","right"];
  138. };
  139. };
  140. } count cTabBFTmembers;
  141. // ------------------ ADD LABEL TO VEHICLES WITH MOUNTED GROUPS / MEMBERS ------------------
  142. if (_drawText && !(_mountedLabels isEqualTo [])) then {
  143. for "_i" from 0 to (count _mountedLabels - 2) step 2 do {
  144. _veh = _mountedLabels select _i;
  145. if (_veh != _playerVehicle) then {
  146. _ctrlScreen drawIcon ["\A3\ui_f\data\map\Markers\System\dummy_ca.paa",cTabColorBlue,getPosASL _veh,cTabIconSize,cTabIconSize,0,_mountedLabels select (_i + 1),0,cTabTxtSize,"TahomaB","left"];
  147. };
  148. };
  149. };
  150. true