Table of Contents

Struct IMenu

Namespace
SampSharp.OpenMp.Core.Api
Assembly
SampSharp.OpenMp.Core.dll

This type represents a pointer to an unmanaged open.mp IMenu interface.

[OpenMpApi(new Type[] { typeof(IExtensible), typeof(IIDProvider) })]
public readonly struct IMenu : IEquatable<IMenu>, IMenu.IManagedInterface, IExtensible.IManagedInterface, IIDProvider.IManagedInterface, IUnmanagedInterface
Implements
Inherited Members

Constructors

IMenu(nint)

Initializes a new instance of the IMenu struct.

public IMenu(nint handle)

Parameters

handle nint

A pointer to the unmanaged interface.

Properties

Handle

Gets the handle to the unmanaged interface instance.

public nint Handle { get; }

Property Value

nint

HasValue

Gets a value indicating whether the pointer has a value.

public bool HasValue { get; }

Property Value

bool

Methods

AddCell(string, byte)

Adds a cell with text to a menu column.

public int AddCell(string itemText, byte column)

Parameters

itemText string

The text for the cell.

column byte

The column index (0 or 1).

Returns

int

The row index of the added cell.

AddExtension<T>(T)

Adds the specified managed extension to this extensible.

public void AddExtension<T>(T extension) where T : Extension

Parameters

extension T

An instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.

Type Parameters

T

The type of the managed extension.

Remarks

A managed extension can only be added to one extensible.

Exceptions

ArgumentException

Throw when an instance of the extension type was already added to this extensible.

Disable()

Disables the entire menu.

public void Disable()

DisableRow(byte)

Disables a menu row, making it unselectable.

public void DisableRow(byte row)

Parameters

row byte

The row index to disable.

Equals(IMenu)

public bool Equals(IMenu other)

Parameters

other IMenu

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

GetCell(byte, byte)

Gets the text of a menu cell.

public string? GetCell(byte column, byte row)

Parameters

column byte

The column index.

row byte

The row index.

Returns

string

The cell text, or null if empty.

GetColumnCount()

Gets the number of columns in the menu.

public int GetColumnCount()

Returns

int

The number of columns (typically 1 or 2).

GetColumnHeader(byte)

Gets the header text of a menu column.

public string? GetColumnHeader(byte column)

Parameters

column byte

The column index.

Returns

string

The header text, or null if not set.

GetColumnWidths()

Gets the widths of the menu columns.

public Vector2 GetColumnWidths()

Returns

Vector2

A Vector2 containing the widths of the columns.

GetExtension(UID)

Gets the extension with the specified id.

public IExtension GetExtension(UID id)

Parameters

id UID

The identifier of the extension type.

Returns

IExtension

The extension or null if the extension could not be found.

GetExtension<T>()

Gets the specified managed extension from this extensible.

public T GetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

GetHashCode()

public override int GetHashCode()

Returns

int

GetID()

Gets the identifier of this unit.

public int GetID()

Returns

int

The identifier of the unit.

GetPosition()

Gets the position of the menu.

public ref Vector2 GetPosition()

Returns

Vector2

A reference to the menu's position as a Vector2.

GetRowCount(byte)

Gets the number of rows in a menu column.

public int GetRowCount(byte column)

Parameters

column byte

The column index.

Returns

int

The number of rows in the column.

HideForPlayer(IPlayer)

Hides the menu from a player.

public void HideForPlayer(IPlayer player)

Parameters

player IPlayer

The player to hide the menu from.

InitForPlayer(IPlayer)

Initializes the menu for a player (called before showing).

public void InitForPlayer(IPlayer player)

Parameters

player IPlayer

The player to initialize the menu for.

IsEnabled()

Checks if the menu is enabled.

public bool IsEnabled()

Returns

bool

true if the menu is enabled; otherwise, false.

IsRowEnabled(byte)

Checks if a menu row is enabled.

public bool IsRowEnabled(byte row)

Parameters

row byte

The row index to check.

Returns

bool

true if the row is enabled; otherwise, false.

QueryExtension<T>()

Gets the specified unmanaged extension from this extensible.

public T QueryExtension<T>() where T : unmanaged, IExtension.IManagedInterface

Returns

T

The unmanaged extension or null if the extension could not be found.

Type Parameters

T

The type of the unmanaged extension.

RemoveExtension(IExtension)

Removes the specified extension from this extensible.

public void RemoveExtension(IExtension extension)

Parameters

extension IExtension

The extension to remove.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension(UID)

Removes the extension with the specified id from this extensible.

public void RemoveExtension(UID id)

Parameters

id UID

The identifier of the extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension<T>(T)

Removes the specified managed extension from this extensible.

public void RemoveExtension<T>(T extension) where T : Extension

Parameters

extension T

The managed extension to remove.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

SetColumnHeader(string, byte)

Sets the header text for a menu column.

public void SetColumnHeader(string header, byte column)

Parameters

header string

The header text to display.

column byte

The column index (0 or 1).

ShowForPlayer(IPlayer)

Shows the menu to a player.

public void ShowForPlayer(IPlayer player)

Parameters

player IPlayer

The player to show the menu to.

TryGetExtension<T>()

Tries to get the specified managed extension from this extensible.

public T? TryGetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T or null if no extension with the specified type could be found.

Type Parameters

T

The type of the managed extension.

TryQueryExtension<T>(out T)

Tries to get the specified unmanaged extension from this extensible.

public bool TryQueryExtension<T>(out T extension) where T : unmanaged, IExtension.IManagedInterface

Parameters

extension T

The extension if found, otherwise null.

Returns

bool

true if the extension was found; false otherwise.

Type Parameters

T

The type of the unmanaged extension.

Operators

operator ==(IMenu, object?)

Determines whether the specified values are equal.

public static bool operator ==(IMenu lhs, object? rhs)

Parameters

lhs IMenu

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are equal; otherwise, false.

explicit operator IMenu(IExtensible)

Casts the IExtensible to a IMenu.

public static explicit operator IMenu(IExtensible value)

Parameters

value IExtensible

The IExtensible to cast.

Returns

IMenu

The converted IMenu.

explicit operator IMenu(IIDProvider)

Casts the IIDProvider to a IMenu.

public static explicit operator IMenu(IIDProvider value)

Parameters

value IIDProvider

The IIDProvider to cast.

Returns

IMenu

The converted IMenu.

explicit operator IExtensible(IMenu)

Casts the IMenu to a IExtensible.

public static explicit operator IExtensible(IMenu value)

Parameters

value IMenu

The IMenu to cast.

Returns

IExtensible

The converted IExtensible.

explicit operator IIDProvider(IMenu)

Casts the IMenu to a IIDProvider.

public static explicit operator IIDProvider(IMenu value)

Parameters

value IMenu

The IMenu to cast.

Returns

IIDProvider

The converted IIDProvider.

operator !=(IMenu, object?)

Determines whether the specified values are not equal.

public static bool operator !=(IMenu lhs, object? rhs)

Parameters

lhs IMenu

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are not equal; otherwise, false.