- 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_FlushDisplay (void);
class FFont;
void C_MidPrint (FFont *font, const char *message, bool bold = false);
bool C_Responder (event_t *ev);
void C_SetNotifyFontScale(double scale);

View file

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

View file

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

View file

@ -637,18 +637,6 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
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)
{
C_HideConsole();

View file

@ -68,6 +68,7 @@
#include "i_time.h"
#include "texturemanager.h"
#include "v_draw.h"
#include "i_interface.h"
#include "gi.h"
@ -77,10 +78,6 @@
#define RIGHTMARGIN 8
#define BOTTOMARGIN 12
extern bool hud_toggled;
void D_ToggleHud();
CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
// ensure a minimum size
@ -95,7 +92,6 @@ static bool conline;
extern int gametic;
extern bool automapactive; // in AM_map.c
extern bool advancedemo;
extern FBaseCVar *CVars;
extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE];
@ -847,7 +843,7 @@ void C_DrawConsole ()
visheight = ConBottom;
if (conback.isValid())
if (conback.isValid() && gamestate != GS_FULLCONSOLE)
{
DrawTexture (twod, TexMan.GetGameTexture(conback), 0, visheight - screen->GetHeight(),
DTA_DestWidth, twod->GetWidth(),
@ -862,6 +858,7 @@ void C_DrawConsole ()
PalEntry pe((uint8_t)(con_alpha * 255), 0, 0, 0);
twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), visheight, pe);
}
if (conline && visheight < screen->GetHeight())
{
twod->AddColorOnlyQuad(0, visheight, screen->GetWidth(), 1, 0xff000000);
@ -947,35 +944,25 @@ void C_DrawConsole ()
void C_FullConsole ()
{
if (hud_toggled)
D_ToggleHud();
if (demoplayback)
G_CheckDemoStatus ();
D_QuitNetGame ();
advancedemo = false;
ConsoleState = c_down;
HistPos = NULL;
TabbedLast = false;
TabbedList = false;
if (gamestate != GS_STARTUP)
{
gamestate = GS_FULLCONSOLE;
primaryLevel->Music = "";
S_Start ();
S_StopMusic(true);
P_FreeLevelData ();
}
else
{
C_AdjustBottom ();
}
gamestate = GS_FULLCONSOLE;
C_AdjustBottom ();
}
void C_ToggleConsole ()
{
if (gamestate == GS_DEMOSCREEN || demoplayback)
int togglestate;
if (gamestate == GS_INTRO) // blocked
{
return;
}
if (gamestate == GS_MENUSCREEN)
{
gameaction = ga_fullconsole;
togglestate = c_down;
}
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
{
@ -983,14 +970,17 @@ void C_ToggleConsole ()
HistPos = NULL;
TabbedLast = false;
TabbedList = false;
if (hud_toggled)
D_ToggleHud();
togglestate = c_falling;
}
else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP)
{
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 ()
@ -1434,38 +1424,3 @@ CCMD(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)
{
case GS_FULLCONSOLE:
D_PageDrawer();
C_DrawConsole ();
M_Drawer ();
End2DAndUpdate ();
@ -2831,6 +2832,13 @@ FString System_GetPlayerName(int node)
{
return players[node].userinfo.GetName();
}
void System_ConsoleToggled(int state)
{
if (state == c_falling && hud_toggled)
D_ToggleHud();
}
//==========================================================================
//
// DoomSpecificInfo
@ -3057,6 +3065,7 @@ static int D_DoomMain_Internal (void)
StrTable_GetGender,
nullptr,
CheckSkipGameOptionBlock,
System_ConsoleToggled,
};

View file

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

View file

@ -75,6 +75,8 @@
#include "i_system.h"
#include "p_conversation.h"
#include "v_palette.h"
#include "s_music.h"
#include "p_setup.h"
#include "v_video.h"
#include "g_hub.h"
@ -1048,6 +1050,29 @@ bool G_Responder (event_t *ev)
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
@ -1158,7 +1183,7 @@ void G_Ticker ()
gameaction = ga_nothing;
break;
case ga_fullconsole:
C_FullConsole ();
G_FullConsole ();
gameaction = ga_nothing;
break;
case ga_togglemap:

View file

@ -42,6 +42,7 @@
#include "serialize_obj.h"
#include "doomstat.h"
#include "vm.h"
#include "c_console.h"
#include "v_draw.h"
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);
}
}
/* 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);
class FFont;
void C_MidPrint(FFont* font, const char* message, bool bold = false);
enum DI_Flags
{

View file

@ -36,7 +36,7 @@
#include "gi.h"
#include "gstrings.h"
#include "d_player.h"
#include "c_console.h"
#include "sbar.h"
#include "filesystem.h"
#include "v_font.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_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
GS_INTRO,
GS_MENUSCREEN = GS_DEMOSCREEN,
GS_FORCEWIPE = -1,
GS_FORCEWIPEFADE = -2,

View file

@ -74,11 +74,8 @@ EXTERN_CVAR(Bool, show_messages)
typedef void(*hfunc)();
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);
void D_ToggleHud();
void I_WaitVBL(int count);
extern bool hud_toggled;
FNewGameStartup NewGameStartupInfo;
@ -1268,6 +1265,7 @@ void SetDefaultMenuColors()
CCMD (menu_main)
{
if (gamestate == GS_FULLCONSOLE) gamestate = GS_MENUSCREEN;
M_StartControlPanel(true);
M_SetMenu(NAME_Mainmenu, -1);
}

View file

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

View file

@ -2738,6 +2738,19 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow)
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
{
native static void HideConsole();
native static void MidPrint(Font fontname, string textlabel, bool bold = false);
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
{
Color colors[256];