MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / StartPersistentHUDMessage

Function StartPersistentHUDMessage

Descent3/hudmessage.cpp:1326–1383  ·  view source on GitHub ↗

Start playing a persistent HUD message

Source from the content-addressed store, hash-verified

1324
1325// Start playing a persistent HUD message
1326void StartPersistentHUDMessage(ddgr_color color, int x, int y, float time, int flags, int sound_index, char *message) {
1327 if (Demo_flags == DF_RECORDING) {
1328 DemoWritePersistantHUDMessage(color, x, y, time, flags, sound_index, message);
1329 }
1330
1331 // set x and y if special formatting.
1332 grtext_SetFont(HUD_FONT);
1333 if (x == HUD_MSG_PERSISTENT_CENTER) {
1334 x = Game_window_x + (Game_window_w - grtext_GetLineWidth(message)) / 2;
1335 }
1336 if (y == HUD_MSG_PERSISTENT_CENTER) {
1337 y = Game_window_y + (Game_window_h - grfont_GetHeight(HUD_FONT)) / 2;
1338 }
1339
1340 // add custom text item
1341 tHUDItem huditem;
1342
1343 memset(&huditem, 0, sizeof(huditem));
1344
1345 huditem.alpha = HUD_ALPHA;
1346 huditem.color = color;
1347 huditem.type = HUD_ITEM_CUSTOMTEXT;
1348 huditem.x = x * DEFAULT_HUD_WIDTH / Max_window_w;
1349 huditem.y = y * DEFAULT_HUD_HEIGHT / Max_window_h;
1350 huditem.data.text = message;
1351 huditem.stat = STAT_MESSAGES;
1352 huditem.flags = HUD_FLAG_PERSISTANT | HUD_FLAG_SMALL; // when hud is shrunk, this will draw outside of normal view
1353
1354 AddHUDItem(&huditem);
1355
1356 Hud_persistent_msg_id = huditem.id;
1357 Hud_persistent_msg_timer = time;
1358 Hud_persistent_msg_flags = flags;
1359
1360 // Set up for FreeSpace-style effect
1361 if (flags & HPF_FREESPACE_DRAW) {
1362
1363 // Create additional hud item for leading character
1364 static char single_char[2] = { 'a', '\0' }; ; // single-character string
1365 huditem.alpha = 255;
1366 huditem.data.text = single_char;
1367 huditem.saturation_count = 2;
1368 AddHUDItem(&huditem);
1369 Hud_persistent_msg_id2 = huditem.id;
1370
1371 tHUDItem *item = GetHUDItem(Hud_persistent_msg_id);
1372 tHUDItem *item2 = GetHUDItem(Hud_persistent_msg_id2);
1373
1374 item2->data.text[0] = item->data.text[0];
1375 item->data.text[0] = 0;
1376
1377 Hud_persistent_msg_current_len = 0;
1378 Hud_persistent_msg_char_timer = CHAR_DELAY;
1379
1380 if (sound_index != SOUND_NONE_INDEX)
1381 Hud_persistent_msg_sound_handle = Sound_system.Play2dSound(sound_index);
1382 }
1383}

Callers 2

AddPersistentHUDMessageFunction · 0.85

Calls 6

grtext_SetFontFunction · 0.85
grfont_GetHeightFunction · 0.85
AddHUDItemFunction · 0.85
GetHUDItemFunction · 0.85
Play2dSoundMethod · 0.80

Tested by

no test coverage detected