1+ use std:: ffi:: { c_char, CString } ;
12use std:: fs:: File ;
23use std:: io:: Read ;
34use std:: mem;
@@ -7,7 +8,8 @@ use std::sync::atomic::Ordering::SeqCst;
78
89use gnal_tsur:: gnal_tsur;
910use hudhook:: { imgui, MessageFilter , RenderContext } ;
10- use hudhook:: imgui:: { Context , FontConfig , FontGlyphRanges , FontId , FontSource , Io } ;
11+ use hudhook:: imgui:: { Context , FontConfig , FontGlyphRanges , FontId , FontSource , ImColor32 , Io , sys} ;
12+ use imgui_sys:: { igGetFont, ImColor , ImVec2 , ImVec4 } ;
1113use once_cell:: sync:: Lazy ;
1214use windows:: Win32 :: UI :: Input :: KeyboardAndMouse :: VK_INSERT ;
1315
@@ -35,7 +37,7 @@ use crate::settings::{AppSettings, load_app_settings, save_app_settings};
3537use crate :: style:: {
3638 set_style_minty_light, set_style_minty_mint, set_style_minty_red, set_style_unicore,
3739} ;
38- use crate :: utils:: { read_memory, read_view_matrix, run_cmd} ;
40+ use crate :: utils:: { f32_to_u8 , float_array_to_u32 , read_memory, read_view_matrix, run_cmd} ;
3941use crate :: vars:: game_vars:: {
4042 ENTITY_LIST_PTR , FOV , LOCAL_PLAYER , NUM_PLAYERS_IN_MATCH , SMOOTH , TRIGGER_DELAY , VIEW_MATRIX ,
4143} ;
@@ -575,15 +577,15 @@ pub unsafe fn on_frame(ui: &imgui::Ui, app_settings: &mut AppSettings) {
575577 if ui. slider (
576578 "Name text size" ,
577579 10.0f32 ,
578- 60 .0f32,
580+ 120 .0f32,
579581 & mut SETTINGS . name_text_thickness ,
580582 ) {
581583 println ! (
582584 "Set name text size to {}" ,
583585 SETTINGS . deref( ) . name_text_thickness
584586 )
585587 }
586- if ui. color_edit3 (
588+ if ui. color_edit4 (
587589 "Ally name text color" ,
588590 & mut SETTINGS . ally_name_text_color ,
589591 ) {
@@ -592,7 +594,7 @@ pub unsafe fn on_frame(ui: &imgui::Ui, app_settings: &mut AppSettings) {
592594 SETTINGS . ally_name_text_color
593595 ) ;
594596 }
595- if ui. color_edit3 (
597+ if ui. color_edit4 (
596598 "Enemy name text color" ,
597599 & mut SETTINGS . enemy_name_text_color ,
598600 ) {
@@ -1115,17 +1117,42 @@ impl hudhook::ImguiRenderLoop for RenderLoop {
11151117 } )
11161118 . unwrap ( ) ;
11171119
1118- let custom_font = ui. push_font ( font_id) ;
1119- background_draw_list. add_text (
1120- [ espleft, esptop - 40.0f32 ] ,
1121- if LOCAL_PLAYER . team ( ) . unwrap ( ) == entity. team ( ) . unwrap ( ) {
1122- SETTINGS . deref ( ) . ally_name_text_color
1123- } else {
1124- SETTINGS . deref ( ) . enemy_name_text_color
1125- } ,
1126- entity. name ( ) . unwrap ( ) ,
1127- ) ;
1128- custom_font. pop ( ) ;
1120+
1121+ unsafe {
1122+ let custom_font = ui. push_font ( font_id) ;
1123+ // Get the entity name and create a CString
1124+ let text = entity. name ( ) . unwrap ( ) ;
1125+ let c_text = CString :: new ( text) . unwrap ( ) ; // Convert to C-compatible string
1126+
1127+ let font_handle = igGetFont ( ) ;
1128+
1129+ // Get the pointer to the C string
1130+ let start: * const c_char = c_text. as_ptr ( ) ; // Use CString to ensure null termination
1131+
1132+ // The end pointer is not necessary when using CString, as you can pass the string slice
1133+ let end: * const c_char = start. add ( c_text. as_bytes ( ) . len ( ) ) ;
1134+
1135+ // Call the function
1136+ sys:: ImDrawList_AddText_FontPtr (
1137+ sys:: igGetBackgroundDrawList_Nil ( ) ,
1138+ font_handle,
1139+ SETTINGS . deref ( ) . name_text_thickness ,
1140+ ImVec2 :: from ( [ espleft, esptop - 80.0f32 ] ) ,
1141+ if LOCAL_PLAYER . team ( ) . unwrap ( ) == entity. team ( ) . unwrap ( ) {
1142+ ImColor32 :: from_rgba ( f32_to_u8 ( SETTINGS . deref ( ) . ally_name_text_color [ 0 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . ally_name_text_color [ 1 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . ally_name_text_color [ 2 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . ally_name_text_color [ 3 ] ) ) . to_bits ( )
1143+ } else {
1144+ ImColor32 :: from_rgba ( f32_to_u8 ( SETTINGS . deref ( ) . enemy_name_text_color [ 0 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . enemy_name_text_color [ 1 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . enemy_name_text_color [ 2 ] ) , f32_to_u8 ( SETTINGS . deref ( ) . enemy_name_text_color [ 3 ] ) ) . to_bits ( )
1145+ } ,
1146+ start,
1147+ end,
1148+ 0.0f32 ,
1149+ std:: ptr:: null ( ) // Assuming you don't want to specify a clipping rectangle
1150+ ) ;
1151+ custom_font. pop ( ) ;
1152+ }
1153+
1154+
1155+
11291156 }
11301157
11311158 if IS_AIMBOT . load ( SeqCst ) && IS_DRAW_FOV . load ( SeqCst ) {
0 commit comments