Skip to content

Commit 0d34aaf

Browse files
committed
Populated dynamic_menu script with all menus and functions
Populated root menu, submenus (offensive, logistics and transports), with both active and inactive menu types. Included proper function triggering for each support.
1 parent 86287dc commit 0d34aaf

File tree

2 files changed

+131
-43
lines changed

2 files changed

+131
-43
lines changed

source/INIT.sqf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ for[{_x = 2},{_x <= 20},{_x = _x + 1}] do {
280280
};
281281
};
282282

283+
//DEBUG - REMOVE BEFORE MERGING
284+
player addAction ["Dynamic Support Menu", "dynamic_menu.sqf", [], 10, false, true];
285+
283286
//Loading player position and gear.
284287
//TODO: Add bought supports.
285288
/*

source/dynamic_menu.sqf

Lines changed: 128 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,167 @@
1-
/**
2-
* Dynamically (re)create the support menus
3-
*
4-
* Generates and updates the Support menus so that they can be displayed by
5-
*
6-
* Params: None.
7-
*
8-
* Return: None.
9-
*/
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.
109
11-
// MY_SUBMENU_inCommunication =
12-
// [
13-
// ["User submenu",true],
14-
// ["Option-1", [2], "", -5, [["expression", "player sidechat ""-1"" "]], "0", "0", "\ca\ui\data\cursor_support_ca"],
15-
// ["Option 0", [3], "", -5, [["expression", "player sidechat "" 0"" "]], "1", "0", "\ca\ui\data\cursor_support_ca"],
16-
// ["Option 1", [4], "", -5, [["expression", "player sidechat "" 1"" "]], "1", "CursorOnGround", "\ca\ui\data\cursor_support_ca"]
17-
// ];
10+
Usage:
11+
[] call "dynamic_menu.sqf";
12+
13+
Returns:
14+
- Nil -
15+
*/
16+
menuItemFormatter = {
17+
format [
18+
"[""%1"", [0], """", -5, [[""expression"", ""%2""]], ""1"", ""%3""]",
19+
_this select 0,
20+
_this select 1,
21+
_this select 2
22+
];
23+
};
1824

1925
_itemsCount = 0;
2026
_offensiveItems = [];
2127
_logisticsItems = [];
2228
_transportItems = [];
2329

24-
_Ucode = "dyn_menu = [[""User menu"",false],";
30+
// Critical note: If you use escape quotes as part of your params to menuItemFormatter,
31+
// You must double-escape those quotes
32+
// eg. "Hello ""mate""" -> "Hello """"mate"""""
33+
// eg. 'Hello "mate"' -> "Hello ""mate""'
2534

2635

36+
//Offensive Submenu checks
2737
if(support_mortar_available) then {
28-
_text = "[""Mortar"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""1""]]";
38+
_text = ["Mortar (2 CP)", '_null = [8, 50, 5, 3, 2, 2, ""grenade""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
2939
_offensiveItems pushBack _text;
3040
} else {
31-
// code is same as above, BUT 'isActive' is false.
32-
_text = "[""Mortar"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""0""]]";
41+
_text = ["Mortar (N/A)", "", 0] call menuItemFormatter;
3342
_offensiveItems pushBack _text;
3443
};
3544

3645
if(support_arty_available) then {
37-
_text = "[""Artillery"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""1""]]";
46+
_text = ["Artillery Strike (4 CP)", '_null = [6, 100, 8, 3, 1, 4, ""R_80mm_HE""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
3847
_offensiveItems pushBack _text;
3948
} else {
40-
_text = "[""Artillery"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""0""]]";
49+
_text = ["Artillery Strike (N/A)", "", 0] call menuItemFormatter;
4150
_offensiveItems pushBack _text;
4251
};
4352

4453
if(support_cluster_available) then {
45-
_text = "[""Cluster Bomb"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""1""]]";
54+
_text = ["Cluster Bomb (6 CP)", '_null = [1, 250, 1, 90, 1, 6, ""grenade""] execVM ""support\cluster\mapclickcluster.sqf""', 1] call menuItemFormatter;
4655
_offensiveItems pushBack _text;
4756
} else {
48-
_text = "[""Cluster Bomb"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""0""]]";
57+
_text = ["Cluster Bomb (N/A)", "", 0] call menuItemFormatter;
4958
_offensiveItems pushBack _text;
5059
};
5160

5261
if(support_jdam_available) then {
53-
_text = "[""JDAM"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""1""]]";
62+
_text = ["JDAM Strike (1 CP)", '_null = [1, 2, 1, 1, 3, 1, ""Bo_Mk82""] execVM ""support\mapclickarty.sqf""', 1] call menuItemFormatter;
5463
_offensiveItems pushBack _text;
5564
} else {
56-
_text = "[""JDAM"", [0], """", -5, [[""expression"", ""player sidechat """"First"""" ""]], ""1"", ""0""]]";
65+
_text = ["JDAM (N/A)", "", 0] call menuItemFormatter;
5766
_offensiveItems pushBack _text;
5867
};
5968

69+
// Compilaton and Call for Offensive SubMenu
6070
_finalString = "offensive_SubMenu = [[""Offensive Supports"",true],";
61-
_finalString += _offensiveItems joinString ",";
71+
_offensiveItemsClassString = _offensiveItems joinString ",";
72+
_finalString = _finalString + _offensiveItemsClassString;
73+
_finalString = _finalString + "];";
74+
75+
_myCode = compile _finalString;
76+
call _myCode;
6277

63-
diag_log format ["DUWS-R: Compiling this string (%1)",_finalString];
64-
_myCode = call compile _finalString;
6578

66-
// if(support_supplydrop_available) then {
67-
// }
68-
// support_paradrop_available = false;
69-
// support_pFLIR_available = false;
70-
// support_uav_recon_available = false;
71-
// support_veh_refit_available = false;
79+
//Logistics Submenu Checks
80+
if(support_supplydrop_available) then {
81+
_text = ["Supply Drop (2 CP)", '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
82+
_logisticsItems pushBack _text;
83+
} else {
84+
_text = ["Supply Drop ((N/A)", '', 0] call menuItemFormatter;
85+
_logisticsItems pushBack _text;
86+
};
7287

73-
// support_helotaxi_available = false;
74-
// support_boattaxi_available = false;
88+
if(support_paradrop_available) then {
89+
_text = ["Airborne troops (25 CP)", '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
90+
_logisticsItems pushBack _text;
91+
} else {
92+
_text = ["Airborne troops (N/A)", '', 0] call menuItemFormatter;
93+
_logisticsItems pushBack _text;
94+
};
95+
96+
if(support_pFLIR_available) then {
97+
_text = ["Supply Drop (2 CP)", '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
98+
_logisticsItems pushBack _text;
99+
} else {
100+
_text = ["Supply Drop (N/A)", '', 0] call menuItemFormatter;
101+
_logisticsItems pushBack _text;
102+
};
103+
104+
if(support_uav_recon_available) then {
105+
_text = ["UAV Recon (3 CP)", '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
106+
_logisticsItems pushBack _text;
107+
} else {
108+
_text = ["UAV Recon (N/A)", '', 0] call menuItemFormatter;
109+
_logisticsItems pushBack _text;
110+
};
75111

76-
if(count _itemsCount > 0) then {
77-
//_Ucode =
78-
//call compile _Ucode;
79-
//showCommandingMenu "#USER:MY_MENU_inCommunication";
112+
if(support_veh_refit_available) then {
113+
_text = ["Vehicle Refit (2 CP)", '_null = [player] execVM ""support\ammobox.sqf""', 1] call menuItemFormatter;
114+
_logisticsItems pushBack _text;
80115
} else {
81-
player commandChat "No support items available at this time!";
82-
}
116+
_text = ["Vehicle Refit (N/A)", '', 0] call menuItemFormatter;
117+
_logisticsItems pushBack _text;
118+
};
119+
120+
121+
// Compilaton and Call for Logistics SubMenu
122+
_finalString = "logistic_SubMenu = [[""Logistical Supports"",true],";
123+
_logisticsItemsClassString = _logisticsItems joinString ",";
124+
_finalString = _finalString + _logisticsItemsClassString;
125+
_finalString = _finalString + "];";
126+
127+
_myCode = compile _finalString;
128+
call _myCode;
129+
130+
//Transport Submenu check
131+
if(support_helotaxi_available) then {
132+
_text = ["Helicopter taxi(1 CP)", '_nill = [getpos player,50] execVM ""support\taxi\helotaxi.sqf""', 1] call menuItemFormatter;
133+
_transportItems pushBack _text;
134+
} else {
135+
_text = ["Helicopter taxi(N/A)", '', 0] call menuItemFormatter;
136+
_transportItems pushBack _text;
137+
};
138+
139+
if(support_boattaxi_available) then {
140+
_text = ["Boat taxi (1 CP)", '_null = [getpos player,10] execVM ""support\taxi\boattaxi.sqf""', 1] call menuItemFormatter;
141+
_transportItems pushBack _text;
142+
} else {
143+
_text = ["Boat taxi (N/A)", '', 0] call menuItemFormatter;
144+
_transportItems pushBack _text;
145+
};
146+
147+
148+
// Compilaton and Call for Transport SubMenu
149+
_finalString = "transport_SubMenu = [[""Transport Supports"",true],";
150+
_transportItemsClassString = _transportItems joinString ",";
151+
_finalString = _finalString + _transportItemsClassString;
152+
_finalString = _finalString + "];";
153+
154+
_myCode = compile _finalString;
155+
call _myCode;
156+
157+
158+
//Construct and show Support Menu root
159+
supportMenu =
160+
[
161+
["Support Menu",false],
162+
["Offensive", [2], "#USER:offensive_SubMenu", -5, [["expression", ""]], "1", "1"],
163+
["Logistics", [3], "#USER:logistic_SubMenu", -5, [["expression", ""]], "1", "1"],
164+
["Transport", [4], "#USER:transport_SubMenu", -5, [["expression", ""]], "1", "1"]
165+
];
166+
167+
showCommandingMenu "#USER:supportMenu";

0 commit comments

Comments
 (0)