Eden Editor: Entity Context Menu: Difference between revisions

From Bohemia Interactive Community
(→‎Conditions: removed isEditList)
m (→‎Variables: added proper variable descriptions)
 
(4 intermediate revisions by the same user not shown)
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">
class ctrlMenu; // First we need to load the base class of the menu
class Display3DEN
{
class ContextMenu : ctrlMenu
{
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)
{
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
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">
<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 71: Line 16:
class Items
class Items
{
{
items[] += {"TAG_ShowAFolder"};
items[] += {"TAG_RootFolder"}; // Root items
class TAG_ShowAFolder
class TAG_RootFolder // Level 1 item
{
{
picture = "someLogo.paa"; // Icon used for the entry called [Custom Folder]
picture = "someLogo.paa";
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 + script1"; // Only show this entry when the object is set to be playable in multiplayer
conditionScript1 = "_this get3DENAttribute 'ControlMP' isEqualTo [true];"
};
};
};
};
Line 93: Line 36:
</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 66:
! class="unsortable" | Description
! class="unsortable" | Description
|-
|-
| selected
| hoverFolder
| 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
| hoverObjectBrain
| True when hovering over an object with simulation "soldier" or "UAVpilot"  
| 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
| hoverObjectVehicle
| True when hovering over a vehicle
| True when hovering over a vehicle
|-
| hoverObject
| True when hovering over any object
|-
| hoverGroup
| True when hovering over any group
|-
|-
| hoverTrigger
| hoverTrigger
Line 135: Line 117:
| True when hovering over any waypoint
| True when hovering over any waypoint
|-
|-
| hoverLogic
| IsInternal
| True when hovering over any logic
| True when using internal executable. For developers only!
|-
| hoverMarker
| True when hovering over any marker
|-
|-
| isMultiplayer
| isMultiplayer
| True when editing in multiplayer environment
| True when editing in multiplayer environment
|-
|-
| hoverObjectUav
| Map
| True when hovering over an UAV
| True when the map is open
|-
| selected
| True when an Eden entity is selected
|-
|-
<!-- Not implemented, removed by dedmen from engine
| selectedGroup
| isEditList
| True when a group is selected
| True when the menu is opened from entity menu
|-
|-
-->
| selectedLogic
| hoverLayer
| True when a logic is selected
| True when hovering over a Layer
|-
| selectedLogicModule
| Try when a module is selected
|-
|-
| hoverObjectCanFly
| selectedMarker
| True when hovering an object which can fly
| True when a Marker is selected
|-
|-
| hoverObjectFlying
| selectedMarkerArea
| True when hovering an object which is flying
| True when a marker of type area is selected
|-
|-
| selectedObject
| selectedObject
| True when an object is selected
| 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
| selectedWaypoint
| True when a waypoint is selected
| True when a waypoint is selected
|-
|-
| selectedLogic
| {{GVI|arma3|2.22}} script1
| True when a logic is selected
| Contains SQF condition defined in {{hl|scriptedCondition1}} property.
|-
| selectedMarker
| True when a Marker is selected
|}
|}


== 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>


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


[[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