pub mod events;
pub mod functions;
use std::ffi::c_void;
pub use functions::load_functions;
use crate::{players::Player, types::vector::Vector2};
pub struct Menu {
handle: *const c_void,
}
impl Menu {
pub fn get_handle(&self) -> *const c_void {
self.handle
}
pub fn new(handle: *const c_void) -> Self {
Self { handle }
}
pub fn create(
title: &str,
columns: u32,
position: Vector2,
column1_widthh: f32,
column2_width: f32,
) -> Option<Menu> {
let mut _id = 0;
functions::Menu_Create(
title,
columns,
position.x,
position.y,
column1_widthh,
column2_width,
&mut _id,
)
}
pub fn destroy(&self) -> bool {
functions::Menu_Destroy(self)
}
pub fn add_item(&self, column: u8, text: &str) -> i32 {
functions::Menu_AddItem(self, column, text)
}
pub fn set_column_header(&self, column: u8, header_title: &str) -> bool {
functions::Menu_SetColumnHeader(self, column, header_title)
}
pub fn show_for_player(&self, player: &Player) -> bool {
functions::Menu_ShowForPlayer(self, player)
}
pub fn hide_for_player(&self, player: &Player) -> bool {
functions::Menu_HideForPlayer(self, player)
}
pub fn disable(&self) -> bool {
functions::Menu_Disable(self)
}
pub fn disable_row(&self, row: u8) -> bool {
functions::Menu_DisableRow(self, row)
}
pub fn is_disabled(&self) -> bool {
functions::Menu_IsDisabled(self)
}
pub fn is_row_disabled(&self, row: i32) -> bool {
functions::Menu_IsRowDisabled(self, row)
}
pub fn get_columns(&self) -> i32 {
functions::Menu_GetColumns(self)
}
pub fn get_items(&self, column: i32) -> i32 {
functions::Menu_GetItems(self, column)
}
pub fn get_pos(&self) -> Vector2 {
let mut pos = Vector2::default();
functions::Menu_GetPos(self, &mut pos.x, &mut pos.y);
pos
}
pub fn get_column_width(&self) -> (f32, f32) {
let (mut column1_width, mut column2_width) = (0.0, 0.0);
functions::Menu_GetColumnWidth(self, &mut column1_width, &mut column2_width);
(column1_width, column2_width)
}
pub fn get_column_header(&self, column: i32) -> String {
let mut header = String::new();
functions::Menu_GetColumnHeader(self, column, &mut header, 32);
header
}
pub fn get_item(&self, column: i32, row: i32) -> String {
let mut title = String::new();
functions::Menu_GetItem(self, column, row, &mut title, 32);
title
}
pub fn get_id(&self) -> i32 {
functions::Menu_GetID(self)
}
pub fn from_id(id: i32) -> Option<Menu> {
functions::Menu_FromID(id)
}
}