- generalized the automap label code.

Using proper scaling and should be reusable from all games now.
This commit is contained in:
Christoph Oelckers 2020-08-24 23:14:55 +02:00
parent 25ade79b90
commit 6672b8af99
4 changed files with 72 additions and 31 deletions

View file

@ -214,7 +214,7 @@ CCMD(sizedown)
CUSTOM_CVARD(Float, hud_statscale, 0.5, CVAR_ARCHIVE, "change the scale of the stats display")
{
if (self < 0.36) self = 0.36;
if (self < 0.36f) self = 0.36f;
else if (self > 1) self = 1;
}

View file

@ -57,7 +57,10 @@
#include "v_draw.h"
#include "gamecvars.h"
#include "m_fixed.h"
#include "gamecontrol.h"
#include "gamestruct.h"
#include "menu.h"
#include "mapinfo.h"
#include "../version.h"
@ -720,7 +723,8 @@ void DBaseStatusBar::PrintLevelStats(FLevelStats &stats)
{
text.Format(TEXTCOLOR_ESCAPESTR "%cS: " TEXTCOLOR_ESCAPESTR "%c%d/%d",
stats.letterColor + 'A', stats.secrets == stats.maxsecrets ? stats.completeColor + 'A' : stats.standardColor + 'A', stats.secrets, stats.maxsecrets);
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
y -= spacing;
}
@ -732,14 +736,57 @@ void DBaseStatusBar::PrintLevelStats(FLevelStats &stats)
if (text.IsNotEmpty())
{
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
y -= spacing;
}
text.Format(TEXTCOLOR_ESCAPESTR "%cT: " TEXTCOLOR_ESCAPESTR "%c%d:%02d", stats.letterColor+'A', stats.standardColor + 'A', stats.time / 60000, (stats.time % 60000) / 1000);
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE);
}
//============================================================================
//
//
//
//============================================================================
void DBaseStatusBar::PrintAutomapInfo(FLevelStats& stats)
{
FString mapname;
if (am_showlabel)
mapname.Format(TEXTCOLOR_ESCAPESTR "%c%s: " TEXTCOLOR_ESCAPESTR "%c%s", stats.letterColor+'A', currentLevel->LabelName(), stats.standardColor+'A', currentLevel->DisplayName());
else
mapname = currentLevel->DisplayName();
double y;
double scale = stats.fontscale * (am_textfont? *hud_statscale : 1); // the tiny default font used by all games here cannot be scaled for readability purposes.
if (stats.spacing <= 0) stats.spacing = stats.font->GetHeight() * stats.fontscale;
double spacing = stats.spacing * (am_textfont ? *hud_statscale : 1);
if (am_nameontop)
{
y = spacing;
}
else if (stats.screenbottomspace < 0)
{
y = 200 - RelTop - spacing;
}
else
{
y = 200 - stats.screenbottomspace - spacing;
}
DrawText(twod, stats.font, stats.standardColor, 2 * hud_statscale, y, mapname, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);
y -= spacing;
if (!(currentLevel->flags & MI_USERMAP) && !(g_gameType & GAMEFLAG_PSEXHUMED))
DrawText(twod, stats.font, stats.standardColor, 2 * hud_statscale, y, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]),
DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);
}
//============================================================================
//
//

View file

@ -190,6 +190,7 @@ public:
void BeginHUD(int resW, int resH, double Alpha);
void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const;
void PrintLevelStats(FLevelStats& stats);
void PrintAutomapInfo(FLevelStats& stats);
int GetTopOfStatusbar() const
{
return SBarTop;

View file

@ -179,50 +179,43 @@ PalEntry DDukeCommonStatusBar::LightForShade(int shade)
void DDukeCommonStatusBar::PrintLevelStats(int bottomy)
{
FLevelStats stats{};
auto pp = &ps[myconnectindex];
stats.fontscale = isRR() ? 0.5 : 1.;
stats.spacing = isRR() ? 10 : 7;
stats.screenbottomspace = bottomy;
stats.time = Scale(pp->player_par, 1000, REALGAMETICSPERSEC);
stats.font = SmallFont;
if (isNamWW2GI())
{
// The stock font of these games is totally unusable for this.
stats.font = ConFont;
stats.spacing = ConFont->GetHeight() + 1;
}
if (automapMode == am_full)
{
// Automap label printer moved here so that it is on top of the screen border.
FString mapname;
if (am_showlabel) mapname.Format(TEXTCOLOR_GOLD "%s: %s%s", currentLevel->LabelName(), (am_textfont && isNamWW2GI()) ? TEXTCOLOR_ORANGE : TEXTCOLOR_UNTRANSLATED, currentLevel->DisplayName());
else mapname = currentLevel->DisplayName();
double scale = isRR() ? 0.5 : 1.;
FFont* font = SmallFont2;
int color = CR_UNTRANSLATED;
if (am_textfont)
if (!am_textfont)
{
scale *= 0.66;
font = isNamWW2GI() ? ConFont : SmallFont;
if (isNamWW2GI()) color = CR_ORANGE;
stats.font = SmallFont2;
stats.spacing = 6;
}
double top = am_nameontop ? 0 : ( 200 - (bottomy < 0 ? RelTop : bottomy) * hud_scale - (isRR()? 25 : 20));
if (!(currentLevel->flags & MI_USERMAP))
DrawText(twod, font, color, 5, top + 6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]),
DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);
DrawText(twod, font, color, 5, top + ((isRR() && am_textfont) ? 15 : 12), mapname,
DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);
stats.standardColor = (isNamWW2GI() && am_textfont)? CR_ORANGE : CR_UNTRANSLATED;
stats.letterColor = CR_GOLD;
DBaseStatusBar::PrintAutomapInfo(stats);
}
else if (hud_stats)
{
// JBF 20040124: display level stats in screen corner
FLevelStats stats{};
auto pp = &ps[myconnectindex];
stats.fontscale = isRR() ? 0.5 : 1.;
stats.spacing = isRR() ? 10 : 7;
stats.screenbottomspace = bottomy;
stats.time = Scale(pp->player_par, 1000, REALGAMETICSPERSEC);
stats.kills = pp->actors_killed;
stats.maxkills = !isRR() && ud.player_skill > 3 ? -2 : pp->max_actors_killed;
stats.frags = ud.multimode > 1 && !ud.coop ? pp->frag - pp->fraggedself : -1;
stats.secrets = pp->secret_rooms;
stats.maxsecrets = pp->max_secret_rooms;
stats.font = SmallFont;
if (isNamWW2GI())
{
// The stock font of these games is totally unusable for this.
stats.font = ConFont;
stats.spacing = ConFont->GetHeight() + 1;
stats.letterColor = CR_ORANGE;
stats.standardColor = CR_YELLOW;
stats.completeColor = CR_FIRE;