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

Function RenderScrollingHUDMessages

Descent3/hudmessage.cpp:1076–1192  ·  view source on GitHub ↗

Renders all the messages we have in the message list. If HUD_MESSAGE_TIME has elapsed, then punt the oldest message and move the others up one

Source from the content-addressed store, hash-verified

1074// Renders all the messages we have in the message list. If HUD_MESSAGE_TIME has
1075// elapsed, then punt the oldest message and move the others up one
1076void RenderScrollingHUDMessages() {
1077 if (Hud_messages_paused)
1078 return;
1079
1080 int shade;
1081 int text_height;
1082 int16_t l, t, r, b;
1083 int i;
1084
1085 // Check for wraps
1086 if (Gametime < Hud_timer)
1087 Hud_timer = Gametime;
1088
1089 grtext_SetFont(HUD_FONT);
1090 text_height = grfont_GetHeight(HUD_FONT);
1091
1092 text_height += (3 * Hud_aspect_y); // add this for a spacer
1093
1094 if (Doing_input_message > HUD_MESSAGE_NONE)
1095 RenderHUDInputMessage();
1096
1097 if (Num_hud_messages == 0)
1098 return;
1099
1100 l = (Small_hud_flag) ? (Max_window_w / 2) : (Game_window_w / 2);
1101 r = l;
1102 t = 0;
1103 b = 0;
1104 for (i = 0; i < Num_hud_messages; i++) {
1105 int x;
1106
1107 if (HUD_message_type[i] == HUD_MESSAGE_BLINKING) {
1108 float blink_time = Gametime;
1109 int iblink = blink_time;
1110 float frac_blink = blink_time - iblink;
1111
1112 float answer = frac_blink / .5;
1113
1114 iblink = answer;
1115
1116 if (iblink == 1 || iblink == 3)
1117 continue;
1118 }
1119
1120 if (i == 0 && Hud_scroll_offset != 0) {
1121 int scolor = text_height + Hud_scroll_offset;
1122 shade = (255 * scolor) / text_height;
1123 } else
1124 shade = 255;
1125
1126 char *message = HUD_messages[i];
1127 int text_width = grtext_GetTextLineWidth(message);
1128 int vp_width = Game_window_w;
1129 int y = (i * text_height) + Hud_scroll_offset;
1130
1131 if (HUD_message_type[i] == HUD_MESSAGE_BLINKING) {
1132 ddgr_color text_color;
1133 text_color = (GR_RGB(shade, 0, 0));

Callers 1

RenderHUDMessagesFunction · 0.85

Calls 10

grtext_SetFontFunction · 0.85
grfont_GetHeightFunction · 0.85
RenderHUDInputMessageFunction · 0.85
grtext_GetTextLineWidthFunction · 0.85
grtext_SetColorFunction · 0.85
grtext_SetAlphaFunction · 0.85
grtext_SetFlagsFunction · 0.85
grtext_PutsFunction · 0.85
GR_RGBFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected