- export common formulae to functions instead of copy-pasting them

This commit is contained in:
Rachael Alexanderson 2020-05-07 02:13:11 -04:00
parent 872e9b252f
commit 7cf52eb0c3
3 changed files with 20 additions and 9 deletions

View file

@ -680,6 +680,19 @@ void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigne
// //
//========================================================================== //==========================================================================
float F2DDrawer::GetClassicFlatScalarWidth()
{
float ar = 4.f / 3.f / (float)ActiveRatio((float)screen->GetWidth(), (float)screen->GetHeight());
float sw = 320.f * classic_scaling_factor / (float)screen->GetWidth() / ar;
return sw;
}
float F2DDrawer::GetClassicFlatScalarHeight()
{
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight();
return sh;
}
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale) void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale)
{ {
float fU1, fU2, fV1, fV2; float fU1, fU2, fV1, fV2;
@ -696,9 +709,8 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
float fs = 1.f / float(flatscale); float fs = 1.f / float(flatscale);
bool flipc = false; bool flipc = false;
float ar = 4.f / 3.f / (float)ActiveRatio((float)screen->GetWidth(), (float)screen->GetHeight()); float sw = GetClassicFlatScalarWidth();
float sw = 320.f * classic_scaling_factor / (float)screen->GetWidth() / ar; float sh = GetClassicFlatScalarHeight();
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight();
switch (local_origin) switch (local_origin)
{ {

View file

@ -174,6 +174,8 @@ private:
void SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcolor, PalEntry &overlaycolor); void SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcolor, PalEntry &overlaycolor);
public: public:
float GetClassicFlatScalarWidth();
float GetClassicFlatScalarHeight();
void AddTexture(FGameTexture* img, DrawParms& parms); void AddTexture(FGameTexture* img, DrawParms& parms);
void AddShape(FGameTexture *img, DShape2D *shape, DrawParms &parms); void AddShape(FGameTexture *img, DShape2D *shape, DrawParms &parms);
void AddPoly(FGameTexture *texture, FVector2 *points, int npoints, void AddPoly(FGameTexture *texture, FVector2 *points, int npoints,

View file

@ -89,8 +89,6 @@ EXTERN_CVAR (Bool, noisedebug)
EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR (Int, con_scaletext)
EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Bool, vid_fps)
EXTERN_CVAR(Bool, inter_subtitles) EXTERN_CVAR(Bool, inter_subtitles)
EXTERN_CVAR(Float, classic_scaling_factor)
EXTERN_CVAR(Float, classic_scaling_pixelaspect)
EXTERN_CVAR(Bool, ui_screenborder_classic_scaling) EXTERN_CVAR(Bool, ui_screenborder_classic_scaling)
CVAR(Int, hud_scale, 0, CVAR_ARCHIVE); CVAR(Int, hud_scale, 0, CVAR_ARCHIVE);
@ -166,9 +164,8 @@ void V_DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
int right = left + width; int right = left + width;
int bottom = top + height; int bottom = top + height;
float ar = 4.f / 3.f / (float)ActiveRatio((float)screen->GetWidth(), (float)screen->GetHeight()); float sw = drawer->GetClassicFlatScalarWidth();
float sw = 320.f * classic_scaling_factor / (float)screen->GetWidth() / ar; float sh = drawer->GetClassicFlatScalarHeight();
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight();
if (!ui_screenborder_classic_scaling) if (!ui_screenborder_classic_scaling)
{ {
@ -1073,7 +1070,7 @@ void DBaseStatusBar::RefreshBackground () const
auto tex = GetBorderTexture(primaryLevel); auto tex = GetBorderTexture(primaryLevel);
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight(); float sh = twod->GetClassicFlatScalarHeight();
if(!CompleteBorder) if(!CompleteBorder)
{ {