- enable the menu and console everywhere, except on the intro logos.

This commit is contained in:
Christoph Oelckers 2020-07-22 00:42:50 +02:00
parent 902fbf6f5d
commit 368298d02d
10 changed files with 117 additions and 98 deletions

View file

@ -2714,11 +2714,8 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t
fr.Read( sprite, sizeof(spritetype)*numsprites); fr.Read( sprite, sizeof(spritetype)*numsprites);
fr.Seek(0, FileReader::SeekSet); fr.Seek(0, FileReader::SeekSet);
int32_t boardsize = fr.GetLength(); auto buffer = fr.Read();
uint8_t *fullboard = (uint8_t*)Xmalloc(boardsize); md4once(buffer.Data(), buffer.Size(), g_loadedMapHack.md4);
fr.Read( fullboard, boardsize);
md4once(fullboard, boardsize, g_loadedMapHack.md4);
Xfree(fullboard);
// Done reading file. // Done reading file.
@ -3019,9 +3016,9 @@ void videoNextPage(void)
// which calls videoNextPage for page flipping again. In this loop the UI drawers may not get called again. // which calls videoNextPage for page flipping again. In this loop the UI drawers may not get called again.
// Ideally this stuff should be moved out of videoNextPage so that all those busy loops won't call UI overlays at all. // Ideally this stuff should be moved out of videoNextPage so that all those busy loops won't call UI overlays at all.
recursion = true; recursion = true;
M_Drawer();
FStat::PrintStat(twod); FStat::PrintStat(twod);
C_DrawConsole(); C_DrawConsole();
M_Drawer();
recursion = false; recursion = false;
} }

View file

@ -63,6 +63,8 @@
#include "v_draw.h" #include "v_draw.h"
#include "g_input.h" #include "g_input.h"
#include "timer.h" #include "timer.h"
#include "menu.h"
#include "raze_music.h"
#define LEFTMARGIN 8 #define LEFTMARGIN 8
#define RIGHTMARGIN 8 #define RIGHTMARGIN 8
@ -780,8 +782,8 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
if (hud_messages != 2 || if (hud_messages != 2 ||
source.IsEmpty() || source.IsEmpty() ||
//gamestate == GS_FULLCONSOLE || gamestate == GS_FULLCONSOLE ||
//gamestate == GS_DEMOSCREEN || gamestate == GS_DEMOSCREEN ||
con_notifylines == 0) con_notifylines == 0)
return; return;
@ -977,9 +979,9 @@ void C_FlushDisplay ()
void C_AdjustBottom () void C_AdjustBottom ()
{ {
/*if (gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) if (gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP)
ConBottom = screen->GetHeight(); ConBottom = twod->GetHeight();
else*/ if (ConBottom > twod->GetHeight() / 2 || ConsoleState == c_down) else if (ConBottom > twod->GetHeight() / 2 || ConsoleState == c_down)
ConBottom = twod->GetHeight() / 2; ConBottom = twod->GetHeight() / 2;
} }
@ -1016,7 +1018,6 @@ void C_Ticker()
ConBottom += (consoletic - lasttic) * (twod->GetHeight() * 2 / 25); ConBottom += (consoletic - lasttic) * (twod->GetHeight() * 2 / 25);
if (ConBottom >= twod->GetHeight() / 2) if (ConBottom >= twod->GetHeight() / 2)
{ {
GSnd->SetSfxPaused(true, PAUSESFX_CONSOLE);
ConBottom = twod->GetHeight() / 2; ConBottom = twod->GetHeight() / 2;
ConsoleState = c_down; ConsoleState = c_down;
} }
@ -1026,7 +1027,6 @@ void C_Ticker()
ConBottom -= (consoletic - lasttic) * (twod->GetHeight() * 2 / 25); ConBottom -= (consoletic - lasttic) * (twod->GetHeight() * 2 / 25);
if (ConBottom <= 0) if (ConBottom <= 0)
{ {
GSnd->SetSfxPaused(false, PAUSESFX_CONSOLE);
ConsoleState = c_up; ConsoleState = c_up;
ConBottom = 0; ConBottom = 0;
} }
@ -1035,10 +1035,6 @@ void C_Ticker()
lasttic = consoletic; lasttic = consoletic;
NotifyStrings.Tick(); NotifyStrings.Tick();
if (ConsoleState == c_down)
{
D_ProcessEvents();
}
} }
void FNotifyBuffer::Tick() void FNotifyBuffer::Tick()
@ -1078,8 +1074,8 @@ void FNotifyBuffer::Draw()
int line, lineadv, color, j; int line, lineadv, color, j;
bool canskip; bool canskip;
//if (gamestate == GS_FULLCONSOLE || gamestate == GS_DEMOSCREEN/* || menuactive != MENU_Off*/) if (gamestate == GS_FULLCONSOLE || gamestate == GS_DEMOSCREEN)
//return; return;
FFont* font = generic_ui ? NewSmallFont : SmallFont? SmallFont : AlternativeSmallFont; FFont* font = generic_ui ? NewSmallFont : SmallFont? SmallFont : AlternativeSmallFont;
@ -1210,12 +1206,10 @@ void C_DrawConsole ()
} }
#if 0
if (menuactive != MENU_Off) if (menuactive != MENU_Off)
{ {
return; return;
} }
#endif
if (lines > 0) if (lines > 0)
{ {
@ -1270,15 +1264,16 @@ void C_DrawConsole ()
} }
} }
#if 0
void C_FullConsole () void C_FullConsole ()
{ {
/*
if (hud_toggled) if (hud_toggled)
D_ToggleHud(); D_ToggleHud();
if (demoplayback) if (demoplayback)
G_CheckDemoStatus (); G_CheckDemoStatus ();
D_QuitNetGame (); D_QuitNetGame ();
advancedemo = false; advancedemo = false;
*/
ConsoleState = c_down; ConsoleState = c_down;
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
@ -1286,29 +1281,24 @@ void C_FullConsole ()
if (gamestate != GS_STARTUP) if (gamestate != GS_STARTUP)
{ {
gamestate = GS_FULLCONSOLE; gamestate = GS_FULLCONSOLE;
primaryLevel->Music = ""; Mus_Stop();
S_Start ();
S_StopMusic(true);
P_FreeLevelData ();
} }
else
{
C_AdjustBottom (); C_AdjustBottom ();
} }
}
#endif
void C_ToggleConsole () void C_ToggleConsole ()
{ {
/* if (gamestate == GS_INTRO) // blocked
if (gamestate == GS_DEMOSCREEN || demoplayback)
{ {
gameaction = ga_fullconsole; return;
} }
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)*/ if (gamestate == GS_DEMOSCREEN)
{
if (ConsoleState == c_up || ConsoleState == c_rising)// && menuactive == MENU_Off) gamestate = GS_FULLCONSOLE;
C_FullConsole();
}
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
{ {
ConsoleState = c_falling; ConsoleState = c_falling;
HistPos = NULL; HistPos = NULL;
@ -1316,7 +1306,7 @@ void C_ToggleConsole ()
TabbedList = false; TabbedList = false;
} }
else //if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP) else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP)
{ {
ConsoleState = c_rising; ConsoleState = c_rising;
C_FlushDisplay (); C_FlushDisplay ();
@ -1390,7 +1380,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
if (ev->data3 & (GKM_SHIFT|GKM_CTRL)) if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer up one page { // Scroll console buffer up one page
RowAdjust += (screen->GetHeight()-4)/active_con_scale(twod) / RowAdjust += (screen->GetHeight()-4)/active_con_scale(twod) /
((/*gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP*/false) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3; ((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
} }
else if (RowAdjust < conbuffer->GetFormattedLineCount()) else if (RowAdjust < conbuffer->GetFormattedLineCount())
{ // Scroll console buffer up { // Scroll console buffer up
@ -1413,7 +1403,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
if (ev->data3 & (GKM_SHIFT|GKM_CTRL)) if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer down one page { // Scroll console buffer down one page
const int scrollamt = (screen->GetHeight()-4)/active_con_scale(twod) / const int scrollamt = (screen->GetHeight()-4)/active_con_scale(twod) /
((/*gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP*/false) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3; ((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
if (RowAdjust < scrollamt) if (RowAdjust < scrollamt)
{ {
RowAdjust = 0; RowAdjust = 0;
@ -1615,6 +1605,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
} }
else if (gamestate == GS_FULLCONSOLE) else if (gamestate == GS_FULLCONSOLE)
{ {
gamestate = GS_DEMOSCREEN;
C_DoCommand ("menu_main"); C_DoCommand ("menu_main");
} }
else else
@ -1723,8 +1714,8 @@ bool C_Responder (event_t *ev)
{ {
if (ev->type != EV_GUI_Event || if (ev->type != EV_GUI_Event ||
ConsoleState == c_up || ConsoleState == c_up ||
ConsoleState == c_rising /*|| ConsoleState == c_rising ||
menuactive != MENU_Off*/) menuactive != MENU_Off)
{ {
return false; return false;
} }

View file

@ -202,7 +202,6 @@ enum
PAUSESFX_CONSOLE = 2 PAUSESFX_CONSOLE = 2
}; };
bool UIActive();
void updatePauseStatus(); void updatePauseStatus();
void updatePauseStatus(bool state, bool multiplayer); void updatePauseStatus(bool state, bool multiplayer);
extern int paused; extern int paused;

View file

@ -6,6 +6,7 @@
enum gamestate_t : int enum gamestate_t : int
{ {
GS_LEVEL, GS_LEVEL,
GS_INTRO,
GS_INTERMISSION, GS_INTERMISSION,
GS_FINALE, GS_FINALE,
GS_DEMOSCREEN, GS_DEMOSCREEN,

View file

@ -55,6 +55,7 @@
#include "raze_sound.h" #include "raze_sound.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "v_video.h" #include "v_video.h"
#include "gamestate.h"
void RegisterDuke3dMenus(); void RegisterDuke3dMenus();
void RegisterBloodMenus(); void RegisterBloodMenus();
@ -204,7 +205,7 @@ bool DMenu::MenuEvent (int mkey, bool fromcontroller)
{ {
case MKEY_Back: case MKEY_Back:
{ {
if (scriptID != 0) //if (scriptID != 0)
{ {
M_MenuSound(CurrentMenu->mParentMenu? BackSound : CloseSound); M_MenuSound(CurrentMenu->mParentMenu? BackSound : CloseSound);
Close(); Close();
@ -823,9 +824,13 @@ bool M_DoResponder (event_t *ev)
{ {
// Pop-up menu? // Pop-up menu?
if (ev->data1 == KEY_ESCAPE) // Should we let the games handle Escape for special actions, like backing out of cameras? if (ev->data1 == KEY_ESCAPE) // Should we let the games handle Escape for special actions, like backing out of cameras?
{
if (gamestate != GS_STARTUP && gamestate != GS_INTRO)
{ {
M_StartControlPanel(true); M_StartControlPanel(true);
M_SetMenu(NAME_IngameMenu, -1); M_SetMenu(gi->CanSave()? NAME_IngameMenu : NAME_Mainmenu, -1);
if (gamestate == GS_FULLCONSOLE) gamestate = GS_DEMOSCREEN;
}
return true; return true;
} }
return false; return false;
@ -872,7 +877,6 @@ void M_Ticker (void)
if (DMenu::MenuTime & 3) return; if (DMenu::MenuTime & 3) return;
if (CurrentMenu != NULL && menuactive != MENU_Off) if (CurrentMenu != NULL && menuactive != MENU_Off)
{ {
if (DMenu::MenuTime != 0) D_ProcessEvents(); // The main loop is blocked when the menu is open and cannot dispatch the events.
if (transition.previous) transition.previous->Ticker(); if (transition.previous) transition.previous->Ticker();
if (CurrentMenu == nullptr) return; // In case one of the sub-screens has closed the menu. if (CurrentMenu == nullptr) return; // In case one of the sub-screens has closed the menu.
CurrentMenu->Ticker(); CurrentMenu->Ticker();

View file

@ -43,6 +43,7 @@
#include "s_soundinternal.h" #include "s_soundinternal.h"
#include "animtexture.h" #include "animtexture.h"
#include "gamestate.h" #include "gamestate.h"
#include "menu.h"
IMPLEMENT_CLASS(DScreenJob, true, false) IMPLEMENT_CLASS(DScreenJob, true, false)
@ -242,6 +243,7 @@ class ScreenJobRunner
bool clearbefore; bool clearbefore;
bool skipped = false; bool skipped = false;
uint64_t startTime = -1; uint64_t startTime = -1;
uint64_t lastTime = -1;
int actionState; int actionState;
int terminateState; int terminateState;
@ -290,12 +292,19 @@ public:
auto now = I_nsTime(); auto now = I_nsTime();
bool skiprequest = inputState.CheckAllInput(); bool skiprequest = inputState.CheckAllInput();
if (startTime == -1) startTime = now; if (startTime == -1) startTime = now;
if (M_Active())
{
startTime += now - lastTime;
}
lastTime = now;
auto clock = now - startTime; auto clock = now - startTime;
if (screenfade < 1.f) if (screenfade < 1.f)
{ {
float ms = (clock / 1'000'000) / job.job->fadetime; float ms = (clock / 1'000'000) / job.job->fadetime;
screenfade = clamp(ms, 0.f, 1.f); screenfade = clamp(ms, 0.f, 1.f);
twod->SetScreenFade(screenfade); if (!M_Active()) twod->SetScreenFade(screenfade);
job.job->fadestate = DScreenJob::fadein; job.job->fadestate = DScreenJob::fadein;
} }
else job.job->fadestate = DScreenJob::visible; else job.job->fadestate = DScreenJob::visible;
@ -308,10 +317,17 @@ public:
int FadeoutFrame() int FadeoutFrame()
{ {
auto now = I_nsTime(); auto now = I_nsTime();
if (M_Active())
{
startTime += now - lastTime;
}
lastTime = now;
auto clock = now - startTime; auto clock = now - startTime;
float ms = (clock / 1'000'000) / jobs[index].job->fadetime; float ms = (clock / 1'000'000) / jobs[index].job->fadetime;
float screenfade2 = clamp(screenfade - ms, 0.f, 1.f); float screenfade2 = clamp(screenfade - ms, 0.f, 1.f);
twod->SetScreenFade(screenfade2); if (!M_Active()) twod->SetScreenFade(screenfade2);
if (screenfade2 <= 0.f) if (screenfade2 <= 0.f)
{ {
twod->Unlock(); // must unlock before displaying. twod->Unlock(); // must unlock before displaying.
@ -368,13 +384,13 @@ public:
ScreenJobRunner *runner; ScreenJobRunner *runner;
void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, bool clearbefore) void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, bool clearbefore, bool blockingui)
{ {
assert(completion != nullptr); assert(completion != nullptr);
if (count) if (count)
{ {
runner = new ScreenJobRunner(jobs, count, completion, clearbefore); runner = new ScreenJobRunner(jobs, count, completion, clearbefore);
gamestate = GS_INTERMISSION; gamestate = blockingui? GS_INTRO : GS_INTERMISSION;
} }
} }

View file

@ -79,7 +79,7 @@ struct JobDesc
}; };
void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true); void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, bool clearbefore = true, bool blockingui = false);
void DeleteScreenJob(); void DeleteScreenJob();
void RunScreenJobFrame(); void RunScreenJobFrame();

View file

@ -272,7 +272,7 @@ void Logo_d(const CompletionFunc &completion)
if (VOLUMEALL && !inputState.CheckAllInput()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } }; if (VOLUMEALL && !inputState.CheckAllInput()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr }; if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
jobs[job++] = { Create<DTitleScreen>(), []() { S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI); } }; jobs[job++] = { Create<DTitleScreen>(), []() { S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI); } };
RunScreenJob(jobs, job, completion); RunScreenJob(jobs, job, completion, true, true);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -203,7 +203,7 @@ void Logo_r(const CompletionFunc& completion)
{ {
jobs[job++] = { PlayVideo("redint.mve"), nullptr }; jobs[job++] = { PlayVideo("redint.mve"), nullptr };
} }
RunScreenJob(jobs, job, completion); RunScreenJob(jobs, job, completion, true, true);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -394,9 +394,12 @@ void app_loop()
gamestate = GS_STARTUP; gamestate = GS_STARTUP;
while (true) while (true)
{
try
{ {
handleevents(); handleevents();
updatePauseStatus(); updatePauseStatus();
D_ProcessEvents();
switch (gamestate) switch (gamestate)
{ {
default: default:
@ -430,6 +433,7 @@ void app_loop()
break; break;
case GS_DEMOSCREEN: case GS_DEMOSCREEN:
case GS_FULLCONSOLE:
drawbackground(); drawbackground();
break; break;
@ -439,6 +443,7 @@ void app_loop()
break; break;
case GS_INTERMISSION: case GS_INTERMISSION:
case GS_INTRO:
RunScreenJobFrame(); // This handles continuation through its completion callback. RunScreenJobFrame(); // This handles continuation through its completion callback.
break; break;
@ -446,6 +451,12 @@ void app_loop()
videoNextPage(); videoNextPage();
videoSetBrightness(0); // immediately reset this so that the value doesn't stick around in the backend. videoSetBrightness(0); // immediately reset this so that the value doesn't stick around in the backend.
} }
catch (CRecoverableError& err)
{
C_FullConsole();
Printf(TEXTCOLOR_RED "%s\n", err.what());
}
}
} }