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

Function AddMultipleLinesToHUDMessages

Descent3/hudmessage.cpp:468–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466// Returns true if line added
467static bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color = -1);
468bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) {
469 char ourstr[HUD_MESSAGE_LENGTH * 2];
470 char *p;
471 // char word[HUD_MESSAGE_LENGTH*2];
472 char nextword[HUD_MESSAGE_LENGTH * 2];
473 static char thisline[HUD_MESSAGE_LENGTH * 2] = "";
474 thisline[0] = '\0';
475 strcpy(ourstr, temp_message);
476 p = strtok(ourstr, " ");
477 bool added = 0;
478 while (p) {
479 strcat(thisline, p);
480 strcat(thisline, " ");
481 // strcpy(word,p);
482
483 p = strtok(NULL, " ");
484 if (p) {
485 strcpy(nextword, p);
486 if ((grtext_GetTextLineWidth(thisline) + grtext_GetTextLineWidth(nextword)) > (Game_window_w * .7)) {
487 if (thisline[strlen(thisline) - 1] == ' ')
488 thisline[strlen(thisline) - 1] = '\0';
489 added |= AddLineToHUDMessages(thisline, color);
490
491 // Scan for color information in the string we just added
492 char *c = NULL, *c2;
493 c2 = strchr(thisline, '\1');
494 while (c2) {
495 c = c2;
496 c2 = strchr(c2 + 4, '\1');
497 }
498 if (c) { // found one
499 for (int i = 0; i < 4; i++)
500 thisline[i] = c[i];
501 thisline[4] = 0;
502 } else
503 thisline[0] = '\0';
504 }
505 p = nextword;
506 }
507 }
508 if (thisline[strlen(thisline) - 1] == ' ')
509 thisline[strlen(thisline) - 1] = '\0';
510 if (thisline[0])
511 added |= AddLineToHUDMessages(thisline, color);
512
513 return added;
514}
515
516// adds a colored hud message to the list
517// Returns true if message added, or false if message not (because the previous message was the same)

Callers 4

AddColoredHUDMessageFunction · 0.85
AddFilteredHUDMessageFunction · 0.85
AddHUDMessageFunction · 0.85

Calls 2

grtext_GetTextLineWidthFunction · 0.85
AddLineToHUDMessagesFunction · 0.85

Tested by

no test coverage detected