omp_gdk/scripting/menus/
mod.rs1pub mod events;
2pub mod functions;
3
4use std::ffi::c_void;
5
6pub use functions::load_functions;
7
8use crate::{players::Player, types::vector::Vector2};
9
10pub struct Menu {
11 handle: *const c_void,
12}
13
14impl Menu {
15 pub fn get_handle(&self) -> *const c_void {
16 self.handle
17 }
18
19 pub fn new(handle: *const c_void) -> Self {
20 Self { handle }
21 }
22
23 pub fn create(
25 title: &str,
26 columns: u32,
27 position: Vector2,
28 column1_widthh: f32,
29 column2_width: f32,
30 ) -> Option<Menu> {
31 let mut _id = 0;
32 functions::Menu_Create(
33 title,
34 columns,
35 position.x,
36 position.y,
37 column1_widthh,
38 column2_width,
39 &mut _id,
40 )
41 }
42
43 pub fn destroy(&self) -> bool {
45 functions::Menu_Destroy(self)
46 }
47
48 pub fn add_item(&self, column: u8, text: &str) -> i32 {
50 functions::Menu_AddItem(self, column, text)
51 }
52
53 pub fn set_column_header(&self, column: u8, header_title: &str) -> bool {
55 functions::Menu_SetColumnHeader(self, column, header_title)
56 }
57
58 pub fn show_for_player(&self, player: &Player) -> bool {
60 functions::Menu_ShowForPlayer(self, player)
61 }
62
63 pub fn hide_for_player(&self, player: &Player) -> bool {
65 functions::Menu_HideForPlayer(self, player)
66 }
67
68 pub fn disable(&self) -> bool {
70 functions::Menu_Disable(self)
71 }
72
73 pub fn disable_row(&self, row: u8) -> bool {
75 functions::Menu_DisableRow(self, row)
76 }
77
78 pub fn is_disabled(&self) -> bool {
80 functions::Menu_IsDisabled(self)
81 }
82
83 pub fn is_row_disabled(&self, row: i32) -> bool {
85 functions::Menu_IsRowDisabled(self, row)
86 }
87
88 pub fn get_columns(&self) -> i32 {
90 functions::Menu_GetColumns(self)
91 }
92
93 pub fn get_items(&self, column: i32) -> i32 {
95 functions::Menu_GetItems(self, column)
96 }
97
98 pub fn get_pos(&self) -> Vector2 {
100 let mut pos = Vector2::default();
101 functions::Menu_GetPos(self, &mut pos.x, &mut pos.y);
102 pos
103 }
104
105 pub fn get_column_width(&self) -> (f32, f32) {
107 let (mut column1_width, mut column2_width) = (0.0, 0.0);
108 functions::Menu_GetColumnWidth(self, &mut column1_width, &mut column2_width);
109 (column1_width, column2_width)
110 }
111
112 pub fn get_column_header(&self, column: i32) -> String {
114 let mut header = String::new();
115 functions::Menu_GetColumnHeader(self, column, &mut header, 32);
116 header
117 }
118
119 pub fn get_item(&self, column: i32, row: i32) -> String {
121 let mut title = String::new();
122 functions::Menu_GetItem(self, column, row, &mut title, 32);
123 title
124 }
125
126 pub fn get_id(&self) -> i32 {
128 functions::Menu_GetID(self)
129 }
130
131 pub fn from_id(id: i32) -> Option<Menu> {
133 functions::Menu_FromID(id)
134 }
135}