- ported the 'entering level' screen.

This commit is contained in:
Christoph Oelckers 2020-07-03 09:59:24 +02:00
parent d2595582d4
commit 5144e8c355
15 changed files with 217 additions and 251 deletions

View file

@ -112,7 +112,9 @@ void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clea
float ms = (clock / 1'000'000) / job.job->fadetime;
screenfade = clamp(ms, 0.f, 1.f);
twod->SetScreenFade(screenfade);
job.job->fadestate = DScreenJob::fadein;
}
else job.job->fadestate = DScreenJob::visible;
job.job->SetClock(clock);
int state = job.job->Frame(clock, skiprequest);
startTime -= job.job->GetClock() - clock;
@ -125,6 +127,7 @@ void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clea
{
if (job.job->fadestyle & DScreenJob::fadeout)
{
job.job->fadestate = DScreenJob::fadeout;
startTime = now;
float screenfade2;
do

View file

@ -11,12 +11,14 @@ class DScreenJob : public DObject
int64_t now;
const int fadestyle;
const float fadetime; // in milliseconds
int fadestate = fadein;
friend void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, bool clearbefore);
public:
enum
{
visible = 0,
fadein = 1,
fadeout = 2,
};
@ -34,6 +36,8 @@ public:
}
virtual int Frame(uint64_t clock, bool skiprequest) { return 0; }
int GetFadeState() const { return fadestate; }
};
//---------------------------------------------------------------------------

View file

@ -1034,6 +1034,46 @@ void e4intro(CompletionFunc completion)
RunScreenJob(jobs, job, completion);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
class DDukeLoadScreen : public DScreenJob
{
std::function<int(void)> callback;
public:
DDukeLoadScreen(const char *mapname_, std::function<int(void)> callback_) : DScreenJob(fadein|fadeout), callback(callback_) {}
int Frame(uint64_t clock, bool skiprequest)
{
DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
// fixme: The level management needs a total overhaul!
if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0)
{
BigText(160, 90, GStrings("TXT_LOADUM"));
GameText(160, 100, boardfilename, 14, 0);
}
else
{
BigText(160, 90, GStrings("TXT_LOADING"));
BigText(160, 114, mapList[(ud.volume_number * MAXLEVELS) + ud.level_number].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;
}
};
// Utility for testing the above screens
CCMD(testscreen)
@ -1090,5 +1130,4 @@ CCMD(testscreen)
}
}
END_DUKE_NS

View file

@ -601,6 +601,49 @@ void dobonus_r(bool bonusonly, CompletionFunc completion)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
class DRRLoadScreen : public DScreenJob
{
std::function<int(void)> callback;
public:
DRRLoadScreen(const char *mapname_, std::function<int(void)> callback_) : DScreenJob(fadein|fadeout), callback(callback_) {}
int Frame(uint64_t clock, bool skiprequest)
{
DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
int y = isRRRA()? 140 : 90;
// fixme: The level management needs a total overhaul!
if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0)
{
BigText(160, y, GStrings("TXT_ENTRUM"), 0);
BigText(160, y+20, boardfilename, 0);
}
else
{
BigText(160, y, GStrings("TXT_ENTERIN"), 0);
// Fixme: This last level hack needs to go away!!!
BigText(160, y+24, mapList[g_lastLevel? 127 : (ud.volume_number * MAXLEVELS) + ud.level_number].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;
}
};
// Utility for testing the above screens
CCMD(testrscreen)
{
@ -644,4 +687,5 @@ CCMD(testrscreen)
}
}
END_DUKE_NS

View file

@ -30,7 +30,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "duke3d.h"
#include "menus.h"
#include "osdcmds.h"
#include "savegame.h"
#include "game.h"

View file

@ -546,6 +546,16 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang)
DTA_Color, pe, DTA_ScaleX, j / 65536., DTA_ScaleY, j/65536., TAG_DONE);
}
}
if (/*textret == 0 &&*/ ud.overhead_on == 2)
{
const int32_t a = RR ? 0 : ((ud.screen_size > 0) ? 147 : 179);
if (!G_HaveUserMap()) // && !(G_GetLogoFlags() & LOGO_HIDEEPISODE))
minitext(5, a + 6, GStrings.localize(gVolumeNames[ud.volume_number]), 0, 2 + 8 + 16 + 256);
minitext(5, a + 6 + 6, currentLevel->DisplayName(), 0, 2 + 8 + 16 + 256);
}
}
END_DUKE_NS

View file

@ -1,62 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef menus_h_
#define menus_h_
#include "compat.h"
BEGIN_DUKE_NS
// a subset of screentext parameters, restricted because menus require accessibility
typedef struct MenuFont_t
{
// int32_t xspace, yline;
vec2_t emptychar, between;
int32_t zoom;
int32_t cursorLeftPosition, cursorCenterPosition, cursorScale, cursorScale2, cursorScale3;
int32_t textflags;
int16_t tilenum;
// selected shade glows, deselected shade is used by Blood, disabled shade is used by SW
int8_t shade_deselected, shade_disabled;
uint8_t pal;
uint8_t pal_selected, pal_deselected, pal_disabled;
uint8_t pal_selected_right, pal_deselected_right, pal_disabled_right;
int32_t get_yline() const { return mulscale16(emptychar.y, zoom); }
} MenuFont_t;
extern MenuFont_t MF_Redfont, MF_Bluefont, MF_Minifont;
void Menu_Init(void);
inline int G_CheckPlayerColor(int color)
{
static int32_t player_pals[] = { 0, 9, 10, 11, 12, 13, 14, 15, 16, 21, 23, };
if (color >= 0 && color < 10) return player_pals[color];
return 0;
}
END_DUKE_NS
#endif

View file

@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "demo.h"
#include "duke3d.h"
#include "menus.h"
#include "savegame.h"
#include "screens.h"

View file

@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "baselayer.h"
#include "osdcmds.h"
#include "net.h"
#include "menus.h"
#include "savegame.h"
#include "demo.h"
@ -1492,6 +1491,14 @@ void G_PostCreateGameState(void)
Net_SendClientInfo();
}
inline int G_CheckPlayerColor(int color)
{
static int32_t player_pals[] = { 0, 9, 10, 11, 12, 13, 14, 15, 16, 21, 23, };
if (color >= 0 && color < 10) return player_pals[color];
return 0;
}
static void G_Startup(void)
{
int32_t i;
@ -1768,6 +1775,7 @@ int32_t SetDefaults(void)
return 0;
}
void Menu_Init(void);
int GameInterface::app_main()
{

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cheats.h"
#include "demo.h" // g_firstDemoFile[]
#include "duke3d.h"
#include "menus.h"
#include "osdcmds.h"
#include "savegame.h"
#include "sbar.h"

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "menus.h"
#include "demo.h"
#include "savegame.h"
#include "statistics.h"
@ -50,90 +49,6 @@ int32_t g_skillSoundVoice = -1;
static void G_DoLoadScreen(const char *statustext, int32_t percent)
{
if (ud.recstat != 2)
{
int32_t i = 0;
//g_player[myconnectindex].ps->palette = palette;
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308
if (!statustext)
{
i = ud.screen_size;
ud.screen_size = 0;
G_UpdateScreenArea();
videoClearScreen(0L);
}
videoClearScreen(0);
int const loadScreenTile = VM_OnEventWithReturn(EVENT_GETLOADTILE, g_player[screenpeek].ps->i, screenpeek, DEER ? 7040 : TILE_LOADSCREEN);
rotatesprite_fs(320<<15,200<<15,65536L,0,loadScreenTile,0,0,2+8+64+BGSTRETCH);
int const textY = RRRA ? 140 : 90;
if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0)
{
menutext_center(textY, RR ? GStrings("TXT_ENTRUM") : GStrings("TXT_LOADUM"));
if (RR)
menutext_center(textY+20, boardfilename);
else
gametext_center_shade_pal(textY+10, boardfilename, 14, 2);
}
else if (RR && g_lastLevel)
{
menutext_center(textY,GStrings("TXT_ENTERIN"));
menutext_center(textY+16+8,GStrings("TXT_CLOSEENCOUNTERS"));
}
else
{
menutext_center(textY, RR ? GStrings("TXT_ENTERIN") : GStrings("TXT_LOADING"));
menutext_center(textY+16+8,mapList[(ud.volume_number*MAXLEVELS) + ud.level_number].DisplayName());
}
#ifndef EDUKE32_TOUCH_DEVICES
if (statustext) gametext_center_number(180, statustext);
#endif
if (percent != -1)
{
int32_t ii = scale(scale(xdim-1,288,320),percent,100);
rotatesprite(31<<16,145<<16,65536,0,929,15,0,2+8+16,0,0,ii,ydim-1);
rotatesprite(159<<16,145<<16,65536,0,929,15,0,2+8+16,0,0,ii,ydim-1);
rotatesprite(30<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1);
rotatesprite(158<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1);
}
videoNextPage();
if (!statustext)
{
inputState.keyFlushChars();
ud.screen_size = i;
}
}
else
{
if (!statustext)
{
videoClearScreen(0L);
//g_player[myconnectindex].ps->palette = palette;
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308
}
/*Gv_SetVar(g_iReturnVarID,TILE_LOADSCREEN, -1, -1);*/
rotatesprite_fs(320<<15,200<<15,65536L, 0,TILE_LOADSCREEN,0,0,2+8+64+BGSTRETCH);
menutext_center(RRRA?155:105,RR? GStrings("TXT_LOADIN") : GStrings("TXT_Loading..."));
if (statustext) gametext_center_number(180, statustext);
videoNextPage();
}
}
extern int32_t fragbarheight(void)
@ -166,7 +81,7 @@ void G_UpdateScreenArea(void)
renderFlushPerms();
{
const int32_t ss = max(ud.screen_size-8,0);
const int32_t ss = std::max(ud.screen_size-8,0);
int32_t x1 = scale(ss,xdim,160);
int32_t x2 = xdim-x1;
@ -392,77 +307,10 @@ static void G_LoadMapHack(char *outbuf, const char *filename)
void cacheit_d();
void cacheit_r();
int G_EnterLevel(int gameMode)
static int LoadTheMap(MapRecord &mi, DukePlayer_t *pPlayer, int gameMode)
{
int32_t i, mii;
char levelName[BMAX_PATH];
// flushpackets();
// waitforeverybody();
vote_map = vote_episode = voting = -1;
ud.respawn_monsters = ud.m_respawn_monsters;
ud.respawn_items = ud.m_respawn_items;
ud.respawn_inventory = ud.m_respawn_inventory;
ud.monsters_off = ud.m_monsters_off;
ud.coop = m_coop;
ud.marker = m_marker;
ud.ffire = m_ffire;
ud.noexits = m_noexits;
if ((gameMode & MODE_DEMO) != MODE_DEMO)
ud.recstat = m_recstat;
if ((gameMode & MODE_DEMO) == 0 && ud.recstat == 2)
ud.recstat = 0;
VM_OnEvent(EVENT_ENTERLEVEL);
//if (g_networkMode != NET_DEDICATED_SERVER)
{
S_PauseSounds(false);
FX_StopAllSounds();
S_ClearSoundLocks();
FX_SetReverb(0);
}
if (Menu_HaveUserMap())
{
int levelNum = G_FindLevelByFile(boardfilename);
if (levelNum != MAXLEVELS*MAXVOLUMES)
{
int volumeNum = levelNum;
levelNum &= MAXLEVELS-1;
volumeNum = (volumeNum - levelNum) / MAXLEVELS;
ud.level_number = m_level_number = levelNum;
ud.volume_number = ud.m_volume_number = volumeNum;
boardfilename[0] = 0;
}
}
// Redirect the final RR level to a valid map record so that currentLevel can point to something.
mii = (RR && g_lastLevel)? 127 : (ud.volume_number*MAXLEVELS)+ud.level_number;
auto &mi = mapList[mii];
if (mi.fileName.IsEmpty() && !Menu_HaveUserMap())
{
Printf(TEXTCOLOR_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1);
return 1;
}
i = ud.screen_size;
ud.screen_size = 0;
FStringf msg("%s . . .", GStrings("TXT_LOADMAP"));
G_DoLoadScreen(msg, -1);
G_UpdateScreenArea();
ud.screen_size = i;
DukePlayer_t *const pPlayer = g_player[0].ps;
int16_t lbang;
if (!VOLUMEONE && Menu_HaveUserMap())
@ -530,6 +378,85 @@ int G_EnterLevel(int gameMode)
if (isRR()) cacheit_r(); else cacheit_d();
//G_CacheMapData();
// G_FadeLoad(0,0,0, 0,252, 28, 4, -2);
return 0;
}
int G_EnterLevel(int gameMode)
{
int32_t i, mii;
// flushpackets();
// waitforeverybody();
vote_map = vote_episode = voting = -1;
ud.respawn_monsters = ud.m_respawn_monsters;
ud.respawn_items = ud.m_respawn_items;
ud.respawn_inventory = ud.m_respawn_inventory;
ud.monsters_off = ud.m_monsters_off;
ud.coop = m_coop;
ud.marker = m_marker;
ud.ffire = m_ffire;
ud.noexits = m_noexits;
if ((gameMode & MODE_DEMO) != MODE_DEMO)
ud.recstat = m_recstat;
if ((gameMode & MODE_DEMO) == 0 && ud.recstat == 2)
ud.recstat = 0;
VM_OnEvent(EVENT_ENTERLEVEL);
//if (g_networkMode != NET_DEDICATED_SERVER)
{
S_PauseSounds(false);
FX_StopAllSounds();
S_ClearSoundLocks();
FX_SetReverb(0);
}
if (Menu_HaveUserMap())
{
int levelNum = G_FindLevelByFile(boardfilename);
if (levelNum != MAXLEVELS*MAXVOLUMES)
{
int volumeNum = levelNum;
levelNum &= MAXLEVELS-1;
volumeNum = (volumeNum - levelNum) / MAXLEVELS;
ud.level_number = m_level_number = levelNum;
ud.volume_number = ud.m_volume_number = volumeNum;
boardfilename[0] = 0;
}
}
// Redirect the final RR level to a valid map record so that currentLevel can point to something.
mii = (RR && g_lastLevel)? 127 : (ud.volume_number*MAXLEVELS)+ud.level_number;
auto& mi = mapList[mii];
if (mi.fileName.IsEmpty() && !Menu_HaveUserMap())
{
Printf(TEXTCOLOR_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1);
return 1;
}
i = ud.screen_size;
ud.screen_size = 0;
FStringf msg("%s . . .", GStrings("TXT_LOADMAP"));
ud.screen_size = i;
DukePlayer_t *const pPlayer = g_player[0].ps;
/*
G_DoLoadScreen(msg, -1);
G_UpdateScreenArea();
*/
int res = LoadTheMap(mi, pPlayer, gameMode);
if (res != 0) return res;
// Try this first so that it can disable the CD player if no tracks are found.
if (RR && !(gameMode & MODE_DEMO))

View file

@ -158,16 +158,6 @@ int32_t G_LoadPlayer(const char *path)
ud.multimode = h.numplayers;
S_PauseSounds(true);
if (numplayers > 1)
{
pub = NUMPAGES;
pus = NUMPAGES;
G_UpdateScreenArea();
drawbackground();
menutext_center(100, "Loading...");
videoNextPage();
}
Net_WaitForEverybody();
FX_StopAllSounds();

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screens.h"
#include "sbar.h"
#include "menus.h"
#include "demo.h"
#include "mdsprite.h"
#include "gamecvars.h"
@ -429,15 +428,6 @@ void G_DisplayRest(int32_t smoothratio)
drawoverheadmap(cposx, cposy, pp->zoom, cang);
restoreinterpolations();
if (/*textret == 0 &&*/ ud.overhead_on == 2)
{
const int32_t a = RR ? 0 : ((ud.screen_size > 0) ? 147 : 179);
if (!G_HaveUserMap()) // && !(G_GetLogoFlags() & LOGO_HIDEEPISODE))
minitext(5, a+6, GStrings.localize(gVolumeNames[ud.volume_number]), 0, 2+8+16+256);
minitext(5, a+6+6, currentLevel->DisplayName(), 0, 2+8+16+256);
}
}
}

View file

@ -24,12 +24,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "compat.h"
#include "sbar.h"
#include "menus.h"
#include "gstrings.h"
BEGIN_DUKE_NS
// a subset of screentext parameters, restricted because menus require accessibility
typedef struct MenuFont_t
{
// int32_t xspace, yline;
vec2_t emptychar, between;
int32_t zoom;
int32_t cursorLeftPosition, cursorCenterPosition, cursorScale, cursorScale2, cursorScale3;
int32_t textflags;
int16_t tilenum;
// selected shade glows, deselected shade is used by Blood, disabled shade is used by SW
int8_t shade_deselected, shade_disabled;
uint8_t pal;
uint8_t pal_selected, pal_deselected, pal_disabled;
uint8_t pal_selected_right, pal_deselected_right, pal_disabled_right;
int32_t get_yline() const { return mulscale16(emptychar.y, zoom); }
} MenuFont_t;
// common font types
// tilenums are set after namesdyn runs.
// These are also modifiable by scripts.
@ -164,6 +182,12 @@ vec2_t gametext_(int32_t x, int32_t y, const char *t, int32_t s, int32_t p, int3
{
return G_ScreenText(MF_Bluefont.tilenum, x, y, MF_Bluefont.zoom, 0, 0, t, s, p, o|2|8|16|ROTATESPRITE_FULL16, a, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y, MF_Bluefont.textflags|f, 0, 0, xdim-1, ydim-1);
}
static FORCE_INLINE int32_t sbarsc(int32_t sc)
{
return scale(sc, ud.statusbarscale, 100);
}
static int32_t sbarx16(int32_t x)
{
if (ud.screen_size == 4) return sbarsc(x);

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once
#include "menus.h"
#include "screentext.h"
BEGIN_DUKE_NS
@ -40,14 +39,7 @@ inline int minitext(int x, int y, const char* t, int p, int sb)
return minitext_(x, y, t, 0, p, sb);
}
static FORCE_INLINE int32_t sbarsc(int32_t sc)
{
return scale(sc, ud.statusbarscale, 100);
}
#define menutext_center(y, t) menutext_(160<<16, (y)<<16, 0, (t), 10|16, TEXT_XCENTER)
#define gametext_center(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER)
#define gametext_center_number(y, t) gametext_(160<<16, (y)<<16, (t), 0, MF_Bluefont.pal, 0, 0, TEXT_XCENTER|TEXT_GAMETEXTNUMHACK)
#define gametext_center_shade_pal(y, t, s, p) gametext_(160<<16, (y)<<16, (t), (s), (p), 0, 0, TEXT_XCENTER)