fn_updateLists.sqf 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. Name: cTab_fnc_updateLists
  3. Author(s):
  4. Gundy, Riouken
  5. Description:
  6. Update lists of cTab units and vehicles
  7. Lists updated:
  8. cTabBFTmembers
  9. cTabBFTgroups
  10. cTabBFTvehicles
  11. cTabUAVlist
  12. cTabHcamlist
  13. List format (all except cTabHcamlist):
  14. Index 0: Unit object
  15. Index 1: Path to icon A
  16. Index 2: Path to icon B (either group size or wingmen)
  17. Index 3: Text to display
  18. Index 4: String of group index
  19. Parameters:
  20. NONE
  21. Returns:
  22. BOOLEAN - Always TRUE
  23. Example:
  24. call cTab_fnc_updateLists;
  25. */
  26. private ["_cTabBFTmembers","_cTabBFTgroups","_cTabBFTvehicles","_cTabUAVlist","_cTabHcamlist","_validSides","_playerEncryptionKey","_playerVehicle","_playerGroup","_updateInterface"];
  27. _cTabBFTmembers = []; // members of player's group
  28. _cTabBFTgroups = []; // other groups
  29. _cTabBFTvehicles = []; // all vehicles
  30. _cTabUAVlist = []; // all remote controllable UAVs
  31. _cTabHcamlist = []; // units with a helmet cam
  32. _validSides = call cTab_fnc_getPlayerSides;
  33. _playerVehicle = vehicle cTab_player;
  34. _playerGroup = group cTab_player;
  35. /*
  36. cTabBFTmembers --- GROUP MEMBERS
  37. */
  38. {
  39. if ((_x != cTab_player) && {[_x,["ItemcTab","ItemAndroid","ItemMicroDAGR"]] call cTab_fnc_checkGear}) then {
  40. 0 = _cTabBFTmembers pushBack [_x,_x call cTab_fnc_getInfMarkerIcon,"",name _x,str([_x] call CBA_fnc_getGroupIndex)];
  41. };
  42. } count units cTab_player;
  43. /*
  44. cTabBFTgroups --- GROUPS
  45. Groups on our side that player is not a member of. Use the leader for positioning if he has a Tablet or Android.
  46. Else, search through the group and use the first member we find equipped with a Tablet or Android for positioning.
  47. */
  48. {
  49. if ((side _x in _validSides) && {_x != _playerGroup}) then {
  50. _leader = objNull;
  51. call {
  52. if ([leader _x,["ItemcTab","ItemAndroid"]] call cTab_fnc_checkGear) exitWith {_leader = leader _x;};
  53. {
  54. if ([_x,["ItemcTab","ItemAndroid"]] call cTab_fnc_checkGear) exitWith {_leader = _x;};
  55. } count units _x;
  56. };
  57. if !(IsNull _leader) then {
  58. _groupSize = count units _x;
  59. _sizeIcon = call {
  60. if (_groupSize <= 3) exitWith {"\A3\ui_f\data\map\markers\nato\group_0.paa"};
  61. if (_groupSize <= 9) exitWith {"\A3\ui_f\data\map\markers\nato\group_1.paa"};
  62. "\A3\ui_f\data\map\markers\nato\group_2.paa"
  63. };
  64. 0 = _cTabBFTgroups pushBack [_leader,"\A3\ui_f\data\map\markers\nato\b_inf.paa",_sizeIcon,groupID _x,""];
  65. };
  66. };
  67. } count allGroups;
  68. /*
  69. cTabBFTvehicles --- VEHICLES
  70. Vehciles on our side, that are not empty and that player is not sitting in.
  71. */
  72. {
  73. if ((side _x in _validSides) && {count (crew _x) > 0} && {_x != _playerVehicle}) then {
  74. _groupID = "";
  75. _name = "";
  76. _customName = _x getVariable ["cTab_groupId",""];
  77. call {
  78. if !(_customName isEqualTo "") exitWith {
  79. _name = _customName;
  80. };
  81. if (group _x == _playerGroup) then {
  82. _groupID = str([_x] call CBA_fnc_getGroupIndex)
  83. };
  84. _name = groupID group _x;
  85. };
  86. _iconA = "";
  87. _iconB = "";
  88. call {
  89. if (_x isKindOf "MRAP_01_base_F") exitWith {_iconA = "\ClonecTab\img\b_mech_inf_wheeled.paa";};
  90. if (_x isKindOf "MRAP_02_base_F") exitWith {_iconA = "\ClonecTab\img\b_mech_inf_wheeled.paa";};
  91. if (_x isKindOf "MRAP_03_base_F") exitWith {_iconA = "\ClonecTab\img\b_mech_inf_wheeled.paa";};
  92. if (_x isKindOf "Wheeled_APC_F") exitWith {_iconA = "\ClonecTab\img\b_mech_inf_wheeled.paa";};
  93. if (_x isKindOf "Truck_F" && {getNumber (configfile >> "cfgVehicles" >> typeOf _x >> "transportSoldier") > 2}) exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_motor_inf.paa";};
  94. if (_x isKindOf "Truck_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_support.paa";};
  95. if (_x isKindOf "Car_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_motor_inf.paa";};
  96. if (_x isKindOf "UAV") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_uav.paa";};
  97. if (_x isKindOf "UAV_01_base_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_uav.paa";};
  98. if (_x isKindOf "Helicopter") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_air.paa"; _iconB = "\ClonecTab\img\icon_air_contact_ca.paa";};
  99. if (_x isKindOf "Plane") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_plane.paa"; _iconB = "\ClonecTab\img\icon_air_contact_ca.paa";};
  100. if (_x isKindOf "Tank" && {getNumber (configfile >> "cfgVehicles" >> typeOf _x >> "transportSoldier") > 6}) exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_mech_inf.paa";};
  101. if (_x isKindOf "MBT_01_arty_base_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_art.paa";};
  102. if (_x isKindOf "MBT_01_mlrs_base_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_art.paa";};
  103. if (_x isKindOf "MBT_02_arty_base_F") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_art.paa";};
  104. if (_x isKindOf "Tank") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_armor.paa";};
  105. if (_x isKindOf "StaticMortar") exitWith {_iconA = "\A3\ui_f\data\map\markers\nato\b_mortar.paa";};
  106. };
  107. call {
  108. if (_iconA isEqualTo "" && {!(_x isKindOf "Static")} && {!(_x isKindOf "StaticWeapon")}) then {_iconA = "\A3\ui_f\data\map\markers\nato\b_unknown.paa";};
  109. if (_iconA isEqualTo "") exitWith {};
  110. 0 = _cTabBFTvehicles pushBack [_x,_iconA,_iconB,_name,_groupID];
  111. };
  112. };
  113. } count vehicles;
  114. /*
  115. cTabUAVlist --- UAVs
  116. */
  117. {
  118. if (side _x in _validSides) then {
  119. 0 = _cTabUAVlist pushBack _x;
  120. };
  121. } count allUnitsUav;
  122. /*
  123. cTabHcamlist --- HELMET CAMS
  124. Units on our side, that have either helmets that have been specified to include a helmet cam, or ItemCTabHCAM in their inventory.
  125. */
  126. {
  127. if (side _x in _validSides) then {
  128. if (headgear _x in cTab_helmetClass_has_HCam || {[_x,["ItemcTabHCam"]] call cTab_fnc_checkGear}) then {
  129. 0 = _cTabHcamlist pushBack _x;
  130. };
  131. };
  132. } count allUnits;
  133. // array to hold interface update commands
  134. _updateInterface = [];
  135. // replace the global list arrays in the end so that we avoid them being empty unnecessarily
  136. cTabBFTmembers = [] + _cTabBFTmembers;
  137. cTabBFTgroups = [] + _cTabBFTgroups;
  138. cTabBFTvehicles = [] + _cTabBFTvehicles;
  139. if !(cTabUAVlist isEqualTo _cTabUAVlist) then {
  140. cTabUAVlist = [] + _cTabUAVlist;
  141. _updateInterface pushBack ["uavListUpdate",true];
  142. };
  143. if !(cTabHcamlist isEqualTo _cTabHcamlist) then {
  144. cTabHcamlist = [] + _cTabHcamlist;
  145. _updateInterface pushBack ["hCamListUpdate",true];
  146. };
  147. // call interface updates
  148. if (count _updateInterface > 0) then {
  149. [_updateInterface] call cTab_fnc_updateInterface;
  150. };
  151. true