mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- implemented proper scaling support for the notify display - both the classic and advanced variant.
This commit is contained in:
parent
1a633ce6a6
commit
a0e4d6f62c
6 changed files with 37 additions and 41 deletions
|
@ -231,14 +231,8 @@ int GetUIScale(F2DDrawer* drawer, int altval);
|
|||
int GetConScale(F2DDrawer* drawer, int altval);
|
||||
|
||||
EXTERN_CVAR(Int, uiscale);
|
||||
EXTERN_CVAR(Int, con_scaletext);
|
||||
EXTERN_CVAR(Int, con_scale);
|
||||
|
||||
inline int active_con_scaletext(F2DDrawer* drawer, bool newconfont = false)
|
||||
{
|
||||
return newconfont ? GetConScale(drawer, con_scaletext) : GetUIScale(drawer, con_scaletext);
|
||||
}
|
||||
|
||||
inline int active_con_scale(F2DDrawer *drawer)
|
||||
{
|
||||
return GetConScale(drawer, con_scale);
|
||||
|
|
|
@ -137,12 +137,14 @@ static char *work = NULL;
|
|||
static int worklen = 0;
|
||||
|
||||
CVAR(Float, con_notifytime, 3.f, CVAR_ARCHIVE)
|
||||
CUSTOM_CVAR(Float, con_notifyscale, 1, CVAR_ARCHIVE)
|
||||
{
|
||||
if (self < 0.36f) self = 0.36f;
|
||||
if (self > 1) self = 1;
|
||||
}
|
||||
|
||||
CVAR(Bool, con_centernotify, false, CVAR_ARCHIVE)
|
||||
CVAR(Bool, con_notify_advanced, false, CVAR_ARCHIVE)
|
||||
CUSTOM_CVAR(Int, con_scaletext, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // 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)
|
||||
|
@ -794,19 +796,22 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
|
|||
con_notifylines == 0)
|
||||
return;
|
||||
|
||||
width = screen->GetWidth() / active_con_scaletext(twod, generic_ui);
|
||||
auto screenratio = ActiveRatio(screen->GetWidth(), screen->GetHeight());
|
||||
|
||||
FFont* font = generic_ui ? NewSmallFont : SmallFont ? SmallFont : 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.)
|
||||
double fontscale = (generic_ui? 0.7 : NotifyFontScale) * con_notifyscale;
|
||||
|
||||
width = int(320 * (screenratio / 1.333) / fontscale);
|
||||
|
||||
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 * NotifyFontScale, str);
|
||||
lines = V_BreakLines (font, width, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
lines = V_BreakLines (font, width * NotifyFontScale, source);
|
||||
lines = V_BreakLines (font, width, source);
|
||||
if (AddType == APPENDLINE)
|
||||
{
|
||||
AddType = NEWLINE;
|
||||
|
@ -1094,7 +1099,8 @@ void FNotifyBuffer::DrawNative()
|
|||
|
||||
int line = (g_gameType & GAMEFLAG_BLOOD)? Top : (g_gameType & GAMEFLAG_SW) ? 40 : font->GetDisplacement();
|
||||
bool canskip = (g_gameType & GAMEFLAG_BLOOD);
|
||||
int lineadv = font->GetHeight();
|
||||
double scale = 1 / (NotifyFontScale * con_notifyscale);
|
||||
int lineadv = font->GetHeight() / NotifyFontScale;
|
||||
|
||||
for (unsigned i = topline; i < Text.Size(); ++i)
|
||||
{
|
||||
|
@ -1116,16 +1122,14 @@ void FNotifyBuffer::DrawNative()
|
|||
{
|
||||
DrawText(twod, font, CR_UNTRANSLATED, 0, line, notify.Text,
|
||||
DTA_FullscreenScale, FSMode_ScaleToHeight,
|
||||
DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_KeepRatio, true,
|
||||
DTA_VirtualWidthF, 320 * scale, DTA_VirtualHeightF, 200 * scale, DTA_KeepRatio, true,
|
||||
DTA_Alpha, alpha, TAG_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
int fac = isRR() ? 2 : 1;
|
||||
|
||||
DrawText(twod, font, CR_UNTRANSLATED, 160 * fac - font->StringWidth(notify.Text) / 2, line, notify.Text,
|
||||
DrawText(twod, font, CR_UNTRANSLATED, 160 * scale - font->StringWidth(notify.Text) / 2, line, notify.Text,
|
||||
DTA_FullscreenScale, FSMode_ScaleToHeight,
|
||||
DTA_VirtualWidth, 320 * fac, DTA_VirtualHeight, 200 * fac,
|
||||
DTA_VirtualWidthF, 320 * scale, DTA_VirtualHeightF, 200 * scale,
|
||||
DTA_Alpha, alpha, TAG_DONE);
|
||||
}
|
||||
line += lineadv;
|
||||
|
@ -1155,13 +1159,15 @@ void FNotifyBuffer::Draw()
|
|||
|
||||
bool center = (con_centernotify != 0.f);
|
||||
int color;
|
||||
|
||||
FFont* font = generic_ui ? NewSmallFont : SmallFont? SmallFont : AlternativeSmallFont;
|
||||
|
||||
int line = Top + font->GetDisplacement() / NotifyFontScale;
|
||||
bool canskip = true;
|
||||
|
||||
int lineadv = font->GetHeight () / NotifyFontScale;
|
||||
|
||||
FFont* font = generic_ui ? NewSmallFont : SmallFont? SmallFont : AlternativeSmallFont;
|
||||
double nfscale = (generic_ui? 0.7 : NotifyFontScale);
|
||||
double scale = 1 / ( * con_notifyscale);
|
||||
|
||||
int line = Top + font->GetDisplacement() / nfscale;
|
||||
int lineadv = font->GetHeight () / nfscale;
|
||||
|
||||
for (unsigned i = 0; i < Text.Size(); ++ i)
|
||||
{
|
||||
|
@ -1184,20 +1190,19 @@ void FNotifyBuffer::Draw()
|
|||
else
|
||||
color = PrintColors[notify.PrintLevel];
|
||||
|
||||
int scale = active_con_scaletext(twod, generic_ui);
|
||||
if (!center)
|
||||
DrawText(twod, font, color, 0, line * NotifyFontScale, notify.Text,
|
||||
DTA_VirtualWidth, twod->GetWidth() / scale * NotifyFontScale,
|
||||
DTA_VirtualHeight, twod->GetHeight() / scale * NotifyFontScale,
|
||||
DTA_FullscreenScale, FSMode_ScaleToHeight,
|
||||
DTA_VirtualWidthF, 320. * scale,
|
||||
DTA_VirtualHeightF, 200. * scale,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_Alpha, alpha, TAG_DONE);
|
||||
else
|
||||
DrawText(twod, font, color, (twod->GetWidth() * NotifyFontScale -
|
||||
font->StringWidth (notify.Text) * scale) / 2 / scale,
|
||||
DrawText(twod, font, color, 160 * scale - font->StringWidth (notify.Text) / 2.,
|
||||
line, notify.Text,
|
||||
DTA_VirtualWidth, twod->GetWidth() / scale * NotifyFontScale,
|
||||
DTA_VirtualHeight, twod->GetHeight() / scale * NotifyFontScale,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_FullscreenScale, FSMode_ScaleToHeight,
|
||||
DTA_VirtualWidthF, 320. * scale,
|
||||
DTA_VirtualHeightF, 200. * scale,
|
||||
DTA_Alpha, alpha, TAG_DONE);
|
||||
line += lineadv;
|
||||
canskip = false;
|
||||
|
|
|
@ -44,13 +44,11 @@ enum
|
|||
};
|
||||
|
||||
|
||||
EXTERN_CVAR (Int, con_scaletext)
|
||||
|
||||
EXTERN_CVAR (Bool, sb_cooperative_enable)
|
||||
EXTERN_CVAR (Bool, sb_deathmatch_enable)
|
||||
EXTERN_CVAR (Bool, sb_teamdeathmatch_enable)
|
||||
|
||||
int active_con_scaletext();
|
||||
int active_con_scale();
|
||||
|
||||
// Public data
|
||||
|
||||
|
@ -243,7 +241,7 @@ void CT_Drawer (void)
|
|||
y = -displayfont->GetHeight()-2;
|
||||
|
||||
scalex = 1;
|
||||
int scale = active_con_scaletext(drawer);
|
||||
int scale = active_con_scale(drawer);
|
||||
int screen_width = twod->GetWidth() / scale;
|
||||
int screen_height= twod->GetHeight() / scale;
|
||||
#if 0 // stuff for later
|
||||
|
|
|
@ -129,7 +129,7 @@ void SECRET_SetMapName(const char *filename, const char *_maptitle)
|
|||
|
||||
void SECRET_Trigger(int num)
|
||||
{
|
||||
if (secret_notify) Printf("Secret #%d found\n", num);
|
||||
if (secret_notify) Printf(PRINT_NONOTIFY, "Secret #%d found\n", num);
|
||||
if (discovered_secrets.Find(num) == discovered_secrets.Size())
|
||||
discovered_secrets.Push(num);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ EXTERN_CVAR (Bool, am_showsecrets)
|
|||
EXTERN_CVAR (Bool, am_showtime)
|
||||
EXTERN_CVAR (Bool, am_showtotaltime)
|
||||
EXTERN_CVAR (Bool, noisedebug)
|
||||
EXTERN_CVAR (Int, con_scaletext)
|
||||
EXTERN_CVAR(Bool, vid_fps)
|
||||
EXTERN_CVAR(Bool, inter_subtitles)
|
||||
CVAR(Bool, log_vgafont, false, CVAR_ARCHIVE)
|
||||
|
|
|
@ -1024,10 +1024,10 @@ OptionMenu "HUDOptions" //protected
|
|||
Title "$OPTMNU_HUD"
|
||||
|
||||
Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 9.0, 1.0, -1
|
||||
Slider "$DSPLYMNU_SBSCALE", "hud_scale", 36, 100, 0.04, 2
|
||||
Slider "$DSPLYMNU_SBSCALE", "hud_scale", 0.36, 1.0, 0.04, 2
|
||||
StaticText ""
|
||||
Option "$DSPLYMNU_LEVELSTATS", "hud_stats", "OnOff"
|
||||
Slider "$DSPLYMNU_STATSCALE", "hud_statscale", 36, 100, 0.04, 2
|
||||
Slider "$DSPLYMNU_STATSCALE", "hud_statscale", 0.36, 1.0, 0.04, 2
|
||||
|
||||
//Slider "$DSPLYMNU_TEXTSCALE", "hud_textscale", 100, 400, 20, 2
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ OptionMenu "HUDOptions" //protected
|
|||
Option "$DSPLYMNU_MESSAGEDISP", "con_notify_advanced", "HudMessageStyle"
|
||||
Option "$MSGMNU_CENTERMESSAGES", "con_centernotify", "OnOff", "con_notify_advanced"
|
||||
Option "$MSGMNU_PULSEMESSAGES", "con_pulsetext", "OnOff", "con_notify_advanced"
|
||||
Slider "$MSGMNU_MESSAGESCALE", "con_scaletext", 0.0, 8.0, 1.0, 1
|
||||
Slider "$MSGMNU_MESSAGESCALE", "con_notifyscale", 0.36, 1.0, 0.04, 2
|
||||
|
||||
StaticText ""
|
||||
Option "$DSPLYMNU_CROSSHAIR", "cl_crosshair", OnOff
|
||||
|
|
Loading…
Reference in a new issue