Eden Editor: Entity Context Menu: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " ( *class [a-zA-Z0-9_]+): *([a-zA-Z0-9_]+ *) " to " $1 : $2 ")
 
(11 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]]
=== Adding a Level 1 Entry ===
=== Adding a Level 1 Entry ===
<syntaxhighlight lang="cpp">class ctrlMenu;//First we need to load the base class of the menu
 
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
class Display3DEN
class Display3DEN
{
{
class ContextMenu: ctrlMenu
class ContextMenu : ctrlMenu
{
{
    class Items
class Items
    {
{
            items[] += {"TAG_ShowOldText"};
items[] += { "TAG_ShowOldText" };
class TAG_ShowOldText
class TAG_ShowOldText
{
{
text = $STR_TAG_contextMenu_showSomeText;//Name of the entry, ideally localised
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
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
action = "systemChat 'Showing some old text.'"; // The code which is executed when the entry was selected
conditionShow = "hoverObject";//The Condition, see below
conditionShow = "hoverObject"; // The Condition, see below
};
};
};
};
};
};
};</syntaxhighlight>
};
</syntaxhighlight>


If you want to add a level one item which has level two entries, see the third example.
If you want to add a level one item which has level two entries, see the third example.


=== Adding a Level 2 Entry ===
=== Adding a Level 2 Entry ===
<syntaxhighlight lang="cpp">class ctrlMenu;//First we need to load the base class of the menu
 
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
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)'''
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'''
picture = "someLogo.paa"; // Icon used for the entry called "Log"
items[] +=//Here we list all items we want to add to the '''Log''' class.  
items[] += // Here we list all items we want to add to the "Log" class.  
{
{
"TAG_ShowSomeText"
"TAG_ShowSomeText"
};
};
};
};
class TAG_ShowSomeText //Now we need to define the entry itself which will be inside the '''Log''' folder '''(Level 2)'''
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
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
action = "systemChat 'Showing some text.'"; // The code which is executed when the entry was selected
conditionShow = "hoverObject";//The Condition, see below
conditionShow = "hoverObject"; // The Condition, see below
};
};
};
};
};
};
};</syntaxhighlight>
};
</syntaxhighlight>


=== Adding a Multi-Level Entry ===
=== Adding a Multi-Level Entry ===
<syntaxhighlight lang="cpp">class ctrlMenu;//First we need to load the base class of the menu
 
<syntaxhighlight lang="cpp">
class ctrlMenu; // First we need to load the base class of the menu
class Display3DEN
class Display3DEN
{
{
class ContextMenu: ctrlMenu
class ContextMenu : ctrlMenu
{
{
    class Items
class Items
    {
{
            items[] += {"TAG_ShowAFolder"};
items[] += {"TAG_ShowAFolder"};
class TAG_ShowAFolder
class TAG_ShowAFolder
{
{
picture = "someLogo.paa"; //Icon used for the entry called '''Custom Folder'''
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; // In order for an entry to show up in the context menu as a level one item, it must have a value defined
items[] =//Here we list all items we want to add to the '''Custom Folder''' class.  
items[] = // Here we list all items we want to add to the [Custom Folder] class.  
{
{
"TAG_ShowSomeText"
"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 // Now we need to define the entry itself which will be the [Show Text] entry, (Level 2)
{
{
text = "Show Text"; //Name of the entry
text = "Show Text"; //Name of the entry
Line 78: Line 90:
};
};
};
};
};</syntaxhighlight>
};
</syntaxhighlight>
 


== Conditions ==
== Conditions ==


*Context menu entries can have different conditions which need to be true in order for the entry to appear.
* 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.
* The condition is defined by the '''conditionShow''' config entry.


<syntaxhighlight lang="cpp">class YourEntry
<syntaxhighlight lang="cpp">
class YourEntry
{
{
action = "call BIS_fnc_someFunction"; // Can be any kind of expression defined as string
action = "call BIS_fnc_someFunction"; // Can be any kind of expression defined as string
text = "Delete Crew"; // Name shown in the context menu
text = "Delete Crew"; // Name shown in the context menu
conditionShow = "hoverObjectVehicle"; // Condition
conditionShow = "hoverObjectVehicle"; // Condition
};</syntaxhighlight>
};
</syntaxhighlight>


The condition is a [[Simple Expression]] and can use one of the variables below:
The condition is a [[Simple Expression]] and can use one of the variables below:
Line 98: Line 114:
! class="unsortable" | Description
! class="unsortable" | Description
|-
|-
| <!-- Condition --> selected
| selected
| <!-- Description -->True when an Eden entity is selected
| True when an Eden entity is selected
|-
|-
| <!-- Condition --> hoverObjectBrain
| hoverObjectBrain
| <!-- Description -->True when hovering over an object with simulation "soldier" or "UAVpilot"  
| True when hovering over an object with simulation "soldier" or "UAVpilot"  
|-
|-
| <!-- Condition --> hoverObjectVehicle
| hoverObjectVehicle
| <!-- Description -->True when hovering over a vehicle
| True when hovering over a vehicle
|-
|-
| <!-- Condition --> hoverObject
| hoverObject
| <!-- Description -->True when hovering over any object
| True when hovering over any object
|-
|-
| <!-- Condition --> hoverGroup
| hoverGroup
| <!-- Description -->True when hovering over any group
| True when hovering over any group
|-
|-
| <!-- Condition --> hoverTrigger
| hoverTrigger
| <!-- Description -->True when hovering over any trigger
| True when hovering over any trigger
|-
|-
| <!-- Condition --> hoverWaypoint
| hoverWaypoint
| <!-- Description -->True when hovering over any waypoint
| True when hovering over any waypoint
|-
|-
| <!-- Condition --> hoverLogic
| hoverLogic
| <!-- Description -->True when hovering over any logic
| True when hovering over any logic
|-
|-
| <!-- Condition --> hoverMarker
| hoverMarker
| <!-- Description -->True when hovering over any marker
| True when hovering over any marker
|-
|-
| <!-- Condition --> isMultiplayer
| isMultiplayer
| <!-- Description -->True when editing in multiplayer environment
| True when editing in multiplayer environment
|-
|-
| <!-- Condition --> hoverObjectUav
| hoverObjectUav
| <!-- Description -->True when hovering over an UAV
| True when hovering over an UAV
|-
|-
| <!-- Condition --> isEditList
| isEditList
| <!-- Description -->True when the menu is opened from entity menu
| True when the menu is opened from entity menu
|-
|-
| <!-- Condition --> hoverLayer
| hoverLayer
| <!-- Description -->True when hovering over a Layer
| True when hovering over a Layer
|-
|-
| <!-- Condition --> hoverObjectCanFly
| hoverObjectCanFly
| <!-- Description -->True when hovering an object which can fly
| True when hovering an object which can fly
|-
|-
| <!-- Condition --> hoverObjectFlying
| hoverObjectFlying
| <!-- Description -->True when hovering an object which is flying
| True when hovering an object which is flying
|-
|-
| <!-- Condition --> selectedObject
| selectedObject
| <!-- Description -->True when an object is selected
| True when an object is selected
|-
|-
| <!-- Condition --> selectedWaypoint
| selectedWaypoint
| <!-- Description -->True when a waypoint is selected
| True when a waypoint is selected
|-
|-
| <!-- Condition --> selectedLogic
| selectedLogic
| <!-- Description -->True when a logic is selected
| True when a logic is selected
|-
|-
| <!-- Condition --> selectedMarker
| selectedMarker
| <!-- Description -->True when a Marker is selected
| True when a Marker is selected
|}
|}


==Useful Variable==
* Once the menu was opened, the following variable can be accessed.
<syntaxhighlight lang="cpp">
_menuData = (uiNamespace getVariable "bis_fnc_3DENEntityMenu_data");
_menuData params ["_posEntity3D","_entity"];


</syntaxhighlight>
== Variables ==
[[Category:Eden Editor|Entity Context Menu]]
 
Once the menu has been opened, the following variables can be accessed:
<sqf>(uiNamespace getVariable "BIS_fnc_3DENEntityMenu_data") params ["_posEntity3D", "_entity"];</sqf>
 
 
[[Category:Eden Editor: Modding|Entity Context Menu]]
[[Category:Eden Editor: Modding|Entity Context Menu]]

Latest revision as of 10:58, 6 December 2023

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

Adding a Level 1 Entry

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
			};
		};
	};
};

If you want to add a level one item which has level two entries, see the third example.

Adding a Level 2 Entry

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
			};
		};
	};
};

Adding a Multi-Level Entry

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";
				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
				items[] = // Here we list all items we want to add to the [Custom Folder] class. 
				{
					"TAG_ShowSomeText"
				};
			};
			class TAG_ShowSomeText // Now we need to define the entry itself which will be the [Show Text] entry, (Level 2)
			{
				text = "Show Text"; //Name of the entry
				action = "systemChat 'Showing some text.'"; //The code which is executed when the entry was selected
				conditionShow = "hoverObject"; //The Condition, see below
			};
		};
	};
};


Conditions

  • 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.
class YourEntry
{
	action = "call BIS_fnc_someFunction"; // Can be any kind of expression defined as string
	text = "Delete Crew"; // Name shown in the context menu
	conditionShow = "hoverObjectVehicle"; // Condition
};

The condition is a Simple Expression and can use one of the variables below:

Condition Description
selected True when an Eden entity is selected
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 True when hovering over any group
hoverTrigger True when hovering over any trigger
hoverWaypoint True when hovering over any waypoint
hoverLogic True when hovering over any logic
hoverMarker True when hovering over any marker
isMultiplayer True when editing in multiplayer environment
hoverObjectUav True when hovering over an UAV
isEditList True when the menu is opened from entity menu
hoverLayer True when hovering over a Layer
hoverObjectCanFly True when hovering an object which can fly
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


Variables

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

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