- 2D drawer cleanup.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:46:57 +02:00
commit b18faacab0
36 changed files with 1032 additions and 1147 deletions

View file

@ -0,0 +1,67 @@
#pragma once
#include <stdint.h>
#include "palentry.h"
// for internal use
struct FColormap
{
PalEntry LightColor; // a is saturation (0 full, 31=b/w, other=custom colormap)
PalEntry FadeColor; // a is fadedensity>>1
uint8_t Desaturation;
uint8_t BlendFactor; // This is for handling Legacy-style colormaps which use a different formula to calculate how the color affects lighting.
uint16_t FogDensity;
void Clear()
{
LightColor = 0xffffff;
FadeColor = 0;
Desaturation = 0;
BlendFactor = 0;
FogDensity = 0;
}
void MakeWhite()
{
LightColor = 0xffffff;
}
void ClearColor()
{
LightColor = 0xffffff;
BlendFactor = 0;
Desaturation = 0;
}
void CopyLight(FColormap &from)
{
LightColor = from.LightColor;
Desaturation = from.Desaturation;
BlendFactor = from.BlendFactor;
}
void CopyFog(FColormap &from)
{
FadeColor = from.FadeColor;
FogDensity = from.FogDensity;
}
void Decolorize()
{
LightColor.Decolorize();
}
bool operator == (const FColormap &other)
{
return LightColor == other.LightColor && FadeColor == other.FadeColor && Desaturation == other.Desaturation &&
BlendFactor == other.BlendFactor && FogDensity == other.FogDensity;
}
bool operator != (const FColormap &other)
{
return !operator==(other);
}
};

View file

@ -94,9 +94,9 @@ void FStat::ToggleStat ()
m_Active = !m_Active;
}
void FStat::PrintStat ()
void FStat::PrintStat (F2DDrawer *drawer)
{
int textScale = active_con_scale();
int textScale = active_con_scale(drawer);
int fontheight = NewConsoleFont->GetHeight() + 1;
int y = screen->GetHeight() / textScale;
@ -116,9 +116,9 @@ void FStat::PrintStat ()
// Count number of linefeeds but ignore terminating ones.
if (stattext[i] == '\n') y -= fontheight;
}
DrawText(twod, NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DrawText(drawer, NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, twod->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
count++;
}

View file

@ -223,6 +223,7 @@ private:
};
class F2DDrawer;
class FStat
{
@ -238,7 +239,7 @@ public:
return m_Active;
}
static void PrintStat ();
static void PrintStat (F2DDrawer *drawer);
static FStat *FindStat (const char *name);
static void ToggleStat (const char *name);
static void EnableStat(const char* name, bool on);