// // HU_CenterMessage // // haleyjd 04/27/04: rewritten to use qstring // void HU_CenterMessage(const char *s) { static qstring qstr(128); int st_height = GameModeInfo->StatusBar->height; qstr.clear(); // haleyjd 02/28/06: colored center message if(centermsg_color) { qstr += centermsg_color; centermsg_color = NULL; } qstr += s; centermessage_widget.setMessage(qstr.constPtr(), (SCREENWIDTH - V_FontStringWidth(hud_font, s)) / 2, (SCREENHEIGHT - V_FontStringHeight(hud_font, s) - ((scaledwindow.height == SCREENHEIGHT) ? 0 : st_height - 8)) / 2, leveltime + (message_timer * 35) / 1000); // print message to console also C_Printf("%s\n", s); }
// // WriteCenteredText // // Local routine to draw centered messages. Candidate for // absorption into future generalized font code. Rewritten // 02/22/04 to use qstring module. // static void WriteCenteredText(char *message) { static qstring qstr; char *rover; const char *buffer; int x, y; int w, h; qstr.clearOrCreate(128); // rather than reallocate memory every time we draw it, // use one buffer and increase the size as neccesary // haleyjd 02/22/04: qstring handles this for us now w = V_FontStringWidth(menu_font_normal, popup_message); h = V_FontStringHeight(menu_font_normal, popup_message); x = (SCREENWIDTH - w) / 2; y = (SCREENHEIGHT - h) / 2; qstr.clear(); rover = message; if(popup_widget.prev) // up over another widget? V_DrawBox(x - 8, y - 8, w + 16, h + 16); while(*rover) { if(*rover == '\n') { buffer = qstr.constPtr(); x = (SCREENWIDTH - V_FontStringWidth(menu_font_normal, buffer)) / 2; V_FontWriteText(menu_font_normal, buffer, x, y, &subscreen43); qstr.clear(); // clear buffer y += menu_font_normal->absh; // next line } else // add next char qstr += *rover; ++rover; } // dont forget the last line.. prob. not \n terminated buffer = qstr.constPtr(); x = (SCREENWIDTH - V_FontStringWidth(menu_font_normal, buffer)) / 2; V_FontWriteText(menu_font_normal, buffer, x, y, &subscreen43); }
// // G_BindDrawer // // Draw the prompt box // void G_BindDrawer(void) { const char *msg = "\n -= input new key =- \n"; int x, y, width, height; // draw the menu in the background MN_DrawMenu(current_menu); width = V_FontStringWidth(menu_font_normal, msg); height = V_FontStringHeight(menu_font_normal, msg); x = (SCREENWIDTH - width) / 2; y = (SCREENHEIGHT - height) / 2; // draw box V_DrawBox(x - 4, y - 4, width + 8, height + 8); // write text in box V_FontWriteText(menu_font_normal, msg, x, y, &subscreen43); }
// // HUDTextWidget::drawer // // Default drawing function for a text widget. // void HUDTextWidget::drawer() { // Do not ever draw automap-only widgets if not in automap mode. // This fixes a long-standing bug automatically. if(flags & TW_AUTOMAP_ONLY && !automapactive) return; // 10/08/05: boxed message support if(flags & TW_BOXED) { int width, height; width = V_FontStringWidth (font, message); height = V_FontStringHeight(font, message); V_DrawBox(x - 4, y - 4, width + 8, height + 8); } if(message && (!cleartic || leveltime < cleartic)) { edefstructvar(vtextdraw_t, vdt); vdt.font = font; vdt.s = message; vdt.x = x; vdt.y = y; vdt.screen = &subscreen43; if(color) { vdt.flags = VTXT_FIXEDCOLOR; vdt.fixedColNum = color - 1; } else vdt.flags = VTXT_NORMAL; V_FontWriteTextEx(vdt); } }
// // HUDMessageWidget::drawer // // Drawer for the player message widget. // void HUDMessageWidget::drawer() { if(!showMessages) return; edefstructvar(vtextdraw_t, vtd); vtd.font = hud_font; vtd.screen = &subscreen43; vtd.flags = VTXT_FIXEDCOLOR; vtd.fixedColNum = mess_colour; // go down a bit if chat active vtd.y = chat_active ? hud_font->absh : 0; for(int i = 0; i < current_messages; i++) { char *msg = messages[i]; // haleyjd 12/26/02: center messages in proper gamemodes // haleyjd 08/26/12: center also if in widescreen modes if(GameModeInfo->flags & GIF_CENTERHUDMSG || vbscreen.getVirtualAspectRatio() > 4 * FRACUNIT / 3) { vtd.x = (SCREENWIDTH - V_FontStringWidth(hud_font, msg)) / 2; vtd.flags |= VTXT_ABSCENTER; } else vtd.x = 0; vtd.s = msg; V_FontWriteTextEx(vtd); vtd.y += V_FontStringHeight(hud_font, msg); } }