- CVAR cleanup, in particular decoupling from game internals, which now get handled via callbacks.

This commit is contained in:
Christoph Oelckers 2020-04-11 13:48:55 +02:00
commit 1479e3a1c3
17 changed files with 432 additions and 374 deletions

View file

@ -317,30 +317,26 @@ CVAR (Color, am_ovportalcolor, 0x004022, CVAR_ARCHIVE);
struct AMColor
{
int Index;
uint32_t RGB;
void FromCVar(FColorCVar & cv)
{
Index = cv.GetIndex();
RGB = uint32_t(cv) | MAKEARGB(255, 0, 0, 0);
}
void FromRGB(int r,int g, int b)
{
RGB = MAKEARGB(255, r, g, b);
Index = ColorMatcher.Pick(r, g, b);
}
void setInvalid()
{
Index = -1;
RGB = -1;
RGB = 0;
}
bool isValid() const
{
return Index > -1;
return RGB != 0;
}
};
@ -1585,7 +1581,7 @@ void DAutomap::clearFB (const AMColor &color)
if (!drawback)
{
screen->Clear (0, 0, f_w, f_h, color.Index, color.RGB);
screen->Clear (0, 0, f_w, f_h, -1, color.RGB);
}
else
{
@ -1752,7 +1748,7 @@ void DAutomap::drawMline (mline_t *ml, const AMColor &color)
if (clipMline (ml, &fl))
{
screen->DrawLine (f_x + fl.a.x, f_y + fl.a.y, f_x + fl.b.x, f_y + fl.b.y, color.Index, color.RGB);
screen->DrawLine (f_x + fl.a.x, f_y + fl.a.y, f_x + fl.b.x, f_y + fl.b.y, -1, color.RGB);
}
}
@ -2955,7 +2951,7 @@ void DAutomap::drawThings ()
if (G_SkillProperty(SKILLP_EasyKey) || am_showkeys_always)
{
// Already drawn by AM_drawKeys(), so don't draw again
color.Index = -1;
color.RGB = 0;
}
else if (am_showkeys)
{
@ -2964,7 +2960,7 @@ void DAutomap::drawThings ()
if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c));
else color = AMColors[AMColors.ThingColor_CountItem];
drawLineCharacter(&CheatKey[0], CheatKey.Size(), 0, 0., color, p.x, p.y);
color.Index = -1;
color.RGB = 0;
}
else
{
@ -2977,7 +2973,7 @@ void DAutomap::drawThings ()
color = AMColors[AMColors.ThingColor_Item];
}
if (color.Index != -1)
if (color.isValid())
{
drawLineCharacter(thintriangle_guy.data(), thintriangle_guy.size(), 16, angle, color, p.x, p.y);
}
@ -3150,7 +3146,7 @@ void DAutomap::drawAuthorMarkers ()
void DAutomap::drawCrosshair (const AMColor &color)
{
screen->DrawPixel(f_w/2, (f_h+1)/2, color.Index, color.RGB);
screen->DrawPixel(f_w/2, (f_h+1)/2, -1, color.RGB);
}
//=============================================================================