use std::ffi::c_void;
pub mod events;
pub mod functions;
pub use functions::load_functions;
use crate::{
players::Player,
types::colour::Colour,
types::vector::{Vector2, Vector3},
};
pub struct TextDraw {
handle: *const c_void,
}
#[deny(non_snake_case)]
impl TextDraw {
pub fn get_handle(&self) -> *const c_void {
self.handle
}
pub fn new(handle: *const c_void) -> Self {
Self { handle }
}
pub fn create(position: Vector2, text: &str) -> Option<TextDraw> {
let mut _id = -1;
functions::TextDraw_Create(position.x, position.y, text, &mut _id)
}
pub fn destroy(&self) -> bool {
functions::TextDraw_Destroy(self)
}
pub fn is_shown_for_player(&self, player: &Player) -> bool {
functions::TextDraw_IsVisibleForPlayer(player, self)
}
pub fn set_letter_size(&self, size: Vector2) -> bool {
functions::TextDraw_SetLetterSize(self, size.x, size.y)
}
pub fn set_text_size(&self, size: Vector2) -> bool {
functions::TextDraw_SetTextSize(self, size.x, size.y)
}
pub fn set_alignment(&self, alignment: TextDrawAlignmentTypes) -> bool {
functions::TextDraw_SetAlignment(self, alignment as i32)
}
pub fn set_color(&self, colour: Colour) -> bool {
functions::TextDraw_SetColor(self, colour.rgba())
}
pub fn use_box(&self, use_box: bool) -> bool {
functions::TextDraw_SetUseBox(self, use_box)
}
pub fn set_box_color(&self, colour: Colour) -> bool {
functions::TextDraw_SetBoxColor(self, colour.rgba())
}
pub fn set_shadow(&self, size: i32) -> bool {
functions::TextDraw_SetShadow(self, size)
}
pub fn set_outline(&self, size: i32) -> bool {
functions::TextDraw_SetOutline(self, size)
}
pub fn set_background_color(&self, colour: Colour) -> bool {
functions::TextDraw_SetBackgroundColor(self, colour.rgba())
}
pub fn set_style(&self, font: TextDrawStyle) -> bool {
functions::TextDraw_SetFont(self, font as i32)
}
pub fn set_proportional(&self, set: bool) -> bool {
functions::TextDraw_SetSetProportional(self, set)
}
pub fn set_selectable(&self, set: bool) -> bool {
functions::TextDraw_SetSelectable(self, set)
}
pub fn show_for_player(&self, player: &Player) -> bool {
functions::TextDraw_ShowForPlayer(player, self)
}
pub fn hide_for_player(&self, player: &Player) -> bool {
functions::TextDraw_HideForPlayer(player, self)
}
pub fn show_for_all(&self) -> bool {
functions::TextDraw_ShowForAll(self)
}
pub fn hide_for_all(&self) -> bool {
functions::TextDraw_HideForAll(self)
}
pub fn set_string(&self, text: &str) -> bool {
functions::TextDraw_SetString(self, text)
}
pub fn set_preview_model(&self, model: i32) -> bool {
functions::TextDraw_SetPreviewModel(self, model)
}
pub fn set_preview_rotation(&self, rotation: Vector3, zoom: f32) -> bool {
functions::TextDraw_SetPreviewRot(self, rotation.x, rotation.y, rotation.z, zoom)
}
pub fn set_preview_veh_colour(&self, colour1: i32, colour2: i32) -> bool {
functions::TextDraw_SetPreviewVehCol(self, colour1, colour2)
}
pub fn set_pos(&self, pos: Vector2) -> bool {
functions::TextDraw_SetPos(self, pos.x, pos.y)
}
pub fn get_string(&self) -> String {
let mut text = String::new();
functions::TextDraw_GetString(self, &mut text, 16);
text
}
pub fn get_letter_size(&self) -> Vector2 {
let mut size = Vector2::default();
functions::TextDraw_GetLetterSize(self, &mut size.x, &mut size.y);
size
}
pub fn get_text_size(&self) -> Vector2 {
let mut size = Vector2::default();
functions::TextDraw_GetTextSize(self, &mut size.x, &mut size.y);
size
}
pub fn get_pos(&self) -> Vector2 {
let mut pos = Vector2::default();
functions::TextDraw_GetPos(self, &mut pos.x, &mut pos.y);
pos
}
pub fn get_color(&self) -> Colour {
Colour::from_rgba(functions::TextDraw_GetColor(self) as u32)
}
pub fn get_box_color(&self) -> Colour {
Colour::from_rgba(functions::TextDraw_GetBoxColor(self) as u32)
}
pub fn get_background_color(&self) -> Colour {
Colour::from_rgba(functions::TextDraw_GetBackgroundColor(self) as u32)
}
pub fn get_shadow(&self) -> i32 {
functions::TextDraw_GetShadow(self)
}
pub fn get_outline(&self) -> i32 {
functions::TextDraw_GetOutline(self)
}
pub fn get_style(&self) -> i32 {
functions::TextDraw_GetFont(self)
}
pub fn is_box(&self) -> bool {
functions::TextDraw_IsBox(self)
}
pub fn is_proportional(&self) -> bool {
functions::TextDraw_IsProportional(self)
}
pub fn is_selectable(&self) -> bool {
functions::TextDraw_IsSelectable(self)
}
pub fn get_alignment(&self) -> TextDrawAlignmentTypes {
unsafe { std::mem::transmute(functions::TextDraw_GetAlignment(self)) }
}
pub fn get_preview_model(&self) -> i32 {
functions::TextDraw_GetPreviewModel(self)
}
pub fn get_preview_rotation(&self) -> (Vector3, f32) {
let mut rotation = Vector3::default();
let mut zoom = 0.0;
functions::TextDraw_GetPreviewRot(
self,
&mut rotation.x,
&mut rotation.y,
&mut rotation.z,
&mut zoom,
);
(rotation, zoom)
}
pub fn get_preview_veh_colour(&self) -> (i32, i32) {
let mut colour1 = 0;
let mut colour2 = 0;
functions::TextDraw_GetPreviewVehColor(self, &mut colour1, &mut colour2);
(colour1, colour2)
}
pub fn set_string_for_player(&self, player: &Player, text: &str) -> bool {
functions::TextDraw_SetStringForPlayer(self, player, text)
}
pub fn get_id(&self) -> i32 {
functions::TextDraw_GetID(self)
}
pub fn from_id(id: i32) -> Option<TextDraw> {
functions::TextDraw_FromID(id)
}
}
pub struct PlayerTextDraw {
handle: *const c_void,
pub player: Player,
}
impl PlayerTextDraw {
pub fn get_handle(&self) -> *const c_void {
self.handle
}
pub fn new(handle: *const c_void, player: Player) -> Self {
Self { handle, player }
}
pub fn is_shown(&self) -> bool {
functions::PlayerTextDraw_IsVisible(&self.player, self)
}
pub fn set_letter_size(&self, size: Vector2) -> bool {
functions::PlayerTextDraw_SetLetterSize(&self.player, self, size.x, size.y)
}
pub fn set_text_size(&self, size: Vector2) -> bool {
functions::PlayerTextDraw_SetTextSize(&self.player, self, size.x, size.y)
}
pub fn alignment(&self, alignment: TextDrawAlignmentTypes) -> bool {
functions::PlayerTextDraw_SetAlignment(&self.player, self, alignment as i32)
}
pub fn color(&self, colour: Colour) -> bool {
functions::PlayerTextDraw_SetColor(&self.player, self, colour.rgba())
}
pub fn use_box(&self, box_use: bool) -> bool {
functions::PlayerTextDraw_UseBox(&self.player, self, box_use)
}
pub fn set_box_color(&self, colour: Colour) -> bool {
functions::PlayerTextDraw_SetBoxColor(&self.player, self, colour.rgba())
}
pub fn set_shadow(&self, size: i32) -> bool {
functions::PlayerTextDraw_SetShadow(&self.player, self, size)
}
pub fn set_outline(&self, size: i32) -> bool {
functions::PlayerTextDraw_SetOutline(&self.player, self, size)
}
pub fn background_color(&self, colour: Colour) -> bool {
functions::PlayerTextDraw_SetBackgroundColor(&self.player, self, colour.rgba())
}
pub fn set_style(&self, font: TextDrawStyle) -> bool {
functions::PlayerTextDraw_SetFont(&self.player, self, font as i32)
}
pub fn set_proportional(&self, set: bool) -> bool {
functions::PlayerTextDraw_SetProportional(&self.player, self, set)
}
pub fn set_selectable(&self, set: bool) -> bool {
functions::PlayerTextDraw_SetSelectable(&self.player, self, set)
}
pub fn show(&self) -> bool {
functions::PlayerTextDraw_Show(&self.player, self)
}
pub fn hide(&self) -> bool {
functions::PlayerTextDraw_Hide(&self.player, self)
}
pub fn set_string(&self, text: &str) -> bool {
functions::PlayerTextDraw_SetString(&self.player, self, text)
}
pub fn set_preview_model(&self, model: i32) -> bool {
functions::PlayerTextDraw_SetPreviewModel(&self.player, self, model)
}
pub fn set_preview_rotation(&self, rotation: Vector3, zoom: f32) -> bool {
functions::PlayerTextDraw_SetPreviewRot(
&self.player,
self,
rotation.x,
rotation.y,
rotation.z,
zoom,
)
}
pub fn set_preview_veh_colour(&self, colour1: i32, colour2: i32) -> bool {
functions::PlayerTextDraw_SetPreviewVehCol(&self.player, self, colour1, colour2)
}
pub fn set_pos(&self, pos: Vector2) -> bool {
functions::PlayerTextDraw_SetPos(&self.player, self, pos.x, pos.y)
}
pub fn get_string(&self) -> String {
let mut text = String::new();
functions::PlayerTextDraw_GetString(&self.player, self, &mut text, 16);
text
}
pub fn get_letter_size(&self) -> Vector2 {
let mut size = Vector2::default();
functions::PlayerTextDraw_GetLetterSize(&self.player, self, &mut size.x, &mut size.y);
size
}
pub fn get_text_size(&self) -> Vector2 {
let mut size = Vector2::default();
functions::PlayerTextDraw_GetTextSize(&self.player, self, &mut size.x, &mut size.y);
size
}
pub fn get_pos(&self) -> Vector2 {
let mut pos = Vector2::default();
functions::PlayerTextDraw_GetPos(&self.player, self, &mut pos.x, &mut pos.y);
pos
}
pub fn get_color(&self) -> Colour {
Colour::from_rgba(functions::PlayerTextDraw_GetColor(&self.player, self) as u32)
}
pub fn get_box_color(&self) -> Colour {
Colour::from_rgba(functions::PlayerTextDraw_GetBoxColor(&self.player, self) as u32)
}
pub fn get_background_colour(&self) -> Colour {
Colour::from_rgba(functions::PlayerTextDraw_GetBackgroundColor(&self.player, self) as u32)
}
pub fn get_shadow(&self) -> i32 {
functions::PlayerTextDraw_GetShadow(&self.player, self)
}
pub fn get_outline(&self) -> i32 {
functions::PlayerTextDraw_GetOutline(&self.player, self)
}
pub fn get_style(&self) -> i32 {
functions::PlayerTextDraw_GetFont(&self.player, self)
}
pub fn is_box(&self) -> bool {
functions::PlayerTextDraw_IsBox(&self.player, self)
}
pub fn is_proportional(&self) -> bool {
functions::PlayerTextDraw_IsProportional(&self.player, self)
}
pub fn is_selectable(&self) -> bool {
functions::PlayerTextDraw_IsSelectable(&self.player, self)
}
pub fn get_alignment(&self) -> TextDrawAlignmentTypes {
unsafe { std::mem::transmute(functions::PlayerTextDraw_GetAlignment(&self.player, self)) }
}
pub fn get_preview_model(&self) -> i32 {
functions::PlayerTextDraw_GetPreviewModel(&self.player, self)
}
pub fn get_preview_rotation(&self) -> (Vector3, f32) {
let mut rotation = Vector3::default();
let mut zoom = 0.0;
functions::PlayerTextDraw_GetPreviewRot(
&self.player,
self,
&mut rotation.x,
&mut rotation.y,
&mut rotation.z,
&mut zoom,
);
(rotation, zoom)
}
pub fn get_preview_veh_colour(&self) -> (i32, i32) {
let mut colour1 = 0;
let mut colour2 = 0;
functions::PlayerTextDraw_GetPreviewVehColor(
&self.player,
self,
&mut colour1,
&mut colour2,
);
(colour1, colour2)
}
pub fn get_id(&self) -> i32 {
functions::PlayerTextDraw_GetID(&self.player, self)
}
pub fn from_id(selfid: i32, player: &Player) -> Option<PlayerTextDraw> {
functions::PlayerTextDraw_FromID(player, selfid)
}
}
#[repr(C)]
#[derive(PartialEq, Clone, Copy, Debug, Default)]
pub enum TextDrawAlignmentTypes {
#[default]
Default,
Left,
Center,
Right,
}
#[repr(C)]
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum TextDrawStyle {
FontBeckettRegular = 0,
FontAharoniBold,
FontBankGothic,
FontPricedown,
Sprite,
Preview,
}