Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Context Menu

About

The package provides you a flexible to adjust system of in-game context menus. The system can be used both with integration into AGUIElement.OnContext callback or as a stand-alone solution.

Usage of the module features allows you to draw and execute programable list of GUI elements with bonded Action handlers. By the press over the menu element an attached action handler will be invoked.

Menu creation

In-game layout

In-game context menu by itself powered with:

Layout fetching from the Resources folder as DynamicResource by the following resource signature:
Bundle: dui2.context
Key: default

You may find default pre-configured layout resource by the following path:
Doloro-GDK \ Doloro-UI-2 \ Resources \ Templates \ Context \ Context menu.prefab

Warning
  1. The resource with the key MUST exist in Resources repository to be found.
  2. Dynamic Resources Database must be loaded before resource property addressing or context menu Open method call. Otherwise, the layout resource will not be located even in case of exist among resources.


Context call

Context menus implemented as static service. All operations with menus going via Doloro.UIEngine2.Modules.Context.ContextMenu class's API.

Following example demonstrates a sample menu creation and call.

// Declaring first item.
var _ctxt0 = new Context.ContextMenuItemInfo()
{
directory = "Item0",
callback = OnItem0Callback;
};
// Declaring second item.
var _ctxt1 = new Context.ContextMenuItemInfo()
{
directory = "Item1",
callback = OnItem1Callback;
};
// Declaring third item.
var _ctxt2 = new Context.ContextMenuItemInfo()
{
directory = "Item2",
callback = OnItem2Callback;
};
// Opening context menu with declared items.
Context.ContextMenu.Open(
new Rect(MOUSE_POSITION, WINDOW_SIZE),
_ctxt0,
_ctxt1,
_ctxt2);
// Handler to call with first item click.
void OnItem0Callback() {...}
// Handler to call with second item click.
void OnItem1Callback() {...}
// Handler to call with third item click.
void OnItem2Callback() {...}
Property Purpose
direction Allows to define item name.
Warning
On current stage context menus not supports multi-layer directories. The features will be added with future updates.
callback Action to call with item click.


AGUIElement integration

To integrate context menu into AGUIElement source you have to implement OnContext handler with context generation logic.

public void OnCustomGUIElement : AGUIElement
{
protected override void OnContextMenu()
{
base.OnContextMenu();
// Declare items.
// Declare callbacks.
// Call context menu Open.
}
}

The handler automatically calls when the element receives RMB click event over it. That allows to define extra actions for interaction with any instance in GUI engine and create much more advance UI.