// // 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; 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) WI_DrawPatch(x, y, colon.lump); } while(t / div); } else { // "sucks" WI_DrawPatch(x - SHORT(sucks.width), y, sucks.lump); } }
void WI_drawStats(void) { // line height int lh; lh = (3 * SHORT(num[0].height)) / 2; WI_slamBackground(); // draw animated background WI_drawAnimatedBack(); WI_drawLF(); WI_DrawPatch(SP_STATSX, SP_STATSY, kills.lump); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); WI_DrawPatch(SP_STATSX, SP_STATSY + lh, items.lump); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY + lh, cnt_items[0]); WI_DrawPatch(SP_STATSX, SP_STATSY + 2 * lh, sp_secret.lump); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY + 2 * lh, cnt_secret[0]); WI_DrawPatch(SP_TIMEX, SP_TIMEY, time.lump); WI_drawTime(SCREENWIDTH / 2 - SP_TIMEX, SP_TIMEY, cnt_time); if(wbs->epsd < 3) { WI_DrawPatch(SCREENWIDTH / 2 + SP_TIMEX, SP_TIMEY, par.lump); WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); } }
// Draws "Entering <LevelName>" void WI_drawEL(void) { int y = WI_TITLEY; // draw "Entering" WI_DrawPatch((SCREENWIDTH - SHORT(entering.width)) / 2, y, entering.lump); // draw level y += (5 * SHORT(lnames[wbs->next].height)) / 4; WI_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next].width)) / 2, y, lnames[wbs->next].lump); }
// Draws "<Levelname> Finished!" void WI_drawLF(void) { int y = WI_TITLEY; // draw <LevelName> WI_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last].width)) / 2, y, lnames[wbs->last].lump); // draw "Finished!" y += (5 * SHORT(lnames[wbs->last].height)) / 4; WI_DrawPatch((SCREENWIDTH - SHORT(finished.width)) / 2, y, finished.lump); }
// // A fairly efficient way to draw a number // based on differences from the old number. // Note: worth the trouble? // void STlib_drawNum(st_number_t * n, boolean refresh) { int numdigits = n->width; int num = *n->num; int w = SHORT(n->p[0].width); int x = n->x; int neg; n->oldnum = *n->num; neg = num < 0; if(neg) { if(numdigits == 2 && num < -9) num = -9; else if(numdigits == 3 && num < -99) num = -99; num = -num; } // clear the area x = n->x - numdigits * w; // if non-number, do not draw it if(num == 1994) return; x = n->x; // in the special case of 0, you draw 0 if(!num) WI_DrawPatch(x - w, n->y, n->p[0].lump); // draw the new number while(num && numdigits--) { x -= w; WI_DrawPatch(x, n->y, n->p[num % 10].lump); num /= 10; } // draw a minus sign if necessary if(neg) WI_DrawPatch(x - 8, n->y, sttminus_i); }
void STlib_updateMultIcon(st_multicon_t * mi, boolean refresh) { /*int w; int h; int x; int y; */ if(*mi->on && (mi->oldinum != *mi->inum || refresh) && (*mi->inum != -1)) { /*if (mi->oldinum != -1) { x = mi->x - SHORT(mi->p[mi->oldinum].patch->leftoffset); y = mi->y - SHORT(mi->p[mi->oldinum].patch->topoffset); w = SHORT(mi->p[mi->oldinum].patch->width); h = SHORT(mi->p[mi->oldinum].patch->height); if (y - ST_Y < 0) I_Error("updateMultIcon: y - ST_Y < 0"); // V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); } */ WI_DrawPatch(mi->x, mi->y, mi->p[*mi->inum].lump); mi->oldinum = *mi->inum; } }
void STlib_updatePercent(st_percent_t * per, int refresh) { if(refresh && *per->n.on) WI_DrawPatch(per->n.x, per->n.y, per->p->lump); STlib_updateNum(&per->n, refresh); }
void WI_drawOnLnode(int n, dpatch_t * c) { int i; int left; int top; int right; int bottom; boolean fits = false; i = 0; do { left = lnodes[wbs->epsd][n].x - SHORT(c[i].leftoffset); top = lnodes[wbs->epsd][n].y - SHORT(c[i].topoffset); right = left + SHORT(c[i].width); bottom = top + SHORT(c[i].height); if(left >= 0 && right < SCREENWIDTH && top >= 0 && bottom < SCREENHEIGHT) fits = true; else i++; } while(!fits && i != 2); if(fits && i < 2) { WI_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, c[i].lump); } else { // DEBUG Con_Message("Could not place patch on level %d", n + 1); } }
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; WI_DrawPatch(x, y, num[n % 10].lump); n /= 10; } // draw a minus sign if necessary if(neg) WI_DrawPatch(x -= 8, y, wiminus.lump); return x; }
void STlib_updateBinIcon(st_binicon_t * bi, boolean refresh) { if(*bi->on && (bi->oldval != *bi->val || refresh)) { WI_DrawPatch(bi->x, bi->y, bi->p->lump); bi->oldval = *bi->val; } }
void WI_drawPercent(int x, int y, int p) { if(p < 0) return; WI_DrawPatch(x, y, percent.lump); WI_drawNum(x, y, p, -1); }
void WI_drawAnimatedBack(void) { int i; wianim_t *a; if(gamemode == commercial) return; if(wbs->epsd > 2) return; for(i = 0; i < NUMANIMS[wbs->epsd]; i++) { a = &anims[wbs->epsd][i]; if(a->ctr >= 0) WI_DrawPatch(a->loc.x, a->loc.y, a->p[a->ctr].lump); } }
void LabelWidget::draw() const { fontid_t fontId = mnRendState->textFonts[font()]; Vector4f const &textColor = mnRendState->textColors[color()]; // float t = (isFocused()? 1 : 0); // // Flash if focused. // if(isFocused() && cfg.common.menuTextFlashSpeed > 0) // { // float const speed = cfg.common.menuTextFlashSpeed / 2.f; // t = (1 + sin(page().timer() / (float)TICSPERSEC * speed * DD_PI)) / 2; // } // Vector4f const color = de::lerp(textColor, Vector4f(Vector3f(cfg.common.menuTextFlashColor), textColor.w), t); const Vector4f color = selectionFlashColor(textColor); const float fadeout = scrollingFadeout(); if (fadeout < .001f) return; DGL_Color4f(1, 1, 1, color.w * fadeout); FR_SetFont(fontId); FR_SetColorAndAlpha(color.x, color.y, color.z, color.w * fadeout); if (d->patch) { String replacement; if(!(d->flags & MNTEXT_NO_ALTTEXT)) { replacement = Hu_ChoosePatchReplacement(patchreplacemode_t(cfg.common.menuPatchReplaceMode), *d->patch, d->text); } DGL_Enable(DGL_TEXTURE_2D); WI_DrawPatch(*d->patch, replacement, geometry().topLeft, ALIGN_TOPLEFT, 0, Hu_MenuMergeEffectWithDrawTextFlags(0)); DGL_Disable(DGL_TEXTURE_2D); return; } DGL_Enable(DGL_TEXTURE_2D); FR_DrawTextXY3(d->text.toUtf8().constData(), geometry().topLeft.x, geometry().topLeft.y, ALIGN_TOPLEFT, Hu_MenuMergeEffectWithDrawTextFlags(0)); DGL_Disable(DGL_TEXTURE_2D); }
void D_Display(void) { static boolean viewactivestate = false; static boolean menuactivestate = false; static boolean inhelpscreensstate = false; static boolean fullscreen = false; static gamestate_t oldgamestate = -1; int y; boolean redrawsbar; player_t *player = &players[displayplayer]; boolean iscam = (player->plr->flags & DDPF_CAMERA) != 0; // $democam if(nodrawers) return; // for comparative timing / profiling redrawsbar = false; // $democam: can be set on every frame if(setblocks > 10 || iscam) { // Full screen. R_ViewWindow(0, 0, 320, 200); } else { int w = setblocks * 32; int h = setblocks * (200 - ST_HEIGHT * cfg.sbarscale / 20) / 10; R_ViewWindow(160 - (w >> 1), (200 - ST_HEIGHT * cfg.sbarscale / 20 - h) >> 1, w, h); } // Do buffered drawing. switch (gamestate) { case GS_LEVEL: if(IS_CLIENT && (!Get(DD_GAME_READY) || !Get(DD_GOTFRAME))) break; if(leveltime < 2) { // Don't render too early; the first couple of frames // might be a bit unstable -- this should be considered // a bug, but since there's an easy fix... break; } if(!automapactive || cfg.automapAlpha < 1) { // Draw the player view. if(IS_CLIENT) { // Server updates mobj flags in NetSv_Ticker. R_SetAllDoomsdayFlags(); } // Don't draw self. Set(DD_VIEWANGLE_OFFSET, ANGLE_MAX * -lookOffset); GL_SetFilter(players[displayplayer].plr->filter); // $democam // How about fullbright? Set(DD_FULLBRIGHT, (player->powers[pw_infrared] > 4 * 32) || (player->powers[pw_infrared] & 8) || player->powers[pw_invulnerability] > 30); // Render the view with possible custom filters. R_RenderPlayerView(players[displayplayer].plr); R_DrawSpecialFilter(); // Crosshair. if(!iscam) X_Drawer(); // $democam } if(automapactive) AM_Drawer(); // Level information is shown for a few seconds in the // beginning of a level. R_DrawLevelTitle(); if((viewheight != 200)) redrawsbar = true; if(inhelpscreensstate && !inhelpscreens) redrawsbar = true; // just put away the help screen if(!iscam) ST_Drawer(viewheight == 200, redrawsbar); // $democam fullscreen = viewheight == 200; HU_Drawer(); // Need to update the borders? if(oldgamestate != GS_LEVEL || ((Get(DD_VIEWWINDOW_WIDTH) != 320 || menuactive || cfg.sbarscale < 20))) { // Update the borders. GL_Update(DDUF_BORDER); } break; case GS_INTERMISSION: WI_Drawer(); break; case GS_WAITING: gl.Clear(DGL_COLOR_BUFFER_BIT); M_WriteText2(5, 188, "WAITING... PRESS ESC FOR MENU", hu_font_a, 1, 0, 0); default: break; } GL_Update(DDUF_FULLSCREEN); menuactivestate = menuactive; viewactivestate = viewactive; inhelpscreensstate = inhelpscreens; oldgamestate = wipegamestate = gamestate; // draw pause pic (but not if InFine active) if(paused && !fi_active) { if(automapactive) y = 4; else y = viewwindowy + 4; WI_DrawPatch(126, y, W_GetNumForName("M_PAUSE")); } // InFine is drawn whenever active. FI_Drawer(); }
void WI_drawNetgameStats(void) { int i; int x; int y; int pwidth = SHORT(percent.width); WI_slamBackground(); // draw animated background WI_drawAnimatedBack(); WI_drawLF(); // draw stat titles (top line) WI_DrawPatch(NG_STATSX + NG_SPACINGX - SHORT(kills.width), NG_STATSY, kills.lump); WI_DrawPatch(NG_STATSX + 2 * NG_SPACINGX - SHORT(items.width), NG_STATSY, items.lump); WI_DrawPatch(NG_STATSX + 3 * NG_SPACINGX - SHORT(secret.width), NG_STATSY, secret.lump); if(dofrags) WI_DrawPatch(NG_STATSX + 4 * NG_SPACINGX - SHORT(frags.width), NG_STATSY, frags.lump); // draw stats y = NG_STATSY + SHORT(kills.height); for(i = 0; i < NUM_TEAMS; i++) { if(!teaminfo[i].members) continue; x = NG_STATSX; WI_DrawPatch(x - SHORT(p[i].width), y, p[i].lump); // If more than 1 member, show the member count. if(teaminfo[i].members > 1) { char tmp[40]; sprintf(tmp, "%i", teaminfo[i].members); M_WriteText2(x - p[i].width + 1, y + p[i].height - 8, tmp, hu_font_a, 1, 1, 1); } if(i == myteam) WI_DrawPatch(x - SHORT(p[i].width), y, star.lump); x += NG_SPACINGX; WI_drawPercent(x - pwidth, y + 10, cnt_kills[i]); x += NG_SPACINGX; WI_drawPercent(x - pwidth, y + 10, cnt_items[i]); x += NG_SPACINGX; WI_drawPercent(x - pwidth, y + 10, cnt_secret[i]); x += NG_SPACINGX; if(dofrags) WI_drawNum(x, y + 10, cnt_frags[i], -1); y += WI_SPACINGY; } }
void WI_drawDeathmatchStats(void) { int i; int j; int x; int y; int w; int lh; // line height lh = WI_SPACINGY; WI_slamBackground(); // draw animated background WI_drawAnimatedBack(); WI_drawLF(); // draw stat titles (top line) WI_DrawPatch(DM_TOTALSX - SHORT(total.width) / 2, DM_MATRIXY - WI_SPACINGY + 10, total.lump); WI_DrawPatch(DM_KILLERSX, DM_KILLERSY, killers.lump); WI_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, victims.lump); // draw P? x = DM_MATRIXX + DM_SPACINGX; y = DM_MATRIXY; for(i = 0; i < NUM_TEAMS; i++) { if(teaminfo[i].members) { WI_DrawPatch(x - SHORT(p[i].width) / 2, DM_MATRIXY - WI_SPACINGY, p[i].lump); WI_DrawPatch(DM_MATRIXX - SHORT(p[i].width) / 2, y, p[i].lump); if(i == myteam) { WI_DrawPatch(x - SHORT(p[i].width) / 2, DM_MATRIXY - WI_SPACINGY, bstar.lump); WI_DrawPatch(DM_MATRIXX - SHORT(p[i].width) / 2, y, star.lump); } // If more than 1 member, show the member count. if(teaminfo[i].members > 1) { char tmp[20]; sprintf(tmp, "%i", teaminfo[i].members); M_WriteText2(x - p[i].width / 2 + 1, DM_MATRIXY - WI_SPACINGY + p[i].height - 8, tmp, hu_font_a, 1, 1, 1); M_WriteText2(DM_MATRIXX - p[i].width / 2 + 1, y + p[i].height - 8, tmp, hu_font_a, 1, 1, 1); } } else { WI_DrawPatch(x - SHORT(bp[i].width) / 2, DM_MATRIXY - WI_SPACINGY, bp[i].lump); WI_DrawPatch(DM_MATRIXX - SHORT(bp[i].width) / 2, y, bp[i].lump); } x += DM_SPACINGX; y += WI_SPACINGY; } // draw stats y = DM_MATRIXY + 10; w = SHORT(num[0].width); for(i = 0; i < NUM_TEAMS; i++) { x = DM_MATRIXX + DM_SPACINGX; if(teaminfo[i].members) { for(j = 0; j < NUM_TEAMS; j++) { if(teaminfo[j].members) WI_drawNum(x + w, y, dm_frags[i][j], 2); x += DM_SPACINGX; } WI_drawNum(DM_TOTALSX + w, y, dm_totals[i], 2); } y += WI_SPACINGY; } }