- preparations for rendering Blood's status bar through the Statusbar class.

This commit is contained in:
Christoph Oelckers 2020-08-02 08:39:51 +02:00
parent 49a25c417b
commit cc8798f6e2
6 changed files with 689 additions and 472 deletions

View file

@ -301,7 +301,6 @@ void CPlayerMsg::Draw(void)
if (gViewSize >= 1)
y += tilesiz[2229].y*((gNetPlayers+3)/4);
viewDrawText(0, buffer, x+1,y+1, -128, 0, 0, false, 256);
viewUpdatePages();
}
bool CPlayerMsg::AddChar(char ch)

View file

@ -47,44 +47,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "v_video.h"
#include "v_font.h"
#include "glbackend/glbackend.h"
#include "statusbar.h"
CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE/*|CVAR_FRONTEND_BLOOD*/, "enable/disable displaying the remaining seconds for power-ups")
BEGIN_BLD_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawStats(PLAYER* pPlayer, int x, int y)
{
const int nFont = 3;
char buffer[128];
if (!hud_stats)
return;
int nHeight;
viewGetFontInfo(nFont, NULL, NULL, &nHeight);
sprintf(buffer, "T:%d:%02d.%02d",
(gLevelTime / (kTicsPerSec * 60)),
(gLevelTime / kTicsPerSec) % 60,
((gLevelTime % kTicsPerSec) * 33) / 10
);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
y += nHeight + 1;
if (gGameOptions.nGameType != 3)
sprintf(buffer, "K:%d/%d", gKillMgr.at4, gKillMgr.at0);
else
sprintf(buffer, "F:%d", pPlayer->fragCount);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
y += nHeight + 1;
sprintf(buffer, "S:%d/%d", gSecretMgr.at4 + gSecretMgr.at8, gSecretMgr.at0);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
}
int gPackIcons[5] = {
static int gPackIcons[5] = {
2569, 2564, 2566, 2568, 2560
};
@ -108,7 +83,7 @@ struct AMMOICON {
int nYOffs;
};
AMMOICON gAmmoIcons[] = {
static AMMOICON gAmmoIcons[] = {
{ -1, 0, 0 },
{ 816, (int)(65536 * 0.5), 0 },
{ 619, (int)(65536 * 0.8), 0 },
@ -131,7 +106,194 @@ struct POWERUPDISPLAY
int remainingDuration;
};
void sortPowerUps(POWERUPDISPLAY* powerups) {
class DBloodStatusBar : public DBaseStatusBar
{
enum NewRSFlags
{
RS_CENTERBOTTOM = 16384,
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatSprite(int nTile, double x, double y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536, ERenderStyle style = STYLE_Normal)
{
int flags = (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), x, y, flags, alpha, -1, -1, scale, scale, shadeToLight(nShade), TRANSLATION(Translation_Remap, nPalette), 0, style);
}
void DrawStatMaskedSprite(int nTile, double x, double y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536)
{
DrawStatSprite(nTile, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatNumber(const char* pFormat, int nNumber, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536)
{
double width = (tileWidth(nTile) + 1) * (nScale / 65536.);
char tempbuf[80];
mysnprintf(tempbuf, 80, pFormat, nNumber);
for (unsigned int i = 0; tempbuf[i]; i++, x += width)
{
if (tempbuf[i] == ' ') continue;
DrawStatSprite(nTile + tempbuf[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void TileHGauge(int nTile, double x, double y, int nMult, int nDiv, int nStat = 0, int nScale = 65536)
{
int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x;
DrawStatSprite(nTile, x, y, 0, 0, nStat|RS_TOPLEFT, nScale);
#if 0
// ???
int xdimcorrect = ClipHigh(scale(ydim, 4, 3), xdim);
int xscalecorrect = divscale16(xdimcorrect, 320);
int sbx;
switch (nStat & (512 + 256))
{
case 256:
sbx = mulscale16(bx, xscalecorrect) - 1;
break;
case 512:
bx -= 320;
sbx = xdim + mulscale16(bx, xscalecorrect) - 1;
break;
default:
bx -= 160;
sbx = (xdim >> 1) + mulscale16(bx, xscalecorrect) - 1;
break;
}
rotatesprite(x << 16, y << 16, nScale, 0, nTile, 0, 0, nStat | 90, 0, 0, sbx, ydim - 1);
#endif
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatSprite_Old(int nTile, int x, int y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536)
{
rotatesprite(x << 16, y << 16, nScale, 0, nTile, nShade, nPalette, nStat | 74, 0, 0, xdim - 1, ydim - 1);
}
void DrawStatMaskedSprite_Old(int nTile, int x, int y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536)
{
rotatesprite(x << 16, y << 16, nScale, 0, nTile, nShade, nPalette, nStat | 10, 0, 0, xdim - 1, ydim - 1);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatNumber_Old(const char* pFormat, int nNumber, int nTile, int x, int y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536)
{
char tempbuf[80];
int width = tilesiz[nTile].x + 1;
x <<= 16;
sprintf(tempbuf, pFormat, nNumber);
for (unsigned int i = 0; i < strlen(tempbuf); i++, x += width * nScale)
{
if (tempbuf[i] == ' ') continue;
rotatesprite(x, y << 16, nScale, 0, nTile + tempbuf[i] - '0', nShade, nPalette, nStat | 10, 0, 0, xdim - 1, ydim - 1);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void TileHGauge_Old(int nTile, int x, int y, int nMult, int nDiv, int nStat = 0, int nScale = 65536)
{
int xdimcorrect = ClipHigh(scale(ydim, 4, 3), xdim);
int xscalecorrect = divscale16(xdimcorrect, 320);
int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x;
int sbx;
switch (nStat & (512 + 256))
{
case 256:
sbx = mulscale16(bx, xscalecorrect) - 1;
break;
case 512:
bx -= 320;
sbx = xdim + mulscale16(bx, xscalecorrect) - 1;
break;
default:
bx -= 160;
sbx = (xdim >> 1) + mulscale16(bx, xscalecorrect) - 1;
break;
}
rotatesprite(x << 16, y << 16, nScale, 0, nTile, 0, 0, nStat | 90, 0, 0, sbx, ydim - 1);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawStats(PLAYER* pPlayer, int x, int y)
{
const int nFont = 3;
char buffer[128];
if (!hud_stats)
return;
int nHeight;
viewGetFontInfo(nFont, NULL, NULL, &nHeight);
sprintf(buffer, "T:%d:%02d.%02d",
(gLevelTime / (kTicsPerSec * 60)),
(gLevelTime / kTicsPerSec) % 60,
((gLevelTime % kTicsPerSec) * 33) / 10
);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
y += nHeight + 1;
if (gGameOptions.nGameType != 3)
sprintf(buffer, "K:%d/%d", gKillMgr.at4, gKillMgr.at0);
else
sprintf(buffer, "F:%d", pPlayer->fragCount);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
y += nHeight + 1;
sprintf(buffer, "S:%d/%d", gSecretMgr.at4 + gSecretMgr.at8, gSecretMgr.at0);
viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void sortPowerUps(POWERUPDISPLAY* powerups) {
for (int i = 1; i < 5; i++)
{
for (int j = 0; j < 5 - i; j++)
@ -144,10 +306,16 @@ void sortPowerUps(POWERUPDISPLAY* powerups) {
}
}
}
}
}
void viewDrawPowerUps(PLAYER* pPlayer)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPowerUps(PLAYER* pPlayer)
{
if (!hud_powerupduration)
return;
@ -179,26 +347,31 @@ void viewDrawPowerUps(PLAYER* pPlayer)
int remainingSeconds = powerups[i].remainingDuration / 100;
if (remainingSeconds > warningTime || ((int)totalclock & 32))
{
DrawStatMaskedSprite(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio));
DrawStatMaskedSprite_Old(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio));
}
DrawStatNumber("%d", remainingSeconds, kSBarNumberInv, x + 15, y, 0, remainingSeconds > warningTime ? 0 : 2, 256, 65536 * 0.5);
DrawStatNumber_Old("%d", remainingSeconds, kSBarNumberInv, x + 15, y, 0, remainingSeconds > warningTime ? 0 : 2, 256, 65536 * 0.5);
y += 20;
}
}
}
}
void viewDrawPack(PLAYER* pPlayer, int x, int y)
{
static int dword_14C508;
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void drawInventory(PLAYER* pPlayer, int x, int y)
{
int packs[5];
if (pPlayer->packItemTime)
//if (pPlayer->packItemTime)
{
int nPacks = 0;
int width = 0;
for (int i = 0; i < 5; i++)
{
if (pPlayer->packSlots[i].curAmount)
//if (pPlayer->packSlots[i].curAmount)
{
packs[nPacks++] = i;
width += tilesiz[gPackIcons[i]].x + 1;
@ -209,56 +382,69 @@ void viewDrawPack(PLAYER* pPlayer, int x, int y)
for (int i = 0; i < nPacks; i++)
{
int nPack = packs[i];
DrawStatSprite(2568, x + 1, y - 8);
DrawStatSprite(2568, x + 1, y - 6);
DrawStatSprite(gPackIcons[nPack], x + 1, y + 1);
DrawStatSprite_Old(2568, x + 1, y - 8);
DrawStatSprite_Old(2568, x + 1, y - 6);
DrawStatSprite_Old(gPackIcons[nPack], x + 1, y + 1);
if (nPack == pPlayer->packItemId)
DrawStatMaskedSprite(2559, x + 1, y + 1);
DrawStatMaskedSprite_Old(2559, x + 1, y + 1);
int nShade;
if (pPlayer->packSlots[nPack].isActive)
nShade = 4;
else
nShade = 24;
DrawStatNumber("%3d", pPlayer->packSlots[nPack].curAmount, 2250, x - 4, y - 13, nShade, 0);
DrawStatNumber_Old("%3d", pPlayer->packSlots[nPack].curAmount, 2250, x - 4, y - 13, nShade, 0);
x += tilesiz[gPackIcons[nPack]].x + 1;
}
}
if (pPlayer->packItemTime != dword_14C508)
{
viewUpdatePages();
}
dword_14C508 = pPlayer->packItemTime;
}
void DrawPackItemInStatusBar(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawPackItemInStatusBar(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat = 0)
{
if (pPlayer->packItemId < 0) return;
DrawStatSprite(gPackIcons[pPlayer->packItemId], x, y, 0, 0, nStat);
DrawStatNumber("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, 2250, x2, y2, 0, 0, nStat);
}
DrawStatSprite_Old(gPackIcons[pPlayer->packItemId], x, y, 0, 0, nStat);
DrawStatNumber_Old("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, 2250, x2, y2, 0, 0, nStat);
}
void DrawPackItemInStatusBar2(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat, int nScale)
{
void DrawPackItemInStatusBar2(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat, int nScale)
{
if (pPlayer->packItemId < 0) return;
DrawStatMaskedSprite(gPackIcons2[pPlayer->packItemId].nTile, x, y + gPackIcons2[pPlayer->packItemId].nYOffs, 0, 0, nStat, gPackIcons2[pPlayer->packItemId].nScale);
DrawStatNumber("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, kSBarNumberInv, x2, y2, 0, 0, nStat, nScale);
}
DrawStatMaskedSprite_Old(gPackIcons2[pPlayer->packItemId].nTile, x, y + gPackIcons2[pPlayer->packItemId].nYOffs, 0, 0, nStat, gPackIcons2[pPlayer->packItemId].nScale);
DrawStatNumber_Old("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, kSBarNumberInv, x2, y2, 0, 0, nStat, nScale);
}
void viewDrawPlayerSlots(void)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPlayerSlots(void)
{
for (int nRows = (gNetPlayers - 1) / 4; nRows >= 0; nRows--)
{
for (int nCol = 0; nCol < 4; nCol++)
{
DrawStatSprite(2229, 40 + nCol * 80, 4 + nRows * 9, 16);
DrawStatSprite_Old(2229, 40 + nCol * 80, 4 + nRows * 9, 16);
}
}
}
}
void viewDrawPlayerFrags(void)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPlayerFrags(void)
{
FString gTempStr;
viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
@ -276,10 +462,16 @@ void viewDrawPlayerFrags(void)
gTempStr.Format("%2d", gPlayer[p].fragCount);
viewDrawText(4, gTempStr, x + 76, y + 1, -128, 11 + col, 2, 0);
}
}
}
void viewDrawPlayerFlags(void)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPlayerFlags(void)
{
FString gTempStr;
viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
@ -306,11 +498,17 @@ void viewDrawPlayerFlags(void)
if (gPlayer[p].hasFlag & 1)
viewDrawText(4, gTempStr, x, y + 1, -128, 11, 2, 0);
}
}
}
void viewDrawCtfHudVanilla(ClockTicks arg)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawCtfHudVanilla(ClockTicks arg)
{
FString gTempStr;
int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || ((int)totalclock & 8))
@ -332,10 +530,16 @@ void viewDrawCtfHudVanilla(ClockTicks arg)
gTempStr.Format("%3d", dword_21EFB0[1]);
viewDrawText(0, gTempStr, x, y + 10, -128, 7, 2, 0, 512);
}
}
}
void flashTeamScore(ClockTicks arg, int team, bool show)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void flashTeamScore(ClockTicks arg, int team, bool show)
{
dassert(0 == team || 1 == team); // 0: blue, 1: red
if (dword_21EFD0[team] == 0 || ((int)totalclock & 8))
@ -345,12 +549,18 @@ void flashTeamScore(ClockTicks arg, int team, bool show)
dword_21EFD0[team] = 0;
if (show)
DrawStatNumber("%d", dword_21EFB0[team], kSBarNumberInv, 290, team ? 125 : 90, 0, team ? 2 : 10, 512, 65536 * 0.75);
DrawStatNumber_Old("%d", dword_21EFB0[team], kSBarNumberInv, 290, team ? 125 : 90, 0, team ? 2 : 10, 512, 65536 * 0.75);
}
}
}
static void viewDrawCtfHud(ClockTicks arg)
{
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawCtfHud(ClockTicks arg)
{
if (0 == gViewSize)
{
flashTeamScore(arg, 0, false);
@ -377,123 +587,163 @@ static void viewDrawCtfHud(ClockTicks arg)
}
bool meHaveBlueFlag = gMe->hasFlag & 1;
DrawStatMaskedSprite(meHaveBlueFlag ? 3558 : 3559, 320, 75, 0, 10, 512, 65536 * 0.35);
DrawStatMaskedSprite_Old(meHaveBlueFlag ? 3558 : 3559, 320, 75, 0, 10, 512, 65536 * 0.35);
if (gBlueFlagDropped)
DrawStatMaskedSprite(2332, 305, 83, 0, 10, 512, 65536);
DrawStatMaskedSprite_Old(2332, 305, 83, 0, 10, 512, 65536);
else if (blueFlagTaken)
DrawStatMaskedSprite(4097, 307, 77, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536);
DrawStatMaskedSprite_Old(4097, 307, 77, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536);
flashTeamScore(arg, 0, true);
bool meHaveRedFlag = gMe->hasFlag & 2;
DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 320, 110, 0, 2, 512, 65536 * 0.35);
DrawStatMaskedSprite_Old(meHaveRedFlag ? 3558 : 3559, 320, 110, 0, 2, 512, 65536 * 0.35);
if (gRedFlagDropped)
DrawStatMaskedSprite(2332, 305, 117, 0, 2, 512, 65536);
DrawStatMaskedSprite_Old(2332, 305, 117, 0, 2, 512, 65536);
else if (redFlagTaken)
DrawStatMaskedSprite(4097, 307, 111, 0, redFlagCarrierColor ? 2 : 10, 512, 65536);
DrawStatMaskedSprite_Old(4097, 307, 111, 0, redFlagCarrierColor ? 2 : 10, 512, 65536);
flashTeamScore(arg, 1, true);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatusBar(int nPalette)
{
BeginStatusBar(320, 200, tilesiz[2200].y);
void UpdateStatusBar(ClockTicks arg)
{
PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite;
int nPalette = 0;
if (gGameOptions.nGameType == 3)
DrawStatMaskedSprite(2200, 160, 200, 0, nPalette, RS_CENTERBOTTOM);
/*
DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172);
if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0)
{
if (pPlayer->teamId & 1)
nPalette = 7;
else
nPalette = 10;
DrawStatNumber_Old("%3d", pXSprite->health >> 4, 2190, 86, 183, 0, 0);
}
if (gViewSize < 0) return;
if (gViewSize == 1)
{
DrawStatMaskedSprite(2169, 12, 195, 0, 0, 256, (int)(65536 * 0.56));
DrawStatNumber("%d", pXSprite->health >> 4, kSBarNumberHealth, 28, 187, 0, 0, 256);
if (pPlayer->armor[1])
{
DrawStatMaskedSprite(2578, 70, 186, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber("%3d", pPlayer->armor[1] >> 4, kSBarNumberArmor2, 83, 187, 0, 0, 256, (int)(65536 * 0.65));
}
if (pPlayer->armor[0])
{
DrawStatMaskedSprite(2586, 112, 195, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber("%3d", pPlayer->armor[0] >> 4, kSBarNumberArmor1, 125, 187, 0, 0, 256, (int)(65536 * 0.65));
}
if (pPlayer->armor[2])
{
DrawStatMaskedSprite(2602, 155, 196, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber("%3d", pPlayer->armor[2] >> 4, kSBarNumberArmor3, 170, 187, 0, 0, 256, (int)(65536 * 0.65));
}
DrawPackItemInStatusBar2(pPlayer, 225, 194, 240, 187, 512, (int)(65536 * 0.7));
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{
int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6)
num /= 10;
if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles)
DrawStatMaskedSprite(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304, 192 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs,
0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale);
DrawStatNumber("%3d", num, kSBarNumberAmmo, 267, 187, 0, 0, 512);
DrawStatNumber_Old("%3d", num, 2240, 216, 183, 0, 0);
}
for (int i = 9; i >= 1; i--)
{
int x = 135 + ((i - 1) / 3) * 23;
int y = 182 + ((i - 1) % 3) * 6;
int num = pPlayer->ammoCount[i];
if (i == 6)
num /= 10;
if (i == pPlayer->weaponAmmo)
{
DrawStatNumber_Old("%3d", num, 2230, x, y, -128, 10);
}
else
{
DrawStatNumber_Old("%3d", num, 2230, x, y, 32, 10);
}
}
if (pPlayer->weaponAmmo == 10)
{
DrawStatNumber_Old("%2d", pPlayer->ammoCount[10], 2230, 291, 194, -128, 10);
}
else
{
DrawStatNumber_Old("%2d", pPlayer->ammoCount[10], 2230, 291, 194, 32, 10);
}
if (pPlayer->weaponAmmo == 11)
{
DrawStatNumber_Old("%2d", pPlayer->ammoCount[11], 2230, 309, 194, -128, 10);
}
else
{
DrawStatNumber_Old("%2d", pPlayer->ammoCount[11], 2230, 309, 194, 32, 10);
}
if (pPlayer->armor[1])
{
TileHGauge_Old(2207, 44, 174, pPlayer->armor[1], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, 2230, 50, 177, 0, 0);
}
if (pPlayer->armor[0])
{
TileHGauge_Old(2209, 44, 182, pPlayer->armor[0], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, 2230, 50, 185, 0, 0);
}
if (pPlayer->armor[2])
{
TileHGauge_Old(2208, 44, 190, pPlayer->armor[2], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, 2230, 50, 193, 0, 0);
}
//FString gTempStr;
//gTempStr.Format("v%s", GetVersionString());
//viewDrawText(3, gTempStr, 20, 191, 32, 0, 1, 0);
for (int i = 0; i < 6; i++)
{
int nTile = 2220 + i;
int x = 73 + (i & 1) * 173;
int y = 171 + (i >> 1) * 11;
if (pPlayer->hasKey[i + 1])
DrawStatMaskedSprite(2552 + i, 260 + 10 * i, 170, 0, 0, 512, (int)(65536 * 0.25));
DrawStatSprite_Old(nTile, x, y);
else
DrawStatSprite_Old(nTile, x, y, 40, 5);
}
DrawStatMaskedSprite_Old(2202, 118, 185, pPlayer->isRunning ? 16 : 40);
DrawStatMaskedSprite_Old(2202, 201, 185, pPlayer->isRunning ? 16 : 40);
if (pPlayer->throwPower)
{
TileHGauge_Old(2260, 124, 175, pPlayer->throwPower, 65536);
}
viewDrawStats(pPlayer, 2, 140);
drawInventory(pPlayer, 160, 200 - tilesiz[2200].y);
viewDrawPowerUps(pPlayer);
*/
}
if (pPlayer->throwPower)
TileHGauge(2260, 124, 175 - 10, pPlayer->throwPower, 65536);
else
viewDrawPack(pPlayer, 166, 200 - tilesiz[2201].y / 2 - 30);
viewDrawStats(pPlayer, 2, 140);
viewDrawPowerUps(pPlayer);
}
else if (gViewSize <= 2)
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawHUD1(int nPalette)
{
if (pPlayer->throwPower)
TileHGauge(2260, 124, 175, pPlayer->throwPower, 65536);
else
viewDrawPack(pPlayer, 166, 200 - tilesiz[2201].y / 2);
}
if (gViewSize == 2)
{
DrawStatSprite(2201, 34, 187, 16, nPalette, 256);
PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite;
DrawStatSprite_Old(2201, 34, 187, 16, nPalette, 256);
if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0)
{
DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 8, 183, 0, 0, 256);
DrawStatNumber_Old("%3d", pXSprite->health >> 4, 2190, 8, 183, 0, 0, 256);
}
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{
int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6)
num /= 10;
DrawStatNumber("%3d", num, 2240, 42, 183, 0, 0, 256);
DrawStatNumber_Old("%3d", num, 2240, 42, 183, 0, 0, 256);
}
DrawStatSprite(2173, 284, 187, 16, nPalette, 512);
DrawStatSprite_Old(2173, 284, 187, 16, nPalette, 512);
if (pPlayer->armor[1])
{
TileHGauge(2207, 250, 175, pPlayer->armor[1], 3200, 512);
DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 255, 178, 0, 0, 512);
TileHGauge_Old(2207, 250, 175, pPlayer->armor[1], 3200, 512);
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, 2230, 255, 178, 0, 0, 512);
}
if (pPlayer->armor[0])
{
TileHGauge(2209, 250, 183, pPlayer->armor[0], 3200, 512);
DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 255, 186, 0, 0, 512);
TileHGauge_Old(2209, 250, 183, pPlayer->armor[0], 3200, 512);
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, 2230, 255, 186, 0, 0, 512);
}
if (pPlayer->armor[2])
{
TileHGauge(2208, 250, 191, pPlayer->armor[2], 3200, 512);
DrawStatNumber("%3d", pPlayer->armor[2] >> 4, 2230, 255, 194, 0, 0, 512);
TileHGauge_Old(2208, 250, 191, pPlayer->armor[2], 3200, 512);
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, 2230, 255, 194, 0, 0, 512);
}
DrawPackItemInStatusBar(pPlayer, 286, 186, 302, 183, 512);
@ -513,105 +763,118 @@ void UpdateStatusBar(ClockTicks arg)
nStat |= 256;
}
if (pPlayer->hasKey[i + 1])
DrawStatSprite(nTile, x, y, 0, 0, nStat);
DrawStatSprite_Old(nTile, x, y, 0, 0, nStat);
#if 0
else
DrawStatSprite(nTile, x, y, 40, 5, nStat);
DrawStatSprite_Old(nTile, x, y, 40, 5, nStat);
#endif
}
viewDrawStats(pPlayer, 2, 140);
viewDrawPowerUps(pPlayer);
}
else if (gViewSize > 2)
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawHUD2()
{
viewDrawPack(pPlayer, 160, 200 - tilesiz[2200].y);
DrawStatMaskedSprite(2200, 160, 172, 16, nPalette);
DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172);
if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0)
PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite;
DrawStatMaskedSprite_Old(2169, 12, 195, 0, 0, 256, (int)(65536 * 0.56));
DrawStatNumber_Old("%d", pXSprite->health >> 4, kSBarNumberHealth, 28, 187, 0, 0, 256);
if (pPlayer->armor[1])
{
DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 86, 183, 0, 0);
DrawStatMaskedSprite_Old(2578, 70, 186, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, kSBarNumberArmor2, 83, 187, 0, 0, 256, (int)(65536 * 0.65));
}
if (pPlayer->armor[0])
{
DrawStatMaskedSprite_Old(2586, 112, 195, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, kSBarNumberArmor1, 125, 187, 0, 0, 256, (int)(65536 * 0.65));
}
if (pPlayer->armor[2])
{
DrawStatMaskedSprite_Old(2602, 155, 196, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, kSBarNumberArmor3, 170, 187, 0, 0, 256, (int)(65536 * 0.65));
}
DrawPackItemInStatusBar2(pPlayer, 225, 194, 240, 187, 512, (int)(65536 * 0.7));
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{
int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6)
num /= 10;
DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0);
if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles)
DrawStatMaskedSprite_Old(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304, 192 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs,
0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale);
DrawStatNumber_Old("%3d", num, kSBarNumberAmmo, 267, 187, 0, 0, 512);
}
for (int i = 9; i >= 1; i--)
{
int x = 135 + ((i - 1) / 3) * 23;
int y = 182 + ((i - 1) % 3) * 6;
int num = pPlayer->ammoCount[i];
if (i == 6)
num /= 10;
if (i == pPlayer->weaponAmmo)
{
DrawStatNumber("%3d", num, 2230, x, y, -128, 10);
}
else
{
DrawStatNumber("%3d", num, 2230, x, y, 32, 10);
}
}
if (pPlayer->weaponAmmo == 10)
{
DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, -128, 10);
}
else
{
DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, 32, 10);
}
if (pPlayer->weaponAmmo == 11)
{
DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, -128, 10);
}
else
{
DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, 32, 10);
}
if (pPlayer->armor[1])
{
TileHGauge(2207, 44, 174, pPlayer->armor[1], 3200);
DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 50, 177, 0, 0);
}
if (pPlayer->armor[0])
{
TileHGauge(2209, 44, 182, pPlayer->armor[0], 3200);
DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 50, 185, 0, 0);
}
if (pPlayer->armor[2])
{
TileHGauge(2208, 44, 190, pPlayer->armor[2], 3200);
DrawStatNumber("%3d", pPlayer->armor[2] >> 4, 2230, 50, 193, 0, 0);
}
//FString gTempStr;
//gTempStr.Format("v%s", GetVersionString());
//viewDrawText(3, gTempStr, 20, 191, 32, 0, 1, 0);
for (int i = 0; i < 6; i++)
{
int nTile = 2220 + i;
int x = 73 + (i & 1) * 173;
int y = 171 + (i >> 1) * 11;
if (pPlayer->hasKey[i + 1])
DrawStatSprite(nTile, x, y);
else
DrawStatSprite(nTile, x, y, 40, 5);
}
DrawStatMaskedSprite(2202, 118, 185, pPlayer->isRunning ? 16 : 40);
DrawStatMaskedSprite(2202, 201, 185, pPlayer->isRunning ? 16 : 40);
if (pPlayer->throwPower)
{
TileHGauge(2260, 124, 175, pPlayer->throwPower, 65536);
}
viewDrawStats(pPlayer, 2, 140);
viewDrawPowerUps(pPlayer);
DrawStatMaskedSprite_Old(2552 + i, 260 + 10 * i, 170, 0, 0, 512, (int)(65536 * 0.25));
}
if (pPlayer->throwPower)
TileHGauge_Old(2260, 124, 175 - 10, pPlayer->throwPower, 65536);
else
drawInventory(pPlayer, 166, 200 - tilesiz[2201].y / 2 - 30);
viewDrawStats(pPlayer, 2, 140);
viewDrawPowerUps(pPlayer);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
public:
void UpdateStatusBar(ClockTicks arg)
{
PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite;
int nPalette = 0;
if (gGameOptions.nGameType == 3)
{
if (pPlayer->teamId & 1)
nPalette = 7;
else
nPalette = 10;
}
if (gViewSize < 0) return;
if (gViewSize == 1)
{
DrawHUD2();
}
else if (gViewSize <= 2)
{
if (pPlayer->throwPower)
TileHGauge_Old(2260, 124, 175, pPlayer->throwPower, 65536);
else
drawInventory(pPlayer, 166, 200 - tilesiz[2201].y / 2);
}
if (gViewSize == 2)
{
DrawHUD1(nPalette);
}
else if (gViewSize > 2)
{
DrawStatusBar(nPalette);
}
viewDrawPlayerFrags();
if (gGameOptions.nGameType < 1) return;
if (gGameOptions.nGameType == 3)
@ -630,6 +893,14 @@ void UpdateStatusBar(ClockTicks arg)
{
viewDrawPlayerFrags();
}
}
};
void UpdateStatusBar(ClockTicks arg)
{
DBloodStatusBar sbar;
sbar.UpdateStatusBar(arg);
}

View file

@ -99,7 +99,6 @@ struct INTERPOLATE {
INTERPOLATE_TYPE type;
};
int pcBackground;
int gViewMode = 3;
int gViewSize = 2;
@ -122,7 +121,7 @@ INTERPOLATE gInterpolation[kMaxInterpolations];
int gViewXCenter, gViewYCenter;
int gViewX0, gViewY0, gViewX1, gViewY1;
int gViewX0S, gViewY0S, gViewX1S, gViewY1S;
int xscale, xscalecorrect, yscale, xstep, ystep;
int xscale, yscale, xstep, ystep;
int gScreenTilt;
@ -212,11 +211,6 @@ void viewGetFontInfo(int id, const char *unk1, int *pXSize, int *pYSize)
}
}
void viewUpdatePages(void)
{
pcBackground = numpages;
}
void viewToggle(int viewMode)
{
if (viewMode == 3)
@ -1041,49 +1035,6 @@ void InitStatusBar(void)
{
tileLoadTile(2200);
}
void DrawStatSprite(int nTile, int x, int y, int nShade, int nPalette, unsigned int nStat, int nScale)
{
rotatesprite(x<<16, y<<16, nScale, 0, nTile, nShade, nPalette, nStat | 74, 0, 0, xdim-1, ydim-1);
}
void DrawStatMaskedSprite(int nTile, int x, int y, int nShade, int nPalette, unsigned int nStat, int nScale)
{
rotatesprite(x<<16, y<<16, nScale, 0, nTile, nShade, nPalette, nStat | 10, 0, 0, xdim-1, ydim-1);
}
void DrawStatNumber(const char *pFormat, int nNumber, int nTile, int x, int y, int nShade, int nPalette, unsigned int nStat, int nScale)
{
char tempbuf[80];
int width = tilesiz[nTile].x+1;
x <<= 16;
sprintf(tempbuf, pFormat, nNumber);
for (unsigned int i = 0; i < strlen(tempbuf); i++, x += width*nScale)
{
if (tempbuf[i] == ' ') continue;
rotatesprite(x, y<<16, nScale, 0, nTile+tempbuf[i]-'0', nShade, nPalette, nStat | 10, 0, 0, xdim-1, ydim-1);
}
}
void TileHGauge(int nTile, int x, int y, int nMult, int nDiv, int nStat, int nScale)
{
int bx = scale(mulscale16(tilesiz[nTile].x,nScale),nMult,nDiv)+x;
int sbx;
switch (nStat&(512+256))
{
case 256:
sbx = mulscale16(bx, xscalecorrect)-1;
break;
case 512:
bx -= 320;
sbx = xdim+mulscale16(bx, xscalecorrect)-1;
break;
default:
bx -= 160;
sbx = (xdim>>1)+mulscale16(bx, xscalecorrect)-1;
break;
}
rotatesprite(x<<16, y<<16, nScale, 0, nTile, 0, 0, nStat|90, 0, 0, sbx, ydim-1);
}
GameStats GameInterface::getStats()
{
return { gKillMgr.at4, gKillMgr.at0, gSecretMgr.at4, gSecretMgr.at0, gLevelTime / kTicsPerSec, gPlayer[myconnectindex].fragCount };
@ -1214,7 +1165,7 @@ void viewResizeView(int size)
gViewXCenter = xdim-xdim/2;
gViewYCenter = ydim-ydim/2;
xscale = divscale16(xdim, 320);
xscalecorrect = divscale16(xdimcorrect, 320);
int xscalecorrect = divscale16(xdimcorrect, 320);
yscale = divscale16(ydim, 200);
xstep = divscale16(320, xdim);
ystep = divscale16(200, ydim);
@ -1256,7 +1207,6 @@ void viewResizeView(int size)
gViewY1S = divscale16(gViewY1, yscale);
}
videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1);
viewUpdatePages();
}
#define kBackTile 253
@ -1276,10 +1226,9 @@ void UpdateFrame(void)
void viewDrawInterface(ClockTicks arg)
{
if (gViewMode == 3/* && gViewSize >= 3*/ && (pcBackground != 0 || videoGetRenderMode() >= REND_POLYMOST))
if (gViewMode == 3 && videoGetRenderMode() >= REND_POLYMOST)
{
UpdateFrame();
pcBackground--;
}
UpdateStatusBar(arg);
}
@ -2915,10 +2864,12 @@ void viewDrawScreen(bool sceneonly)
//}
//lastClock = gGameClock;
}
#if 0
if (byte_1A76C6)
{
DrawStatSprite(2048, xdim-15, 20);
}
#endif
CalcFrameRate();
viewDrawMapTitle();
@ -3007,8 +2958,10 @@ void viewLoadingScreenUpdate(const char *pzText4, int nPercent)
viewDrawText(3, pzText4, 160, 124, -128, 0, 1, 1);
}
#if 0
if (nPercent != -1)
TileHGauge(2260, 86, 110, nPercent, 100, 0, 131072);
#endif
viewDrawText(3, GStrings("TXTB_PLSWAIT"), 160, 134, -128, 0, 1, 1);
}

View file

@ -106,7 +106,6 @@ extern int gLastPal;
void viewGetFontInfo(int id, const char *unk1, int *pXSize, int *pYSize);
void viewUpdatePages(void);
void viewToggle(int viewMode);
void viewInitializePrediction(void);
void viewUpdatePrediction(GINPUT *pInput);
@ -126,12 +125,6 @@ void RestoreInterpolations(void);
void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int nPalette, int position, char shadow, unsigned int nStat = 0, uint8_t alpha = 0);
void viewTileSprite(int nTile, int nShade, int nPalette, int x1, int y1, int x2, int y2);
void InitStatusBar(void);
void DrawStatSprite(int nTile, int x, int y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536);
void DrawStatMaskedSprite(int nTile, int x, int y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536);
void DrawStatNumber(const char *pFormat, int nNumber, int nTile, int x, int y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536);
void TileHGauge(int nTile, int x, int y, int nMult, int nDiv, int nStat = 0, int nScale = 65536);
void viewDrawPack(PLAYER *pPlayer, int x, int y);
void DrawPackItemInStatusBar(PLAYER *pPlayer, int x, int y, int x2, int y2, int nStat = 0);
void UpdateStatusBar(ClockTicks arg);
void viewInit(void);
void viewResizeView(int size);

View file

@ -281,16 +281,16 @@ void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, doub
//
//============================================================================
void DBaseStatusBar::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)
void DBaseStatusBar::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)
{
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);
DrawGraphic(tex, x, y, flags, Alpha, boxwidth, boxheight, scaleX, scaleY, color, translation, rotate, style);
}
void DBaseStatusBar::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)
void DBaseStatusBar::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)
{
double texwidth = tex->GetDisplayWidth() * scaleX;
double texheight = tex->GetDisplayHeight() * scaleY;
@ -414,6 +414,7 @@ void DBaseStatusBar::DrawGraphic(FGameTexture* tex, double x, double y, int flag
DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1,
DTA_FlipX, !!(flags & DI_MIRROR),
DTA_Rotate, rotate,
DTA_LegacyRenderStyle, style,
TAG_DONE);
}

View file

@ -178,8 +178,8 @@ public:
DVector2 GetHUDScale() const;
void NewGame ();
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);
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);
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 styöe = 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 styöe = 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);
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);