- RR: Fixed the drink and eat meters on the status bar.

Turned out that the status bar's DrawGraphic cannot handle it with its coordinate hackery, this needs a separate, cleaner interface function that does not mess around with the pivot which needs to be passed unaltered to the backend to properly rotate around it
This commit is contained in:
Christoph Oelckers 2021-02-28 21:46:36 +01:00
parent fa8ca81460
commit 80404558f6
4 changed files with 103 additions and 11 deletions

View file

@ -452,16 +452,16 @@ void DStatusBarCore::StatusbarToRealCoords(double& x, double& y, double& w, doub
//
//============================================================================
void DStatusBarCore::DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color, int translation, double rotate, ERenderStyle style)
void DStatusBarCore::DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color, int translation, ERenderStyle style)
{
if (!texture.isValid())
return;
FGameTexture* tex = TexMan.GetGameTexture(texture, !(flags & DI_DONTANIMATE));
DrawGraphic(tex, x, y, flags, Alpha, boxwidth, boxheight, scaleX, scaleY, color, translation, rotate, style);
DrawGraphic(tex, x, y, flags, Alpha, boxwidth, boxheight, scaleX, scaleY, color, translation, style);
}
void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color, int translation, double rotate, ERenderStyle style)
void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color, int translation, ERenderStyle style)
{
double texwidth = tex->GetDisplayWidth() * scaleX;
double texheight = tex->GetDisplayHeight() * scaleY;
@ -590,7 +590,96 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag
DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1,
DTA_FlipX, !!(flags & DI_MIRROR),
DTA_FlipY, !!(flags& DI_MIRRORY),
DTA_Rotate, rotate,
DTA_LegacyRenderStyle, style,
TAG_DONE);
}
//============================================================================
//
// draw stuff
//
//============================================================================
void DStatusBarCore::DrawRotated(FTextureID texture, double x, double y, double angle, int flags, double Alpha, double scaleX, double scaleY, PalEntry color, int translation, ERenderStyle style)
{
if (!texture.isValid())
return;
FGameTexture* tex = TexMan.GetGameTexture(texture, !(flags & DI_DONTANIMATE));
DrawRotated(tex, x, y, angle, flags, Alpha, scaleX, scaleY, color, translation, style);
}
void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color, int translation, ERenderStyle style)
{
double texwidth = tex->GetDisplayWidth() * scaleX;
double texheight = tex->GetDisplayHeight() * scaleY;
double texleftoffs = tex->GetDisplayLeftOffset() * scaleY;
double textopoffs = tex->GetDisplayTopOffset() * scaleY;
// resolve auto-alignment before making any adjustments to the position values.
if (!(flags & DI_SCREEN_MANUAL_ALIGN))
{
if (x < 0) flags |= DI_SCREEN_RIGHT;
else flags |= DI_SCREEN_LEFT;
if (y < 0) flags |= DI_SCREEN_BOTTOM;
else flags |= DI_SCREEN_TOP;
}
Alpha *= this->Alpha;
if (Alpha <= 0) return;
x += drawOffset.X;
y += drawOffset.Y;
DVector2 Scale = GetHUDScale();
scaleX = 1 / scaleX;
scaleY = 1 / scaleY;
if (!fullscreenOffsets)
{
StatusbarToRealCoords(x, y, texwidth, texheight);
}
else
{
double orgx, orgy;
switch (flags & DI_SCREEN_HMASK)
{
default: orgx = 0; break;
case DI_SCREEN_HCENTER: orgx = twod->GetWidth() / 2; break;
case DI_SCREEN_RIGHT: orgx = twod->GetWidth(); break;
}
switch (flags & DI_SCREEN_VMASK)
{
default: orgy = 0; break;
case DI_SCREEN_VCENTER: orgy = twod->GetHeight() / 2; break;
case DI_SCREEN_BOTTOM: orgy = twod->GetHeight(); break;
}
// move stuff in the top right corner a bit down if the fps counter is on.
if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10;
x *= Scale.X;
y *= Scale.Y;
scaleX *= Scale.X;
scaleY *= Scale.Y;
x += orgx;
y += orgy;
}
DrawTexture(twod, tex, x, y,
DTA_ScaleX, scaleX,
DTA_ScaleY, scaleY,
DTA_Color, color,
DTA_CenterOffsetRel, !!(flags & DI_ITEM_RELCENTER),
DTA_Rotate, angle,
DTA_TranslationIndex, translation ? translation : (flags & DI_TRANSLATABLE) ? GetTranslation() : 0,
DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0,
DTA_Alpha, Alpha,
DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED),
DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1,
DTA_FlipX, !!(flags & DI_MIRROR),
DTA_FlipY, !!(flags & DI_MIRRORY),
DTA_LegacyRenderStyle, style,
TAG_DONE);
}

View file

@ -184,8 +184,10 @@ public:
virtual void SetScale();
void ValidateResolution(int& hres, int& vres) const;
void StatusbarToRealCoords(double& x, double& y, double& w, double& h) const;
void DrawGraphic(FGameTexture* texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent);
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, double rotate = 0, ERenderStyle style = STYLE_Translucent);
void DrawGraphic(FGameTexture* texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawRotated(FTextureID texture, double x, double y, double angle, int flags, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawRotated(FGameTexture* tex, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt);
void TransformRect(double& x, double& y, double& w, double& h, int flags = 0);
void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0);

View file

@ -131,7 +131,7 @@ private:
int flags = align | ((nStat & RS_CENTERBOTTOM)? DI_ITEM_CENTER_BOTTOM : (nStat & RS_TOPLEFT)? DI_ITEM_LEFT_TOP : DI_ITEM_RELCENTER);
double alpha = 1.;
double scale = nScale / 65536.;
DrawGraphic(tileGetTexture(nTile, true), x, y, flags, alpha, -1, -1, scale, scale, shadeToLight(nShade), TRANSLATION(Translation_Remap, nPalette), 0, style);
DrawGraphic(tileGetTexture(nTile, true), x, y, flags, alpha, -1, -1, scale, scale, shadeToLight(nShade), TRANSLATION(Translation_Remap, nPalette), style);
}
void DrawStatMaskedSprite(int nTile, double x, double y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536, int align = DI_SCREEN_AUTO)
{
@ -198,7 +198,7 @@ private:
int bx = scale(MulScale(w, nScale, 16), nMult, nDiv) + x;
double scale = double(bx - x) / w;
double sc = nScale / 65536.;
DrawGraphic(tileGetTexture(nTile, true), x, y, DI_ITEM_LEFT_TOP, 1., -1, -1, scale*sc, sc, 0xffffffff, 0, 0);
DrawGraphic(tileGetTexture(nTile, true), x, y, DI_ITEM_LEFT_TOP, 1., -1, -1, scale*sc, sc, 0xffffffff, 0);
}

View file

@ -35,6 +35,8 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "names_r.h"
#include "texturemanager.h"
#include "dukeactor.h"
#include "v_video.h"
#include "v_draw.h"
BEGIN_DUKE_NS
@ -411,9 +413,8 @@ public:
p->drunkang = 400;
}
// Todo: These need rotation support which currently does not exist.
DrawGraphic(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, 1, -1, -1, scale, scale, 0xffffffff, 0, p->drunkang * (-360. / 2048));
DrawGraphic(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, 1, -1, -1, scale, scale, 0xffffffff, 0, p->eatang * (-360. / 2048));
DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0);
DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * (-360. / 2048), 1, scale, scale, 0xffffffff, 0);
if (p->drink_amt >= 0 && p->drink_amt <= 30)
{