|
| 1 | +/* |
| 2 | + Author: UltraNoobian (Brenden Cai) |
| 3 | +
|
| 4 | + Description: |
| 5 | + Dynamically generate and update the Support menus, then display the root menu. |
| 6 | +
|
| 7 | + Parameter(s): |
| 8 | + None. |
| 9 | +
|
| 10 | + Usage: |
| 11 | + [] call "dynamic_menu.sqf"; |
| 12 | +
|
| 13 | + Returns: |
| 14 | + - Nil - |
| 15 | +*/ |
| 16 | +menuItemFormatter = { |
| 17 | + format [ |
| 18 | + "[""%1"", [%2], """", -5, [[""expression"", ""%3""]], ""1"", ""%4""]", |
| 19 | + _this select 0, |
| 20 | + _this select 1, |
| 21 | + _this select 2, |
| 22 | + _this select 3 |
| 23 | + ]; |
| 24 | +}; |
| 25 | + |
| 26 | +_itemsCount = 0; |
| 27 | +_offensiveItems = []; |
| 28 | +_logisticsItems = []; |
| 29 | +_transportItems = []; |
| 30 | + |
| 31 | +// Critical note: If you use escape quotes as part of your params to menuItemFormatter, |
| 32 | +// You must double-escape those quotes |
| 33 | +// eg. "Hello ""mate""" -> "Hello """"mate""""" |
| 34 | +// eg. 'Hello "mate"' -> "Hello ""mate""' |
| 35 | + |
| 36 | + |
| 37 | +//Offensive Submenu checks |
| 38 | +if(support_mortar_available) then { |
| 39 | + _text = ["Mortar (2 CP)", 2, '_null = [8, 50, 5, 3, 2, 2, ""grenade""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter; |
| 40 | + _offensiveItems pushBack _text; |
| 41 | +} else { |
| 42 | + _text = ["Mortar (N/A)", 2, "", 0] call menuItemFormatter; |
| 43 | + _offensiveItems pushBack _text; |
| 44 | +}; |
| 45 | + |
| 46 | +if(support_arty_available) then { |
| 47 | + _text = ["Artillery Strike (4 CP)", 3, '_null = [6, 100, 8, 3, 1, 4, ""R_80mm_HE""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter; |
| 48 | + _offensiveItems pushBack _text; |
| 49 | +} else { |
| 50 | + _text = ["Artillery Strike (N/A)", 3, "", 0] call menuItemFormatter; |
| 51 | + _offensiveItems pushBack _text; |
| 52 | +}; |
| 53 | + |
| 54 | +if(support_cluster_available) then { |
| 55 | + _text = ["Cluster Bomb (6 CP)", 4, '_null = [1, 250, 1, 90, 1, 6, ""grenade""] execVM ""support\cluster\mapclickcluster.sqf""', 1] call menuItemFormatter; |
| 56 | + _offensiveItems pushBack _text; |
| 57 | +} else { |
| 58 | + _text = ["Cluster Bomb (N/A)", 4, "", 0] call menuItemFormatter; |
| 59 | + _offensiveItems pushBack _text; |
| 60 | +}; |
| 61 | + |
| 62 | +if(support_jdam_available) then { |
| 63 | + _text = ["JDAM Strike (1 CP)", 5, '_null = [1, 2, 1, 1, 3, 1, ""Bo_Mk82""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter; |
| 64 | + _offensiveItems pushBack _text; |
| 65 | +} else { |
| 66 | + _text = ["JDAM (N/A)", 5, "", 0] call menuItemFormatter; |
| 67 | + _offensiveItems pushBack _text; |
| 68 | +}; |
| 69 | + |
| 70 | +// Compilaton and Call for Offensive SubMenu |
| 71 | +_finalString = "offensive_SubMenu = [[""Offensive Supports"",true],"; |
| 72 | +_offensiveItemsClassString = _offensiveItems joinString ","; |
| 73 | +_finalString = _finalString + _offensiveItemsClassString; |
| 74 | +_finalString = _finalString + "];"; |
| 75 | + |
| 76 | +_myCode = compile _finalString; |
| 77 | +call _myCode; |
| 78 | + |
| 79 | + |
| 80 | +//Logistics Submenu Checks |
| 81 | +if(support_supplydrop_available) then { |
| 82 | + _text = ["Supply Drop (2 CP)", 2, '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter; |
| 83 | + _logisticsItems pushBack _text; |
| 84 | +} else { |
| 85 | + _text = ["Supply Drop ((N/A)", 2, '', 0] call menuItemFormatter; |
| 86 | + _logisticsItems pushBack _text; |
| 87 | +}; |
| 88 | + |
| 89 | +if(support_paradrop_available) then { |
| 90 | + _text = ["Airborne troops (25 CP)", 3, '_null = [player] execVM ""support\paradrop.sqf""', 1] call menuItemFormatter; |
| 91 | + _logisticsItems pushBack _text; |
| 92 | +} else { |
| 93 | + _text = ["Airborne troops (N/A)", 3, '', 0] call menuItemFormatter; |
| 94 | + _logisticsItems pushBack _text; |
| 95 | +}; |
| 96 | + |
| 97 | +if(support_uav_recon_available) then { |
| 98 | + _text = ["UAV Recon (3 CP)", 4, '_null = [player] execVM ""support\mapclickuav.sqf""', 1] call menuItemFormatter; |
| 99 | + _logisticsItems pushBack _text; |
| 100 | +} else { |
| 101 | + _text = ["UAV Recon (N/A)", 4, '', 0] call menuItemFormatter; |
| 102 | + _logisticsItems pushBack _text; |
| 103 | +}; |
| 104 | + |
| 105 | +if(support_veh_refit_available) then { |
| 106 | + _text = ["Vehicle Refit (2 CP)", 5, '_null = [player] execVM ""support\veh_refit.sqf""', 1] call menuItemFormatter; |
| 107 | + _logisticsItems pushBack _text; |
| 108 | +} else { |
| 109 | + _text = ["Vehicle Refit (N/A)", 5, '', 0] call menuItemFormatter; |
| 110 | + _logisticsItems pushBack _text; |
| 111 | +}; |
| 112 | + |
| 113 | + |
| 114 | +// Compilaton and Call for Logistics SubMenu |
| 115 | +_finalString = "logistic_SubMenu = [[""Logistical Supports"",true],"; |
| 116 | +_logisticsItemsClassString = _logisticsItems joinString ","; |
| 117 | +_finalString = _finalString + _logisticsItemsClassString; |
| 118 | +_finalString = _finalString + "];"; |
| 119 | + |
| 120 | +_myCode = compile _finalString; |
| 121 | +call _myCode; |
| 122 | + |
| 123 | +//Transport Submenu check |
| 124 | +if(support_helotaxi_available) then { |
| 125 | + _text = ["Helicopter taxi(1 CP)", 2, '_nill = [getpos player,50] execVM ""support\taxi\helotaxi.sqf""', 1] call menuItemFormatter; |
| 126 | + _transportItems pushBack _text; |
| 127 | +} else { |
| 128 | + _text = ["Helicopter taxi(N/A)", 2, '', 0] call menuItemFormatter; |
| 129 | + _transportItems pushBack _text; |
| 130 | +}; |
| 131 | + |
| 132 | +if(support_boattaxi_available) then { |
| 133 | + _text = ["Boat taxi (1 CP)", 3, '_null = [getpos player,10] execVM ""support\taxi\boattaxi.sqf""', 1] call menuItemFormatter; |
| 134 | + _transportItems pushBack _text; |
| 135 | +} else { |
| 136 | + _text = ["Boat taxi (N/A)", 3, '', 0] call menuItemFormatter; |
| 137 | + _transportItems pushBack _text; |
| 138 | +}; |
| 139 | + |
| 140 | + |
| 141 | +// Compilaton and Call for Transport SubMenu |
| 142 | +_finalString = "transport_SubMenu = [[""Transport Supports"",true],"; |
| 143 | +_transportItemsClassString = _transportItems joinString ","; |
| 144 | +_finalString = _finalString + _transportItemsClassString; |
| 145 | +_finalString = _finalString + "];"; |
| 146 | + |
| 147 | +_myCode = compile _finalString; |
| 148 | +call _myCode; |
| 149 | + |
| 150 | + |
| 151 | +//Construct and show Support Menu root |
| 152 | +supportMenu = |
| 153 | +[ |
| 154 | + ["Support Menu",false], |
| 155 | + ["Offensive", [2], "#USER:offensive_SubMenu", -5, [["expression", ""]], "1", "1"], |
| 156 | + ["Logistics", [3], "#USER:logistic_SubMenu", -5, [["expression", ""]], "1", "1"], |
| 157 | + ["Transport", [4], "#USER:transport_SubMenu", -5, [["expression", ""]], "1", "1"] |
| 158 | +]; |
| 159 | + |
| 160 | +showCommandingMenu "#USER:supportMenu"; |
0 commit comments