diff --git a/src/console.c b/src/console.c index c9df73ed4..e8e1fa541 100644 --- a/src/console.c +++ b/src/console.c @@ -57,6 +57,9 @@ I_mutex con_mutex; static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing + + con_loadprogress_t con_startup_loadprogress = 0; // Progress for startup load bar + static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc; // set true when screen size has changed @@ -1517,16 +1520,17 @@ void CONS_Printf(const char *fmt, ...) if (startup && (!setrenderneeded)) { #ifdef _WINDOWS - patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_CACHE); + patch_t *con_backpic = W_CachePatchName("STARTUP", PU_CACHE); // Jimita: CON_DrawBackpic just called V_DrawScaledPatch - V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, con_backpic, NULL); + V_DrawScaledPatch(0, 0, 0, con_backpic); W_UnlockCachedPatch(con_backpic); - I_LoadingScreen(txt); // Win32/OS2 only + I_LoadingScreen(txt); // Win32/OS2 only #else // here we display the console text - CON_Drawer(); + //CON_Drawer(); + CON_DrawLoadBar(); I_FinishUpdate(); // page flip or blit buffer #endif } @@ -1902,3 +1906,43 @@ void CON_Drawer(void) Unlock_state(); } + +// +// Error handling for the loading bar, to ensure it doesn't skip any steps. +// +void CON_SetLoadingProgress(con_loadprogress_t newStep) +{ + const con_loadprogress_t expectedStep = con_startup_loadprogress + 1; + + if (newStep != expectedStep) + { + I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", newStep, expectedStep); + return; + } + + con_startup_loadprogress = newStep; +} + +// +// Draws a simple white fill at the bottom of startup for load progress +// +void CON_DrawLoadBar(void) +{ + const INT16 barheight = 2; + INT16 barwidth = 0; + + Lock_state(); + + if (!con_started || !graphics_started) + { + Unlock_state(); + return; + } + + CON_DrawBackpic(); + + barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / LOADED_ALLDONE; + V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0); + + Unlock_state(); +} diff --git a/src/console.h b/src/console.h index 898290c39..75f7c7bbd 100644 --- a/src/console.h +++ b/src/console.h @@ -27,6 +27,25 @@ extern boolean con_recalc; extern boolean con_startup; +typedef enum +{ + LOADED_ZINIT = 1, + LOADED_ISTARTUPTIMER, + LOADED_IWAD, + LOADED_PWAD, + LOADED_ISTARTUPGRAPHICS, + LOADED_HULOADGRAPHICS, + LOADED_RENDERER, + LOADED_MINIT, + LOADED_RINIT, + LOADED_SINITSFXCHANNELS, + LOADED_STINIT, + LOADED_DCHECKNETGAME, + LOADED_ALLDONE = LOADED_DCHECKNETGAME, +} con_loadprogress_t; + +extern con_loadprogress_t con_startup_loadprogress; + // top clip value for view render: do not draw part of view hidden by console extern INT32 con_clipviewtop; @@ -62,3 +81,7 @@ void CON_ToggleOff(void); boolean CON_Ready(void); void CON_LogMessage(const char *msg); + +// Startup loading bar +void CON_SetLoadingProgress(con_loadprogress_t newStep); +void CON_DrawLoadBar(void); diff --git a/src/d_main.c b/src/d_main.c index 97523966d..d52ded552 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -733,7 +733,6 @@ tic_t rendergametic; void D_SRB2Loop(void) { tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS; - static lumpnum_t gstartuplumpnum; if (dedicated) server = true; @@ -770,14 +769,17 @@ void D_SRB2Loop(void) LMFAO this was showing garbage under OpenGL because I_FinishUpdate was called afterward */ + +#if 0 /* Smells like a hack... Don't fade Sonic's ass into the title screen. */ if (gamestate != GS_TITLESCREEN) { - gstartuplumpnum = W_CheckNumForName("STARTUP"); + static lumpnum_t gstartuplumpnum = W_CheckNumForName("STARTUP"); if (gstartuplumpnum == LUMPERROR) gstartuplumpnum = W_GetNumForName("MISSING"); V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(gstartuplumpnum, PU_PATCH)); } +#endif for (;;) { @@ -1256,7 +1258,6 @@ void D_SRB2Main(void) configfile[sizeof configfile - 1] = '\0'; } - // Create addons dir snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); I_mkdir(addonsdir, 0755); @@ -1280,6 +1281,7 @@ void D_SRB2Main(void) CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n"); Z_Init(); + CON_SetLoadingProgress(LOADED_ZINIT); // Do this up here so that WADs loaded through the command line can use ExecCfg COM_Init(); @@ -1363,6 +1365,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupTimer()...\n"); I_StartupTimer(); + CON_SetLoadingProgress(LOADED_ISTARTUPTIMER); // Make backups of some SOCcable tables. P_BackupTables(); @@ -1426,6 +1429,8 @@ void D_SRB2Main(void) } } + CON_SetLoadingProgress(LOADED_IWAD); + CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n"); W_InitMultipleFiles(startuppwads, true); D_CleanFile(startuppwads); @@ -1463,6 +1468,8 @@ void D_SRB2Main(void) } } + CON_SetLoadingProgress(LOADED_PWAD); + cht_Init(); //---------------------------------------------------- READY SCREEN @@ -1470,6 +1477,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupGraphics()...\n"); I_StartupGraphics(); + CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS); #ifdef HWRENDER // Lactozilla: Add every hardware mode CVAR and CCMD. @@ -1495,6 +1503,7 @@ void D_SRB2Main(void) CONS_Printf("HU_LoadGraphics()...\n"); HU_LoadGraphics(); + CON_SetLoadingProgress(LOADED_HULOADGRAPHICS); //--------------------------------------------------------- CONFIG.CFG M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()" @@ -1525,6 +1534,7 @@ void D_SRB2Main(void) // check the renderer's state D_CheckRendererState(); } + CON_SetLoadingProgress(LOADED_RENDERER); wipegamestate = gamestate; @@ -1554,9 +1564,11 @@ void D_SRB2Main(void) CONS_Printf("M_Init(): Init miscellaneous info.\n"); M_Init(); + CON_SetLoadingProgress(LOADED_MINIT); CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); + CON_SetLoadingProgress(LOADED_RINIT); // setting up sound if (dedicated) @@ -1584,6 +1596,7 @@ void D_SRB2Main(void) digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound } } + if (!( sound_disabled && digital_disabled )) { CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); @@ -1591,11 +1604,13 @@ void D_SRB2Main(void) I_InitMusic(); S_InitSfxChannels(cv_soundvolume.value); } + CON_SetLoadingProgress(LOADED_SINITSFXCHANNELS); S_InitMusicDefs(); CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); + CON_SetLoadingProgress(LOADED_STINIT); // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) @@ -1613,6 +1628,7 @@ void D_SRB2Main(void) CONS_Printf("D_CheckNetGame(): Checking network game status.\n"); if (D_CheckNetGame()) autostart = true; + CON_SetLoadingProgress(LOADED_DCHECKNETGAME); if (splitscreen && !M_CheckParm("-connect")) // Make sure multiplayer & autostart is set if you have splitscreen, even after D_CheckNetGame multiplayer = autostart = true; @@ -1827,6 +1843,12 @@ void D_SRB2Main(void) DRPC_Init(); } #endif + + if (con_startup_loadprogress != LOADED_ALLDONE) + { + I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", con_startup_loadprogress, LOADED_ALLDONE); + return; + } } const char *D_Home(void) diff --git a/src/f_finale.c b/src/f_finale.c index ed4024d0a..4355cf231 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -38,7 +38,6 @@ #include "p_setup.h" #include "st_stuff.h" // hud hiding #include "fastcmp.h" -#include "console.h" #include "lua_hud.h" @@ -1977,6 +1976,8 @@ void F_TitleScreenDrawer(void) V_DrawSmallScaledPatch(84, 36, transval<mo->color = player->skincolor; G_GhostAddColor((INT32) (player - players), GHC_NORMAL); } + + P_RestoreMusic(player); } }