Eden Editor: Entity Context Menu: Difference between revisions

From Bohemia Interactive Community
(added information about uiNamespace variables and added syntax highlighting)
m (→‎Variables: added proper variable descriptions)
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TOC|side}}
== Create a custom Entity Context Menu entry==
== 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.<br><br>
* 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.
<br><br>
[[File:A3_3DEN_contextMenu.jpg|500px]]
[[File:A3_3DEN_contextMenu.jpg|500px]]
<syntaxhighlight lang="cpp">class ctrlMenu;//First we need to load the base class of the menu
 
== Config ==
<syntaxhighlight lang="cpp">
class ctrlMenu; // Load base class
class Display3DEN
class Display3DEN
{
{
class ContextMenu: ctrlMenu
class ContextMenu : ctrlMenu
{
{
    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'''
picture = "someLogo.paa";
items[] +=//Here we list all items we want to add to the '''Log''' class.
text = "Custom Folder";
{
value = 0;
"TAG_ShowSomeText"
items[] = {"TAG_ShowSomeText"}; // Items in "folder" TAG_RootFolder
};
};
};
class TAG_ShowSomeText//Now we need to define the entry itself which will be inside the '''Log''' folder '''(Level 2)'''
class TAG_ShowSomeText // Level 2 item
{
{
text = $STR_TAG_contextMenu_showSomeText;//Name of the entry, ideally localised
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 + script1"; // Only show this entry when the object is set to be playable in multiplayer
conditionScript1 = "_this get3DENAttribute 'ControlMP' isEqualTo [true];"
};
};
};
};
};
};
};</syntaxhighlight>
};
</syntaxhighlight>


=== Properties ===


 
{| class="wikitable"
== Conditions ==
! Property !! Description !! Data type
 
|-
*Context menu entries can have different conditions which need to be true in order for the entry to appear.
| text|| Text shown in the menu. Can be [[isLocalized|localized]]. || [[String]]
*The condition is defined by the '''conditionShow''' config entry.
|-
 
| picture || Item path to a picture shown in front of the text. || [[String]]
<syntaxhighlight lang="cpp">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
|-
};</syntaxhighlight>
| enable || Used by the engine. Internal use only. || [[Number]]
 
|-
The condition is a [[Simple Expression]] and can use one of the variables below:
| 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]]
|-
| 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 48: Line 66:
! class="unsortable" | Description
! class="unsortable" | Description
|-
|-
| <!-- Condition --> selected
| hoverFolder
| <!-- Description -->True when an Eden entity is selected
| 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!
|-
|-
| <!-- Condition --> hoverObjectBrain
| isMultiplayer
| <!-- Description -->True when hovering over an object with simulation "soldier" or "UAVpilot"
| True when editing in multiplayer environment
|-
|-
| <!-- Condition --> hoverObjectVehicle
| Map
| <!-- Description -->True when hovering over a vehicle
| True when the map is open
|-
|-
| <!-- Condition --> hoverObject
| selected
| <!-- Description -->True when hovering over any object
| True when an Eden entity is selected
|-
|-
| <!-- Condition --> hoverGroup
| selectedGroup
| <!-- Description -->True when hovering over any group
| True when a group is selected
|-
|-
| <!-- Condition --> hoverTrigger
| selectedLogic
| <!-- Description -->True when hovering over any trigger
| True when a logic is selected
|-
|-
| <!-- Condition --> hoverWaypoint
| selectedLogicModule
| <!-- Description -->True when hovering over any waypoint
| Try when a module is selected
|-
|-
| <!-- Condition --> hoverLogic
| selectedMarker
| <!-- Description -->True when hovering over any logic
| True when a Marker is selected
|-
|-
| <!-- Condition --> hoverMarker
| selectedMarkerArea
| <!-- Description -->True when hovering over any marker
| True when a marker of type area is selected
|-
|-
| <!-- Condition --> isMultiplayer
| selectedObject
| <!-- Description -->True when editing in multiplayer environment
| True when an object is selected
|-
|-
| <!-- Condition --> hoverObjectUav
| selectedObjectAgent
| <!-- Description -->True when hovering over an UAV
|
|-
|-
| <!-- Condition --> isEditList
| selectedObjectAttached
| <!-- Description -->True when the menu is opened from entity menu
|  
|-
|-
| <!-- Condition --> hoverLayer
| selectedObjectBrain
| <!-- Description -->True when hovering over a Layer
| True when an object with simulation "soldier" or "UAVpilot" is selected
|-
|-
| <!-- Condition --> hoverObjectCanFly
| selectedObjectCanFly
| <!-- Description -->True when hovering an object which can fly
| True when the selected object can fly
|-
|-
| <!-- Condition --> hoverObjectFlying
| selectedObjectFlying
| <!-- Description -->True when hovering an object which is flying
| True when the selected object is flying
|-
|-
| <!-- Condition --> selectedObject
| selectedObjectVehicle
| <!-- Description -->True when an object is selected
| True when a vehicle is selected
|-
|-
| <!-- Condition --> selectedWaypoint
| selectedTrigger
| <!-- Description -->True when a waypoint is selected
| True when a trigger is selected
|-
|-
| <!-- Condition --> selectedLogic
| selectedWaypoint
| <!-- Description -->True when a logic is selected
| True when a waypoint is selected
|-
|-
| <!-- Condition --> selectedMarker
| {{GVI|arma3|2.22}} script1
| <!-- Description -->True when a Marker is selected
| Contains SQF condition defined in {{hl|scriptedCondition1}} property.
|}
|}


==Useful Variables==
== Variables ==
* When working with the context menu it can be handy to work with some uiNamespace variables.
Once the menu has been opened, the following variables can be accessed:
<syntaxhighlight lang="cpp">
<sqf>(uiNamespace getVariable "BIS_fnc_3DENEntityMenu_data") params ["_posEntity3D", "_entity"];</sqf>
_menuData = (uiNamespace getVariable "bis_fnc_3DENEntityMenu_data");
 
_pos3D = _menuData select 0;//Is the position of the entity in 3D coordinates
* 0: _posEntity3D: [[Vector3D]] - Position of the entity on which the right click happened
_entity = _menuData select 1;//Is the entity which was right clicked at.
* 1: _entity: [[Object]] - Eden entity on which the right click happened
</syntaxhighlight>
 
[[Category:Eden Editor|Entity Context Menu]]
[[Category:Eden Editor: Modding|Entity Context Menu]]
[[Category:Eden Editor: Modding|Entity Context Menu]]

Latest revision as of 12:56, 20 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 + script1"; // Only show this entry when the object is set to be playable in multiplayer
				conditionScript1 = "_this get3DENAttribute 'ControlMP' isEqualTo [true];"
			};
		};
	};
};

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 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"];

  • 0: _posEntity3D: Vector3D - Position of the entity on which the right click happened
  • 1: _entity: Object - Eden entity on which the right click happened