Eden Editor: Entity Context Menu: Difference between revisions

From Bohemia Interactive Community
(Added missing conditions)
(Entire overhaul of the documentation and added 2.22 additions)
Line 7: Line 7:
[[File:A3_3DEN_contextMenu.jpg|500px]]
[[File:A3_3DEN_contextMenu.jpg|500px]]


=== Adding a Level 1 Entry ===
== Config ==
 
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
class Display3DEN
{
class ContextMenu : ctrlMenu
{
class Items
{
items[] += { "TAG_ShowOldText" };
class TAG_ShowOldText
{
text = "$STR_TAG_contextMenu_showSomeText"; // Name of the entry, ideally localised
value = 0; // In order for an entry to show up in the context menu as a level one item, it must have a value defined
action = "systemChat 'Showing some old text.'"; // The code which is executed when the entry was selected
conditionShow = "hoverObject"; // The Condition, see below
};
};
};
};
</syntaxhighlight>
 
If you want to add a level one item which has level two entries, see the third example.
 
=== Adding a Level 2 Entry ===
 
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
class ctrlMenu; // Load base class
class Display3DEN
class Display3DEN
{
{
Line 42: Line 16:
class Items
class Items
{
{
class Log // The easiest way to add an entry is to use one of the already available folders, here we use the class "Log" (Level 1)
items[] += {"TAG_RootFolder"}; // Root items
{
class TAG_RootFolder // Level 1 item
picture = "someLogo.paa"; // Icon used for the entry called "Log"
items[] += // Here we list all items we want to add to the "Log" class.
{
"TAG_ShowSomeText"
};
};
class TAG_ShowSomeText // Now we need to define the entry itself which will be inside the "Log" folder (Level 2)
{
{
text = "$STR_TAG_contextMenu_showSomeText"; // Name of the entry, ideally localised
picture = "someLogo.paa";
action = "systemChat 'Showing some text.'"; // The code which is executed when the entry was selected
conditionShow = "hoverObject"; // The Condition, see below
};
};
};
};
</syntaxhighlight>
 
=== Adding a Multi-Level Entry ===
 
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
class Display3DEN
{
class ContextMenu : ctrlMenu
{
class Items
{
items[] += {"TAG_ShowAFolder"};
class TAG_ShowAFolder
{
picture = "someLogo.paa"; // Icon used for the entry called [Custom Folder]
text = "Custom Folder";
text = "Custom Folder";
value = 0; // In order for an entry to show up in the context menu as a level one item, it must have a value defined
value = 0;
items[] = // Here we list all items we want to add to the [Custom Folder] class.
items[] = {"TAG_ShowSomeText"}; // Items in "folder" TAG_RootFolder
{
"TAG_ShowSomeText"
};
};
};
class TAG_ShowSomeText // Now we need to define the entry itself which will be the [Show Text] entry, (Level 2)
class TAG_ShowSomeText // Level 2 item
{
{
text = "Show Text"; //Name of the entry
text = "Show Text";
action = "systemChat 'Showing some text.'"; //The code which is executed when the entry was selected
action = "systemChat 'Showing some text.'";
conditionShow = "hoverObject"; //The Condition, see below
conditionShow = "hoverObject";
};
};
};
};
Line 93: Line 35:
</syntaxhighlight>
</syntaxhighlight>


=== Properties ===


== Conditions ==
{| class="wikitable"
 
! Property !! Description !! Data type
* Context menu entries can have different conditions which need to be true in order for the entry to appear.
|-
* The condition is defined by the '''conditionShow''' config entry.
| text|| Text shown in the menu. Can be [[isLocalized|localized]]. || [[String]]
 
|-
<syntaxhighlight lang="cpp">
| picture || Item path to a picture shown in front of the text. || [[String]]
class YourEntry
|-
{
| action || An SQF expression [[call]]ed when the item is activated. || [[String]]
action = "call BIS_fnc_someFunction"; // Can be any kind of expression defined as string
|-
text = "Delete Crew"; // Name shown in the context menu
| data || Used by the engine. Internal use only. || [[String]]
conditionShow = "hoverObjectVehicle"; // Condition
|-
};
| enable || Used by the engine. Internal use only. || [[Number]]
</syntaxhighlight>
|-
 
| shortcuts[] || Each entry can have a single shortcut assigned to it. The shortcut only works when the context menu is open. This did not work prior to {{GVI|arma3|2.22}}. || [[Array]]
The condition is a [[Simple Expression]] and can use one of the variables below:
|-
| value || An internal bit flag. Set it to 0 to always show the item in the root of the config menu. Otherwise ignore it. || [[Number]]
|-
| {{GVI|arma3|2.22}} conditionScript1 || Scripted condition that needs to return a [[Boolean]]. It is only evaluated if simple expression {{hl|script1}} is used inside {{hl|conditionShow}}.
{{Feature|warning|This condition is evaluated for all menu items and all selected entities {{hl|entityCount * menuItemCount {{=}} evaluationCount}}. Keep these expressions as simple as possible!}}
|| [[String]]
|-
| conditionShow || A condition represented as simple expression. Needs to return 1 ([[true]]) in order for the item to be visible. A list of all available expression is listed below.|| [[String]]
|}


{| class="wikitable sortable"
{| class="wikitable sortable"
Line 114: Line 65:
! class="unsortable" | Description
! class="unsortable" | Description
|-
|-
| selected
| hoverFolder
| True when an Eden entity is selected
| True when hovering over a folder (layer)
|-
| hoverObjectBrain
| True when hovering over an object with simulation "soldier" or "UAVpilot"
|-
| hoverObjectVehicle
| True when hovering over a vehicle
|-
| hoverObject
| True when hovering over any object
|-
|-
| hoverGroup
| hoverGroup
| True when hovering over any group
| True when hovering over any group
|-
|-
| hoverTrigger
| hoverLayer
| True when hovering over any trigger
| True when hovering over a Layer
|-
| hoverWaypoint
| True when hovering over any waypoint
|-
|-
| hoverLogic
| hoverLogic
| True when hovering over any logic
| True when hovering over any logic
|-
| hoverLogicModule
| True when hovering over a module
|-
|-
| hoverMarker
| hoverMarker
| True when hovering over any marker
| True when hovering over any marker
|-
|-
| isMultiplayer
| hoverMarkerArea
| True when editing in multiplayer environment
| True when hovering over a marker of type area
|-
| hoverObject
| True when hovering over any object
|-
| hoverObjectAgent
|
|-
|-
| hoverObjectUav
| hoverObjectAttached
| True when hovering over an UAV
|
|-
|-
| hoverLayer
| hoverObjectBrain
| True when hovering over a Layer
| True when hovering over an object with simulation "soldier" or "UAVpilot"
|-
|-
| hoverObjectCanFly
| hoverObjectCanFly
Line 154: Line 102:
|-
|-
| hoverObjectFlying
| hoverObjectFlying
| True when hovering an object which is flying
|-
| selectedObject
| True when an object is selected
|-
| selectedWaypoint
| True when a waypoint is selected
|-
| selectedLogic
| True when a logic is selected
|-
| selectedMarker
| True when a Marker is selected
|-
| Hover0bjectFlying
| True when hovering over a object that can fly
| True when hovering over a object that can fly
|-
|-
| HoverFolder
| hoverObjectUav
| True when hovering over a folder (layer)
| True when hovering over an UAV
|-
|-
| HoverLogicModule
| hoverObjectVehicle
| True when hovering over a module
| True when hovering over a vehicle
|-
|-
| HoverMarkerArea
| hoverTrigger
| True when hovering over a marker of type area
| True when hovering over any trigger
|-
|-
| HoverObjectAgent
| hoverWaypoint
|
| True when hovering over any waypoint
|-
| HoverObjectAttached
|
|-
|-
| IsInternal
| IsInternal
Line 191: Line 121:
| IsMultiplayer
| IsMultiplayer
| True when editing in multiplayer
| True when editing in multiplayer
|-
| isMultiplayer
| True when editing in multiplayer environment
|-
|-
| Map
| Map
| True when the map is open
| True when the map is open
|-
|-
| SelectedGroup
| selected
| True when an Eden entity is selected
|-
| selectedGroup
| True when a group is selected
| True when a group is selected
|-
|-
| SelectedLogicModule
| selectedLogic
| True when a logic is selected
|-
| selectedLogicModule
| Try when a module is selected
| Try when a module is selected
|-
|-
| SelectedMarkerArea
| selectedMarker
| True when a Marker is selected
|-
| selectedMarkerArea
| True when a marker of type area is selected
| True when a marker of type area is selected
|-
|-
| SelectedObjectAgent
| selectedObject
| True when an object is selected
|-
| selectedObjectAgent
|
|
|-
|-
| SelectedObjectAttached
| selectedObjectAttached
|  
|  
|-
|-
| SelectedObjectBrain
| selectedObjectBrain
| True when an object with simulation "soldier" or "UAVpilot" is selected
| True when an object with simulation "soldier" or "UAVpilot" is selected
|-
|-
| SelectedObjectCanFly
| selectedObjectCanFly
| True when the selected object can fly
| True when the selected object can fly
|-
|-
| SelectedObjectFlying
| selectedObjectFlying
| True when the selected object is flying
| True when the selected object is flying
|-
|-
| SelectedObjectVehicle
| selectedObjectVehicle
| True when a vehicle is selected
| True when a vehicle is selected
|-
|-
| SelectedTrigger
| selectedTrigger
| True when a trigger is selected
| True when a trigger is selected
|-
| selectedWaypoint
| True when a waypoint is selected
|-
| {{GVI|arma3|2.22}} script1
| Contains SQF condition defined in {{hl|scriptedCondition1}} property.
|}
|}


== Variables ==
== Variables ==
Once the menu has been opened, the following variables can be accessed:
Once the menu has been opened, the following variables can be accessed:
<sqf>(uiNamespace getVariable "BIS_fnc_3DENEntityMenu_data") params ["_posEntity3D", "_entity"];</sqf>
<sqf>(uiNamespace getVariable "BIS_fnc_3DENEntityMenu_data") params ["_posEntity3D", "_entity"];</sqf>

Revision as of 18:27, 19 April 2026

Create a custom Entity Context Menu entry

  • Entries for the Context Menu are defined in the class Display3DEN.
  • The menu has multiple levels, the first level for example contains options like "Go Here" or folders like "Log". Those folders on the other hand can have another level, level 2.



A3 3DEN contextMenu.jpg

Config

class ctrlMenu; // Load base class
class Display3DEN
{
	class ContextMenu : ctrlMenu
	{
		class Items
		{
			items[] += {"TAG_RootFolder"}; // Root items
			class TAG_RootFolder // Level 1 item
			{
				picture = "someLogo.paa";
				text = "Custom Folder";
				value = 0;
				items[] = {"TAG_ShowSomeText"}; // Items in "folder" TAG_RootFolder
			};
			class TAG_ShowSomeText // Level 2 item
			{
				text = "Show Text";
				action = "systemChat 'Showing some text.'";
				conditionShow = "hoverObject";
			};
		};
	};
};

Properties

Property Description Data type
text Text shown in the menu. Can be localized. String
picture Item path to a picture shown in front of the text. String
action An SQF expression called when the item is activated. String
data Used by the engine. Internal use only. String
enable Used by the engine. Internal use only. Number
shortcuts[] Each entry can have a single shortcut assigned to it. The shortcut only works when the context menu is open. This did not work prior to Arma 3 logo black.png 2.22. Array
value An internal bit flag. Set it to 0 to always show the item in the root of the config menu. Otherwise ignore it. Number
Arma 3 logo black.png 2.22 conditionScript1 Scripted condition that needs to return a Boolean. It is only evaluated if simple expression script1 is used inside conditionShow.
This condition is evaluated for all menu items and all selected entities entityCount * menuItemCount = evaluationCount. Keep these expressions as simple as possible!
String
conditionShow A condition represented as simple expression. Needs to return 1 (true) in order for the item to be visible. A list of all available expression is listed below. String
Condition Description
hoverFolder True when hovering over a folder (layer)
hoverGroup True when hovering over any group
hoverLayer True when hovering over a Layer
hoverLogic True when hovering over any logic
hoverLogicModule True when hovering over a module
hoverMarker True when hovering over any marker
hoverMarkerArea True when hovering over a marker of type area
hoverObject True when hovering over any object
hoverObjectAgent
hoverObjectAttached
hoverObjectBrain True when hovering over an object with simulation "soldier" or "UAVpilot"
hoverObjectCanFly True when hovering an object which can fly
hoverObjectFlying True when hovering over a object that can fly
hoverObjectUav True when hovering over an UAV
hoverObjectVehicle True when hovering over a vehicle
hoverTrigger True when hovering over any trigger
hoverWaypoint True when hovering over any waypoint
IsInternal True when using internal executable. For developers only!
IsMultiplayer True when editing in multiplayer
isMultiplayer True when editing in multiplayer environment
Map True when the map is open
selected True when an Eden entity is selected
selectedGroup True when a group is selected
selectedLogic True when a logic is selected
selectedLogicModule Try when a module is selected
selectedMarker True when a Marker is selected
selectedMarkerArea True when a marker of type area is selected
selectedObject True when an object is selected
selectedObjectAgent
selectedObjectAttached
selectedObjectBrain True when an object with simulation "soldier" or "UAVpilot" is selected
selectedObjectCanFly True when the selected object can fly
selectedObjectFlying True when the selected object is flying
selectedObjectVehicle True when a vehicle is selected
selectedTrigger True when a trigger is selected
selectedWaypoint True when a waypoint is selected
Arma 3 logo black.png 2.22 script1 Contains SQF condition defined in scriptedCondition1 property.

Variables

Once the menu has been opened, the following variables can be accessed:

(uiNamespace getVariable "BIS_fnc_3DENEntityMenu_data") params ["_posEntity3D", "_entity"];