| |
| |
| |
| |
| |
| |
| |
| |
|
|
| local sampapi = require 'sampapi' |
| local shared = sampapi.shared |
| local mt = require 'sampapi.metatype' |
| local ffi = require 'ffi' |
|
|
| shared.require 'CVector' |
|
|
| shared.ffi.cdef[[ |
| typedef struct STransmit STransmit; |
| #pragma pack(push, 1) |
| struct STransmit { |
| union { |
| struct { |
| unsigned char m_bBox : 1; |
| unsigned char m_bLeft : 1; |
| unsigned char m_bRight : 1; |
| unsigned char m_bCenter : 1; |
| unsigned char m_bProportional : 1; |
| }; |
| unsigned char m_nFlags; |
| }; |
| float m_fLetterWidth; |
| float m_fLetterHeight; |
| D3DCOLOR m_letterColor; |
| float m_fBoxWidth; |
| float m_fBoxHeight; |
| D3DCOLOR m_boxColor; |
| unsigned char m_nShadow; |
| bool m_bOutline; |
| D3DCOLOR m_backgroundColor; |
| unsigned char m_nStyle; |
| unsigned char is_selectable; |
| float m_fX; |
| float m_fY; |
| short unsigned int m_nModel; |
| SCVector m_rotation; |
| float m_fZoom; |
| short unsigned int m_aColor[2]; |
| }; |
| #pragma pack(pop) |
| |
| typedef struct SData SData; |
| #pragma pack(push, 1) |
| struct SData { |
| float m_fLetterWidth; |
| float m_fLetterHeight; |
| D3DCOLOR m_letterColor; |
| unsigned char unknown; |
| unsigned char m_bCenter; |
| unsigned char m_bBox; |
| float m_fBoxSizeX; |
| float m_fBoxSizeY; |
| D3DCOLOR m_boxColor; |
| unsigned char m_nProportional; |
| D3DCOLOR m_backgroundColor; |
| unsigned char m_nShadow; |
| unsigned char m_nOutline; |
| unsigned char m_bLeft; |
| unsigned char m_bRight; |
| int m_nStyle; |
| float m_fX; |
| float m_fY; |
| unsigned char pad_[8]; |
| long unsigned int field_99B; |
| long unsigned int field_99F; |
| long unsigned int m_nIndex; |
| unsigned char is_selectable; |
| short unsigned int m_nModel; |
| SCVector m_rotation; |
| float m_fZoom; |
| short unsigned int m_aColor[2]; |
| unsigned char field_9BE; |
| unsigned char drawn_this_frame; |
| unsigned char text_contains_keys; |
| long unsigned int computed_left; |
| long unsigned int computed_top; |
| long unsigned int computed_right; |
| long unsigned int computed_bottom; |
| unsigned char is_selected; |
| long unsigned int color_if_selected; |
| }; |
| #pragma pack(pop) |
| |
| typedef struct SCTextDraw SCTextDraw; |
| #pragma pack(push, 1) |
| struct SCTextDraw { |
| char m_szText[801]; |
| char m_szString[1602]; |
| SData m_data; |
| }; |
| #pragma pack(pop) |
| ]] |
|
|
| shared.validate_size('struct STransmit', 0x3f) |
| shared.validate_size('struct SData', 0x73) |
| shared.validate_size('struct SCTextDraw', 0x9d6) |
|
|
| local CTextDraw_constructor = ffi.cast('void(__thiscall*)(SCTextDraw*, STransmit*, const char*)', 0xB36E0) |
| local CTextDraw_destructor = ffi.cast('void(__thiscall*)(SCTextDraw*)', 0xB2F50) |
| local function CTextDraw_new(...) |
| local obj = ffi.gc(ffi.new('struct SCTextDraw[1]'), CTextDraw_destructor) |
| CTextDraw_constructor(obj, ...) |
| return obj |
| end |
|
|
| local SCTextDraw_mt = { |
| SetText = ffi.cast('void(__thiscall*)(SCTextDraw*, const char*)', sampapi.GetAddress(0xB36E0)), |
| Draw = ffi.cast('void(__thiscall*)(SCTextDraw*)', sampapi.GetAddress(0xB3480)), |
| } |
| mt.set_handler('struct SCTextDraw', '__index', SCTextDraw_mt) |
|
|
| return { |
| new = CTextDraw_new, |
| } |