- some fixes for the console.

* it is now possible to switch back to the main intro loop from the fullscreen console.
* do not distort the background of the fullscreen console. Always draw the console on top of what the main loop currently displays with a translucent black overlay.
* do not use the CONPIC for the fullscreen console as it tends to be more of a distraction than an asset when filling the entire screen.
* cleaned up c_console.cpp and moved several pieces of code unrelated to actual console management out of it.
This commit is contained in:
Christoph Oelckers 2020-10-25 09:16:37 +01:00
parent 7676ed641c
commit 194824f810
17 changed files with 122 additions and 85 deletions

View file

@ -77,9 +77,6 @@ void C_HideConsole (void);
void C_AdjustBottom (void); void C_AdjustBottom (void);
void C_FlushDisplay (void); void C_FlushDisplay (void);
class FFont;
void C_MidPrint (FFont *font, const char *message, bool bold = false);
bool C_Responder (event_t *ev); bool C_Responder (event_t *ev);
void C_SetNotifyFontScale(double scale); void C_SetNotifyFontScale(double scale);

View file

@ -26,6 +26,7 @@ struct SystemCallbacks
int (*GetGender)(); int (*GetGender)();
void (*MenuClosed)(); void (*MenuClosed)();
bool (*CheckMenudefOption)(const char* opt); bool (*CheckMenudefOption)(const char* opt);
void (*ConsoleToggled)(int state);
}; };
extern SystemCallbacks sysCallbacks; extern SystemCallbacks sysCallbacks;

View file

@ -819,6 +819,7 @@ void V_InitFonts()
BigFont = OriginalBigFont; BigFont = OriginalBigFont;
} }
AlternativeSmallFont = OriginalSmallFont; AlternativeSmallFont = OriginalSmallFont;
AlternativeBigFont = OriginalBigFont;
} }
void V_LoadTranslations() void V_LoadTranslations()

View file

@ -637,18 +637,6 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);
const char* txt = text[0] == '$' ? GStrings(&text[1]) : text.GetChars();
C_MidPrint(fnt, txt, bold);
return 0;
}
DEFINE_ACTION_FUNCTION(_Console, HideConsole) DEFINE_ACTION_FUNCTION(_Console, HideConsole)
{ {
C_HideConsole(); C_HideConsole();

View file

@ -68,6 +68,7 @@
#include "i_time.h" #include "i_time.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "v_draw.h" #include "v_draw.h"
#include "i_interface.h"
#include "gi.h" #include "gi.h"
@ -77,10 +78,6 @@
#define RIGHTMARGIN 8 #define RIGHTMARGIN 8
#define BOTTOMARGIN 12 #define BOTTOMARGIN 12
extern bool hud_toggled;
void D_ToggleHud();
CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{ {
// ensure a minimum size // ensure a minimum size
@ -95,7 +92,6 @@ static bool conline;
extern int gametic; extern int gametic;
extern bool automapactive; // in AM_map.c extern bool automapactive; // in AM_map.c
extern bool advancedemo;
extern FBaseCVar *CVars; extern FBaseCVar *CVars;
extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE]; extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE];
@ -847,7 +843,7 @@ void C_DrawConsole ()
visheight = ConBottom; visheight = ConBottom;
if (conback.isValid()) if (conback.isValid() && gamestate != GS_FULLCONSOLE)
{ {
DrawTexture (twod, TexMan.GetGameTexture(conback), 0, visheight - screen->GetHeight(), DrawTexture (twod, TexMan.GetGameTexture(conback), 0, visheight - screen->GetHeight(),
DTA_DestWidth, twod->GetWidth(), DTA_DestWidth, twod->GetWidth(),
@ -862,6 +858,7 @@ void C_DrawConsole ()
PalEntry pe((uint8_t)(con_alpha * 255), 0, 0, 0); PalEntry pe((uint8_t)(con_alpha * 255), 0, 0, 0);
twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), visheight, pe); twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), visheight, pe);
} }
if (conline && visheight < screen->GetHeight()) if (conline && visheight < screen->GetHeight())
{ {
twod->AddColorOnlyQuad(0, visheight, screen->GetWidth(), 1, 0xff000000); twod->AddColorOnlyQuad(0, visheight, screen->GetWidth(), 1, 0xff000000);
@ -947,35 +944,25 @@ void C_DrawConsole ()
void C_FullConsole () void C_FullConsole ()
{ {
if (hud_toggled)
D_ToggleHud();
if (demoplayback)
G_CheckDemoStatus ();
D_QuitNetGame ();
advancedemo = false;
ConsoleState = c_down; ConsoleState = c_down;
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
TabbedList = false; TabbedList = false;
if (gamestate != GS_STARTUP)
{
gamestate = GS_FULLCONSOLE; gamestate = GS_FULLCONSOLE;
primaryLevel->Music = "";
S_Start ();
S_StopMusic(true);
P_FreeLevelData ();
}
else
{
C_AdjustBottom (); C_AdjustBottom ();
} }
}
void C_ToggleConsole () void C_ToggleConsole ()
{ {
if (gamestate == GS_DEMOSCREEN || demoplayback) int togglestate;
if (gamestate == GS_INTRO) // blocked
{
return;
}
if (gamestate == GS_MENUSCREEN)
{ {
gameaction = ga_fullconsole; gameaction = ga_fullconsole;
togglestate = c_down;
} }
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off) else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
{ {
@ -983,14 +970,17 @@ void C_ToggleConsole ()
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
TabbedList = false; TabbedList = false;
if (hud_toggled) togglestate = c_falling;
D_ToggleHud();
} }
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();
togglestate = c_rising;
} }
else return;
// This must be done as an event callback because the client code does not control the console toggling.
if (sysCallbacks.ConsoleToggled) sysCallbacks.ConsoleToggled(togglestate);
} }
void C_HideConsole () void C_HideConsole ()
@ -1434,38 +1424,3 @@ CCMD(toggleconsole)
C_ToggleConsole(); C_ToggleConsole();
} }
/* Printing in the middle of the screen */
CVAR(Float, con_midtime, 3.f, CVAR_ARCHIVE)
const char *console_bar = "----------------------------------------";
void C_MidPrint (FFont *font, const char *msg, bool bold)
{
if (StatusBar == nullptr || screen == nullptr)
return;
// [MK] allow the status bar to take over MidPrint
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessMidPrint)
{
FString msgstr = msg;
VMValue params[] = { (DObject*)StatusBar, font, &msgstr, bold };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
if (msg != nullptr)
{
auto color = (EColorRange)PrintColors[bold? PRINTLEVELS+1 : PRINTLEVELS];
Printf(PRINT_HIGH|PRINT_NONOTIFY, TEXTCOLOR_ESCAPESTR "%c%s\n%s\n%s\n", color, console_bar, msg, console_bar);
StatusBar->AttachMessage (Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0, color, con_midtime), MAKE_ID('C','N','T','R'));
}
else
{
StatusBar->DetachMessage (MAKE_ID('C','N','T','R'));
}
}

View file

@ -1080,6 +1080,7 @@ void D_Display ()
switch (gamestate) switch (gamestate)
{ {
case GS_FULLCONSOLE: case GS_FULLCONSOLE:
D_PageDrawer();
C_DrawConsole (); C_DrawConsole ();
M_Drawer (); M_Drawer ();
End2DAndUpdate (); End2DAndUpdate ();
@ -2831,6 +2832,13 @@ FString System_GetPlayerName(int node)
{ {
return players[node].userinfo.GetName(); return players[node].userinfo.GetName();
} }
void System_ConsoleToggled(int state)
{
if (state == c_falling && hud_toggled)
D_ToggleHud();
}
//========================================================================== //==========================================================================
// //
// DoomSpecificInfo // DoomSpecificInfo
@ -3057,6 +3065,7 @@ static int D_DoomMain_Internal (void)
StrTable_GetGender, StrTable_GetGender,
nullptr, nullptr,
CheckSkipGameOptionBlock, CheckSkipGameOptionBlock,
System_ConsoleToggled,
}; };

View file

@ -33,6 +33,10 @@
#include "startupinfo.h" #include "startupinfo.h"
#include "c_cvars.h" #include "c_cvars.h"
extern bool advancedemo;
extern bool hud_toggled;
void D_ToggleHud();
struct event_t; struct event_t;
// //

View file

@ -75,6 +75,8 @@
#include "i_system.h" #include "i_system.h"
#include "p_conversation.h" #include "p_conversation.h"
#include "v_palette.h" #include "v_palette.h"
#include "s_music.h"
#include "p_setup.h"
#include "v_video.h" #include "v_video.h"
#include "g_hub.h" #include "g_hub.h"
@ -1048,6 +1050,29 @@ bool G_Responder (event_t *ev)
ev->type == EV_Mouse); ev->type == EV_Mouse);
} }
static void G_FullConsole()
{
int oldgs = gamestate;
if (hud_toggled)
D_ToggleHud();
if (demoplayback)
G_CheckDemoStatus();
D_QuitNetGame();
advancedemo = false;
C_FullConsole();
if (oldgs != GS_STARTUP)
{
primaryLevel->Music = "";
S_Start();
S_StopMusic(true);
P_FreeLevelData();
}
}
//========================================================================== //==========================================================================
// //
// FRandom :: StaticSumSeeds // FRandom :: StaticSumSeeds
@ -1158,7 +1183,7 @@ void G_Ticker ()
gameaction = ga_nothing; gameaction = ga_nothing;
break; break;
case ga_fullconsole: case ga_fullconsole:
C_FullConsole (); G_FullConsole ();
gameaction = ga_nothing; gameaction = ga_nothing;
break; break;
case ga_togglemap: case ga_togglemap:

View file

@ -42,6 +42,7 @@
#include "serialize_obj.h" #include "serialize_obj.h"
#include "doomstat.h" #include "doomstat.h"
#include "vm.h" #include "vm.h"
#include "c_console.h"
#include "v_draw.h" #include "v_draw.h"
EXTERN_CVAR(Int, con_scaletext) EXTERN_CVAR(Int, con_scaletext)
@ -890,3 +891,39 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
DHUDMessageFadeOut::DoDraw (linenum, x, y, clean, hudheight); DHUDMessageFadeOut::DoDraw (linenum, x, y, clean, hudheight);
} }
} }
/* Printing in the middle of the screen */
CVAR(Float, con_midtime, 3.f, CVAR_ARCHIVE)
const char* console_bar = "----------------------------------------";
void C_MidPrint(FFont* font, const char* msg, bool bold)
{
if (StatusBar == nullptr || screen == nullptr)
return;
// [MK] allow the status bar to take over MidPrint
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessMidPrint)
{
FString msgstr = msg;
VMValue params[] = { (DObject*)StatusBar, font, &msgstr, bold };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
if (msg != nullptr)
{
auto color = (EColorRange)PrintColors[bold ? PRINTLEVELS + 1 : PRINTLEVELS];
Printf(PRINT_HIGH | PRINT_NONOTIFY, TEXTCOLOR_ESCAPESTR "%c%s\n%s\n%s\n", color, console_bar, msg, console_bar);
StatusBar->AttachMessage(Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0, color, con_midtime), MAKE_ID('C', 'N', 'T', 'R'));
}
else
{
StatusBar->DetachMessage(MAKE_ID('C', 'N', 'T', 'R'));
}
}

View file

@ -540,6 +540,10 @@ extern FGameTexture *CrosshairImage;
int GetInventoryIcon(AActor *item, uint32_t flags, int *applyscale = nullptr); int GetInventoryIcon(AActor *item, uint32_t flags, int *applyscale = nullptr);
class FFont;
void C_MidPrint(FFont* font, const char* message, bool bold = false);
enum DI_Flags enum DI_Flags
{ {

View file

@ -36,7 +36,7 @@
#include "gi.h" #include "gi.h"
#include "gstrings.h" #include "gstrings.h"
#include "d_player.h" #include "d_player.h"
#include "c_console.h" #include "sbar.h"
#include "filesystem.h" #include "filesystem.h"
#include "v_font.h" #include "v_font.h"
#include "vm.h" #include "vm.h"

View file

@ -14,6 +14,7 @@ enum gamestate_t : int
GS_STARTUP, // [RH] Console is fullscreen, and game is just starting GS_STARTUP, // [RH] Console is fullscreen, and game is just starting
GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
GS_INTRO, GS_INTRO,
GS_MENUSCREEN = GS_DEMOSCREEN,
GS_FORCEWIPE = -1, GS_FORCEWIPE = -1,
GS_FORCEWIPEFADE = -2, GS_FORCEWIPEFADE = -2,

View file

@ -74,11 +74,8 @@ EXTERN_CVAR(Bool, show_messages)
typedef void(*hfunc)(); typedef void(*hfunc)();
DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr); DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr);
bool OkForLocalization(FTextureID texnum, const char* substitute); bool OkForLocalization(FTextureID texnum, const char* substitute);
void D_ToggleHud();
void I_WaitVBL(int count); void I_WaitVBL(int count);
extern bool hud_toggled;
FNewGameStartup NewGameStartupInfo; FNewGameStartup NewGameStartupInfo;
@ -1268,6 +1265,7 @@ void SetDefaultMenuColors()
CCMD (menu_main) CCMD (menu_main)
{ {
if (gamestate == GS_FULLCONSOLE) gamestate = GS_MENUSCREEN;
M_StartControlPanel(true); M_StartControlPanel(true);
M_SetMenu(NAME_Mainmenu, -1); M_SetMenu(NAME_Mainmenu, -1);
} }

View file

@ -37,7 +37,7 @@
#include "templates.h" #include "templates.h"
#include "p_local.h" #include "p_local.h"
#include "t_script.h" #include "t_script.h"
#include "c_console.h" #include "sbar.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "d_player.h" #include "d_player.h"
#include "filesystem.h" #include "filesystem.h"

View file

@ -2738,6 +2738,19 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow)
return MIN(numret, 4); return MIN(numret, 4);
} }
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);
const char* txt = text[0] == '$' ? GStrings(&text[1]) : text.GetChars();
C_MidPrint(fnt, txt, bold);
return 0;
}
//========================================================================== //==========================================================================
// //
// //

View file

@ -493,7 +493,6 @@ struct Font native
struct Console native struct Console native
{ {
native static void HideConsole(); native static void HideConsole();
native static void MidPrint(Font fontname, string textlabel, bool bold = false);
native static vararg void Printf(string fmt, ...); native static vararg void Printf(string fmt, ...);
} }

View file

@ -42,6 +42,11 @@ extend struct Screen
} }
} }
extend struct Console
{
native static void MidPrint(Font fontname, string textlabel, bool bold = false);
}
extend struct Translation extend struct Translation
{ {
Color colors[256]; Color colors[256];