mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-13 07:57:51 +00:00
- consolidated the 3 nearly identical code fragments handling the weapon's YAdjust for the different renderers into a utility function in DPSprite.
This commit is contained in:
parent
4392b4e96d
commit
ead28db007
5 changed files with 31 additions and 39 deletions
|
@ -433,21 +433,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy,
|
||||||
x2 += viewwindowx;
|
x2 += viewwindowx;
|
||||||
|
|
||||||
// killough 12/98: fix psprite positioning problem
|
// killough 12/98: fix psprite positioning problem
|
||||||
ftexturemid = 100.f - sy - r.top;
|
ftexturemid = 100.f - sy - r.top - psp->GetYAdjust(screenblocks >= 11);
|
||||||
|
|
||||||
AWeapon * wi = player->ReadyWeapon;
|
|
||||||
if (wi && wi->YAdjust != 0)
|
|
||||||
{
|
|
||||||
float fYAd = wi->YAdjust;
|
|
||||||
if (screenblocks >= 11)
|
|
||||||
{
|
|
||||||
ftexturemid -= fYAd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ftexturemid -= float(StatusBar->GetDisplacement()) * fYAd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f);
|
scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f);
|
||||||
y1 = viewwindowy + vh / 2 - (ftexturemid * scale);
|
y1 = viewwindowy + vh / 2 - (ftexturemid * scale);
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
#include "sbar.h"
|
||||||
|
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
@ -1348,6 +1349,32 @@ void DPSprite::OnDestroy()
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
float DPSprite::GetYAdjust(bool fullscreen)
|
||||||
|
{
|
||||||
|
AWeapon *weapon = dyn_cast<AWeapon>(GetCaller());
|
||||||
|
if (weapon != nullptr)
|
||||||
|
{
|
||||||
|
float fYAd = weapon->YAdjust;
|
||||||
|
if (fYAd != 0)
|
||||||
|
{
|
||||||
|
if (fullscreen)
|
||||||
|
{
|
||||||
|
return fYAd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return StatusBar->GetDisplacement() * fYAd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
ADD_STAT(psprites)
|
ADD_STAT(psprites)
|
||||||
{
|
{
|
||||||
FString out;
|
FString out;
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
void ResetInterpolation() { oldx = x; oldy = y; }
|
void ResetInterpolation() { oldx = x; oldy = y; }
|
||||||
void OnDestroy() override;
|
void OnDestroy() override;
|
||||||
std::pair<FRenderStyle, float> GetRenderStyle(FRenderStyle ownerstyle, double owneralpha);
|
std::pair<FRenderStyle, float> GetRenderStyle(FRenderStyle ownerstyle, double owneralpha);
|
||||||
|
float GetYAdjust(bool fullscreen);
|
||||||
|
|
||||||
double x, y, alpha;
|
double x, y, alpha;
|
||||||
double oldx, oldy;
|
double oldx, oldy;
|
||||||
|
|
|
@ -296,18 +296,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
viewheight == renderTarget->GetHeight() ||
|
viewheight == renderTarget->GetHeight() ||
|
||||||
(renderTarget->GetWidth() > (BASEXCENTER * 2))))
|
(renderTarget->GetWidth() > (BASEXCENTER * 2))))
|
||||||
{ // Adjust PSprite for fullscreen views
|
{ // Adjust PSprite for fullscreen views
|
||||||
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
vis.texturemid -= pspr->GetYAdjust(renderToCanvas || viewheight == renderTarget->GetHeight());
|
||||||
if (weapon != nullptr && weapon->YAdjust != 0)
|
|
||||||
{
|
|
||||||
if (renderToCanvas || viewheight == renderTarget->GetHeight())
|
|
||||||
{
|
|
||||||
vis.texturemid -= weapon->YAdjust;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vis.texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (pspr->GetID() < PSP_TARGETCENTER)
|
if (pspr->GetID() < PSP_TARGETCENTER)
|
||||||
{ // Move the weapon down for 1280x1024.
|
{ // Move the weapon down for 1280x1024.
|
||||||
|
|
|
@ -295,18 +295,7 @@ namespace swrenderer
|
||||||
viewheight == viewport->RenderTarget->GetHeight() ||
|
viewheight == viewport->RenderTarget->GetHeight() ||
|
||||||
(viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2))))
|
(viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2))))
|
||||||
{ // Adjust PSprite for fullscreen views
|
{ // Adjust PSprite for fullscreen views
|
||||||
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
vis.texturemid -= pspr->GetYAdjust(renderToCanvas || viewheight == viewport->RenderTarget->GetHeight());
|
||||||
if (weapon != nullptr && weapon->YAdjust != 0)
|
|
||||||
{
|
|
||||||
if (renderToCanvas || viewheight == viewport->RenderTarget->GetHeight())
|
|
||||||
{
|
|
||||||
vis.texturemid -= weapon->YAdjust;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vis.texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (pspr->GetID() < PSP_TARGETCENTER)
|
if (pspr->GetID() < PSP_TARGETCENTER)
|
||||||
{ // Move the weapon down for 1280x1024.
|
{ // Move the weapon down for 1280x1024.
|
||||||
|
|
Loading…
Reference in a new issue