| 210 | } |
| 211 | |
| 212 | void CGameObject::GenerateObjectHandlesTexture(wstr_t text) |
| 213 | { |
| 214 | #ifndef NEW_RENDERER_ENABLED |
| 215 | if (m_TextureObjectHandles.Texture != 0) |
| 216 | { |
| 217 | glDeleteTextures(1, &m_TextureObjectHandles.Texture); |
| 218 | m_TextureObjectHandles.Texture = 0; |
| 219 | } |
| 220 | #else |
| 221 | if (m_TextureObjectHandles.Texture != RENDER_TEXTUREHANDLE_INVALID) |
| 222 | { |
| 223 | Render_DestroyTexture(m_TextureObjectHandles.Texture); |
| 224 | m_TextureObjectHandles.Texture = RENDER_TEXTUREHANDLE_INVALID; |
| 225 | } |
| 226 | #endif |
| 227 | |
| 228 | int width = g_ObjectHandlesWidth - 20; |
| 229 | uint8_t font = 1; |
| 230 | CTextSprite textTexture; |
| 231 | uint16_t color = 0xFFFF; |
| 232 | uint8_t cell = 30; |
| 233 | TEXT_ALIGN_TYPE tat = TS_CENTER; |
| 234 | uint16_t flags = 0; |
| 235 | |
| 236 | if (g_FontManager.GetWidthW(font, text) > width) |
| 237 | { |
| 238 | text = g_FontManager.GetTextByWidthW(font, text, width - 6, true); |
| 239 | } |
| 240 | |
| 241 | auto textData = |
| 242 | g_FontManager.GeneratePixelsW(font, textTexture, text, color, cell, width, tat, flags); |
| 243 | if (textData.empty()) |
| 244 | { |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | static const int size = g_ObjectHandlesWidth * g_ObjectHandlesHeight; |
| 249 | uint16_t pixels[size] = { 0 }; |
| 250 | |
| 251 | memcpy(&pixels[0], &g_ObjectHandlesBackgroundPixels[0], size * 2); |
| 252 | |
| 253 | color = 0; |
| 254 | if (NPC) |
| 255 | { |
| 256 | if (IsPlayer()) |
| 257 | { |
| 258 | color = 0x0386; |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | color = g_ConfigManager.GetColorByNotoriety(GameCharacterPtr()->Notoriety); |
| 263 | } |
| 264 | |
| 265 | if (color != 0u) |
| 266 | { |
| 267 | for (int x = 0; x < g_ObjectHandlesWidth; x++) |
| 268 | { |
| 269 | for (int y = 0; y < g_ObjectHandlesHeight; y++) |
no test coverage detected