mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- allow all DHUDMessage calls to substitute SmallFont
This is a preparation for setting a generic HUD mode where all these should be able to use the VGA font instead, and not just C_MidPrint.
This commit is contained in:
parent
8b0dd1376f
commit
fe37c3bc4f
10 changed files with 50 additions and 47 deletions
|
@ -79,8 +79,20 @@ 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)
|
||||
bool generic_hud, generic_ui;
|
||||
|
||||
EXTERN_CVAR(Bool, ui_generic)
|
||||
|
||||
CUSTOM_CVAR(Bool, hud_generic, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // All HUD elements only use generic assets
|
||||
{
|
||||
generic_hud = self || ui_generic;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, ui_generic, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // The entire UI uses generic assets (this excludes the primary menus)
|
||||
{
|
||||
generic_ui = self;
|
||||
generic_hud = self || hud_generic;
|
||||
}
|
||||
|
||||
FConsoleBuffer *conbuffer;
|
||||
|
||||
|
@ -782,9 +794,10 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
|
|||
con_notifylines == 0)
|
||||
return;
|
||||
|
||||
width = DisplayWidth / active_con_scaletext(con_consolefont);
|
||||
width = DisplayWidth / active_con_scaletext(hud_generic);
|
||||
|
||||
FFont *font = *con_consolefont ? NewSmallFont : SmallFont;
|
||||
FFont *font = hud_generic ? NewSmallFont : SmallFont;
|
||||
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)
|
||||
{
|
||||
|
@ -897,7 +910,7 @@ int PrintString (int iprintlevel, const char *outline)
|
|||
I_PrintStr(outline);
|
||||
|
||||
conbuffer->AddText(printlevel, outline);
|
||||
if (vidactive && screen && SmallFont && !(iprintlevel & PRINT_NONOTIFY))
|
||||
if (vidactive && screen && !(iprintlevel & PRINT_NONOTIFY))
|
||||
{
|
||||
NotifyStrings.AddString(printlevel, outline);
|
||||
}
|
||||
|
@ -1067,7 +1080,7 @@ void FNotifyBuffer::Draw()
|
|||
line = Top;
|
||||
canskip = true;
|
||||
|
||||
FFont *font = *con_consolefont ? NewSmallFont : SmallFont;
|
||||
FFont *font = hud_generic ? NewSmallFont : SmallFont;
|
||||
lineadv = font->GetHeight ();
|
||||
|
||||
for (unsigned i = 0; i < Text.Size(); ++ i)
|
||||
|
@ -1090,11 +1103,11 @@ void FNotifyBuffer::Draw()
|
|||
else
|
||||
color = PrintColors[notify.PrintLevel];
|
||||
|
||||
if (color == CR_UNTRANSLATED && *con_consolefont)
|
||||
if (color == CR_UNTRANSLATED && hud_generic)
|
||||
{
|
||||
color = C_GetDefaultFontColor();
|
||||
}
|
||||
int scale = active_con_scaletext(con_consolefont);
|
||||
int scale = active_con_scaletext(hud_generic);
|
||||
if (!center)
|
||||
screen->DrawText (font, color, 0, line, notify.Text,
|
||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||
|
@ -1103,7 +1116,7 @@ void FNotifyBuffer::Draw()
|
|||
DTA_Alpha, alpha, TAG_DONE);
|
||||
else
|
||||
screen->DrawText (font, color, (screen->GetWidth() -
|
||||
SmallFont->StringWidth (notify.Text) * scale) / 2 / scale,
|
||||
font->StringWidth (notify.Text) * scale) / 2 / scale,
|
||||
line, notify.Text,
|
||||
DTA_VirtualWidth, screen->GetWidth() / scale,
|
||||
DTA_VirtualHeight, screen->GetHeight() / scale,
|
||||
|
@ -1756,16 +1769,7 @@ void C_MidPrint (FFont *font, const char *msg, bool bold)
|
|||
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);
|
||||
|
||||
bool altscale = false;
|
||||
if (font == nullptr)
|
||||
{
|
||||
altscale = con_midconsolefont;
|
||||
font = altscale ? NewSmallFont : SmallFont;
|
||||
if (altscale && color == CR_UNTRANSLATED) color = C_GetDefaultFontColor();
|
||||
}
|
||||
|
||||
StatusBar->AttachMessage (Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0,
|
||||
color, con_midtime, altscale), MAKE_ID('C','N','T','R'));
|
||||
StatusBar->AttachMessage (Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0, color, con_midtime), MAKE_ID('C','N','T','R'));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1075,13 +1075,6 @@ void D_PageDrawer (void)
|
|||
DTA_BilinearFilter, true,
|
||||
TAG_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PageBlank)
|
||||
{
|
||||
screen->DrawText (SmallFont, CR_WHITE, 0, 0, "Page graphic goes here", TAG_DONE);
|
||||
}
|
||||
}
|
||||
if (Advisory != NULL)
|
||||
{
|
||||
screen->DrawTexture (Advisory, 4, 160, DTA_320x200, true, TAG_DONE);
|
||||
|
|
|
@ -253,4 +253,6 @@ EXTERN_CVAR (Int, compatflags2);
|
|||
// Filters from AddAutoloadFiles(). Used to filter files from archives.
|
||||
extern FString LumpFilterIWAD;
|
||||
|
||||
// These control whether certain items use generic text output instead of game-specific one.
|
||||
extern bool generic_hud, generic_ui;
|
||||
#endif
|
||||
|
|
|
@ -350,7 +350,7 @@ CCMD (weapnext)
|
|||
// [BC] Option to display the name of the weapon being cycled to.
|
||||
if ((displaynametags & 2) && StatusBar && SmallFont && SendItemUse)
|
||||
{
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(SmallFont, SendItemUse->GetTag(),
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(nullptr, SendItemUse->GetTag(),
|
||||
1.5f, 0.90f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID( 'W', 'E', 'P', 'N' ));
|
||||
}
|
||||
if (SendItemUse != players[consoleplayer].ReadyWeapon)
|
||||
|
@ -376,7 +376,7 @@ CCMD (weapprev)
|
|||
// [BC] Option to display the name of the weapon being cycled to.
|
||||
if ((displaynametags & 2) && StatusBar && SmallFont && SendItemUse)
|
||||
{
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(SmallFont, SendItemUse->GetTag(),
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(nullptr, SendItemUse->GetTag(),
|
||||
1.5f, 0.90f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID( 'W', 'E', 'P', 'N' ));
|
||||
}
|
||||
if (SendItemUse != players[consoleplayer].ReadyWeapon)
|
||||
|
@ -389,7 +389,7 @@ static void DisplayNameTag(AActor *actor)
|
|||
{
|
||||
auto tag = actor->GetTag();
|
||||
if ((displaynametags & 1) && StatusBar && SmallFont)
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(SmallFont, tag,
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(nullptr, tag,
|
||||
1.5f, 0.80f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID('S', 'I', 'N', 'V'));
|
||||
|
||||
}
|
||||
|
|
|
@ -39,8 +39,11 @@
|
|||
#include "v_video.h"
|
||||
#include "cmdlib.h"
|
||||
#include "serializer.h"
|
||||
#include "doomstat.h"
|
||||
#include "vm.h"
|
||||
|
||||
EColorRange C_GetDefaultFontColor();
|
||||
|
||||
EXTERN_CVAR(Int, con_scaletext)
|
||||
|
||||
IMPLEMENT_CLASS(DHUDMessageBase, false, true)
|
||||
|
@ -128,7 +131,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, bool altscale)
|
||||
EColorRange textColor, float holdTime)
|
||||
{
|
||||
if (hudwidth == 0 || hudheight == 0)
|
||||
{
|
||||
|
@ -139,7 +142,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;
|
||||
AltScale = font == nullptr && generic_hud; // generic_hud only takes effect for messages that do not scale the screen and use the default font.
|
||||
if (fabs (x) > 2.f)
|
||||
{
|
||||
CenterX = true;
|
||||
|
@ -197,10 +200,11 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h
|
|||
Top = y;
|
||||
HoldTics = (int)(holdTime * TICRATE);
|
||||
Tics = -1; // -1 to compensate for one additional Tick the message will receive.
|
||||
TextColor = textColor;
|
||||
Font = font? font : AltScale? NewSmallFont : SmallFont;
|
||||
if (Font == NewSmallFont && textColor == CR_UNTRANSLATED) TextColor = C_GetDefaultFontColor();
|
||||
else TextColor = textColor;
|
||||
State = 0;
|
||||
SourceText = copystring (text);
|
||||
Font = font;
|
||||
VisibilityFlags = 0;
|
||||
Style = STYLE_Translucent;
|
||||
Alpha = 1.;
|
||||
|
@ -251,7 +255,8 @@ void DHUDMessage::Serialize(FSerializer &arc)
|
|||
("handleaspect", HandleAspect)
|
||||
("visibilityflags", VisibilityFlags)
|
||||
("style", Style)
|
||||
("alpha", Alpha);
|
||||
("alpha", Alpha)
|
||||
("altscale", AltScale);
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
|
|
|
@ -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, bool altscale = false);
|
||||
EColorRange textColor, float holdTime);
|
||||
virtual void OnDestroy () override;
|
||||
|
||||
virtual void Serialize(FSerializer &arc);
|
||||
|
@ -207,7 +207,7 @@ class DHUDMessageTypeOnFadeOut : public DHUDMessageFadeOut
|
|||
DECLARE_CLASS (DHUDMessageTypeOnFadeOut, DHUDMessageFadeOut)
|
||||
public:
|
||||
DHUDMessageTypeOnFadeOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
|
||||
EColorRange textColor, float typeTime, float holdTime, float fadeOutTime);
|
||||
EColorRange textColor, float typeTime, float holdTime, float fadeOutTimee);
|
||||
|
||||
virtual void Serialize(FSerializer &arc);
|
||||
virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight);
|
||||
|
|
|
@ -754,7 +754,7 @@ void DBaseStatusBar::ShowPlayerName ()
|
|||
EColorRange color;
|
||||
|
||||
color = (CPlayer == &players[consoleplayer]) ? CR_GOLD : CR_GREEN;
|
||||
AttachMessage (Create<DHUDMessageFadeOut> (SmallFont, CPlayer->userinfo.GetName(),
|
||||
AttachMessage (Create<DHUDMessageFadeOut> (nullptr, CPlayer->userinfo.GetName(),
|
||||
1.5f, 0.92f, 0, 0, color, 2.f, 0.35f), MAKE_ID('P','N','A','M'));
|
||||
}
|
||||
|
||||
|
|
|
@ -8662,18 +8662,17 @@ 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> (font, work, x, y, hudwidth, hudheight, color, holdTime);
|
||||
msg = Create<DHUDMessage> (activefont, 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> (font, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime);
|
||||
msg = Create<DHUDMessageFadeOut> (activefont, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime);
|
||||
}
|
||||
break;
|
||||
case 2: // type on, then fade out
|
||||
|
@ -8681,7 +8680,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> (font, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime);
|
||||
msg = Create<DHUDMessageTypeOnFadeOut> (activefont, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime);
|
||||
}
|
||||
break;
|
||||
case 3: // fade in, then fade out
|
||||
|
@ -8689,7 +8688,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> (font, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime);
|
||||
msg = Create<DHUDMessageFadeInOut> (activefont, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ static void TerminalResponse (const char *str)
|
|||
// merchants can tell you something like this but continue to show
|
||||
// their dialogue screen. I think most other conversations use this
|
||||
// only as a response for terminating the dialogue.
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(SmallFont, str,
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(nullptr, str,
|
||||
float(CleanWidth/2) + 0.4f, float(ConversationMenuY - 110 + CleanHeight/2), CleanWidth, -CleanHeight,
|
||||
CR_UNTRANSLATED, 3.f, 1.f), MAKE_ID('T','A','L','K'));
|
||||
}
|
||||
|
|
|
@ -412,7 +412,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
PronounMessage (GStrings("SPREEKILLSELF"), buff,
|
||||
player->userinfo.GetGender(), player->userinfo.GetName(),
|
||||
player->userinfo.GetName());
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut>(SmallFont, buff,
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut>(nullptr, buff,
|
||||
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
{
|
||||
PronounMessage (GStrings("SPREEOVER"), buff, player->userinfo.GetGender(),
|
||||
player->userinfo.GetName(), source->player->userinfo.GetName());
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (SmallFont, buff,
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (nullptr, buff,
|
||||
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
{
|
||||
PronounMessage (spreemsg, buff, player->userinfo.GetGender(),
|
||||
player->userinfo.GetName(), source->player->userinfo.GetName());
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (SmallFont, buff,
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (nullptr, buff,
|
||||
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
{
|
||||
PronounMessage (multimsg, buff, player->userinfo.GetGender(),
|
||||
player->userinfo.GetName(), source->player->userinfo.GetName());
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (SmallFont, buff,
|
||||
StatusBar->AttachMessage (Create<DHUDMessageFadeOut> (nullptr, buff,
|
||||
1.5f, 0.8f, 0, 0, CR_RED, 3.f, 0.5f), MAKE_ID('M','K','I','L'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue