// // Display level completion time and par, // or "sucks" message if overflow. // void WI_drawTime(int x, int y, int t) { int div; int n; if (t < 0) return; x += (num[0]->width - 11) * 4; if (t <= 61 * 59) { div = 1; do { n = (t / div) % 60; x = WI_drawNum(x, y, n, 2) - SHORT(colon->width); div *= 60; // draw if (div == 60 || t / div) V_DrawPatchWithShadow(x + 1, y + 1, FB, colon, true); } while (t / div); if (t < 60) WI_drawNum(x, y, 0, 2); } else // "sucks" V_DrawPatchWithShadow(x + 13 - SHORT(sucks->width), y + 1, FB, sucks, false); }
void WI_drawPercent(int x, int y, int p) { if (p < 0) return; V_DrawPatchWithShadow(x + 1, y + 1, FB, percent, false); WI_drawNum(x, y, p, -1); }
// Draws "Entering <LevelName>" void WI_drawEL(void) { int x = (ORIGINALWIDTH - SHORT(entering->width)) / 2; int y = WI_TITLEY; char name[9]; // draw "Entering" V_DrawPatchWithShadow(x + 1, y + 1, FB, entering, false); // draw level y += 14; if (gamemode == commercial) snprintf(name, 9, "CWILV%2.2d", wbs->next); else snprintf(name, 9, "WILV%d%d", wbs->epsd, wbs->next); if (W_CheckMultipleLumps(name) > 1 && !nerve) V_DrawPatchWithShadow((ORIGINALWIDTH - SHORT(lnames[wbs->next]->width)) / 2 + 1, y + 1, FB, lnames[wbs->next], false); else WI_drawWILV(y, nextmapname); }
// Draws "<Levelname> Finished!" void WI_drawLF(void) { int x = (ORIGINALWIDTH - SHORT(finished->width)) / 2; int y = WI_TITLEY; char name[9]; // draw <LevelName> if (gamemode == commercial) snprintf(name, 9, "CWILV%2.2d", wbs->last); else snprintf(name, 9, "WILV%d%d", wbs->epsd, wbs->last); if (W_CheckMultipleLumps(name) > 1 && !nerve) V_DrawPatchWithShadow((ORIGINALWIDTH - SHORT(lnames[wbs->last]->width)) / 2 + 1, y + 1, FB, lnames[wbs->last], false); else WI_drawWILV(y, mapname); // draw "Finished!" y += 14; V_DrawPatchWithShadow(x + 1, y + 1, FB, finished, false); }
// // Draws a number. // If digits > 0, then use that many digits minimum, // otherwise only use as many as necessary. // Returns new x position. // int WI_drawNum(int x, int y, int n, int digits) { int fontwidth = SHORT(num[0]->width); int neg; int temp; if (digits < 0) { if (!n) // make variable-length zeros 1 digit long digits = 1; else { // figure out # of digits in # digits = 0; temp = n; while (temp) { temp /= 10; digits++; } } } neg = n < 0; if (neg) n = -n; // if non-number, do not draw it if (n == 1994) return 0; // draw the new number while (digits--) { x -= fontwidth; x += 2 * (n % 10 == 1); V_DrawPatchWithShadow(x + 1, y + 1, FB, num[n % 10], true); x -= 2 * (n % 10 == 1); n /= 10; } // draw a minus sign if necessary if (neg) V_DrawPatch(x -= 8, y, FB, wiminus); return x; }
void WI_drawStats(void) { // line height int lh = (3 * SHORT(num[0]->height)) / 2; WI_slamBackground(); // draw animated background WI_drawAnimatedBack(); WI_drawLF(); V_DrawPatchWithShadow(SP_STATSX + 1, SP_STATSY + 1, FB, kills, false); WI_drawPercent(ORIGINALWIDTH - SP_STATSX - 14, SP_STATSY, cnt_kills[0]); V_DrawPatchWithShadow(SP_STATSX + 1, SP_STATSY + lh + 1, FB, items, false); WI_drawPercent(ORIGINALWIDTH - SP_STATSX - 14, SP_STATSY + lh, cnt_items[0]); if (totalsecret) { if (!WISCRT2) M_DrawString(SP_STATSX, SP_STATSY + 2 * lh - 3, "secrets"); else V_DrawPatchWithShadow(SP_STATSX + 1, SP_STATSY + 2 * lh + 1, FB, sp_secret, false); WI_drawPercent(ORIGINALWIDTH - SP_STATSX - 14, SP_STATSY + 2 * lh, cnt_secret[0]); } V_DrawPatchWithShadow(SP_TIMEX + 1, SP_TIMEY + 1, FB, timepatch, false); WI_drawTime(ORIGINALWIDTH / 2 - SP_TIMEX * 2, SP_TIMEY, cnt_time); if (canmodify) { V_DrawPatchWithShadow(ORIGINALWIDTH / 2 + SP_TIMEX * 2 + 5, SP_TIMEY + 1, FB, par, false); WI_drawTime(ORIGINALWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); } }
void F_CastPrint(char *text) { const char *ch; int c; int cx; int w; int width; // find width ch = text; width = 0; while (ch) { c = *ch++; if (!c) break; c = toupper(c) - HU_FONTSTART; if (c < 0 || c > HU_FONTSIZE) { width += 4; continue; } w = SHORT(hu_font[c]->width); width += w; } // draw it cx = (ORIGINALWIDTH - width) / 2; ch = text; while (ch) { c = *ch++; if (!c) break; c = toupper(c) - HU_FONTSTART; if (c < 0 || c > HU_FONTSIZE) { cx += 4; continue; } w = SHORT(hu_font[c]->width); V_DrawPatchWithShadow(cx + 1, 181, hu_font[c], false); cx += w; } }
void D_Display(void) { static boolean viewactivestate = false; static boolean menuactivestate = false; static boolean pausedstate = false; static gamestate_t oldgamestate = (gamestate_t)(-1); static int borderdrawcount; int nowtime; int tics; int wipestart; boolean done; // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize(); oldgamestate = (gamestate_t)(-1); // force background redraw borderdrawcount = 3; } // save the current screen if about to wipe if ((wipe = (gamestate != wipegamestate || forcewipe))) { wipe_StartScreen(); if (forcewipe) forcewipe = false; else menuactive = false; } if (gamestate != GS_LEVEL) { if (gamestate != oldgamestate) I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE)); switch (gamestate) { case GS_INTERMISSION: WI_Drawer(); break; case GS_FINALE: F_Drawer(); break; case GS_DEMOSCREEN: D_PageDrawer(); break; } } else if (gametic) { HU_Erase(); ST_Drawer(viewheight == SCREENHEIGHT, true); // draw the view directly R_RenderPlayerView(&players[displayplayer]); if (automapactive) AM_Drawer(); // see if the border needs to be initially drawn if (oldgamestate != GS_LEVEL) { viewactivestate = false; // view was not active R_FillBackScreen(); // draw the pattern into the back screen } // see if the border needs to be updated to the screen if (!automapactive) { if (scaledviewwidth != SCREENWIDTH) { if (menuactive || menuactivestate || !viewactivestate || paused || pausedstate || message_on) borderdrawcount = 3; if (borderdrawcount) { R_DrawViewBorder(); // erase old menu stuff borderdrawcount--; } } if (graphicdetail == LOW) V_LowGraphicDetail(0, viewheight2); } HU_Drawer(); } menuactivestate = menuactive; viewactivestate = viewactive; oldgamestate = wipegamestate = gamestate; // draw pause pic if ((pausedstate = paused)) { M_DarkBackground(); if (M_PAUSE) { patch_t *patch = W_CacheLumpName("M_PAUSE", PU_CACHE); if (widescreen) V_DrawPatchWithShadow((ORIGINALWIDTH - patch->width) / 2, viewwindowy / 2 + (viewheight / 2 - patch->height) / 2, 0, patch, false); else V_DrawPatchWithShadow((ORIGINALWIDTH - patch->width) / 2, (ORIGINALHEIGHT - patch->height) / 2, 0, patch, false); } else { if (widescreen) M_DrawCenteredString(viewwindowy / 2 + (viewheight / 2 - 16) / 2, "Paused"); else M_DrawCenteredString((ORIGINALHEIGHT - 16) / 2, "Paused"); } } // menus go directly to the screen M_Drawer(); // menu is drawn even on top of everything // normal update if (!wipe) { I_FinishUpdate(); // page flip or blit buffer return; } // wipe update wipe_EndScreen(); wipestart = I_GetTime() - 1; do { do { nowtime = I_GetTime(); tics = nowtime - wipestart; I_Sleep(1); } while (tics <= 0); wipestart = nowtime; done = wipe_ScreenWipe(tics); blurred = false; M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(); // page flip or blit buffer } while (!done); }
static void F_TextWrite(void) { // draw some of the text onto the screen byte *src; byte *dest; int x, y, w; int count = FixedDiv((finalecount - 10) * FRACUNIT, TextSpeed()) >> FRACBITS; const char *ch = finaletext; int cx = 12; int cy = 10; int i; char letter; char prev = ' '; // erase the entire screen to a tiled background src = (byte *)W_CacheLumpName((char *)finaleflat, PU_CACHE); dest = screens[0]; for (y = 0; y < SCREENHEIGHT; y += 2) for (x = 0; x < SCREENWIDTH / 32; x += 2) { for (i = 0; i < 64; i++) { int j = i * 2; byte dot = *(src + (((y / 2) & 63) << 6) + i); if (y * SCREENWIDTH + x + j < SCREENWIDTH * (SCREENHEIGHT - 1)) *(dest + j) = dot; j++; if (y * SCREENWIDTH + x + j < SCREENWIDTH * (SCREENHEIGHT - 1)) *(dest + j) = dot; j += SCREENWIDTH; if (y * SCREENWIDTH + x + j < SCREENWIDTH * (SCREENHEIGHT - 1)) *(dest + j) = dot; j--; if (y * SCREENWIDTH + x + j < SCREENWIDTH * (SCREENHEIGHT - 1)) *(dest + j) = dot; } dest += 128; } if (count < 0) count = 0; for (; count; count--) { char c = *ch++; if (!c) break; if (c == '\n') { cx = 12; cy += (prev == '\n' ? 8 : 11); prev = c; continue; } letter = c; c = toupper(c) - HU_FONTSTART; if (c < 0 || c >= HU_FONTSIZE) { cx += (prev == '.' || prev == '!' || prev == '?' || prev == '\"' ? 5 : 3); prev = letter; continue; } if (STCFN034) { w = SHORT(hu_font[c]->width); V_DrawPatchWithShadow(cx + 1, cy + 1, hu_font[c], false); } else { int k = 0; if (prev == ' ') { if (letter == '\"') c = 64; else if (letter == '\'') c = 65; } while (kern[k].char1) { if (prev == kern[k].char1 && c == kern[k].char2) { cx += kern[k].adjust; break; } k++; } w = strlen(smallcharset[c]) / 10 - 1; M_DrawSmallChar(cx + 1, cy + 1, c, true); } prev = letter; cx += w; } }