77#include " generated_detours.h"
88#include " ../../scaled_ui_base/shared.h"
99#include " debug/hook_callsite.h"
10- #include " debug/callsite_classifier.h"
1110#include < string.h>
1211
1312static bool s_dmRankingScorePhase = true ;
@@ -64,8 +63,6 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
6463 g_centerPrintAnchorY = static_cast <float >(screenY);
6564 s_cpLastY = static_cast <float >(screenY);
6665 }
67- } else if (g_currentFontCaller == FontCaller::MissionStatus) {
68- g_missionStatusAnchorY = static_cast <float >(screenY);
6966 }
7067
7168 SOFBUDDY_ASSERT (font != nullptr );
@@ -75,16 +72,25 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
7572 realFont = REALFONT_UNKNOWN ;
7673 }
7774
78- if (g_currentFontCaller == FontCaller::SCRDrawPause) {
79- float s = fontScale;
80- if (s <= 0 .0f ) s = 1 .0f ;
75+ if (g_currentFontCaller == FontCaller::MissionStatus) {
76+ const float s = snapped_text_scale_active (fontScale);
77+ if (s != 1 .0f ) {
78+ const float vid_w = (viddef_width && *viddef_width > 0 )
79+ ? static_cast <float >(*viddef_width)
80+ : (current_vid_w > 0 ? static_cast <float >(current_vid_w) : 640 .0f );
81+ const float textW = vid_w - 2 .0f * static_cast <float >(screenX);
82+ screenX -= static_cast <int >(textW * (s - 1 .0f ) * 0 .5f );
83+ }
84+ } else if (g_currentFontCaller == FontCaller::SCRDrawPause) {
85+ const float s = snapped_text_scale_active (fontScale);
8186 if (s != 1 .0f ) {
8287 const float textW = (float )(current_vid_w - 2 * screenX);
8388 const float textH = (float )(current_vid_h - 2 * screenY);
8489 screenX -= (int )(textW * (s - 1 .0f ) * 0 .5f );
8590 screenY -= (int )(textH * (s - 1 .0f ) * 0 .5f );
8691 }
8792 } else if (g_activeRenderType == uiRenderType::HudDmRanking) {
93+ const float hs = snapped_text_scale_active (hudScale);
8894 int fontWidth = 12 ;
8995 int offsetEdge = 40 ;
9096
@@ -94,16 +100,16 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
94100 static int * s_dm_ranking_state = (int *)rvaToAbsExe ((void *)0x001E7E94 );
95101 if (s_dm_ranking_state && *s_dm_ranking_state == 7 ) {
96102 int half_text_len = screenX - (current_vid_w - (offsetEdge * x_scale));
97- screenX = current_vid_w - offsetEdge * x_scale - 16 * hudScale + half_text_len*hudScale ;
98- screenY = 20 * screen_y_scale + 64 * hudScale + 6 * screen_y_scale;
103+ screenX = current_vid_w - offsetEdge * x_scale - 16 * hs + half_text_len * hs ;
104+ screenY = 20 * screen_y_scale + 64 * hs + 6 * screen_y_scale;
99105 } else {
100- screenX = current_vid_w - 16 * hudScale - offsetEdge * x_scale - hudScale* fontWidth * strlen (text) / 2 ;
101- screenY = screenY + (hudScale - 1 ) * (32 + 3 );
106+ screenX = current_vid_w - 16 * hs - offsetEdge * x_scale - hs * fontWidth * strlen (text) / 2 ;
107+ screenY = screenY + (hs - 1 ) * (32 + 3 );
102108
103109 if (s_dmRankingScorePhase) {
104110 s_dmRankingScorePhase = false ;
105111 } else {
106- screenY = screenY + (hudScale - 1 ) * (realFontSizes[realFont] + 3 );
112+ screenY = screenY + (hs - 1 ) * (realFontSizes[realFont] + 3 );
107113 s_dmRankingScorePhase = true ;
108114 }
109115 }
@@ -112,13 +118,15 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
112118 if (s_dmRankingScorePhase) {
113119 s_dmRankingScorePhase = false ;
114120 } else {
115- screenY = screenY + (hudScale - 1 ) * (realFontSizes[realFont] + 3 );
121+ screenY = screenY + (hs - 1 ) * (realFontSizes[realFont] + 3 );
116122 s_dmRankingScorePhase = true ;
117123 }
118- screenX = current_vid_w - offsetEdge * x_scale - 16 * hudScale - hudScale* fontWidth * strlen (text) / 2 ;
124+ screenX = current_vid_w - offsetEdge * x_scale - 16 * hs - hs * fontWidth * strlen (text) / 2 ;
119125 }
120126
121127 } else if (g_activeRenderType == uiRenderType::HudInventory) {
128+ // Match cropped pics (raw hudScale); glyph snap drifts text off the panels.
129+ const float hs = hudScale;
122130 if ( hudInventory_wasItem ) {
123131 if (text && ( (text[0 ] >= ' 0' && text[0 ] <= ' 8' ) || (text[0 ] ==' 9' && text[1 ] != ' m' ) ) ) {
124132 float set_x,set_y;
@@ -127,8 +135,8 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
127135 drawCroppedPicVertex (false ,false ,set_x,set_y);
128136 hudCroppedEnum = before;
129137
130- screenX = set_x + -52 .0f * hudScale ;
131- screenY = set_y + -29 .0f * hudScale ;
138+ screenX = set_x + -52 .0f * hs ;
139+ screenY = set_y + -29 .0f * hs ;
132140 } else {
133141 float set_x,set_y;
134142 enumCroppedDrawMode before = hudCroppedEnum;
@@ -138,7 +146,7 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
138146 drawCroppedPicVertex (true ,false ,set_x,set_y);
139147 hudCroppedEnum = before;
140148
141- screenX = set_x + -111 .0f * hudScale ;
149+ screenX = set_x + -111 .0f * hs ;
142150 screenY = set_y;
143151 }
144152 } else {
@@ -150,8 +158,8 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
150158 drawCroppedPicVertex (false ,false ,set_x,set_y);
151159 hudCroppedEnum = before;
152160
153- screenX = set_x + -97 .0f * hudScale ;
154- screenY = set_y + -29 .0f * hudScale ;
161+ screenX = set_x + -97 .0f * hs ;
162+ screenY = set_y + -29 .0f * hs ;
155163 }
156164 else {
157165 float set_x,set_y;
@@ -162,15 +170,13 @@ void hkR_DrawFont(int screenX, int screenY, char * text, int colorPalette, char
162170 drawCroppedPicVertex (true ,false ,set_x,set_y);
163171 hudCroppedEnum = before;
164172
165- screenX = set_x + -79 .0f * hudScale ;
173+ screenX = set_x + -79 .0f * hs ;
166174 screenY = set_y;
167175 }
168176 }
169177 }
170178 original (screenX, screenY, text, colorPalette, font, rememberLastColor);
171179
172- // MissionStatus and SCR_DrawCenterPrint are set by their parent hooks and span
173- // multiple R_DrawFont calls (one per line); keep the caller so lines 2+ scale too.
174180 if (g_currentFontCaller != FontCaller::MissionStatus &&
175181 g_currentFontCaller != FontCaller::SCR_DrawCenterPrint)
176182 g_currentFontCaller = FontCaller::Unknown;
0 commit comments