rust-samp-sdk 3.6.0

Low-level FFI bindings for the SA-MP AMX virtual machine and open.mp native component ABI. Used internally by `rust-samp`; depend on it directly only if you need raw access without the higher-level macros and lifecycle.
Documentation
//! `IMenu` — generated by `cargo xtask gen-omp` from `Server/Components/Menus/menus.hpp`.
//! Implemented by `Menu` in the server's `Menus`.
//!
//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
//! regenerate. Slots are clang's layout of the header for each ABI, checked
//! against the official binaries by `cargo xtask check-abi --generated`.

#![allow(unused_imports)]

use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
use crate::omp::types::{
    Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
    UID, Vector2, Vector3, Vector4, WorldTimePoint,
};
use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
use crate::omp::*;

slots! {
    /// `void IMenu::setColumnHeader(StringView, MenuColumn)`
    SLOT_SET_COLUMN_HEADER: usize = 6, 5;
    /// `int IMenu::addCell(StringView, MenuColumn)`
    SLOT_ADD_CELL: usize = 7, 6;
    /// `void IMenu::disableRow(MenuRow)`
    SLOT_DISABLE_ROW: usize = 8, 7;
    /// `bool IMenu::isRowEnabled(MenuRow)`
    SLOT_IS_ROW_ENABLED: usize = 9, 8;
    /// `void IMenu::disable()`
    SLOT_DISABLE: usize = 10, 9;
    /// `bool IMenu::isEnabled()`
    SLOT_IS_ENABLED: usize = 11, 10;
    /// `const Vector2 & IMenu::getPosition()`
    SLOT_GET_POSITION: usize = 12, 11;
    /// `int IMenu::getRowCount(MenuColumn)`
    SLOT_GET_ROW_COUNT: usize = 13, 12;
    /// `int IMenu::getColumnCount()`
    SLOT_GET_COLUMN_COUNT: usize = 14, 13;
    /// `Vector2 IMenu::getColumnWidths()`
    SLOT_GET_COLUMN_WIDTHS: usize = 15, 14;
    /// `const StringView IMenu::getColumnHeader(MenuColumn)`
    SLOT_GET_COLUMN_HEADER: usize = 16, 15;
    /// `const StringView IMenu::getCell(MenuColumn, MenuRow)`
    SLOT_GET_CELL: usize = 17, 16;
    /// `void IMenu::initForPlayer(IPlayer &)`
    SLOT_INIT_FOR_PLAYER: usize = 18, 17;
    /// `void IMenu::showForPlayer(IPlayer &)`
    SLOT_SHOW_FOR_PLAYER: usize = 19, 18;
    /// `void IMenu::hideForPlayer(IPlayer &)`
    SLOT_HIDE_FOR_PLAYER: usize = 20, 19;
}

virtual_fns! {
    /// `void IMenu::setColumnHeader(StringView, MenuColumn)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_set_column_header(
        menu: IMenu,
        header: StringView,
        column: u8,
    ) = [0, SLOT_SET_COLUMN_HEADER];

    /// `int IMenu::addCell(StringView, MenuColumn)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_add_cell(
        menu: IMenu,
        item_text: StringView,
        column: u8,
    ) -> i32 = [0, SLOT_ADD_CELL] or 0;

    /// `void IMenu::disableRow(MenuRow)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_disable_row(menu: IMenu, row: u8) = [0, SLOT_DISABLE_ROW];

    /// `bool IMenu::isRowEnabled(MenuRow)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_is_row_enabled(menu: IMenu, row: u8) -> bool = [0, SLOT_IS_ROW_ENABLED] or false;

    /// `void IMenu::disable()`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_disable(menu: IMenu) = [0, SLOT_DISABLE];

    /// `bool IMenu::isEnabled()`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_is_enabled(menu: IMenu) -> bool = [0, SLOT_IS_ENABLED] or false;

    /// `const Vector2 & IMenu::getPosition()`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_position(
        menu: IMenu,
    ) -> *const Vector2 = [0, SLOT_GET_POSITION] or std::ptr::null();

    /// `int IMenu::getRowCount(MenuColumn)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_row_count(menu: IMenu, column: u8) -> i32 = [0, SLOT_GET_ROW_COUNT] or 0;

    /// `int IMenu::getColumnCount()`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    #[must_use]
    pub fn menu_column_count(menu: IMenu) -> i32 = [0, SLOT_GET_COLUMN_COUNT] or 0;

    /// `void IMenu::initForPlayer(IPlayer &)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_init_for_player(menu: IMenu, player: *mut IPlayer) = [0, SLOT_INIT_FOR_PLAYER];

    /// `void IMenu::showForPlayer(IPlayer &)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_show_for_player(menu: IMenu, player: *mut IPlayer) = [0, SLOT_SHOW_FOR_PLAYER];

    /// `void IMenu::hideForPlayer(IPlayer &)`.
    ///
    /// # Safety
    /// `menu` must be a live `IMenu`.
    pub fn menu_hide_for_player(menu: IMenu, player: *mut IPlayer) = [0, SLOT_HIDE_FOR_PLAYER];
}

/// `Vector2 IMenu::getColumnWidths()`.
///
/// # Safety
/// `menu` must be a live `IMenu`.
#[must_use]
pub unsafe fn menu_column_widths(menu: *mut IMenu) -> Option<Vector2> {
    call_vtable_small_struct!(
        menu.cast::<u8>(),
        0,
        SLOT_GET_COLUMN_WIDTHS,
        Vector2,
        Vector2::default()
    )
}

/// `const StringView IMenu::getColumnHeader(MenuColumn)`.
///
/// # Safety
/// `menu` must be a live `IMenu`.
#[must_use]
pub unsafe fn menu_column_header(menu: *mut IMenu, column: u8) -> Option<String> {
    let view = call_vtable_small_struct!(
        menu.cast::<u8>(),
        0,
        SLOT_GET_COLUMN_HEADER,
        StringView,
        StringView::EMPTY,
        (u8)(column)
    )?;
    unsafe { view.to_owned_string() }
}

/// `const StringView IMenu::getCell(MenuColumn, MenuRow)`.
///
/// # Safety
/// `menu` must be a live `IMenu`.
#[must_use]
pub unsafe fn menu_cell(menu: *mut IMenu, column: u8, row: u8) -> Option<String> {
    let view = call_vtable_small_struct!(
        menu.cast::<u8>(),
        0,
        SLOT_GET_CELL,
        StringView,
        StringView::EMPTY,
        (u8, u8)(column, row)
    )?;
    unsafe { view.to_owned_string() }
}