diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02697a671a..bd2a29013f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -450,7 +450,6 @@ set( PLAT_WIN32_SOURCES common/platform/win32/i_system.cpp common/platform/win32/i_specialpaths.cpp common/platform/win32/st_start.cpp - common/platform/win32/st_start_util.cpp common/platform/win32/gl_sysfb.cpp common/platform/win32/base_sysfb.cpp common/platform/win32/win32basevideo.cpp diff --git a/src/common/engine/i_net.cpp b/src/common/engine/i_net.cpp index 7ea8c0bf93..0283140223 100644 --- a/src/common/engine/i_net.cpp +++ b/src/common/engine/i_net.cpp @@ -292,7 +292,7 @@ void PacketGet (void) if (err == WSAECONNRESET) { // The remote node aborted unexpectedly, so pretend it sent an exit packet - if (StartScreen != NULL) + if (StartWindow != NULL) { I_NetMessage ("The connection from %s was dropped.\n", GetPlayerName(node).GetChars()); @@ -1049,19 +1049,19 @@ void I_NetMessage(const char* text, ...) // todo: later these must be dispatched by the main menu, not the start screen. void I_NetProgress(int val) { - StartScreen->NetProgress(val); + StartWindow->NetProgress(val); } void I_NetInit(const char* msg, int num) { - StartScreen->NetInit(msg, num); + StartWindow->NetInit(msg, num); } bool I_NetLoop(bool (*timer_callback)(void*), void* userdata) { - return StartScreen->NetLoop(timer_callback, userdata); + return StartWindow->NetLoop(timer_callback, userdata); } void I_NetDone() { - StartScreen->NetDone(); + StartWindow->NetDone(); } #ifdef __WIN32__ const char *neterror (void) diff --git a/src/common/engine/palettecontainer.h b/src/common/engine/palettecontainer.h index 10883a3744..615ae92c46 100644 --- a/src/common/engine/palettecontainer.h +++ b/src/common/engine/palettecontainer.h @@ -135,16 +135,19 @@ public: FRemapTable* GetTranslation(int slot, int index) { + if (TranslationTables.Size() <= (unsigned)slot) return nullptr; return TranslationTables[slot].GetVal(index); } void ClearTranslationSlot(int slot) { + if (TranslationTables.Size() <= (unsigned)slot) return; TranslationTables[slot].Clear(); } unsigned NumTranslations(int slot) const { + if (TranslationTables.Size() <= (unsigned)slot) return 0; return TranslationTables[slot].Size(); } diff --git a/src/common/engine/st_start.h b/src/common/engine/st_start.h index 0df16500a4..cf97915257 100644 --- a/src/common/engine/st_start.h +++ b/src/common/engine/st_start.h @@ -81,7 +81,7 @@ protected: -extern FStartupScreen *StartScreen; +extern FStartupScreen *StartWindow; extern void ST_Endoom(); @@ -95,10 +95,10 @@ extern void ST_Endoom(); inline void DeleteStartupScreen() { - if (StartScreen != nullptr) + if (StartWindow != nullptr) { - delete StartScreen; - StartScreen = nullptr; + delete StartWindow; + StartWindow = nullptr; } } diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index 51da146d31..bcc6aee51f 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/common/platform/posix/sdl/i_system.cpp @@ -79,7 +79,7 @@ double PerfToSec, PerfToMillisec; CVAR(Bool, con_printansi, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE); CVAR(Bool, con_4bitansi, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE); -extern FStartupScreen *StartScreen; +extern FStartupScreen *StartWindow; void I_SetIWADInfo() { @@ -278,10 +278,10 @@ void I_PrintStr(const char *cp) } } - if (StartScreen) CleanProgressBar(); + if (StartWindow) CleanProgressBar(); fputs(printData.GetChars(),stdout); if (terminal) fputs("\033[0m",stdout); - if (StartScreen) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos); + if (StartWindow) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos); } int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad) diff --git a/src/common/platform/posix/sdl/st_start.cpp b/src/common/platform/posix/sdl/st_start.cpp index 7304ee485b..a86213d9bc 100644 --- a/src/common/platform/posix/sdl/st_start.cpp +++ b/src/common/platform/posix/sdl/st_start.cpp @@ -78,7 +78,7 @@ extern void CleanProgressBar(); // PUBLIC DATA DEFINITIONS ------------------------------------------------- -FStartupScreen *StartScreen; +FStartupScreen *StartWindow; CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { diff --git a/src/common/platform/win32/i_mainwindow.cpp b/src/common/platform/win32/i_mainwindow.cpp index 9579485a67..d3e27b21c3 100644 --- a/src/common/platform/win32/i_mainwindow.cpp +++ b/src/common/platform/win32/i_mainwindow.cpp @@ -150,7 +150,7 @@ void MainWindow::ShowErrorPane(const char* text) return; } - if (StartScreen != NULL) // Ensure that the network pane is hidden. + if (StartWindow != NULL) // Ensure that the network pane is hidden. { I_NetDone(); } diff --git a/src/common/platform/win32/st_start.cpp b/src/common/platform/win32/st_start.cpp index 9eea5ef209..b2788fcf71 100644 --- a/src/common/platform/win32/st_start.cpp +++ b/src/common/platform/win32/st_start.cpp @@ -65,7 +65,7 @@ extern HINSTANCE g_hInst; // PUBLIC DATA DEFINITIONS ------------------------------------------------- -FStartupScreen *StartScreen; +FStartupScreen *StartWindow; // PRIVATE DATA DEFINITIONS ------------------------------------------------ diff --git a/src/common/startscreen/startscreen.cpp b/src/common/startscreen/startscreen.cpp index 20637719d8..7c3b6c5f53 100644 --- a/src/common/startscreen/startscreen.cpp +++ b/src/common/startscreen/startscreen.cpp @@ -368,7 +368,7 @@ FStartScreen* GetGameStartScreen(int max_progress) Printf("Error creating start screen: %s\n", err.what()); // fall through to the generic startup screen } - return CreateGenericStartScreen(max_progress); + //return CreateGenericStartScreen(max_progress); } return nullptr; } diff --git a/src/common/startscreen/startscreen.h b/src/common/startscreen/startscreen.h index 2700767cbc..2b81a9cfb1 100644 --- a/src/common/startscreen/startscreen.h +++ b/src/common/startscreen/startscreen.h @@ -100,6 +100,5 @@ protected: }; FStartScreen* GetGameStartScreen(int max_progress); -extern FStartScreen* StartScreen; extern void ST_Endoom(); diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index c7b5fad3d8..af57204fc4 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -1186,19 +1186,19 @@ FGameTexture *CreateShaderTexture(bool, bool); void InitBuildTiles(); FImageSource* CreateEmptyTexture(); -void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)) +void FTextureManager::Init() { - progressFunc = progressFunc_; DeleteAll(); - //if (BuildTileFiles.Size() == 0) CountBuildTiles (); + // Add all the static content auto nulltex = MakeGameTexture(new FImageTexture(CreateEmptyTexture()), nullptr, ETextureType::Null); AddGameTexture(nulltex); // This is for binding to unused texture units, because accessing an unbound texture unit is undefined. It's a one pixel empty texture. auto emptytex = MakeGameTexture(new FImageTexture(CreateEmptyTexture()), nullptr, ETextureType::Override); emptytex->SetSize(1, 1); - AddGameTexture(emptytex); + AddGameTexture(emptytex); + // some special textures used in the game. AddGameTexture(CreateShaderTexture(false, false)); AddGameTexture(CreateShaderTexture(false, true)); @@ -1211,6 +1211,12 @@ void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildI mt = MakeGameTexture(new AnimTexture(), "AnimTextureFrame2", ETextureType::Override); mt->SetUpscaleFlag(false, true); AddGameTexture(mt); +} + +void FTextureManager::AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)) +{ + progressFunc = progressFunc_; + //if (BuildTileFiles.Size() == 0) CountBuildTiles (); int wadcnt = fileSystem.GetNumWads(); diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 54d4aa8b8c..03212ddf54 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -123,7 +123,8 @@ public: void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build); void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build); - void Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo &)); + void Init(); + void AddTextures(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&)); void DeleteAll(); void ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free); diff --git a/src/d_main.cpp b/src/d_main.cpp index 9091e7889b..2784f4c29d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -119,6 +119,7 @@ #include "hwrenderer/scene/hw_drawinfo.h" #include "doomfont.h" #include "screenjob.h" +#include "startscreen.h" #ifdef __unix__ #include "i_system.h" // for SHARE_DIR @@ -329,6 +330,7 @@ FString lastIWAD; int restart = 0; bool AppActive = true; bool playedtitlemusic; +FStartScreen* StartScreen; cycle_t FrameCycles; @@ -2130,6 +2132,7 @@ static void CheckCmdLine() timelimit = 20.f; } + if (!StartScreen) return; // // Build status bar line! // @@ -3064,6 +3067,11 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr D_GrabCVarDefaults(); //parse DEFCVARS + int max_progress = TexMan.GuesstimateNumTextures(); + int per_shader_progress = 0;//screen->GetShaderCount()? (max_progress / 10 / screen->GetShaderCount()) : 0; + bool nostartscreen = batchrun || restart || Args->CheckParm("-join") || Args->CheckParm("-host") || Args->CheckParm("-norun"); + StartScreen = nostartscreen? nullptr : GetGameStartScreen(per_shader_progress > 0 ? max_progress * 10 / 9 : max_progress + 3); + GameConfig->DoKeySetup(gameinfo.ConfigName); // Now that wads are loaded, define mod-specific cvars. @@ -3096,22 +3104,24 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr Printf("%s", ci.GetChars()); } - // [RH] Initialize palette management - InitPalette (); + InitPalette(); + TexMan.Init(); if (!batchrun) Printf ("V_Init: allocate screen.\n"); if (!restart) { V_InitScreenSize(); - } - - if (!restart) - { // This allocates a dummy framebuffer as a stand-in until V_Init2 is called. V_InitScreen (); + + if (StartScreen != nullptr) + { + V_Init2(); + StartScreen->Render(); + } + } - - if (restart) + else { // Update screen palette when restarting screen->UpdatePalette(); @@ -3133,31 +3143,11 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr if (!batchrun) Printf ("ST_Init: Init startup screen.\n"); if (!restart) { - if (GameStartupInfo.Type == FStartupInfo::DefaultStartup) - { - switch (gameinfo.gametype) - { - case GAME_Hexen: - GameStartupInfo.Type = FStartupInfo::HexenStartup; - break; - - case GAME_Heretic: - GameStartupInfo.Type = FStartupInfo::HereticStartup; - break; - - case GAME_Strife: - GameStartupInfo.Type = FStartupInfo::StrifeStartup; - break; - - default: - break; - } - } - StartScreen = FStartupScreen::CreateInstance (TexMan.GuesstimateNumTextures() + 5); + StartWindow = FStartupScreen::CreateInstance (TexMan.GuesstimateNumTextures() + 5); } else { - StartScreen = new FStartupScreen(0); + StartWindow = new FStartupScreen(0); } CheckCmdLine(); @@ -3183,14 +3173,19 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr if (!batchrun) Printf ("Texman.Init: Init texture manager.\n"); UpdateUpscaleMask(); SpriteFrames.Clear(); - TexMan.Init([]() { StartScreen->Progress(); }, CheckForHacks); + TexMan.AddTextures([]() + { + StartWindow->Progress(); + if (StartScreen) StartScreen->Progress(1); + }, CheckForHacks); PatchTextures(); TexAnim.Init(); C_InitConback(TexMan.CheckForTexture(gameinfo.BorderFlat, ETextureType::Flat), true, 0.25); FixWideStatusBar(); - StartScreen->Progress(); + StartWindow->Progress(); + if (StartScreen) StartScreen->Progress(1); V_InitFonts(); InitDoomFonts(); V_LoadTranslations(); @@ -3216,12 +3211,15 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr I_FatalError ("No player classes defined"); } - StartScreen->Progress (); + StartWindow->Progress(); + if (StartScreen) StartScreen->Progress (1); ParseGLDefs(); if (!batchrun) Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars()); - StartScreen->LoadingStatus ("Loading graphics", 0x3f); + if (StartScreen) StartScreen->LoadingStatus ("Loading graphics", 0x3f); + if (StartScreen) StartScreen->Progress(1); + StartWindow->Progress(); R_Init (); if (!batchrun) Printf ("DecalLibrary: Load decals.\n"); @@ -3282,7 +3280,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr primaryLevel->BotInfo.wanted_botnum = primaryLevel->BotInfo.getspawned.Size(); if (!batchrun) Printf ("P_Init: Init Playloop state.\n"); - StartScreen->LoadingStatus ("Init game engine", 0x3f); + if (StartScreen) StartScreen->LoadingStatus ("Init game engine", 0x3f); AM_StaticInit(); P_Init (); @@ -3311,7 +3309,7 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr if (!restart) { if (!batchrun) Printf ("D_CheckNetGame: Checking network game status.\n"); - StartScreen->LoadingStatus ("Checking network game status.", 0x3f); + if (StartScreen) StartScreen->LoadingStatus ("Checking network game status.", 0x3f); if (!D_CheckNetGame ()) { return 0; @@ -3346,8 +3344,6 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr autostart = true; } - delete StartScreen; - StartScreen = NULL; S_Sound (CHAN_BODY, 0, "misc/startupdone", 1, ATTN_NONE); if (Args->CheckParm("-norun") || batchrun) @@ -3355,11 +3351,18 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray& allwads, TArr return 1337; // special exit } - V_Init2(); + if (StartScreen == nullptr) V_Init2(); while(!screen->CompileNextShader()) { // here we can do some visual updates later } + if (StartScreen) + { + StartScreen->Progress(max_progress); // advance progress bar to the end. + StartScreen->Render(true); + delete StartScreen; + StartScreen = NULL; + } twod->fullscreenautoaspect = gameinfo.fullscreenautoaspect; // Initialize the size of the 2D drawer so that an attempt to access it outside the draw code won't crash. twod->Begin(screen->GetWidth(), screen->GetHeight()); diff --git a/src/rendering/r_utility.cpp b/src/rendering/r_utility.cpp index 89c3613299..30bde0b212 100644 --- a/src/rendering/r_utility.cpp +++ b/src/rendering/r_utility.cpp @@ -393,8 +393,7 @@ FRenderer* SWRenderer; void R_Init () { - StartScreen->Progress(); - R_InitTranslationTables (); + //R_InitTranslationTables (); R_SetViewSize (screenblocks); if (SWRenderer == NULL)