Merge branch 'master' of https://github.com/coelckers/gzdoom into vulkan2

This commit is contained in:
Rachael Alexanderson 2019-03-11 22:07:46 -04:00
commit 879aae1bd3
290 changed files with 57672 additions and 346 deletions

View file

@ -1146,6 +1146,7 @@ set (PCH_SOURCES
gamedata/fonts/singlepicfont.cpp
gamedata/fonts/specialfont.cpp
gamedata/fonts/font.cpp
gamedata/fonts/hexfont.cpp
gamedata/fonts/v_font.cpp
gamedata/fonts/v_text.cpp
gamedata/p_xlat.cpp

View file

@ -1199,7 +1199,7 @@ static void PrintSecretString(const char *string, bool thislevel)
else colstr = TEXTCOLOR_GREEN;
}
}
auto brok = V_BreakLines(ConFont, screen->GetWidth()*95/100, string);
auto brok = V_BreakLines(CurrentConsoleFont, screen->GetWidth()*95/100, string);
for (auto &line : brok)
{

View file

@ -32,6 +32,8 @@
**
*/
#include <string>
#include "templates.h"
#include "p_setup.h"
#include "i_system.h"
@ -77,6 +79,9 @@ CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
if (self >= 0 && self < 128) self = 128;
}
CVAR(Bool, con_consolefont, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, con_midconsolefont, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
FConsoleBuffer *conbuffer;
static void C_TabComplete (bool goForward);
@ -126,11 +131,6 @@ static GameAtExit *ExitCmdList;
EXTERN_CVAR (Bool, show_messages)
static unsigned int TickerAt, TickerMax;
static bool TickerPercent;
static const char *TickerLabel;
static bool TickerVisible;
static bool ConsoleDrawing;
// Buffer for AddToConsole()
@ -169,13 +169,13 @@ struct History
struct FCommandBuffer
{
private:
FString Text; // The actual command line text
std::u32string Text;
unsigned CursorPos = 0;
unsigned StartPos = 0; // First character to display
unsigned CursorPosChars = 0;
unsigned StartPosChars = 0;
unsigned CursorPosCells = 0;
unsigned StartPosCells = 0;
FString YankBuffer; // Deleted text buffer
std::u32string YankBuffer; // Deleted text buffer
public:
bool AppendToYankBuffer = false; // Append consecutive deletes to buffer
@ -191,37 +191,39 @@ public:
FString GetText() const
{
return Text;
FString build;
for (auto chr : Text) build.AppendCharacter(chr);
return build;
}
size_t TextLength() const
{
return Text.Len();
return Text.length();
}
void Draw(int x, int y, int scale, bool cursor)
{
if (scale == 1)
{
screen->DrawChar(ConFont, CR_ORANGE, x, y, '\x1c', TAG_DONE);
screen->DrawText(ConFont, CR_ORANGE, x + ConFont->GetCharWidth(0x1c), y,
screen->DrawChar(CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', TAG_DONE);
screen->DrawText(CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
&Text[StartPos], TAG_DONE);
if (cursor)
{
screen->DrawChar(ConFont, CR_YELLOW,
x + ConFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * ConFont->GetCharWidth(0xb),
screen->DrawChar(CurrentConsoleFont, CR_YELLOW,
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb),
y, '\xb', TAG_DONE);
}
}
else
{
screen->DrawChar(ConFont, CR_ORANGE, x, y, '\x1c',
screen->DrawChar(CurrentConsoleFont, CR_ORANGE, x, y, '\x1c',
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true, TAG_DONE);
screen->DrawText(ConFont, CR_ORANGE, x + ConFont->GetCharWidth(0x1c), y,
screen->DrawText(CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
&Text[StartPos],
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
@ -229,8 +231,8 @@ public:
if (cursor)
{
screen->DrawChar(ConFont, CR_YELLOW,
x + ConFont->GetCharWidth(0x1c) + (CursorPosChars - StartPosChars) * ConFont->GetCharWidth(0xb),
screen->DrawChar(CurrentConsoleFont, CR_YELLOW,
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb),
y, '\xb',
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
@ -239,72 +241,99 @@ public:
}
}
unsigned BytesForChars(unsigned chars)
unsigned CalcCellSize(unsigned length)
{
unsigned bytes = 0;
while (chars > 0)
{
if ((Text[bytes++] & 0xc0) != 0x80) chars--;
unsigned cellcount = 0;
for (unsigned i = 0; i < length; i++)
{
int w;
NewConsoleFont->GetChar(Text[i], CR_UNTRANSLATED, &w);
cellcount += w / 9;
}
return bytes;
return cellcount;
}
unsigned CharsForCells(unsigned cellin, bool *overflow)
{
unsigned chars = 0;
int cells = cellin;
while (cells > 0)
{
int w;
NewConsoleFont->GetChar(Text[chars++], CR_UNTRANSLATED, &w);
cells -= w / 9;
}
*overflow = (cells < 0);
return chars;
}
void MakeStartPosGood()
{
int n = StartPosChars;
// Make sure both values point to something valid.
if (CursorPos > Text.length()) CursorPos = (unsigned)Text.length();
if (StartPos > Text.length()) StartPos = (unsigned)Text.length();
CursorPosCells = CalcCellSize(CursorPos);
StartPosCells = CalcCellSize(StartPos);
unsigned LengthCells = CalcCellSize((unsigned)Text.length());
int n = StartPosCells;
unsigned cols = ConCols / active_con_scale();
if (StartPosChars >= Text.CharacterCount())
if (StartPosCells >= LengthCells)
{ // Start of visible line is beyond end of line
n = CursorPosChars - cols + 2;
n = CursorPosCells - cols + 2;
}
if ((CursorPosChars - StartPosChars) >= cols - 2)
if ((CursorPosCells - StartPosCells) >= cols - 2)
{ // The cursor is beyond the visible part of the line
n = CursorPosChars - cols + 2;
n = CursorPosCells - cols + 2;
}
if (StartPosChars > CursorPosChars)
if (StartPosCells > CursorPosCells)
{ // The cursor is in front of the visible part of the line
n = CursorPosChars;
n = CursorPosCells;
}
StartPosCells = MAX(0, n);
bool overflow;
StartPos = CharsForCells(StartPosCells, &overflow);
if (overflow)
{
// We ended up in the middle of a double cell character, so set the start to the following character.
StartPosCells++;
StartPos = CharsForCells(StartPosCells, &overflow);
}
StartPosChars = MAX(0, n);
StartPos = BytesForChars(StartPosChars);
}
void CursorStart()
{
CursorPos = 0;
StartPos = 0;
CursorPosChars = 0;
StartPosChars = 0;
CursorPosCells = 0;
StartPosCells = 0;
}
void CursorEnd()
{
CursorPos = (unsigned)Text.Len();
CursorPosChars = (unsigned)Text.CharacterCount();
StartPosChars = 0;
CursorPos = (unsigned)Text.length();
MakeStartPosGood();
}
private:
void MoveCursorLeft()
{
CursorPosChars--;
do CursorPos--;
while ((Text[CursorPos] & 0xc0) == 0x80); // Step back to the last non-continuation byte.
CursorPos--;
}
void MoveCursorRight()
{
CursorPosChars++;
do CursorPos++;
while ((Text[CursorPos] & 0xc0) == 0x80); // Step back to the last non-continuation byte.
CursorPos++;
}
public:
void CursorLeft()
{
if (CursorPosChars > 0)
if (CursorPos > 0)
{
MoveCursorLeft();
MakeStartPosGood();
@ -313,7 +342,7 @@ public:
void CursorRight()
{
if (CursorPosChars < Text.CharacterCount())
if (CursorPos < Text.length())
{
MoveCursorRight();
MakeStartPosGood();
@ -322,20 +351,20 @@ public:
void CursorWordLeft()
{
if (CursorPosChars > 0)
if (CursorPos > 0)
{
do MoveCursorLeft();
while (CursorPosChars > 0 && Text[CursorPos - 1] != ' ');
while (CursorPos > 0 && Text[CursorPos - 1] != ' ');
MakeStartPosGood();
}
}
void CursorWordRight()
{
if (CursorPosChars < Text.CharacterCount())
if (CursorPos < Text.length())
{
do MoveCursorRight();
while (CursorPosChars < Text.CharacterCount() && Text[CursorPos] != ' ');
while (CursorPos < Text.length() && Text[CursorPos] != ' ');
MakeStartPosGood();
}
}
@ -344,22 +373,17 @@ public:
{
if (CursorPos > 0)
{
auto now = CursorPos;
MoveCursorLeft();
Text.Remove(CursorPos, now - CursorPos);
Text.erase(CursorPos, 1);
MakeStartPosGood();
}
}
void DeleteRight()
{
if (CursorPosChars < Text.CharacterCount())
if (CursorPos < Text.length())
{
auto now = CursorPos;
MoveCursorRight();
Text.Remove(now, CursorPos - now);
CursorPos = now;
CursorPosChars--;
Text.erase(CursorPos, 1);
MakeStartPosGood();
}
}
@ -373,11 +397,11 @@ public:
CursorWordLeft();
if (AppendToYankBuffer) {
YankBuffer = FString(&Text[CursorPos], now - CursorPos) + YankBuffer;
YankBuffer = Text.substr(CursorPos, now - CursorPos) + YankBuffer;
} else {
YankBuffer = FString(&Text[CursorPos], now - CursorPos);
YankBuffer = Text.substr(CursorPos, now - CursorPos);
}
Text.Remove(CursorPos, now - CursorPos);
Text.erase(CursorPos, now - CursorPos);
MakeStartPosGood();
}
}
@ -387,47 +411,41 @@ public:
if (CursorPos > 0)
{
if (AppendToYankBuffer) {
YankBuffer = FString(&Text[0], CursorPos) + YankBuffer;
YankBuffer = Text.substr(0, CursorPos) + YankBuffer;
} else {
YankBuffer = FString(&Text[0], CursorPos);
YankBuffer = Text.substr(0, CursorPos);
}
Text.Remove(0, CursorPos);
Text.erase(0, CursorPos);
CursorStart();
}
}
void DeleteLineRight()
{
if (CursorPos < Text.Len())
if (CursorPos < Text.length())
{
if (AppendToYankBuffer) {
YankBuffer += FString(&Text[CursorPos], Text.Len() - CursorPos);
YankBuffer += Text.substr(CursorPos, Text.length() - CursorPos);
} else {
YankBuffer = FString(&Text[CursorPos], Text.Len() - CursorPos);
YankBuffer = Text.substr(CursorPos, Text.length() - CursorPos);
}
Text.Truncate(CursorPos);
Text.resize(CursorPos);
CursorEnd();
}
}
void AddChar(int character)
{
int size;
auto encoded = MakeUTF8(character, &size);
if (*encoded != 0)
if (Text.length() == 0)
{
if (Text.IsEmpty())
{
Text = encoded;
}
else
{
Text.Insert(CursorPos, (char*)encoded);
}
CursorPos += size;
CursorPosChars++;
MakeStartPosGood();
Text += character;
}
else
{
Text.insert(CursorPos, 1, character);
}
CursorPos++;
MakeStartPosGood();
}
void AddString(FString clip)
@ -436,35 +454,52 @@ public:
{
// Only paste the first line.
long brk = clip.IndexOfAny("\r\n\b");
std::u32string build;
if (brk >= 0)
{
clip.Truncate(brk);
clip = MakeUTF8(clip.GetChars()); // Make sure that we actually have UTF-8 text.
}
if (Text.IsEmpty())
auto strp = (const uint8_t*)clip.GetChars();
while (auto chr = GetCharFromString(strp)) build += chr;
if (Text.length() == 0)
{
Text = clip;
Text = build;
}
else
{
Text.Insert(CursorPos, clip);
Text.insert(CursorPos, build);
}
CursorPos += (unsigned)clip.Len();
CursorPosChars += (unsigned)clip.CharacterCount();
CursorPos += (unsigned)build.length();
MakeStartPosGood();
}
}
void SetString(const FString &str)
{
Text = MakeUTF8(str);
Text.clear();
auto strp = (const uint8_t*)str.GetChars();
while (auto chr = GetCharFromString(strp)) Text += chr;
CursorEnd();
MakeStartPosGood();
}
void AddYankBuffer()
{
AddString(YankBuffer);
if (YankBuffer.length() > 0)
{
if (Text.length() == 0)
{
Text = YankBuffer;
}
else
{
Text.insert(CursorPos, YankBuffer);
}
CursorPos += (unsigned)YankBuffer.length();
MakeStartPosGood();
}
}
};
static FCommandBuffer CmdLine;
@ -594,6 +629,12 @@ void DequeueConsoleText ()
EnqueuedTextTail = &EnqueuedText;
}
EColorRange C_GetDefaultFontColor()
{
// Ideally this should analyze the SmallFont and pick a matching color.
return gameinfo.gametype == GAME_Doom ? CR_RED : gameinfo.gametype == GAME_Chex ? CR_GREEN : gameinfo.gametype == GAME_Strife ? CR_GOLD : CR_GRAY;
}
void C_InitConback()
{
conback = TexMan.CheckForTexture ("CONBACK", ETextureType::MiscPatch);
@ -616,10 +657,10 @@ void C_InitConsole (int width, int height, bool ingame)
int cwidth, cheight;
vidactive = ingame;
if (ConFont != NULL)
if (CurrentConsoleFont != NULL)
{
cwidth = ConFont->GetCharWidth ('M');
cheight = ConFont->GetHeight();
cwidth = CurrentConsoleFont->GetCharWidth ('M');
cheight = CurrentConsoleFont->GetHeight();
}
else
{
@ -792,16 +833,18 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
return;
}
width = DisplayWidth / active_con_scaletext();
width = DisplayWidth / active_con_scaletext(con_consolefont);
FFont *font = *con_consolefont ? NewConsoleFont : SmallFont;
if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel)
{
FString str = Text[Text.Size() - 1].Text + source;
lines = V_BreakLines (SmallFont, width, str);
lines = V_BreakLines (font, width, str);
}
else
{
lines = V_BreakLines (SmallFont, width, source);
lines = V_BreakLines (font, width, source);
if (AddType == APPENDLINE)
{
AddType = NEWLINE;
@ -1036,7 +1079,8 @@ void FNotifyBuffer::Draw()
line = Top;
canskip = true;
lineadv = SmallFont->GetHeight ();
FFont *font = *con_consolefont ? NewConsoleFont : SmallFont;
lineadv = font->GetHeight ();
for (unsigned i = 0; i < Text.Size(); ++ i)
{
@ -1058,15 +1102,19 @@ void FNotifyBuffer::Draw()
else
color = PrintColors[notify.PrintLevel];
int scale = active_con_scaletext();
if (color == CR_UNTRANSLATED && *con_consolefont)
{
color = C_GetDefaultFontColor();
}
int scale = active_con_scaletext(con_consolefont);
if (!center)
screen->DrawText (SmallFont, color, 0, line, notify.Text,
screen->DrawText (font, color, 0, line, notify.Text,
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
else
screen->DrawText (SmallFont, color, (screen->GetWidth() -
screen->DrawText (font, color, (screen->GetWidth() -
SmallFont->StringWidth (notify.Text) * scale) / 2 / scale,
line, notify.Text,
DTA_VirtualWidth, screen->GetWidth() / scale,
@ -1092,19 +1140,6 @@ void FNotifyBuffer::Draw()
}
}
void C_InitTicker (const char *label, unsigned int max, bool showpercent)
{
TickerPercent = showpercent;
TickerMax = max;
TickerLabel = label;
TickerAt = 0;
}
void C_SetTicker (unsigned int at, bool forceUpdate)
{
TickerAt = at > TickerMax ? TickerMax : at;
}
void C_DrawConsole ()
{
static int oldbottom = 0;
@ -1113,15 +1148,15 @@ void C_DrawConsole ()
int textScale = active_con_scale();
left = LEFTMARGIN;
lines = (ConBottom/textScale-ConFont->GetHeight()*2)/ConFont->GetHeight();
if (-ConFont->GetHeight() + lines*ConFont->GetHeight() > ConBottom/textScale - ConFont->GetHeight()*7/2)
lines = (ConBottom/textScale-CurrentConsoleFont->GetHeight()*2)/CurrentConsoleFont->GetHeight();
if (-CurrentConsoleFont->GetHeight() + lines*CurrentConsoleFont->GetHeight() > ConBottom/textScale - CurrentConsoleFont->GetHeight()*7/2)
{
offset = -ConFont->GetHeight()/2;
offset = -CurrentConsoleFont->GetHeight()/2;
lines--;
}
else
{
offset = -ConFont->GetHeight();
offset = -CurrentConsoleFont->GetHeight();
}
oldbottom = ConBottom;
@ -1153,71 +1188,19 @@ void C_DrawConsole ()
if (ConBottom >= 12)
{
if (textScale == 1)
screen->DrawText (ConFont, CR_ORANGE, SCREENWIDTH - 8 -
ConFont->StringWidth (GetVersionString()),
ConBottom / textScale - ConFont->GetHeight() - 4,
screen->DrawText (CurrentConsoleFont, CR_ORANGE, SCREENWIDTH - 8 -
CurrentConsoleFont->StringWidth (GetVersionString()),
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
GetVersionString(), TAG_DONE);
else
screen->DrawText(ConFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
ConFont->StringWidth(GetVersionString()),
ConBottom / textScale - ConFont->GetHeight() - 4,
screen->DrawText(CurrentConsoleFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
CurrentConsoleFont->StringWidth(GetVersionString()),
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
GetVersionString(),
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
if (TickerMax)
{
char tickstr[256];
const int tickerY = ConBottom / textScale - ConFont->GetHeight() - 4;
size_t i;
int tickend = ConCols / textScale - SCREENWIDTH / textScale / 90 - 6;
int tickbegin = 0;
if (TickerLabel)
{
tickbegin = (int)strlen (TickerLabel) + 2;
mysnprintf (tickstr, countof(tickstr), "%s: ", TickerLabel);
}
if (tickend > 256 - ConFont->GetCharWidth(0x12))
tickend = 256 - ConFont->GetCharWidth(0x12);
tickstr[tickbegin] = 0x10;
memset (tickstr + tickbegin + 1, 0x11, tickend - tickbegin);
tickstr[tickend + 1] = 0x12;
tickstr[tickend + 2] = ' ';
if (TickerPercent)
{
mysnprintf (tickstr + tickend + 3, countof(tickstr) - tickend - 3,
"%d%%", Scale (TickerAt, 100, TickerMax));
}
else
{
tickstr[tickend+3] = 0;
}
if (textScale == 1)
screen->DrawText (ConFont, CR_BROWN, LEFTMARGIN, tickerY, tickstr, TAG_DONE);
else
screen->DrawText (ConFont, CR_BROWN, LEFTMARGIN, tickerY, tickstr,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
// Draw the marker
i = LEFTMARGIN+5+tickbegin*8 + Scale (TickerAt, (int32_t)(tickend - tickbegin)*8, TickerMax);
if (textScale == 1)
screen->DrawChar (ConFont, CR_ORANGE, (int)i, tickerY, 0x13, TAG_DONE);
else
screen->DrawChar(ConFont, CR_ORANGE, (int)i, tickerY, 0x13,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
TickerVisible = true;
}
else
{
TickerVisible = false;
}
}
}
@ -1230,12 +1213,12 @@ void C_DrawConsole ()
if (lines > 0)
{
// No more enqueuing because adding new text to the console won't touch the actual print data.
conbuffer->FormatText(ConFont, ConWidth / textScale);
conbuffer->FormatText(CurrentConsoleFont, ConWidth / textScale);
unsigned int consolelines = conbuffer->GetFormattedLineCount();
FBrokenLines *blines = conbuffer->GetLines();
FBrokenLines *printline = blines + consolelines - 1 - RowAdjust;
int bottomline = ConBottom / textScale - ConFont->GetHeight()*2 - 4;
int bottomline = ConBottom / textScale - CurrentConsoleFont->GetHeight()*2 - 4;
ConsoleDrawing = true;
@ -1243,11 +1226,11 @@ void C_DrawConsole ()
{
if (textScale == 1)
{
screen->DrawText(ConFont, CR_TAN, LEFTMARGIN, offset + lines * ConFont->GetHeight(), p->Text, TAG_DONE);
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
}
else
{
screen->DrawText(ConFont, CR_TAN, LEFTMARGIN, offset + lines * ConFont->GetHeight(), p->Text,
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
@ -1262,14 +1245,14 @@ void C_DrawConsole ()
{
CmdLine.Draw(left, bottomline, textScale, cursoron);
}
if (RowAdjust && ConBottom >= ConFont->GetHeight()*7/2)
if (RowAdjust && ConBottom >= CurrentConsoleFont->GetHeight()*7/2)
{
// Indicate that the view has been scrolled up (10)
// and if we can scroll no further (12)
if (textScale == 1)
screen->DrawChar (ConFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
screen->DrawChar (CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
else
screen->DrawChar(ConFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
screen->DrawChar(CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
@ -1404,7 +1387,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer up one page
RowAdjust += (SCREENHEIGHT-4)/active_con_scale() /
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? ConFont->GetHeight() : ConFont->GetHeight()*2) - 3;
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
}
else if (RowAdjust < conbuffer->GetFormattedLineCount())
{ // Scroll console buffer up
@ -1427,7 +1410,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer down one page
const int scrollamt = (SCREENHEIGHT-4)/active_con_scale() /
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? ConFont->GetHeight() : ConFont->GetHeight()*2) - 3;
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
if (RowAdjust < scrollamt)
{
RowAdjust = 0;
@ -1795,8 +1778,18 @@ void C_MidPrint (FFont *font, const char *msg)
AddToConsole (-1, msg);
AddToConsole (-1, bar3);
auto color = (EColorRange)PrintColors[PRINTLEVELS];
bool altscale = false;
if (font == nullptr)
{
altscale = con_midconsolefont;
font = altscale ? NewConsoleFont : SmallFont;
if (altscale && color == CR_UNTRANSLATED) color = C_GetDefaultFontColor();
}
StatusBar->AttachMessage (Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0,
(EColorRange)PrintColors[PRINTLEVELS], con_midtime), MAKE_ID('C','N','T','R'));
color, con_midtime, altscale), MAKE_ID('C','N','T','R'));
}
else
{
@ -1812,8 +1805,17 @@ void C_MidPrintBold (FFont *font, const char *msg)
AddToConsole (-1, msg);
AddToConsole (-1, bar3);
auto color = (EColorRange)PrintColors[PRINTLEVELS+1];
bool altscale = false;
if (font == nullptr)
{
altscale = con_midconsolefont;
font = altscale ? NewConsoleFont : SmallFont;
if (altscale && color == CR_UNTRANSLATED) color = C_GetDefaultFontColor();
}
StatusBar->AttachMessage (Create<DHUDMessage> (font, msg, 1.5f, 0.375f, 0, 0,
(EColorRange)PrintColors[PRINTLEVELS+1], con_midtime), MAKE_ID('C','N','T','R'));
color, con_midtime, altscale), MAKE_ID('C','N','T','R'));
}
else
{
@ -1824,7 +1826,7 @@ void C_MidPrintBold (FFont *font, const char *msg)
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER_NOT_NULL(fnt, FFont);
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);

View file

@ -47,7 +47,10 @@ typedef enum cstate_t
}
constate_e;
#define PRINTLEVELS 5
enum
{
PRINTLEVELS = 5
};
extern int PrintColors[PRINTLEVELS + 2];
extern constate_e ConsoleState;
@ -74,9 +77,6 @@ void C_HideConsole (void);
void C_AdjustBottom (void);
void C_FlushDisplay (void);
void C_InitTicker (const char *label, unsigned int max, bool showpercent=true);
void C_SetTicker (unsigned int at, bool forceUpdate=false);
class FFont;
void C_MidPrint (FFont *font, const char *message);
void C_MidPrintBold (FFont *font, const char *message);

View file

@ -563,7 +563,7 @@ void C_DoCommand (const char *cmd, int keynum)
const char *beg;
// Skip any beginning whitespace
while (*cmd && *cmd <= ' ')
while (*cmd > 0 && *cmd <= ' ')
cmd++;
// Find end of the command name
@ -575,7 +575,7 @@ void C_DoCommand (const char *cmd, int keynum)
else
{
beg = cmd;
for (end = cmd+1; *end > ' '; ++end)
for (end = cmd+1; *end > ' ' || *end < 0; ++end)
;
}
@ -728,7 +728,7 @@ void AddCommandString (const char *text, int keynum)
more = 0;
}
// Intercept wait commands here. Note: wait must be lowercase
while (*cmd && *cmd <= ' ')
while (*cmd > 0 && *cmd <= ' ')
cmd++;
if (*cmd)
{

View file

@ -40,6 +40,7 @@
#include "sbar.h"
#include "v_video.h"
#include "utf8.h"
#include "gstrings.h"
enum
{
@ -233,16 +234,16 @@ void CT_PasteChat(const char *clip)
void CT_Drawer (void)
{
FFont *displayfont = ConFont;
FFont *displayfont = NewConsoleFont;
if (chatmodeon)
{
static const char *prompt = "Say: ";
FStringf prompt("%s ", GStrings("TXT_SAY"));
int x, scalex, y, promptwidth;
y = (viewactive || gamestate != GS_LEVEL) ? -10 : -30;
y = (viewactive || gamestate != GS_LEVEL) ? -displayfont->GetHeight()-2 : -displayfont->GetHeight() - 22;
scalex = 1;
int scale = active_con_scaletext();
int scale = active_con_scaletext(true);
int screen_width = SCREENWIDTH / scale;
int screen_height= SCREENHEIGHT / scale;
int st_y = StatusBar->GetTopOfStatusbar() / scale;
@ -264,7 +265,7 @@ void CT_Drawer (void)
}
printstr += displayfont->GetCursor();
screen->DrawText (displayfont, CR_GREEN, 0, y, prompt,
screen->DrawText (displayfont, CR_GREEN, 0, y, prompt.GetChars(),
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
screen->DrawText (displayfont, CR_GREY, promptwidth, y, printstr,
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);

View file

@ -2169,7 +2169,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_CENTERPRINT:
s = ReadString (stream);
C_MidPrint (SmallFont, s);
C_MidPrint (nullptr, s);
break;
case DEM_UINFCHANGED:

View file

@ -623,7 +623,7 @@ void FParser::SF_Tip(void)
if (t_argc>0 && Script->trigger &&
Script->trigger->CheckLocalView())
{
C_MidPrint(SmallFont, GetFormatString(0).GetChars());
C_MidPrint(nullptr, GetFormatString(0).GetChars());
}
}
@ -643,7 +643,7 @@ void FParser::SF_TimedTip(void)
{
float saved = con_midtime;
con_midtime = intvalue(t_argv[0])/100.0f;
C_MidPrint(SmallFont, GetFormatString(1).GetChars());
C_MidPrint(nullptr, GetFormatString(1).GetChars());
con_midtime=saved;
}
}
@ -662,7 +662,7 @@ void FParser::SF_PlayerTip(void)
int plnum = T_GetPlayerNum(t_argv[0]);
if (plnum!=-1 && Level->Players[plnum]->mo->CheckLocalView())
{
C_MidPrint(SmallFont, GetFormatString(1).GetChars());
C_MidPrint(nullptr, GetFormatString(1).GetChars());
}
}
}

View file

@ -2054,7 +2054,7 @@ void G_DoAutoSave ()
}
readableTime = myasctime ();
description.Format("Autosave %.12s", readableTime + 4);
description.Format("Autosave %s", readableTime);
G_DoSaveGame (false, file, description);
}
@ -2077,14 +2077,9 @@ static void PutSaveWads (FSerializer &arc)
static void PutSaveComment (FSerializer &arc)
{
const char *readableTime;
int levelTime;
// Get the current date and time
readableTime = myasctime ();
FString comment;
comment.Format("%.10s%.5s%.9s", readableTime, &readableTime[19], &readableTime[10]);
FString comment = myasctime();
arc.AddString("Creation Time", comment);

View file

@ -2142,9 +2142,9 @@ int IsPointInMap(FLevelLocals *Level, double x, double y, double z)
for (uint32_t i = 0; i < subsector->numlines; i++)
{
// Skip single sided lines.
// Skip double sided lines.
seg_t *seg = subsector->firstline + i;
if (seg->backsector != nullptr) continue;
if (seg->backsector != nullptr || seg->linedef == nullptr) continue;
divline_t dline;
P_MakeDivline(seg->linedef, &dline);

View file

@ -128,7 +128,7 @@ void DHUDMessageBase::CallDraw(int bottom, int visibility)
//============================================================================
DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
EColorRange textColor, float holdTime)
EColorRange textColor, float holdTime, bool altscale)
{
if (hudwidth == 0 || hudheight == 0)
{
@ -139,6 +139,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h
// for x range [0.0, 1.0]: Positions center of box
// for x range [1.0, 2.0]: Positions center of box, and centers text inside it
HUDWidth = HUDHeight = 0;
AltScale = altscale;
if (fabs (x) > 2.f)
{
CenterX = true;
@ -319,7 +320,7 @@ void DHUDMessage::ResetText (const char *text)
}
else
{
width = SCREENWIDTH / active_con_scaletext();
width = SCREENWIDTH / active_con_scaletext(AltScale);
}
Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (uint8_t *)text);
@ -379,7 +380,7 @@ void DHUDMessage::Draw (int bottom, int visibility)
xscale = yscale = 1;
if (HUDWidth == 0)
{
int scale = active_con_scaletext();
int scale = active_con_scaletext(AltScale);
screen_width /= scale;
screen_height /= scale;
bottom /= scale;
@ -483,7 +484,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight)
{
if (hudheight == 0)
{
int scale = active_con_scaletext();
int scale = active_con_scaletext(AltScale);
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH / scale,
DTA_VirtualHeight, SCREENHEIGHT / scale,
@ -576,7 +577,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh
float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics);
if (hudheight == 0)
{
int scale = active_con_scaletext();
int scale = active_con_scaletext(AltScale);
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH / scale,
DTA_VirtualHeight, SCREENHEIGHT / scale,
@ -665,7 +666,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu
float trans = float(Alpha * Tics / FadeInTics);
if (hudheight == 0)
{
int scale = active_con_scaletext();
int scale = active_con_scaletext(AltScale);
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH / scale,
DTA_VirtualHeight, SCREENHEIGHT / scale,
@ -741,7 +742,7 @@ void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc)
bool DHUDMessageTypeOnFadeOut::Tick ()
{
if (LineLen > 0 && !Super::Tick ())
if (!Super::Tick ())
{
if (State == 3)
{
@ -836,7 +837,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in
{
if (hudheight == 0)
{
int scale = active_con_scaletext();
int scale = active_con_scaletext(AltScale);
screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text,
DTA_VirtualWidth, SCREENWIDTH / scale,
DTA_VirtualHeight, SCREENHEIGHT / scale,

View file

@ -84,7 +84,7 @@ class DHUDMessage : public DHUDMessageBase
DECLARE_CLASS (DHUDMessage, DHUDMessageBase)
public:
DHUDMessage (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
EColorRange textColor, float holdTime);
EColorRange textColor, float holdTime, bool altscale = false);
virtual void OnDestroy () override;
virtual void Serialize(FSerializer &arc);
@ -140,6 +140,7 @@ protected:
int ClipX, ClipY, ClipWidth, ClipHeight, WrapWidth; // in HUD coords
int ClipLeft, ClipTop, ClipRight, ClipBot; // in screen coords
bool HandleAspect;
bool AltScale;
EColorRange TextColor;
FFont *Font;
FRenderStyle Style;

View file

@ -48,6 +48,7 @@
#include "g_levellocals.h"
#include "vm.h"
#include "i_system.h"
#include "utf8.h"
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
enum

View file

@ -58,6 +58,7 @@
#include "gstrings.h"
#include "events.h"
#include "g_game.h"
#include "utf8.h"
#include "../version.h"

View file

@ -220,7 +220,7 @@ static void PrintMessage (const char *str)
{
str = GStrings(str+1);
}
C_MidPrint (SmallFont, str);
C_MidPrint (nullptr, str);
}
}

View file

@ -0,0 +1,238 @@
/*
** bdffont.cpp
** Management for the VGA consolefont
**
**---------------------------------------------------------------------------
** Copyright 2019 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 "doomerrors.h"
#include "textures.h"
#include "image.h"
#include "v_font.h"
#include "w_wad.h"
#include "utf8.h"
#include "sc_man.h"
#include "fontinternals.h"
// This is a font character that reads RLE compressed data.
class FHexFontChar : public FImageSource
{
public:
FHexFontChar(uint8_t *sourcedata, int swidth, int width, int height);
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
protected:
int SourceWidth;
const uint8_t *SourceData;
};
//==========================================================================
//
// FHexFontChar :: FHexFontChar
//
// Used by HEX fonts.
//
//==========================================================================
FHexFontChar::FHexFontChar (uint8_t *sourcedata, int swidth, int width, int height)
: SourceData (sourcedata)
{
SourceWidth = swidth;
Width = width;
Height = height;
LeftOffset = 0;
TopOffset = 0;
}
//==========================================================================
//
// FHexFontChar :: Get8BitPixels
//
// The render style has no relevance here.
//
//==========================================================================
TArray<uint8_t> FHexFontChar::CreatePalettedPixels(int)
{
int destSize = Width * Height;
TArray<uint8_t> Pixels(destSize, true);
uint8_t *dest_p = Pixels.Data();
const uint8_t *src_p = SourceData;
memset(dest_p, 0, destSize);
for (int y = 0; y < Height; y++)
{
for (int x = 0; x < SourceWidth; x++)
{
int byte = *src_p++;
uint8_t *pixelstart = dest_p + 8 * x * Height + y;
for (int bit = 0; bit < 8; bit++)
{
if (byte & (128 >> bit))
{
pixelstart[bit*Height] = y+2;
// Add a shadow at the bottom right, similar to the old console font.
if (y != Height - 1)
{
pixelstart[bit*Height + Height + 1] = 1;
}
}
}
}
}
return Pixels;
}
class FHexFont : public FFont
{
TArray<uint8_t> glyphdata;
unsigned glyphmap[65536] = {};
public:
//==========================================================================
//
// parse a HEX font
//
//==========================================================================
void ParseDefinition(int lumpnum)
{
FScanner sc;
FirstChar = INT_MAX;
LastChar = INT_MIN;
sc.OpenLumpNum(lumpnum);
sc.SetCMode(true);
glyphdata.Push(0); // ensure that index 0 can be used as 'not present'.
while (sc.GetString())
{
int codepoint = (int)strtoull(sc.String, nullptr, 16);
sc.MustGetStringName(":");
sc.MustGetString();
if (codepoint >= 0 && codepoint < 65536 && !sc.Compare("00000000000000000000000000000000")) // don't set up empty glyphs.
{
unsigned size = (unsigned)strlen(sc.String);
unsigned offset = glyphdata.Reserve(size/2 + 1);
glyphmap[codepoint] = offset;
glyphdata[offset++] = size / 2;
for(unsigned i = 0; i < size; i+=2)
{
char hex[] = { sc.String[i], sc.String[i+1], 0 };
glyphdata[offset++] = (uint8_t)strtoull(hex, nullptr, 16);
}
if (codepoint < FirstChar) FirstChar = codepoint;
if (codepoint > LastChar) LastChar = codepoint;
}
}
}
//==========================================================================
//
// FHexFont :: FHexFont
//
// Loads a HEX font
//
//==========================================================================
FHexFont (const char *fontname, int lump)
: FFont(lump)
{
assert(lump >= 0);
FontName = fontname;
ParseDefinition(lump);
Next = FirstFont;
FirstFont = this;
FontHeight = 16;
SpaceWidth = 9;
GlobalKerning = 0;
translateUntranslated = true;
LoadTranslations();
}
//==========================================================================
//
// FHexFont :: LoadTranslations
//
//==========================================================================
void LoadTranslations()
{
const int spacing = 9;
double luminosity[256];
memset (PatchRemap, 0, 256);
for (int i = 0; i < 18; i++)
{
// Create a gradient similar to the old console font.
PatchRemap[i] = i;
luminosity[i] = i == 1? 0.01 : 0.5 + (i-2) * (0.5 / 17.);
}
ActiveColors = 18;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
if (glyphmap[i] > 0)
{
auto offset = glyphmap[i];
int size = glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar (&glyphdata[offset+1], size, size * 9, 16));
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic);
}
else Chars[i - FirstChar].XMove = spacing;
}
BuildTranslations (luminosity, nullptr, &TranslationParms[1][0], ActiveColors, nullptr);
}
};
//==========================================================================
//
//
//
//==========================================================================
FFont *CreateHexLumpFont (const char *fontname, int lump)
{
return new FHexFont(fontname, lump);
}

View file

@ -122,6 +122,7 @@ static const uint16_t loweruppercase[] = {
0x0078,0x0058,
0x0079,0x0059,
0x007A,0x005A,
0x00DF,0x1E9E,
0x00E0,0x00C0,
0x00E1,0x00C1,
0x00E2,0x00C2,
@ -864,7 +865,8 @@ int stripaccent(int code)
FFont *V_GetFont(const char *name, const char *fontlumpname)
{
if (!stricmp(name, "CONFONT")) name = "ConsoleFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
if (!stricmp(name, "DBIGFONT")) name = "BigFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
else if (!stricmp(name, "CONFONT")) name = "ConsoleFont"; // several mods have used the name CONFONT directly and effectively duplicated the font.
FFont *font = FFont::FindFont (name);
if (font == nullptr)
{
@ -1441,6 +1443,13 @@ void V_InitFonts()
InitLowerUpper();
V_InitCustomFonts();
FFont *CreateHexLumpFont(const char *fontname, int lump);
auto lump = Wads.CheckNumForFullName("newconsolefont.hex", 0); // This is always loaded from gzdoom.pk3 to prevent overriding it with incomplete replacements.
if (lump == -1) I_FatalError("newconsolefont.hex not found"); // This font is needed - do not start up without it.
NewConsoleFont = CreateHexLumpFont("NewConsoleFont", lump);
CurrentConsoleFont = NewConsoleFont;
// load the heads-up font
if (!(SmallFont = V_GetFont("SmallFont", "SMALLFNT")))
{
@ -1526,6 +1535,6 @@ void V_ClearFonts()
delete FFont::FirstFont;
}
FFont::FirstFont = nullptr;
SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
CurrentConsoleFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
}

View file

@ -164,7 +164,7 @@ protected:
};
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont;
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *CurrentConsoleFont;
void V_InitFonts();
void V_ClearFonts();

View file

@ -38,6 +38,7 @@
#include <wctype.h>
#include "v_text.h"
#include "utf8.h"
#include "v_video.h"

View file

@ -85,6 +85,4 @@ inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const char
inline TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const FString &str, bool preservecolor = false)
{ return V_BreakLines (font, maxwidth, (const uint8_t *)str.GetChars(), preservecolor); }
int GetCharFromString(const uint8_t *&string);
#endif //__V_TEXT_H__

View file

@ -478,8 +478,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
comment = time;
if (time.Len() > 0) comment += "\n";
comment += pcomment;
SaveComment = V_BreakLines(SmallFont, WindowSize, comment.GetChars());
SaveCommentString = comment;
// Extract pic
FResourceLump *pic = resf->FindLump("savepic.png");
@ -533,9 +532,8 @@ void FSavegameManager::UnloadSaveData()
{
delete SavePic;
}
SaveComment.Clear();
SaveComment.ShrinkToFit();
SaveCommentString = "";
SavePic = nullptr;
SavePicData.Clear();
}
@ -592,46 +590,6 @@ DEFINE_ACTION_FUNCTION(FSavegameManager, DrawSavePic)
ACTION_RETURN_BOOL(self->DrawSavePic(x, y, w, h));
}
//=============================================================================
//
//
//
//=============================================================================
void FSavegameManager::DrawSaveComment(FFont *font, int cr, int x, int y, int scalefactor)
{
int sx = CleanXfac;
int sy = CleanYfac;
CleanXfac = CleanYfac = scalefactor;
int maxlines = screen->GetHeight()>400?10:screen->GetHeight()>240?7:screen->GetHeight()>200?8:5;
if (SmallFont->GetHeight() > 9) maxlines--; // not Doom
// I'm not sure why SaveComment would go nullptr in this loop, but I got
// a crash report where it was nullptr when i reached 1, so now I check
// for that.
for (int i = 0; i < maxlines && (unsigned)i < SaveComment.Size(); ++i)
{
screen->DrawText(font, cr, x, y + font->GetHeight() * i * scalefactor, SaveComment[i].Text, DTA_CleanNoMove, true, TAG_DONE);
}
CleanXfac = sx;
CleanYfac = sy;
}
DEFINE_ACTION_FUNCTION(FSavegameManager, DrawSaveComment)
{
PARAM_SELF_STRUCT_PROLOGUE(FSavegameManager);
PARAM_POINTER(fnt, FFont);
PARAM_INT(cr);
PARAM_INT(x);
PARAM_INT(y);
PARAM_INT(fac);
self->DrawSaveComment(fnt, cr, x, y, fac);
return 0;
}
//=============================================================================
//
//
@ -642,9 +600,7 @@ void FSavegameManager::SetFileInfo(int Selected)
{
if (!SaveGames[Selected]->Filename.IsEmpty())
{
FString work;
work.Format("File on disk:\n%s", SaveGames[Selected]->Filename.GetChars());
SaveComment = V_BreakLines(SmallFont, WindowSize, work);
SaveCommentString.Format("File on disk:\n%s", SaveGames[Selected]->Filename.GetChars());
}
}
@ -753,4 +709,5 @@ DEFINE_FIELD(FSaveGameNode, bNoDelete);
DEFINE_FIELD(FSavegameManager, WindowSize);
DEFINE_FIELD(FSavegameManager, quickSaveSlot);
DEFINE_FIELD(FSavegameManager, SaveCommentString);

View file

@ -74,10 +74,10 @@ private:
int LastAccessed = -1;
TArray<char> SavePicData;
FTexture *SavePic = nullptr;
TArray<FBrokenLines> SaveComment;
public:
int WindowSize = 0;
FString SaveCommentString;
FSaveGameNode *quickSaveSlot = nullptr;
~FSavegameManager();

View file

@ -705,7 +705,7 @@ protected:
TObjPtr<AActor*> activator;
line_t *activationline;
bool backSide;
FFont *activefont;
FFont *activefont = nullptr;
int hudwidth, hudheight;
int ClipRectLeft, ClipRectTop, ClipRectWidth, ClipRectHeight;
int WrapWidth;
@ -774,7 +774,7 @@ protected:
private:
DLevelScript();
DLevelScript() = default;
friend class DACSThinker;
};
@ -3506,11 +3506,6 @@ void DLevelScript::Serialize(FSerializer &arc)
}
}
DLevelScript::DLevelScript ()
{
activefont = SmallFont;
}
void DLevelScript::Unlink ()
{
DACSThinker *controller = Level->ACSThinker;
@ -3924,10 +3919,6 @@ void DLevelScript::DoSetFont (int fontnum)
{
const char *fontname = Level->Behaviors.LookupString (fontnum);
activefont = V_GetFont (fontname);
if (activefont == NULL)
{
activefont = SmallFont;
}
}
int DLevelScript::DoSetMaster (AActor *self, AActor *master)
@ -8676,17 +8667,18 @@ scriptwait:
color = CLAMPCOLOR(Stack[optstart-4]);
}
FFont *font = activefont ? activefont : SmallFont;
switch (type & 0xFF)
{
default: // normal
alpha = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 1.f;
msg = Create<DHUDMessage> (activefont, work, x, y, hudwidth, hudheight, color, holdTime);
msg = Create<DHUDMessage> (font, work, x, y, hudwidth, hudheight, color, holdTime);
break;
case 1: // fade out
{
float fadeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f;
alpha = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 1.f;
msg = Create<DHUDMessageFadeOut> (activefont, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime);
msg = Create<DHUDMessageFadeOut> (font, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime);
}
break;
case 2: // type on, then fade out
@ -8694,7 +8686,7 @@ scriptwait:
float typeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.05f;
float fadeTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f;
alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart+2]) : 1.f;
msg = Create<DHUDMessageTypeOnFadeOut> (activefont, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime);
msg = Create<DHUDMessageTypeOnFadeOut> (font, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime);
}
break;
case 3: // fade in, then fade out
@ -8702,7 +8694,7 @@ scriptwait:
float inTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f;
float outTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f;
alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart + 2]) : 1.f;
msg = Create<DHUDMessageFadeInOut> (activefont, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime);
msg = Create<DHUDMessageFadeInOut> (font, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime);
}
break;
}
@ -10286,7 +10278,6 @@ DLevelScript::DLevelScript (FLevelLocals *l, AActor *who, line_t *where, int num
activator = who;
activationline = where;
backSide = flags & ACS_BACKSIDE;
activefont = SmallFont;
hudwidth = hudheight = 0;
ClipRectLeft = ClipRectTop = ClipRectWidth = ClipRectHeight = WrapWidth = 0;
HandleAspect = true;

View file

@ -1309,7 +1309,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Print)
con_midtime = float(time);
}
FString formatted = strbin1(text);
C_MidPrint(font != NULL ? font : SmallFont, formatted.GetChars());
C_MidPrint(font, formatted.GetChars());
con_midtime = saved;
}
return 0;
@ -1341,7 +1341,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PrintBold)
con_midtime = float(time);
}
FString formatted = strbin1(text);
C_MidPrintBold(font != NULL ? font : SmallFont, formatted.GetChars());
C_MidPrintBold(font, formatted.GetChars());
con_midtime = saved;
return 0;
}

View file

@ -592,12 +592,12 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl
{
if (printmessage)
{
if (!showsecretsector || sectornum < 0) C_MidPrint(SmallFont, GStrings["SECRETMESSAGE"]);
if (!showsecretsector || sectornum < 0) C_MidPrint(nullptr, GStrings["SECRETMESSAGE"]);
else
{
FString s = GStrings["SECRETMESSAGE"];
s.AppendFormat(" (Sector %d)", sectornum);
C_MidPrint(SmallFont, s);
C_MidPrint(nullptr, s);
}
}
if (playsound) S_Sound (CHAN_AUTO | CHAN_UI, "misc/secret", 1, ATTN_NORM);

View file

@ -87,6 +87,28 @@ int GetUIScale(int altval)
return MAX(1,MIN(scaleval, max));
}
// The new console font is twice as high, so the scaling calculation must factor that in.
int GetConScale(int altval)
{
int scaleval;
if (altval > 0) scaleval = altval;
else if (uiscale == 0)
{
// Default should try to scale to 640x400
int vscale = screen->GetHeight() / 800;
int hscale = screen->GetWidth() / 1280;
scaleval = clamp(vscale, 1, hscale);
}
else scaleval = uiscale / 2;
// block scales that result in something larger than the current screen.
int vmax = screen->GetHeight() / 400;
int hmax = screen->GetWidth() / 640;
int max = MAX(vmax, hmax);
return MAX(1, MIN(scaleval, max));
}
// [RH] Stretch values to make a 320x200 image best fit the screen
// without using fractional steppings
int CleanXfac, CleanYfac;

View file

@ -38,6 +38,7 @@
#include <wctype.h>
#include "v_text.h"
#include "utf8.h"
#include "v_video.h"
@ -248,10 +249,14 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawChar)
//
//==========================================================================
void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms)
// This is only needed as a dummy. The code using wide strings does not need color control.
EColorRange V_ParseFontColor(const char32_t *&color_value, int normalcolor, int boldcolor) { return CR_UNTRANSLATED; }
template<class chartype>
void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double y, const chartype *string, DrawParms &parms)
{
int w;
const uint8_t *ch;
const chartype *ch;
int c;
double cx;
double cy;
@ -274,13 +279,13 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double
kerning = font->GetDefaultKerning();
ch = (const uint8_t *)string;
ch = string;
cx = x;
cy = y;
auto currentcolor = normalcolor;
while ((const char *)ch - string < parms.maxstrlen)
while (ch - string < parms.maxstrlen)
{
c = GetCharFromString(ch);
if (!c)
@ -327,6 +332,24 @@ void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, co
Va_List tags;
DrawParms parms;
if (font == NULL || string == NULL)
return;
va_start(tags.list, tag_first);
bool res = ParseDrawTextureTags(nullptr, 0, 0, tag_first, tags, &parms, true);
va_end(tags.list);
if (!res)
{
return;
}
DrawTextCommon(font, normalcolor, x, y, (const uint8_t*)string, parms);
}
void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, const char32_t *string, int tag_first, ...)
{
Va_List tags;
DrawParms parms;
if (font == NULL || string == NULL)
return;
@ -353,13 +376,13 @@ void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, co
{
return;
}
DrawTextCommon(font, normalcolor, x, y, string, parms);
DrawTextCommon(font, normalcolor, x, y, (const uint8_t*)string, parms);
}
DEFINE_ACTION_FUNCTION(_Screen, DrawText)
{
PARAM_PROLOGUE;
PARAM_POINTER(font, FFont);
PARAM_POINTER_NOT_NULL(font, FFont);
PARAM_INT(cr);
PARAM_FLOAT(x);
PARAM_FLOAT(y);

View file

@ -426,6 +426,7 @@ void FormatGUID (char *buffer, size_t buffsize, const GUID &guid)
const char *myasctime ()
{
static char readabletime[50];
time_t clock;
struct tm *lt;
@ -433,11 +434,12 @@ const char *myasctime ()
lt = localtime (&clock);
if (lt != NULL)
{
return asctime (lt);
strftime(readabletime, 50, "%F %T", lt);
return readabletime;
}
else
{
return "Pre Jan 01 00:00:00 1970\n";
return "Unknown\n";
}
}

View file

@ -87,7 +87,7 @@ void FStat::PrintStat ()
{
int textScale = active_con_scale();
int fontheight = ConFont->GetHeight() + 1;
int fontheight = NewConsoleFont->GetHeight() + 1;
int y = SCREENHEIGHT / textScale;
int count = 0;
@ -105,7 +105,7 @@ void FStat::PrintStat ()
// Count number of linefeeds but ignore terminating ones.
if (stattext[i] == '\n') y -= fontheight;
}
screen->DrawText(ConFont, CR_GREEN, 5 / textScale, y, stattext,
screen->DrawText(NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);

View file

@ -3,6 +3,10 @@
int utf8_encode(int32_t codepoint, uint8_t *buffer, int *size);
int utf8_decode(const uint8_t *src, int *size);
int GetCharFromString(const uint8_t *&string);
inline int GetCharFromString(const char32_t *&string)
{
return *string++;
}
const char *MakeUTF8(const char *outline, int *numchars = nullptr); // returns a pointer to a static buffer, assuming that its caller will immediately process the result.
const char *MakeUTF8(int codepoint, int *psize = nullptr);

View file

@ -393,8 +393,8 @@ size_t FString::CharacterCount() const
int FString::GetNextCharacter(int &position) const
{
const uint8_t *cp = (const uint8_t*)Chars;
const uint8_t *cpread = cp + position;
const uint8_t *cp = (const uint8_t*)Chars + position;
const uint8_t *cpread = cp;
int chr = GetCharFromString(cpread);
position += int(cpread - cp);
return chr;
@ -828,12 +828,12 @@ void FString::StripLeftRight ()
if (max == 0) return;
for (i = 0; i < max; ++i)
{
if (!isspace((unsigned char)Chars[i]))
if (Chars[i] < 0 || !isspace((unsigned char)Chars[i]))
break;
}
for (j = max - 1; j >= i; --j)
{
if (!isspace((unsigned char)Chars[j]))
if (Chars[i] < 0 || !isspace((unsigned char)Chars[j]))
break;
}
if (i == 0 && j == max - 1)

View file

@ -145,7 +145,7 @@ public:
int DisplayWidth, DisplayHeight;
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont;
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *CurrentConsoleFont;
uint32_t Col2RGB8[65][256];
uint32_t *Col2RGB8_LessPrecision[65];
@ -950,6 +950,7 @@ DEFINE_GLOBAL(SmallFont)
DEFINE_GLOBAL(SmallFont2)
DEFINE_GLOBAL(BigFont)
DEFINE_GLOBAL(ConFont)
DEFINE_GLOBAL(NewConsoleFont)
DEFINE_GLOBAL(IntermissionFont)
DEFINE_GLOBAL(CleanXfac)
DEFINE_GLOBAL(CleanYfac)

View file

@ -343,7 +343,8 @@ protected:
template<class T>
bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) const;
void DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms);
template<class T>
void DrawTextCommon(FFont *font, int normalcolor, double x, double y, const T *string, DrawParms &parms);
F2DDrawer m2DDrawer;
private:
@ -529,6 +530,7 @@ public:
void DrawText(FFont *font, int normalcolor, double x, double y, const char *string, VMVa_List &args);
void DrawChar(FFont *font, int normalcolor, double x, double y, int character, int tag_first, ...);
void DrawChar(FFont *font, int normalcolor, double x, double y, int character, VMVa_List &args);
void DrawText(FFont *font, int normalcolor, double x, double y, const char32_t *string, int tag_first, ...);
void DrawFrame(int left, int top, int width, int height);
void DrawBorder(FTextureID, int x1, int y1, int x2, int y2);
@ -609,19 +611,20 @@ bool AspectTallerThanWide(float aspect);
void ScaleWithAspect(int &w, int &h, int Width, int Height);
int GetUIScale(int altval);
int GetConScale(int altval);
EXTERN_CVAR(Int, uiscale);
EXTERN_CVAR(Int, con_scaletext);
EXTERN_CVAR(Int, con_scale);
inline int active_con_scaletext()
inline int active_con_scaletext(bool newconfont = false)
{
return GetUIScale(con_scaletext);
return newconfont? GetConScale(con_scaletext) : GetUIScale(con_scaletext);
}
inline int active_con_scale()
{
return GetUIScale(con_scale);
return GetConScale(con_scale);
}

View file

@ -70,6 +70,7 @@
#include "x86.h"
#include "stats.h"
#include "v_text.h"
#include "utf8.h"
#include "d_main.h"
#include "d_net.h"

View file

@ -0,0 +1,20 @@
The font is a combination of "Unicode VGA font" (http://www.inp.nsk.su./~bolkhov/files/fonts/univga/)
License: "The UNI-VGA font can be distributed and modified freely, according to the X license."
All code points not present in the above were taken from "GNU Unifont" (http://unifoundry.com/unifont.html)
License: GPL v2 with the following exception:
The license for the compiled fonts is covered by the above GPL terms
with the GNU font embedding exception, as follows:
As a special exception, if you create a document which uses this font,
and embed this font or unaltered portions of this font into the document,
this font does not by itself cause the resulting document to be covered
by the GNU General Public License. This exception does not however
invalidate any other reasons why the document might be covered by the
GNU General Public License. If you modify this font, you may extend
this exception to your version of the font, but you are not obligated
to do so. If you do not wish to do so, delete this exception statement
from your version.
See "http://www.gnu.org/licenses/gpl-faq.html#FontException" for more details.

File diff suppressed because it is too large Load diff

View file

@ -127,7 +127,7 @@ class PuzzleItem : Inventory
Owner.A_PlaySound ("*puzzfail", CHAN_VOICE);
if (Owner.CheckLocalView())
{
Console.MidPrint ("SmallFont", PuzzFailMessage, true);
Console.MidPrint (null, PuzzFailMessage, true);
}
return false;
}

View file

@ -108,13 +108,13 @@ class AlienSpectre1 : SpectralMonster
}
else if (cls == "AlienSpectre2")
{
Console.MidPrint("SmallFont", "$TXT_KILLED_BISHOP");
Console.MidPrint(null, "$TXT_KILLED_BISHOP");
log = 74;
player.GiveInventoryType ("QuestItem21");
}
else if (cls == "AlienSpectre3")
{
Console.MidPrint("SmallFont", "$TXT_KILLED_ORACLE");
Console.MidPrint(null, "$TXT_KILLED_ORACLE");
// If there are any Oracles still alive, kill them.
ThinkerIterator it = ThinkerIterator.Create("Oracle");
Actor oracle;
@ -144,7 +144,7 @@ class AlienSpectre1 : SpectralMonster
}
else if (cls == "AlienSpectre4")
{
Console.MidPrint("SmallFont", "$TXT_KILLED_MACIL");
Console.MidPrint(null, "$TXT_KILLED_MACIL");
player.GiveInventoryType ("QuestItem24");
if (player.FindInventory ("QuestItem25") == null)
{ // Richter has taken over. Macil is a snake.
@ -157,7 +157,7 @@ class AlienSpectre1 : SpectralMonster
}
else if (cls == "AlienSpectre5")
{
Console.MidPrint("SmallFont", "$TXT_KILLED_LOREMASTER");
Console.MidPrint(null, "$TXT_KILLED_LOREMASTER");
player.GiveInventoryType ("QuestItem26");
if (!multiplayer)

View file

@ -531,7 +531,7 @@ class Scanner : PowerupGiver
{
if (Owner.CheckLocalView())
{
Console.MidPrint("SmallFont", "$TXT_NEEDMAP");
Console.MidPrint(null, "$TXT_NEEDMAP");
}
return false;
}
@ -632,7 +632,7 @@ class RaiseAlarm : DummyStrifeItem
dropper.target.SoundAlert(dropper.target);
if (dropper.target.CheckLocalView())
{
Console.MidPrint(SmallFont, "$TXT_YOUFOOL");
Console.MidPrint(null, "$TXT_YOUFOOL");
}
}
Destroy ();
@ -672,7 +672,7 @@ class CloseDoor222 : DummyStrifeItem
{
if (dropper.target.CheckLocalView())
{
Console.MidPrint(SmallFont, "$TXT_YOUREDEAD");
Console.MidPrint(null, "$TXT_YOUREDEAD");
}
dropper.target.SoundAlert(dropper.target);
}

View file

@ -32,7 +32,7 @@ extend class Actor
if (msg != msgid) // if both are identical there was no message of this name in the stringtable.
{
Console.MidPrint ("SmallFont", msg);
Console.MidPrint (null, msg);
}
}

View file

@ -22,6 +22,7 @@ struct _ native // These are the global variables, the struct is only here to av
native readonly Font smallfont2;
native readonly Font bigfont;
native readonly Font confont;
native readonly Font NewConsoleFont;
native readonly Font intermissionfont;
native readonly int CleanXFac;
native readonly int CleanYFac;

View file

@ -47,6 +47,7 @@ struct SavegameManager native ui
{
native int WindowSize;
native SaveGameNode quickSaveSlot;
native readonly String SaveCommentString;
native static SavegameManager GetManager();
native void ReadSaveStrings();
@ -58,7 +59,10 @@ struct SavegameManager native ui
native int ExtractSaveData(int index);
native void ClearSaveStuff();
native bool DrawSavePic(int x, int y, int w, int h);
native void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor);
deprecated("4.0") void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor)
{
// Unfortunately, this was broken beyond repair so it now prints nothing.
}
native void SetFileInfo(int Selected);
native int SavegameCount();
native SaveGameNode GetSavegame(int i);
@ -95,9 +99,13 @@ class LoadSaveMenu : ListMenu
int commentHeight;
int commentRight;
int commentBottom;
int commentRows;
bool mEntering;
TextEnterMenu mInput;
double FontScale;
BrokenLines BrokenSaveComment;
@ -115,11 +123,12 @@ class LoadSaveMenu : ListMenu
savepicLeft = 10;
savepicTop = 54*CleanYfac;
savepicWidth = 216*screen.GetWidth()/640;
savepicHeight = 135*screen.GetHeight()/400;
manager.WindowSize = savepicWidth / CleanXfac;
savepicWidth = 216*screen.GetWidth() / 640;
savepicHeight = 135*screen.GetHeight() / 400;
rowHeight = (ConFont.GetHeight() + 1) * CleanYfac;
FontScale = max(screen.GetHeight() / 480, 1);
rowHeight = max((NewConsoleFont.GetHeight() + 1) * FontScale, 1);
listboxLeft = savepicLeft + savepicWidth + 14;
listboxTop = savepicTop;
listboxWidth = screen.GetWidth() - listboxLeft - 10;
@ -136,7 +145,10 @@ class LoadSaveMenu : ListMenu
commentHeight = listboxHeight - savepicHeight - 16;
commentRight = commentLeft + commentWidth;
commentBottom = commentTop + commentHeight;
commentRows = commentHeight / rowHeight;
}
//=============================================================================
//
@ -146,7 +158,7 @@ class LoadSaveMenu : ListMenu
override void OnDestroy()
{
manager.ClearSaveStuff ();
//manager.ClearSaveStuff ();
Super.OnDestroy();
}
@ -190,7 +202,13 @@ class LoadSaveMenu : ListMenu
Screen.DrawFrame (commentLeft, commentTop, commentWidth, commentHeight);
screen.Clear (commentLeft, commentTop, commentRight, commentBottom, 0, 0);
manager.DrawSaveComment(SmallFont, Font.CR_GOLD, commentLeft, commentTop, CleanYfac);
int numlinestoprint = min(commentRows, BrokenSaveComment? BrokenSaveComment.Count() : 0);
for(int i = 0; i < numlinestoprint; i++)
{
screen.DrawText(NewConsoleFont, Font.CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment.StringAt(i),
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
}
// Draw file area
Screen.DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight);
@ -201,7 +219,8 @@ class LoadSaveMenu : ListMenu
String text = Stringtable.Localize("$MNU_NOFILES");
int textlen = SmallFont.StringWidth(text) * CleanXfac;
screen.DrawText (SmallFont, Font.CR_GOLD, listboxLeft+(listboxWidth-textlen)/2, listboxTop+(listboxHeight-rowHeight)/2, text, DTA_CleanNoMove, true);
screen.DrawText (NewConsoleFont, Font.CR_GOLD, (listboxLeft+(listboxWidth-textlen)/2) / FontScale, (listboxTop+(listboxHeight-rowHeight)/2) / FontScale, text,
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
return;
}
@ -212,11 +231,11 @@ class LoadSaveMenu : ListMenu
node = manager.GetSavegame(j);
if (node.bOldVersion)
{
colr = Font.CR_BLUE;
colr = Font.CR_RED;
}
else if (node.bMissingWads)
{
colr = Font.CR_ORANGE;
colr = Font.CR_YELLOW;
}
else if (j == Selected)
{
@ -228,7 +247,6 @@ class LoadSaveMenu : ListMenu
}
screen.SetClipRect(listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1));
int fontoffset = -CleanYFac;
if (j == Selected)
{
@ -236,26 +254,32 @@ class LoadSaveMenu : ListMenu
didSeeSelected = true;
if (!mEntering)
{
screen.DrawText (ConFont, colr, listboxLeft+1, listboxTop+rowHeight*i+CleanYfac + fontoffset, node.SaveTitle, DTA_CleanNoMove, true);
screen.DrawText (NewConsoleFont, colr, (listboxLeft+1) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, node.SaveTitle,
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
}
else
{
String s = mInput.GetText() .. ConFont.GetCursor();
int length = ConFont.StringWidth(s) * CleanXFac;
String s = mInput.GetText() .. NewConsoleFont.GetCursor();
int length = NewConsoleFont.StringWidth(s) * FontScale;
int displacement = min(0, listboxWidth - 2 - length);
screen.DrawText (ConFont, Font.CR_WHITE, listboxLeft + 1 + displacement, listboxTop+rowHeight*i+CleanYfac + fontoffset, s, DTA_CleanNoMove, true);
screen.DrawText (NewConsoleFont, Font.CR_WHITE, (listboxLeft + 1 + displacement) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, s,
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
}
}
else
{
screen.DrawText (ConFont, colr, listboxLeft+1, listboxTop+rowHeight*i+CleanYfac + fontoffset, node.SaveTitle, DTA_CleanNoMove, true);
screen.DrawText (NewConsoleFont, colr, (listboxLeft+1) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, node.SaveTitle,
DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale);
}
screen.ClearClipRect();
j++;
}
}
void UpdateSaveComment()
{
BrokenSaveComment = NewConsoleFont.BreakLines(manager.SaveCommentString, commentWidth / FontScale);
}
//=============================================================================
//
@ -279,6 +303,7 @@ class LoadSaveMenu : ListMenu
}
manager.UnloadSaveData ();
manager.ExtractSaveData (Selected);
UpdateSaveComment();
}
return true;
@ -294,6 +319,7 @@ class LoadSaveMenu : ListMenu
}
manager.UnloadSaveData ();
manager.ExtractSaveData (Selected);
UpdateSaveComment();
}
return true;
@ -312,6 +338,7 @@ class LoadSaveMenu : ListMenu
}
manager.UnloadSaveData ();
manager.ExtractSaveData (Selected);
UpdateSaveComment();
}
return true;
@ -330,6 +357,7 @@ class LoadSaveMenu : ListMenu
}
manager.UnloadSaveData ();
manager.ExtractSaveData (Selected);
UpdateSaveComment();
}
return true;
@ -341,6 +369,7 @@ class LoadSaveMenu : ListMenu
if (Selected < manager.SavegameCount())
{
Selected = manager.RemoveSaveSlot (Selected);
UpdateSaveComment();
}
return true;
}
@ -368,6 +397,7 @@ class LoadSaveMenu : ListMenu
Selected = TopItem + lineno;
manager.UnloadSaveData ();
manager.ExtractSaveData (Selected);
UpdateSaveComment();
if (type == MOUSE_Release)
{
if (MenuEvent(MKEY_Enter, true))
@ -400,6 +430,7 @@ class LoadSaveMenu : ListMenu
{
case UIEvent.Key_F1:
manager.SetFileInfo(Selected);
UpdateSaveComment();
return true;
case UIEvent.Key_DEL:

View file

@ -138,9 +138,7 @@ class DoomStatusScreen : StatusScreen
drawLF();
// Fixme: This should try to retrieve the color from the intermission font and use the best approximation here
let tcolor = Font.CR_RED;
// For visual consistency, only use the patches here if all are present.
bool useGfx = TexMan.OkForLocalization(Kills, "$TXT_IMKILLS")
&& TexMan.OkForLocalization(Items, "$TXT_IMITEMS")
@ -148,6 +146,9 @@ class DoomStatusScreen : StatusScreen
&& TexMan.OkForLocalization(Timepic, "$TXT_IMTIME")
&& (!wbs.partime || TexMan.OkForLocalization(Par, "$TXT_IMPAR"));
// Fixme: This should try to retrieve the color from the intermission font and use the best approximation here
let tcolor = useGfx? Font.CR_UNTRANSLATED : Font.CR_RED;
Font printFont;
if (useGfx)

Some files were not shown because too many files have changed in this diff Show more