- added ability to customize font of automap marks

Set am_markfont CVAR to a desired font name
Use am_markcolor to select a text color, has no effect with the default font, AMMNUMx
This commit is contained in:
alexey.lysiuk 2019-02-13 13:05:31 +02:00 committed by Christoph Oelckers
parent 914818cb88
commit be6ce43045
3 changed files with 42 additions and 3 deletions

View file

@ -189,6 +189,10 @@ CVAR(Bool, am_portaloverlay, true, CVAR_ARCHIVE)
CVAR(Bool, am_showgrid, false, CVAR_ARCHIVE) CVAR(Bool, am_showgrid, false, CVAR_ARCHIVE)
CVAR(Float, am_zoomdir, 0, CVAR_ARCHIVE) CVAR(Float, am_zoomdir, 0, CVAR_ARCHIVE)
static const char *const DEFAULT_FONT_NAME = "AMMNUMx";
CVAR(String, am_markfont, DEFAULT_FONT_NAME, CVAR_ARCHIVE)
CVAR(Int, am_markcolor, CR_GREY, CVAR_ARCHIVE)
CCMD(am_togglefollow) CCMD(am_togglefollow)
{ {
am_followplayer = !am_followplayer; am_followplayer = !am_followplayer;
@ -1128,7 +1132,9 @@ void DAutomap::restoreScaleAndLoc ()
int DAutomap::addMark () int DAutomap::addMark ()
{ {
if (marknums[0].isValid()) // Add a mark when default font is selected and its textures (AMMNUM?)
// are loaded. Mark is always added when custom font is selected
if (stricmp(*am_markfont, DEFAULT_FONT_NAME) != 0 || marknums[0].isValid())
{ {
auto m = markpointnum; auto m = markpointnum;
markpoints[markpointnum].x = m_x + m_w/2; markpoints[markpointnum].x = m_x + m_w/2;
@ -3032,12 +3038,29 @@ void DAutomap::DrawMarker (FTexture *tex, double x, double y, int yadjust,
void DAutomap::drawMarks () void DAutomap::drawMarks ()
{ {
FFont* font;
bool fontloaded = false;
for (int i = 0; i < AM_NUMMARKPOINTS; i++) for (int i = 0; i < AM_NUMMARKPOINTS; i++)
{ {
if (markpoints[i].x != -1) if (markpoints[i].x != -1)
{ {
DrawMarker (TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0, if (!fontloaded)
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]); {
font = stricmp(*am_markfont, DEFAULT_FONT_NAME) == 0 ? nullptr : V_GetFont(am_markfont);
fontloaded = true;
}
if (font == nullptr)
{
DrawMarker(TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]);
}
else
{
char numstr[2] = { char('0' + i), 0 };
screen->DrawText(font, am_markcolor, CXMTOF(markpoints[i].x), CYMTOF(markpoints[i].y), numstr, TAG_DONE);
}
} }
} }
} }

View file

@ -2003,6 +2003,8 @@ AUTOMAPMNU_SHOWTRIGGERLINES = "Show trigger lines";
AUTOMAPMNU_SHOWTHINGSPRITES = "Show things as sprites"; AUTOMAPMNU_SHOWTHINGSPRITES = "Show things as sprites";
AUTOMAPMNU_PTOVERLAY = "Overlay portals"; AUTOMAPMNU_PTOVERLAY = "Overlay portals";
AUTOMAPMNU_EMPTYSPACEMARGIN = "Empty space margin"; AUTOMAPMNU_EMPTYSPACEMARGIN = "Empty space margin";
AUTOMAPMNU_MARKFONT = "Mark font";
AUTOMAPMNU_MARKCOLOR = "Mark color";
// Automap Controls // Automap Controls
MAPCNTRLMNU_TITLE = "CUSTOMIZE MAP CONTROLS"; MAPCNTRLMNU_TITLE = "CUSTOMIZE MAP CONTROLS";
@ -2503,6 +2505,9 @@ OPTVAL_VTAVANILLA = "Auto (Vanilla Preferred)";
OPTVAL_SCALENEAREST = "Scaled (Nearest)"; OPTVAL_SCALENEAREST = "Scaled (Nearest)";
OPTVAL_SCALELINEAR = "Scaled (Linear)"; OPTVAL_SCALELINEAR = "Scaled (Linear)";
OPTVAL_LETTERBOX = "Letterbox"; OPTVAL_LETTERBOX = "Letterbox";
OPTVAL_SMALL = "Small";
OPTVAL_LARGE = "Large";
OPTVAL_CONSOLE = "Console";
// Colors // Colors
C_BRICK = "\cabrick"; C_BRICK = "\cabrick";

View file

@ -1077,6 +1077,14 @@ OptionValue MapTriggers
2, "$OPTVAL_ON" 2, "$OPTVAL_ON"
} }
OptionString MapMarkFont
{
"AMMNUMx", "$OPTVAL_DEFAULT"
"SmallFont", "$OPTVAL_SMALL"
"BigFont", "$OPTVAL_LARGE"
"ConsoleFont", "$OPTVAL_CONSOLE"
}
OptionMenu AutomapOptions protected OptionMenu AutomapOptions protected
{ {
Title "$AUTOMAPMNU_TITLE" Title "$AUTOMAPMNU_TITLE"
@ -1103,6 +1111,9 @@ OptionMenu AutomapOptions protected
Option "$AUTOMAPMNU_SHOWKEYS", "am_showkeys", "OnOff" Option "$AUTOMAPMNU_SHOWKEYS", "am_showkeys", "OnOff"
Option "$AUTOMAPMNU_SHOWTRIGGERLINES", "am_showtriggerlines", "MapTriggers" Option "$AUTOMAPMNU_SHOWTRIGGERLINES", "am_showtriggerlines", "MapTriggers"
Option "$AUTOMAPMNU_SHOWTHINGSPRITES", "am_showthingsprites", "STSTypes" Option "$AUTOMAPMNU_SHOWTHINGSPRITES", "am_showthingsprites", "STSTypes"
StaticText " "
Option "$AUTOMAPMNU_MARKFONT", "am_markfont", "MapMarkFont"
Option "$AUTOMAPMNU_MARKCOLOR", "am_markcolor", "TextColors"
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------