- set up the loadscreen code.

This isn't active, though, because load times are so short these days that all this results in is an irritating screen flash before the level starts.
It may be activated later when hires assets are in use.

Fixes #10 (or not...? ;) )
This commit is contained in:
Christoph Oelckers 2020-09-09 22:42:01 +02:00
parent 093d991bff
commit b52a2b0d9a
6 changed files with 50 additions and 60 deletions

View file

@ -280,12 +280,11 @@ void EndGameLoadSaveConstruct(void)
class DBloodLoadScreen : public DScreenJob
{
std::function<int(void)> callback;
const char* pzLoadingScreenText1;
MapRecord* rec;
public:
DBloodLoadScreen(const char* caption, MapRecord* maprec, std::function<int(void)> callback_) : DScreenJob(fadein | fadeout), callback(callback_), rec(maprec)
DBloodLoadScreen(const char* caption, MapRecord* maprec) : DScreenJob(), rec(maprec)
{
if (gGameOptions.nGameType == 0) pzLoadingScreenText1 = GStrings("TXTB_LLEVEL");
else pzLoadingScreenText1 = GStrings(FStringf("TXTB_NETGT%d", gGameOptions.nGameType));
@ -298,16 +297,15 @@ public:
DrawMenuCaption(pzLoadingScreenText1);
viewDrawText(1, rec->DisplayName(), 160, 50, -128, 0, 1, 1);
viewDrawText(3, GStrings("TXTB_PLSWAIT"), 160, 134, -128, 0, 1, 1);
// Initiate the level load once the page has been faded in completely.
if (callback && GetFadeState() == visible)
{
callback();
callback = nullptr;
}
if (clock > 5'000'000'000) return 0; // make sure the screen stays long enough to be seen.
return skiprequest ? -1 : 1;
return 0;
}
};
void loadscreen(MapRecord* rec, CompletionFunc func)
{
JobDesc job = { Create<DBloodLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
}
END_BLD_NS

View file

@ -1053,30 +1053,28 @@ void e4intro(const CompletionFunc& completion)
class DDukeLoadScreen : public DScreenJob
{
std::function<int(void)> callback;
MapRecord* rec;
public:
DDukeLoadScreen(MapRecord *maprec, std::function<int(void)> callback_) : DScreenJob(fadein|fadeout), callback(callback_), rec(maprec) {}
DDukeLoadScreen(MapRecord *maprec) : DScreenJob(0), rec(maprec) {}
int Frame(uint64_t clock, bool skiprequest)
{
twod->ClearScreen();
DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
BigText(160, 90, (rec->flags & MI_USERMAP)? GStrings("TXT_LOADUM") : GStrings("TXT_LOADING"));
BigText(160, 114, rec->DisplayName());
// Initiate the level load once the page has been faded in completely.
if (callback && GetFadeState() == visible)
{
callback();
callback = nullptr;
}
if (clock > 5'000'000'000) return 0; // make sure the screen stays long enough to be seen.
return skiprequest? -1 : 1;
return 0;
}
};
void loadscreen_d(MapRecord *rec, CompletionFunc func)
{
JobDesc job = { Create<DDukeLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
}
void PrintPaused_d()
{
BigText(160, 100, GStrings("Game Paused"));

View file

@ -611,11 +611,10 @@ void dobonus_r(int bonusonly, const CompletionFunc& completion)
class DRRLoadScreen : public DScreenJob
{
std::function<int(void)> callback;
MapRecord* rec;
public:
DRRLoadScreen(MapRecord* maprec, std::function<int(void)> callback_) : DScreenJob(fadein | fadeout), callback(callback_), rec(maprec) {}
DRRLoadScreen(MapRecord* maprec) : DScreenJob(0), rec(maprec) {}
int Frame(uint64_t clock, bool skiprequest)
{
@ -624,18 +623,16 @@ public:
int y = isRRRA()? 140 : 90;
BigText(160, y, (rec->flags & MI_USERMAP) ? GStrings("TXT_ENTRUM") : GStrings("TXT_ENTERIN"), 0);
BigText(160, y+24, rec->DisplayName(), 0);
// Initiate the level load once the page has been faded in completely.
if (callback && GetFadeState() == visible)
{
callback();
callback = nullptr;
}
if (clock > 5'000'000'000) return 0; // make sure the screen stays long enough to be seen.
return skiprequest? -1 : 1;
return 0;
}
};
void loadscreen_r(MapRecord* rec, CompletionFunc func)
{
JobDesc job = { Create<DRRLoadScreen>(rec) };
RunScreenJob(&job, 1, func);
}
void PrintPaused_r()
{
BigText(160, 100, GStrings("Game Paused"), 0);

View file

@ -221,7 +221,7 @@ void prelevel_d(int g);
void prelevel_r(int g);
void e4intro(const CompletionFunc& completion);
void exitlevel(MapRecord *next);
int enterlevel(MapRecord* mi, int gm);
void enterlevel(MapRecord* mi, int gm);
void donewgame(MapRecord* map, int sk);
void startnewgame(MapRecord* map, int skill);
void setlocalplayerinput(player_struct *pp);

View file

@ -158,12 +158,23 @@ void GameInterface::Render()
//
//
//---------------------------------------------------------------------------
void loadscreen_d(MapRecord* rec, CompletionFunc func);
void loadscreen_r(MapRecord* rec, CompletionFunc func);
void GameInterface::NextLevel(MapRecord* map, int skill)
{
if (skill != -1) ud.player_skill = skill + 1;
int res = enterlevel(map, 0);
if (res) gameaction = ga_startup;
#if 0
// Loading is so fast on modern system so that this only serves as an irritant, not an asset.
auto loadscreen = isRR() ? loadscreen_r : loadscreen_d;
loadscreen_d(map, [=](bool)
{
enterlevel(map, 0);
gameaction = ga_level;
});
#endif
enterlevel(map, 0);
}
//---------------------------------------------------------------------------

View file

@ -861,14 +861,12 @@ static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode)
int16_t lbang;
if (VOLUMEONE && (mi->flags & MI_USERMAP))
{
Printf(TEXTCOLOR_RED "Cannot load user maps with shareware version!\n");
return 1;
I_Error("Cannot load user maps with shareware version!\n");
}
if (engineLoadBoard(mi->fileName, VOLUMEONE, &p->pos, &lbang, &p->cursectnum) < 0)
{
Printf(TEXTCOLOR_RED "Map \"%s\" not found or invalid map version!\n", mi->fileName.GetChars());
return 1;
I_Error("Map \"%s\" not found or invalid map version!\n", mi->fileName.GetChars());
}
currentLevel = mi;
SECRET_SetMapName(mi->DisplayName(), mi->name);
@ -926,7 +924,7 @@ static void clearfrags(void)
//
//---------------------------------------------------------------------------
int enterlevel(MapRecord *mi, int gamemode)
void enterlevel(MapRecord *mi, int gamemode)
{
// flushpackets();
// waitforeverybody();
@ -947,12 +945,7 @@ int enterlevel(MapRecord *mi, int gamemode)
auto p = &ps[0];
/*
G_DoLoadScreen(msg, -1); // this should be done outside of this function later.
*/
int res = LoadTheMap(mi, p, gamemode);
if (res != 0) return res;
LoadTheMap(mi, p, gamemode);
// Try this first so that it can disable the CD player if no tracks are found.
if (isRR())
@ -990,7 +983,6 @@ int enterlevel(MapRecord *mi, int gamemode)
clearfrags();
resettimevars(); // Here we go
setLevelStarted(mi);
return 0;
}
//---------------------------------------------------------------------------
@ -1010,18 +1002,12 @@ void startnewgame(MapRecord* map, int skill)
newgame(map, skill, [=](bool)
{
if (enterlevel(map, 0))
{
gameaction = ga_mainmenu;
}
else
{
ud.showweapons = cl_showweapon;
setlocalplayerinput(&ps[myconnectindex]);
PlayerColorChanged();
inputState.ClearAllInput();
gameaction = ga_level;
}
enterlevel(map, 0);
ud.showweapons = cl_showweapon;
setlocalplayerinput(&ps[myconnectindex]);
PlayerColorChanged();
inputState.ClearAllInput();
gameaction = ga_level;
});
}