void UIChat_UpdateGeometry(uiwidget_t* obj) { const char* text = UIChat_Text(obj); assert(obj->type == GUI_CHAT); Rect_SetWidthHeight(obj->geometry, 0, 0); if(!UIChat_IsActive(obj)) return; FR_SetFont(obj->font); Rect_SetWidthHeight(obj->geometry, cfg.msgScale * (FR_TextWidth(text) + FR_CharWidth('_')), cfg.msgScale * (MAX_OF(FR_TextHeight(text), FR_CharHeight('_')))); }
//========================================================================== // DD_Progress // Draws a progress bar. Flags consists of one or more PBARF_* flags. //========================================================================== void Con_Progress(int count, int flags) { int x, y, w, h, bor = 2, bar = 10; int maxWidth = 500; int mainBor = 5; int fonthgt; if(!progress_active || isDedicated || !progress_enabled) return; if(flags & PBARF_SET) progress = count; else progress += count; // Make sure it's in range. if(progress < 0) progress = 0; if(progress > progress_max) progress = progress_max; // Update the startup window progress bar. SW_SetBarPos(progress); // If GL is not available, we cannot proceed any further. if(!GL_IsInited()) return; if(flags & PBARF_DONTSHOW && progress < progress_max && progress_shown + 5 >= progress) return; // Don't show yet. progress_shown = progress; if(!(flags & PBARF_NOBACKGROUND)) { // This'll redraw the startup screen to this page (necessary // if page flipping is used by the display adapter). Con_DrawStartupScreen(false); // If we're in the User Interface, this'll redraw it. UI_Drawer(); } fonthgt = FR_TextHeight("A"); // Go into screen projection mode. gl.MatrixMode(DGL_PROJECTION); gl.PushMatrix(); gl.LoadIdentity(); // 1-to-1 mapping for the whole window. gl.Ortho(0, 0, screenWidth, screenHeight, -1, 1); // Calculate the size and dimensions of the progress window. w = screenWidth - 30; if(w < 50) w = 50; // An unusual occurance... if(w > maxWidth) w = maxWidth; // Restrict width to the case of 640x480. x = (screenWidth - w) / 2; // Center on screen. h = 2 * bor + fonthgt + 15 + bar; y = screenHeight - 15 - h; /*x = 15; w = screenWidth - 2*x; h = 2*bor + fonthgt + 15 + bar; y = screenHeight - 15 - h; */ // Draw the (opaque black) shadow. UI_GradientEx(x, y, w, h, mainBor, UI_COL(UIC_SHADOW), 0, 1, 1); // Background. UI_GradientEx(x, y, w, h, mainBor, UI_COL(UIC_BG_MEDIUM), UI_COL(UIC_BG_LIGHT), 1, 1); UI_DrawRect(x, y, w, h, mainBor, UI_COL(UIC_BRD_HI), 1); x += bor; y += bor; w -= 2 * bor; h -= 2 * bor; // Title. x += 5; y += 5; w -= 10; gl.Color4f(0, 0, 0, .5f); FR_TextOut(progress_title, x + 3, y + 3); gl.Color3f(1, 1, 1); FR_TextOut(progress_title, x + 1, y + 1); y += fonthgt + 5; // Bar. UI_GradientEx(x, y, w, bar, 4, UI_COL(UIC_SHADOW), 0, .7f, .3f); UI_GradientEx(x + 1, y + 1, 8 + (w - 8) * progress / progress_max - 2, bar - 2, 4, UI_COL(UIC_BG_LIGHT), UI_COL(UIC_BRD_LOW), progress / (float) progress_max, -1); UI_DrawRect(x + 1, y + 1, 8 + (w - 8) * progress / progress_max - 2, bar - 2, 4, UI_COL(UIC_TEXT), 1); // Show what was drawn. if(!(flags & PBARF_NOBLIT)) gl.Show(); // Restore old projection matrix. gl.MatrixMode(DGL_PROJECTION); gl.PopMatrix(); }
void FR_TextSize(Size2Raw* size, const char* text) { if(!size) return; size->width = FR_TextWidth(text); size->height = FR_TextHeight(text); }