- cleaned up c_console.cpp to be moved into 'common'.

This commit is contained in:
Christoph Oelckers 2020-10-25 12:18:06 +01:00
parent 59701ddd81
commit f912712f9d
11 changed files with 409 additions and 294 deletions

View file

@ -803,6 +803,7 @@ set (PCH_SOURCES
bbannouncer.cpp bbannouncer.cpp
console/c_cmds.cpp console/c_cmds.cpp
console/c_console.cpp console/c_console.cpp
console/c_notifybuffer.cpp
console/c_functions.cpp console/c_functions.cpp
ct_chat.cpp ct_chat.cpp
d_iwad.cpp d_iwad.cpp
@ -1046,6 +1047,7 @@ set (PCH_SOURCES
common/console/c_cvars.cpp common/console/c_cvars.cpp
common/console/c_dispatch.cpp common/console/c_dispatch.cpp
common/console/c_commandbuffer.cpp common/console/c_commandbuffer.cpp
common/console/c_notifybufferbase.cpp
common/console/c_tabcomplete.cpp common/console/c_tabcomplete.cpp
common/console/c_expr.cpp common/console/c_expr.cpp
common/utility/engineerrors.cpp common/utility/engineerrors.cpp

View file

@ -58,7 +58,6 @@ extern constate_e ConsoleState;
void C_InitConsole (int width, int height, bool ingame); void C_InitConsole (int width, int height, bool ingame);
void C_DeinitConsole (); void C_DeinitConsole ();
void C_InitConback(); void C_InitConback();
void C_ClearMessages();
// Adjust the console for a new screen mode // Adjust the console for a new screen mode
void C_NewModeAdjust (void); void C_NewModeAdjust (void);
@ -76,9 +75,13 @@ void C_FullConsole (void);
void C_HideConsole (void); void C_HideConsole (void);
void C_AdjustBottom (void); void C_AdjustBottom (void);
void C_FlushDisplay (void); void C_FlushDisplay (void);
class FNotifyBufferBase;
void C_SetNotifyBuffer(FNotifyBufferBase *nbb);
bool C_Responder (event_t *ev); bool C_Responder (event_t *ev);
extern double NotifyFontScale;
void C_SetNotifyFontScale(double scale); void C_SetNotifyFontScale(double scale);
extern const char *console_bar; extern const char *console_bar;

View file

@ -0,0 +1,141 @@
/*
** c_notifybufferbase.cpp
** Implements the buffer for the notification message
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** Copyright 2005-2020 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "v_text.h"
#include "i_time.h"
#include "v_draw.h"
#include "c_notifybufferbase.h"
void FNotifyBufferBase::Shift(int maxlines)
{
if (maxlines >= 0 && Text.Size() > (unsigned)maxlines)
{
Text.Delete(0, Text.Size() - maxlines);
}
}
void FNotifyBufferBase::Clear()
{
Text.Clear();
}
void FNotifyBufferBase::AddString(int printlevel, FFont *printFont, const FString &source, int formatwidth, float keeptime, int maxlines)
{
if (printFont == nullptr) return; // Without an initialized font we cannot handle the message (this is for those which come here before the font system is ready.)
LineHeight = printFont->GetHeight();
TArray<FBrokenLines> lines;
if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel)
{
FString str = Text[Text.Size() - 1].Text + source;
lines = V_BreakLines (printFont, formatwidth, str);
}
else
{
lines = V_BreakLines (printFont, formatwidth, source);
if (AddType == APPENDLINE)
{
AddType = NEWLINE;
}
}
if (lines.Size() == 0)
return;
for (auto &line : lines)
{
FNotifyText newline;
newline.Text = line.Text;
newline.TimeOut = int(keeptime * GameTicRate);
newline.Ticker = 0;
newline.PrintLevel = printlevel;
if (AddType == NEWLINE || Text.Size() == 0)
{
if (maxlines > 0)
{
Shift(maxlines - 1);
}
Text.Push(newline);
}
else
{
Text[Text.Size() - 1] = newline;
}
AddType = NEWLINE;
}
switch (source[source.Len()-1])
{
case '\r': AddType = REPLACELINE; break;
case '\n': AddType = NEWLINE; break;
default: AddType = APPENDLINE; break;
}
TopGoal = 0;
}
void FNotifyBufferBase::Tick()
{
if (TopGoal > Top)
{
Top++;
}
else if (TopGoal < Top)
{
Top--;
}
// Remove lines from the beginning that have expired.
unsigned i;
for (i = 0; i < Text.Size(); ++i)
{
Text[i].Ticker++;
}
for (i = 0; i < Text.Size(); ++i)
{
if (Text[i].TimeOut != 0 && Text[i].TimeOut > Text[i].Ticker)
break;
}
if (i > 0)
{
Text.Delete(0, i);
Top += LineHeight;
}
}

View file

@ -0,0 +1,39 @@
#pragma once
#include "zstring.h"
#include "tarray.h"
class FFont;
struct FNotifyText
{
int TimeOut;
int Ticker;
int PrintLevel;
FString Text;
};
class FNotifyBufferBase
{
public:
virtual ~FNotifyBufferBase() = default;
virtual void AddString(int printlevel, FString source) = 0;
virtual void Shift(int maxlines);
virtual void Clear();
virtual void Tick();
virtual void Draw() = 0;
protected:
TArray<FNotifyText> Text;
int Top = 0;
int TopGoal = 0;
int LineHeight = 0;
enum { NEWLINE, APPENDLINE, REPLACELINE } AddType = NEWLINE;
void AddString(int printlevel, FFont *printFont, const FString &source, int formatwidth, float keeptime, int maxlines);
};

View file

@ -35,44 +35,36 @@
#include <string> #include <string>
#include "templates.h" #include "templates.h"
#include "p_setup.h"
#include "i_system.h"
#include "version.h" #include "version.h"
#include "g_game.h"
#include "c_bind.h" #include "c_bind.h"
#include "c_console.h" #include "c_console.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "hu_stuff.h" #include "gamestate.h"
#include "i_system.h"
#include "i_video.h"
#include "g_input.h"
#include "v_palette.h"
#include "v_video.h"
#include "v_text.h" #include "v_text.h"
#include "filesystem.h" #include "filesystem.h"
#include "sbar.h"
#include "s_sound.h"
#include "doomstat.h"
#include "d_gui.h" #include "d_gui.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "d_net.h"
#include "d_event.h" #include "d_event.h"
#include "d_player.h"
#include "gstrings.h"
#include "c_consolebuffer.h" #include "c_consolebuffer.h"
#include "g_levellocals.h"
#include "vm.h"
#include "utf8.h" #include "utf8.h"
#include "s_music.h" #include "v_2ddrawer.h"
#include "v_draw.h"
#include "v_font.h"
#include "printf.h"
#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 "i_interface.h"
#include "v_video.h"
#include "i_system.h"
#include "gi.h" #include "menu.h"
#include "menustate.h"
#include "v_2ddrawer.h"
#include "c_notifybufferbase.h"
#include "g_input.h"
#include "c_commandbuffer.h" #include "c_commandbuffer.h"
#include "vm.h"
#define LEFTMARGIN 8 #define LEFTMARGIN 8
#define RIGHTMARGIN 8 #define RIGHTMARGIN 8
@ -84,13 +76,23 @@ CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
if (self >= 0 && self < 128) self = 128; if (self >= 0 && self < 128) self = 128;
} }
double NotifyFontScale = 1;
DEFINE_GLOBAL(NotifyFontScale)
void C_SetNotifyFontScale(double scale)
{
NotifyFontScale = scale;
}
FConsoleBuffer *conbuffer; FConsoleBuffer *conbuffer;
static FTextureID conback; static FTextureID conback;
static uint32_t conshade; static uint32_t conshade;
static bool conline; static bool conline;
extern int chatmodeon;
extern FBaseCVar *CVars; extern FBaseCVar *CVars;
extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE]; extern FConsoleCommand *Commands[FConsoleCommand::HASH_SIZE];
@ -101,15 +103,6 @@ int ConBottom, ConScroll, RowAdjust;
uint64_t CursorTicker; uint64_t CursorTicker;
constate_e ConsoleState = c_up; constate_e ConsoleState = c_up;
double NotifyFontScale = 1;
DEFINE_GLOBAL(NotifyFontScale)
void C_SetNotifyFontScale(double scale)
{
NotifyFontScale = scale;
}
static int TopLine, InsertLine; static int TopLine, InsertLine;
static void ClearConsole (); static void ClearConsole ();
@ -128,20 +121,10 @@ static GameAtExit *ExitCmdList;
#define SCROLLDN 2 #define SCROLLDN 2
#define SCROLLNO 0 #define SCROLLNO 0
EXTERN_CVAR (Bool, show_messages)
// Buffer for AddToConsole() // Buffer for AddToConsole()
static char *work = NULL; static char *work = NULL;
static int worklen = 0; static int worklen = 0;
CVAR(Float, con_notifytime, 3.f, CVAR_ARCHIVE)
CVAR(Bool, con_centernotify, false, CVAR_ARCHIVE)
CUSTOM_CVAR(Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high resolutions?
{
if (self < 0) self = 0;
}
CVAR(Bool, con_pulsetext, false, CVAR_ARCHIVE)
CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE) CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE)
{ {
if (self < 0) self = 0; if (self < 0) self = 0;
@ -153,6 +136,13 @@ CUSTOM_CVAR(Float, con_alpha, 0.75f, CVAR_ARCHIVE)
if (self > 1.f) self = 1.f; if (self > 1.f) self = 1.f;
} }
// Show developer messages if true.
CUSTOM_CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
FScriptPosition::Developer = self;
}
// Command to run when Ctrl-D is pressed at start of line // Command to run when Ctrl-D is pressed at start of line
CVAR(String, con_ctrl_d, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(String, con_ctrl_d, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -168,51 +158,15 @@ struct History
static struct History *HistHead = NULL, *HistTail = NULL, *HistPos = NULL; static struct History *HistHead = NULL, *HistTail = NULL, *HistPos = NULL;
static int HistSize; static int HistSize;
#define NUMNOTIFIES 4 static FNotifyBufferBase *NotifyStrings;
#define NOTIFYFADETIME 6
struct FNotifyText void C_SetNotifyBuffer(FNotifyBufferBase* nbb)
{ {
int TimeOut; NotifyStrings = nbb;
int Ticker;
int PrintLevel;
FString Text;
};
struct FNotifyBuffer
{
public:
FNotifyBuffer();
void AddString(int printlevel, FString source);
void Shift(int maxlines);
void Clear()
{
Text.Clear();
if (StatusBar == nullptr) return;
IFVIRTUALPTR(StatusBar, DBaseStatusBar, FlushNotify)
{
VMValue params[] = { (DObject*)StatusBar };
VMCall(func, params, countof(params), nullptr, 1);
}
}
void Tick();
void Draw();
private:
TArray<FNotifyText> Text;
int Top;
int TopGoal;
enum { NEWLINE, APPENDLINE, REPLACELINE } AddType;
};
static FNotifyBuffer NotifyStrings;
CUSTOM_CVAR(Int, con_notifylines, NUMNOTIFIES, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
{
NotifyStrings.Shift(self);
} }
int PrintColors[PRINTLEVELS+2] = { CR_UNTRANSLATED, CR_GOLD, CR_GRAY, CR_GREEN, CR_GREEN, CR_UNTRANSLATED }; int PrintColors[PRINTLEVELS+2] = { CR_UNTRANSLATED, CR_GOLD, CR_GRAY, CR_GREEN, CR_GREEN, CR_UNTRANSLATED };
static void setmsgcolor (int index, int color); static void setmsgcolor (int index, int color);
@ -263,7 +217,7 @@ void C_InitConback()
if (!conback.isValid()) if (!conback.isValid())
{ {
conback = TexMan.GetTextureID (gameinfo.TitlePage, ETextureType::MiscPatch); conback.SetInvalid();
conshade = MAKEARGB(175,0,0,0); conshade = MAKEARGB(175,0,0,0);
conline = true; conline = true;
} }
@ -422,101 +376,6 @@ static void setmsgcolor (int index, int color)
PrintColors[index] = color; PrintColors[index] = color;
} }
extern int DisplayWidth;
FNotifyBuffer::FNotifyBuffer()
{
Top = TopGoal = 0;
AddType = NEWLINE;
}
void FNotifyBuffer::Shift(int maxlines)
{
if (maxlines >= 0 && Text.Size() > (unsigned)maxlines)
{
Text.Delete(0, Text.Size() - maxlines);
}
}
void FNotifyBuffer::AddString(int printlevel, FString source)
{
TArray<FBrokenLines> lines;
int width;
if (!show_messages ||
source.IsEmpty() ||
gamestate == GS_FULLCONSOLE ||
gamestate == GS_DEMOSCREEN ||
con_notifylines == 0)
return;
// [MK] allow the status bar to take over notify printing
if (StatusBar != nullptr)
{
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessNotify)
{
VMValue params[] = { (DObject*)StatusBar, printlevel, &source };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
}
width = DisplayWidth / active_con_scaletext(twod, generic_ui);
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
if (font == nullptr) return; // Without an initialized font we cannot handle the message (this is for those which come here before the font system is ready.)
if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel)
{
FString str = Text[Text.Size() - 1].Text + source;
lines = V_BreakLines (font, width, str);
}
else
{
lines = V_BreakLines (font, width, source);
if (AddType == APPENDLINE)
{
AddType = NEWLINE;
}
}
if (lines.Size() == 0)
return;
for (auto &line : lines)
{
FNotifyText newline;
newline.Text = line.Text;
newline.TimeOut = int(con_notifytime * GameTicRate);
newline.Ticker = 0;
newline.PrintLevel = printlevel;
if (AddType == NEWLINE || Text.Size() == 0)
{
if (con_notifylines > 0)
{
Shift(con_notifylines - 1);
}
Text.Push(newline);
}
else
{
Text[Text.Size() - 1] = newline;
}
AddType = NEWLINE;
}
switch (source[source.Len()-1])
{
case '\r': AddType = REPLACELINE; break;
case '\n': AddType = NEWLINE; break;
default: AddType = APPENDLINE; break;
}
TopGoal = 0;
}
void AddToConsole (int printlevel, const char *text) void AddToConsole (int printlevel, const char *text)
{ {
@ -585,9 +444,9 @@ int PrintString (int iprintlevel, const char *outline)
I_PrintStr(outline); I_PrintStr(outline);
conbuffer->AddText(printlevel, outline); conbuffer->AddText(printlevel, outline);
if (vidactive && screen && !(iprintlevel & PRINT_NONOTIFY)) if (vidactive && screen && !(iprintlevel & PRINT_NONOTIFY) && NotifyStrings)
{ {
NotifyStrings.AddString(printlevel, outline); NotifyStrings->AddString(iprintlevel, outline);
} }
} }
if (Logfile != nullptr && !(iprintlevel & PRINT_NOLOG)) if (Logfile != nullptr && !(iprintlevel & PRINT_NOLOG))
@ -599,11 +458,6 @@ int PrintString (int iprintlevel, const char *outline)
return 0; // Don't waste time on calculating this if nothing at all was printed... return 0; // Don't waste time on calculating this if nothing at all was printed...
} }
void C_ClearMessages()
{
NotifyStrings.Clear();
}
int VPrintf (int printlevel, const char *format, va_list parms) int VPrintf (int printlevel, const char *format, va_list parms)
{ {
FString outline; FString outline;
@ -655,7 +509,7 @@ int DPrintf (int level, const char *format, ...)
void C_FlushDisplay () void C_FlushDisplay ()
{ {
NotifyStrings.Clear(); if (NotifyStrings) NotifyStrings->Clear();
} }
void C_AdjustBottom () void C_AdjustBottom ()
@ -710,101 +564,7 @@ void C_Ticker()
} }
lasttic = consoletic; lasttic = consoletic;
NotifyStrings.Tick(); if (NotifyStrings) NotifyStrings->Tick();
}
void FNotifyBuffer::Tick()
{
if (TopGoal > Top)
{
Top++;
}
else if (TopGoal < Top)
{
Top--;
}
// Remove lines from the beginning that have expired.
unsigned i;
for (i = 0; i < Text.Size(); ++i)
{
Text[i].Ticker++;
}
for (i = 0; i < Text.Size(); ++i)
{
if (Text[i].TimeOut != 0 && Text[i].TimeOut > Text[i].Ticker)
break;
}
if (i > 0)
{
Text.Delete(0, i);
FFont* font = generic_ui ? NewSmallFont : AlternativeSmallFont;
Top += font->GetHeight();
}
}
void FNotifyBuffer::Draw()
{
bool center = (con_centernotify != 0.f);
int line, lineadv, color, j;
bool canskip;
FFont* font = generic_ui ? NewSmallFont : AlternativeSmallFont;
line = Top + font->GetDisplacement();
canskip = true;
lineadv = font->GetHeight ();
for (unsigned i = 0; i < Text.Size(); ++ i)
{
FNotifyText &notify = Text[i];
if (notify.TimeOut == 0)
continue;
j = notify.TimeOut - notify.Ticker;
if (j > 0)
{
double alpha = (j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1;
if (con_pulsetext)
{
alpha *= 0.7 + 0.3 * sin(I_msTime() / 100.);
}
if (notify.PrintLevel >= PRINTLEVELS)
color = CR_UNTRANSLATED;
else
color = PrintColors[notify.PrintLevel];
int scale = active_con_scaletext(twod, generic_ui);
if (!center)
DrawText(twod, font, color, 0, line, notify.Text,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, twod->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
else
DrawText(twod, font, color, (twod->GetWidth() -
font->StringWidth (notify.Text) * scale) / 2 / scale,
line, notify.Text,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, twod->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
line += lineadv;
canskip = false;
}
else
{
notify.TimeOut = 0;
}
}
if (canskip)
{
Top = TopGoal;
}
} }
void C_DrawConsole () void C_DrawConsole ()
@ -829,9 +589,9 @@ void C_DrawConsole ()
oldbottom = ConBottom; oldbottom = ConBottom;
if (ConsoleState == c_up && gamestate != GS_INTRO && gamestate != GS_INTERMISSION && if (ConsoleState == c_up && gamestate != GS_INTRO && gamestate != GS_INTERMISSION &&
gamestate != GS_FULLCONSOLE && gamestate == GS_MENUSCREEN) gamestate != GS_FULLCONSOLE && gamestate != GS_MENUSCREEN)
{ {
NotifyStrings.Draw(); if (NotifyStrings) NotifyStrings->Draw();
return; return;
} }
else if (ConBottom) else if (ConBottom)

View file

@ -0,0 +1,179 @@
/*
** c_notifybuffer.cpp
** Implements the buffer for the notification message
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** Copyright 2005-2020 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "c_console.h"
#include "vm.h"
#include "gamestate.h"
#include "c_cvars.h"
#include "sbar.h"
#include "v_video.h"
#include "i_time.h"
#include "c_notifybufferbase.h"
struct FNotifyBuffer : public FNotifyBufferBase
{
public:
void AddString(int printlevel, FString source) override;
void Clear() override;
void Draw() override;
};
static FNotifyBuffer NotifyStrings;
EXTERN_CVAR(Bool, show_messages)
extern bool generic_ui;
CVAR(Float, con_notifytime, 3.f, CVAR_ARCHIVE)
CVAR(Bool, con_centernotify, false, CVAR_ARCHIVE)
CVAR(Bool, con_pulsetext, false, CVAR_ARCHIVE)
CUSTOM_CVAR(Int, con_scaletext, 0, CVAR_ARCHIVE) // Scale notify text at high resolutions?
{
if (self < 0) self = 0;
}
enum { NOTIFYFADETIME = 6 };
CUSTOM_CVAR(Int, con_notifylines, 4, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
{
NotifyStrings.Shift(self);
}
void FNotifyBuffer::Clear()
{
FNotifyBufferBase::Clear();
if (StatusBar == nullptr) return;
IFVIRTUALPTR(StatusBar, DBaseStatusBar, FlushNotify)
{
VMValue params[] = { (DObject*)StatusBar };
VMCall(func, params, countof(params), nullptr, 1);
}
}
void FNotifyBuffer::AddString(int printlevel, FString source)
{
if (!show_messages ||
source.IsEmpty() ||
gamestate == GS_FULLCONSOLE ||
gamestate == GS_DEMOSCREEN ||
con_notifylines == 0)
return;
// [MK] allow the status bar to take over notify printing
if (StatusBar != nullptr)
{
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessNotify)
{
VMValue params[] = { (DObject*)StatusBar, printlevel, &source };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
}
int width = DisplayWidth / active_con_scaletext(twod, generic_ui);
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
FNotifyBufferBase::AddString(printlevel & PRINT_TYPES, font, source, width, con_notifytime, con_notifylines);
}
void FNotifyBuffer::Draw()
{
bool center = (con_centernotify != 0.f);
int line, lineadv, color, j;
bool canskip;
FFont* font = generic_ui ? NewSmallFont : AlternativeSmallFont;
line = Top + font->GetDisplacement();
canskip = true;
lineadv = font->GetHeight ();
for (unsigned i = 0; i < Text.Size(); ++ i)
{
FNotifyText &notify = Text[i];
if (notify.TimeOut == 0)
continue;
j = notify.TimeOut - notify.Ticker;
if (j > 0)
{
double alpha = (j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1;
if (con_pulsetext)
{
alpha *= 0.7 + 0.3 * sin(I_msTime() / 100.);
}
if (notify.PrintLevel >= PRINTLEVELS)
color = CR_UNTRANSLATED;
else
color = PrintColors[notify.PrintLevel];
int scale = active_con_scaletext(twod, generic_ui);
if (!center)
DrawText(twod, font, color, 0, line, notify.Text,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, twod->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
else
DrawText(twod, font, color, (twod->GetWidth() -
font->StringWidth (notify.Text) * scale) / 2 / scale,
line, notify.Text,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, twod->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
line += lineadv;
canskip = false;
}
else
{
notify.TimeOut = 0;
}
}
if (canskip)
{
Top = TopGoal;
}
}
void SetConsoleNotifyBuffer()
{
C_SetNotifyBuffer(&NotifyStrings);
}

View file

@ -52,8 +52,6 @@ enum
}; };
EXTERN_CVAR (Int, con_scaletext)
EXTERN_CVAR (Bool, sb_cooperative_enable) EXTERN_CVAR (Bool, sb_cooperative_enable)
EXTERN_CVAR (Bool, sb_deathmatch_enable) EXTERN_CVAR (Bool, sb_deathmatch_enable)
EXTERN_CVAR (Bool, sb_teamdeathmatch_enable) EXTERN_CVAR (Bool, sb_teamdeathmatch_enable)

View file

@ -151,6 +151,7 @@ void P_Shutdown();
void M_SaveDefaultsFinal(); void M_SaveDefaultsFinal();
void R_Shutdown(); void R_Shutdown();
void I_ShutdownInput(); void I_ShutdownInput();
void SetConsoleNotifyBuffer();
const FIWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad); const FIWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad);
@ -3636,6 +3637,7 @@ int GameMain()
}; };
C_InstallHandlers(&cb); C_InstallHandlers(&cb);
SetConsoleNotifyBuffer();
try try
{ {

View file

@ -51,12 +51,6 @@ CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, alwaysapplydmflags, false, CVAR_SERVERINFO); CVAR(Bool, alwaysapplydmflags, false, CVAR_SERVERINFO);
// Show developer messages if true.
CUSTOM_CVAR(Int, developer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
FScriptPosition::Developer = self;
}
// [RH] Feature control cvars // [RH] Feature control cvars
CVAR(Bool, var_friction, true, CVAR_SERVERINFO); CVAR(Bool, var_friction, true, CVAR_SERVERINFO);

View file

@ -45,8 +45,6 @@
#include "c_console.h" #include "c_console.h"
#include "v_draw.h" #include "v_draw.h"
EXTERN_CVAR(Int, con_scaletext)
IMPLEMENT_CLASS(DHUDMessageBase, false, true) IMPLEMENT_CLASS(DHUDMessageBase, false, true)
IMPLEMENT_POINTERS_START(DHUDMessageBase) IMPLEMENT_POINTERS_START(DHUDMessageBase)
IMPLEMENT_POINTER(Next) IMPLEMENT_POINTER(Next)

View file

@ -86,7 +86,6 @@ EXTERN_CVAR (Bool, am_showitems)
EXTERN_CVAR (Bool, am_showtime) EXTERN_CVAR (Bool, am_showtime)
EXTERN_CVAR (Bool, am_showtotaltime) EXTERN_CVAR (Bool, am_showtotaltime)
EXTERN_CVAR (Bool, noisedebug) EXTERN_CVAR (Bool, noisedebug)
EXTERN_CVAR (Int, con_scaletext)
EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Bool, vid_fps)
EXTERN_CVAR(Bool, inter_subtitles) EXTERN_CVAR(Bool, inter_subtitles)
EXTERN_CVAR(Bool, ui_screenborder_classic_scaling) EXTERN_CVAR(Bool, ui_screenborder_classic_scaling)