static int libd_drawString(lua_State *L) { fixed_t x = luaL_checkinteger(L, 1); fixed_t y = luaL_checkinteger(L, 2); const char *str = luaL_checkstring(L, 3); INT32 flags = luaL_optinteger(L, 4, V_ALLOWLOWERCASE); enum align align = luaL_checkoption(L, 5, "left", align_opt); flags &= ~V_PARAMMASK; // Don't let crashes happen. if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); switch(align) { case align_left: V_DrawString(x, y, flags, str); break; case align_center: V_DrawCenteredString(x, y, flags, str); break; case align_right: V_DrawRightAlignedString(x, y, flags, str); break; case align_fixed: V_DrawStringAtFixed(x, y, flags, str); break; } return 0; }
static int libd_drawString(lua_State *L) { fixed_t x = luaL_checkinteger(L, 1); fixed_t y = luaL_checkinteger(L, 2); const char *str = luaL_checkstring(L, 3); INT32 flags = luaL_optinteger(L, 4, V_ALLOWLOWERCASE); enum align align = luaL_checkoption(L, 5, "left", align_opt); flags &= ~V_PARAMMASK; // Don't let crashes happen. HUDONLY switch(align) { // hu_font case align_left: V_DrawString(x, y, flags, str); break; case align_center: V_DrawCenteredString(x, y, flags, str); break; case align_right: V_DrawRightAlignedString(x, y, flags, str); break; case align_fixed: V_DrawStringAtFixed(x, y, flags, str); break; // hu_font, 0.5x scale case align_small: V_DrawSmallString(x, y, flags, str); break; case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; // tny_font case align_thin: V_DrawThinString(x, y, flags, str); break; case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; } return 0; }
static void D_Display(void) { static boolean menuactivestate = false; static gamestate_t oldgamestate = -1; boolean redrawsbar = false; static boolean wipe = false; INT32 wipedefindex = 0; if (dedicated) return; if (nodrawers) return; // for comparative timing/profiling // check for change of screen size (video mode) if (setmodeneeded && !wipe) SCR_SetMode(); // change video mode if (vid.recalc) SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize(); oldgamestate = -1; // force background redraw redrawsbar = true; } // save the current screen if about to wipe if (gamestate != wipegamestate) { wipe = true; F_WipeStartScreen(); } else wipe = false; // draw buffered stuff to screen // Used only by linux GGI version I_UpdateNoBlit(); if (wipe) { // set for all later wipedefindex = gamestate; // wipe_xxx_toblack if (gamestate == GS_INTERMISSION) { if (intertype == int_spec) // Special Stage wipedefindex = wipe_specinter_toblack; else if (intertype != int_coop) // Multiplayer wipedefindex = wipe_multinter_toblack; } if (rendermode != render_none) { // Fade to black first if (gamestate != GS_LEVEL // fades to black on its own timing, always && wipedefs[wipedefindex] != UINT8_MAX) { V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); #ifdef HWRENDER if(rendermode != render_soft) HWR_PrepFadeToBlack(); #endif F_WipeEndScreen(); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); } F_WipeStartScreen(); } } // do buffered drawing switch (gamestate) { case GS_LEVEL: if (!gametic) break; HU_Erase(); if (automapactive) AM_Drawer(); if (wipe || menuactivestate || (rendermode != render_soft && rendermode != render_none) || vid.recalc) redrawsbar = true; break; case GS_INTERMISSION: Y_IntermissionDrawer(); HU_Erase(); HU_Drawer(); break; case GS_TIMEATTACK: break; case GS_INTRO: F_IntroDrawer(); if (wipegamestate == (gamestate_t)-1) wipe = true; break; case GS_CUTSCENE: F_CutsceneDrawer(); HU_Erase(); HU_Drawer(); break; case GS_GAMEEND: F_GameEndDrawer(); break; case GS_EVALUATION: F_GameEvaluationDrawer(); HU_Drawer(); break; case GS_CONTINUING: F_ContinueDrawer(); break; case GS_CREDITS: F_CreditDrawer(); HU_Erase(); HU_Drawer(); break; case GS_TITLESCREEN: F_TitleScreenDrawer(); break; case GS_WAITINGPLAYERS: // The clientconnect drawer is independent... case GS_DEDICATEDSERVER: case GS_NULL: break; } // clean up border stuff // see if the border needs to be initially drawn if (gamestate == GS_LEVEL) { #if 0 if (oldgamestate != GS_LEVEL) R_FillBackScreen(); // draw the pattern into the back screen #endif // draw the view directly if (!automapactive && !dedicated && cv_renderview.value) { if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { topleft = screens[0] + viewwindowy*vid.width + viewwindowx; objectsdrawn = 0; #ifdef HWRENDER if (rendermode != render_soft) HWR_RenderPlayerView(0, &players[displayplayer]); else #endif if (rendermode != render_none) R_RenderPlayerView(&players[displayplayer]); } // render the second screen if (splitscreen && players[secondarydisplayplayer].mo) { #ifdef HWRENDER if (rendermode != render_soft) HWR_RenderPlayerView(1, &players[secondarydisplayplayer]); else #endif if (rendermode != render_none) { viewwindowy = vid.height / 2; M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0])); topleft = screens[0] + viewwindowy*vid.width + viewwindowx; R_RenderPlayerView(&players[secondarydisplayplayer]); viewwindowy = 0; M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); } } // Image postprocessing effect if (postimgtype) V_DoPostProcessor(0, postimgtype, postimgparam); if (postimgtype2) V_DoPostProcessor(1, postimgtype2, postimgparam2); } if (lastdraw) { if (rendermode == render_soft) VID_BlitLinearScreen(screens[0], screens[1], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); lastdraw = false; } ST_Drawer(redrawsbar); HU_Drawer(); } // change gamma if needed if (gamestate != oldgamestate && gamestate != GS_LEVEL) V_SetPalette(0); menuactivestate = menuactive; oldgamestate = wipegamestate = gamestate; // draw pause pic if (paused && cv_showhud.value && (!menuactive || netgame)) { INT32 py; patch_t *patch; if (automapactive) py = 4; else py = viewwindowy + 4; patch = W_CachePatchName("M_PAUSE", PU_CACHE); V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, 0, patch); } // vid size change is now finished if it was on... vid.recalc = 0; // FIXME: draw either console or menu, not the two if (gamestate != GS_TIMEATTACK) CON_Drawer(); M_Drawer(); // menu is drawn even on top of everything NetUpdate(); // send out any new accumulation // It's safe to end the game now. if (G_GetExitGameFlag()) { Command_ExitGame_f(); G_ClearExitGameFlag(); } // // normal update // if (!wipe) { if (cv_netstat.value) { char s[50]; Net_GetNetStat(); s[sizeof s - 1] = '\0'; snprintf(s, sizeof s - 1, "get %d b/s", getbps); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-40, V_YELLOWMAP, s); snprintf(s, sizeof s - 1, "send %d b/s", sendbps); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-30, V_YELLOWMAP, s); snprintf(s, sizeof s - 1, "GameMiss %.2f%%", gamelostpercent); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-20, V_YELLOWMAP, s); snprintf(s, sizeof s - 1, "SysMiss %.2f%%", lostpercent); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s); } I_FinishUpdate(); // page flip or blit buffer return; } // // wipe update // wipedefindex += WIPEFINALSHIFT; if (rendermode != render_none) { F_WipeEndScreen(); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); } }