opd_s R_TextWidth_t = { 0x734570, TOC };
int(*R_TextWidth)(const char *text, int maxChars, Font_s *font) = (int(*)(const char*, int, Font_s*))&R_TextWidth_t;
struct Font_s
{
int fontName;
float pixelHeight;
int glyphCount;
int material;
int glowMaterial;
int glyphs;
};
float textWidth(float x, float y, int font, float scale, char* text) {
ScreenPlacement* scr = (ScreenPlacement*)0xD69D04;
scr->realViewableMaxX = (int32_t)x;
scr->realViewableMaxY = (int32_t)y;
Font_s* font_p = UI_GetFontHandle(scr, font, scale);
return (float)R_TextWidth(text, 15, font_p);
}
float textWidth(UI::TextHud text_hud) {
ScreenPlacement* scr = (ScreenPlacement*)0xD69D04;
scr->realViewableMaxX = (int32_t)text_hud.hud.x;
scr->realViewableMaxY = (int32_t)text_hud.hud.y;
Font_s* font_p = UI_GetFontHandle(scr, text_hud.font, text_hud.scale);
return (float)R_TextWidth(text_hud.text, 15, font_p);
}
void centerText(UI::TextHud** options, float center_point) {
for (int i = 0; i < number_of_options; ++i) {
options[i]->hud.x = (center_point - (UI::textWidth(*options[i]) / 3.5f));
}
}
UI::TextHud options[20]; // 20 options
centerText(&options, 600.0f) // pass in your array of options by reference
opd_s R_TextWidth_t = { 0x734570, TOC };
int(*R_TextWidth)(const char *text, int maxChars, Font_s *font) = (int(*)(const char*, int, Font_s*))&R_TextWidth_t;
struct Font_s
{
int fontName;
float pixelHeight;
int glyphCount;
int material;
int glowMaterial;
int glyphs;
};
float textWidth(float x, float y, int font, float scale, char* text) {
ScreenPlacement* scr = (ScreenPlacement*)0xD69D04;
scr->realViewableMaxX = (int32_t)x;
scr->realViewableMaxY = (int32_t)y;
Font_s* font_p = UI_GetFontHandle(scr, font, scale);
return (float)R_TextWidth(text, 15, font_p);
}
float textWidth(UI::TextHud text_hud) {
ScreenPlacement* scr = (ScreenPlacement*)0xD69D04;
scr->realViewableMaxX = (int32_t)text_hud.hud.x;
scr->realViewableMaxY = (int32_t)text_hud.hud.y;
Font_s* font_p = UI_GetFontHandle(scr, text_hud.font, text_hud.scale);
return (float)R_TextWidth(text_hud.text, 15, font_p);
}
void centerText(UI::TextHud** options, float center_point) {
for (int i = 0; i < number_of_options; ++i) {
options[i]->hud.x = (center_point - (UI::textWidth(*options[i]) / 3.5f));
}
}
UI::TextHud options[20]; // 20 options
centerText(&options, 600.0f) // pass in your array of options by reference
Copyright © 2024, NextGenUpdate.
All Rights Reserved.