- ported Blood's status bar to the Status bar class.

Now it allows downscaling just like Duke's.
This commit is contained in:
Christoph Oelckers 2020-08-02 13:35:34 +02:00
parent b259b94300
commit 3a32e8840f
5 changed files with 167 additions and 265 deletions

View file

@ -114,22 +114,33 @@ class DBloodStatusBar : public DBaseStatusBar
{ {
RS_CENTERBOTTOM = 16384, RS_CENTERBOTTOM = 16384,
}; };
DHUDFont smallf, tinyf;
public:
DBloodStatusBar()
{
smallf = { SmallFont, 0, Off, 0, 0 };
tinyf = { gFont[4], 4, CellRight, 0, 0 };
}
private:
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
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) 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 align = DI_SCREEN_AUTO)
{ {
int flags = (nStat & RS_CENTERBOTTOM)? DI_ITEM_CENTER_BOTTOM : (nStat & RS_TOPLEFT)? DI_ITEM_LEFT_TOP : DI_ITEM_RELCENTER; int flags = align | ((nStat & RS_CENTERBOTTOM)? DI_ITEM_CENTER_BOTTOM : (nStat & RS_TOPLEFT)? DI_ITEM_LEFT_TOP : DI_ITEM_RELCENTER);
double alpha = 1.; double alpha = 1.;
double scale = nScale / 65536.; double scale = nScale / 65536.;
DrawGraphic(tileGetTexture(nTile), x, y, flags, alpha, -1, -1, scale, scale, shadeToLight(nShade), TRANSLATION(Translation_Remap, nPalette), 0, style); 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) 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)
{ {
DrawStatSprite(nTile, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent); DrawStatSprite(nTile, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -138,16 +149,18 @@ class DBloodStatusBar : public DBaseStatusBar
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DrawStatNumber(const char* pFormat, int nNumber, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536) void DrawStatNumber(const char* pFormat, int nNumber, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536, int align = 0)
{ {
double width = (tileWidth(nTile) + 1) * (nScale / 65536.); double width = (tileWidth(nTile) + 1) * (nScale / 65536.);
char tempbuf[80]; char tempbuf[80];
mysnprintf(tempbuf, 80, pFormat, nNumber); mysnprintf(tempbuf, 80, pFormat, nNumber);
x += 0.5;
y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem.
for (unsigned int i = 0; tempbuf[i]; i++, x += width) for (unsigned int i = 0; tempbuf[i]; i++, x += width)
{ {
if (tempbuf[i] == ' ') continue; if (tempbuf[i] == ' ') continue;
DrawStatSprite(nTile + tempbuf[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent); DrawStatSprite(nTile + tempbuf[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align);
} }
} }
@ -161,135 +174,45 @@ class DBloodStatusBar : public DBaseStatusBar
{ {
int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x; int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x;
DrawStatSprite(nTile, x, y, 0, 0, nStat|RS_TOPLEFT, nScale); 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)) //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void PrintLevelStats(PLAYER* pPlayer, int bottomy)
{ {
case 256: if (gViewMode == 3 && hud_stats)
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); FLevelStats stats{};
stats.fontscale = 1.;
stats.spacing = SmallFont->GetHeight() + 2;
stats.screenbottomspace = bottomy;
stats.font = SmallFont;
stats.letterColor = CR_DARKRED;
stats.standardColor = CR_DARKGRAY;
stats.completeColor = CR_DARKGREEN;
stats.time = Scale(gLevelTime, 1000, kTicsPerSec);
stats.kills = gKillMgr.at4;
stats.maxkills = gKillMgr.at0;
stats.frags = gGameOptions.nGameType == 3? pPlayer->fragCount : -1;
stats.secrets = gSecretMgr.at4 + gSecretMgr.at8;
stats.maxsecrets = gSecretMgr.at0;
DBaseStatusBar::PrintLevelStats(stats);
} }
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);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// // ok
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -339,7 +262,7 @@ class DBloodStatusBar : public DBaseStatusBar
const int warningTime = 5; const int warningTime = 5;
const int x = 15; const int x = 15;
int y = 50; int y = -50;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
if (powerups[i].remainingDuration) if (powerups[i].remainingDuration)
@ -347,10 +270,10 @@ class DBloodStatusBar : public DBaseStatusBar
int remainingSeconds = powerups[i].remainingDuration / 100; int remainingSeconds = powerups[i].remainingDuration / 100;
if (remainingSeconds > warningTime || ((int)totalclock & 32)) if (remainingSeconds > warningTime || ((int)totalclock & 32))
{ {
DrawStatMaskedSprite_Old(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio)); DrawStatMaskedSprite(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio), DI_SCREEN_LEFT_CENTER);
} }
DrawStatNumber_Old("%d", remainingSeconds, kSBarNumberInv, x + 15, y, 0, remainingSeconds > warningTime ? 0 : 2, 256, 65536 * 0.5); DrawStatNumber("%d", remainingSeconds, kSBarNumberInv, x + 15, y, 0, remainingSeconds > warningTime ? 0 : 2, 256, 65536 * 0.5, DI_SCREEN_LEFT_CENTER);
y += 20; y += 20;
} }
} }
@ -382,17 +305,17 @@ class DBloodStatusBar : public DBaseStatusBar
for (int i = 0; i < nPacks; i++) for (int i = 0; i < nPacks; i++)
{ {
int nPack = packs[i]; int nPack = packs[i];
DrawStatSprite_Old(2568, x + 1, y - 8); DrawStatSprite(2568, x + 1, y - 8);
DrawStatSprite_Old(2568, x + 1, y - 6); DrawStatSprite(2568, x + 1, y - 6);
DrawStatSprite_Old(gPackIcons[nPack], x + 1, y + 1); DrawStatSprite(gPackIcons[nPack], x + 1, y + 1);
if (nPack == pPlayer->packItemId) if (nPack == pPlayer->packItemId)
DrawStatMaskedSprite_Old(2559, x + 1, y + 1); DrawStatMaskedSprite(2559, x + 1, y + 1);
int nShade; int nShade;
if (pPlayer->packSlots[nPack].isActive) if (pPlayer->packSlots[nPack].isActive)
nShade = 4; nShade = 4;
else else
nShade = 24; nShade = 24;
DrawStatNumber_Old("%3d", pPlayer->packSlots[nPack].curAmount, 2250, x - 4, y - 13, nShade, 0); DrawStatNumber("%3d", pPlayer->packSlots[nPack].curAmount, 2250, x - 4, y - 13, nShade, 0);
x += tilesiz[gPackIcons[nPack]].x + 1; x += tilesiz[gPackIcons[nPack]].x + 1;
} }
} }
@ -404,20 +327,22 @@ class DBloodStatusBar : public DBaseStatusBar
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DrawPackItemInStatusBar(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat = 0) void DrawPackItemInStatusBar(PLAYER* pPlayer, int x, int y, int x2, int y2)
{ {
if (pPlayer->packItemId < 0) return; auto id = pPlayer->packItemId;
//id = 0;
if (id < 0) return;
DrawStatSprite_Old(gPackIcons[pPlayer->packItemId], x, y, 0, 0, nStat); DrawStatSprite(gPackIcons[id], x, y, 0, 0);
DrawStatNumber_Old("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, 2250, x2, y2, 0, 0, nStat); DrawStatNumber("%3d", pPlayer->packSlots[id].curAmount, 2250, x2, y2, 0, 0);
} }
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; if (pPlayer->packItemId < 0) return;
DrawStatMaskedSprite_Old(gPackIcons2[pPlayer->packItemId].nTile, x, y + gPackIcons2[pPlayer->packItemId].nYOffs, 0, 0, nStat, gPackIcons2[pPlayer->packItemId].nScale); DrawStatMaskedSprite(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); DrawStatNumber("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, kSBarNumberInv, x2, y2, 0, 0, nStat, nScale);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -432,7 +357,7 @@ class DBloodStatusBar : public DBaseStatusBar
{ {
for (int nCol = 0; nCol < 4; nCol++) for (int nCol = 0; nCol < 4; nCol++)
{ {
DrawStatSprite_Old(2229, 40 + nCol * 80, 4 + nRows * 9, 16); DrawStatSprite(2229, -120 + nCol * 80, 4 + nRows * 9, 16, 0, 0, 65536, STYLE_Normal, DI_SCREEN_CENTER_TOP);
} }
} }
} }
@ -449,7 +374,7 @@ class DBloodStatusBar : public DBaseStatusBar
viewDrawPlayerSlots(); viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p]) for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{ {
int x = 80 * (i & 3); int x = -160 + 80 * (i & 3);
int y = 9 * (i / 4); int y = 9 * (i / 4);
int col = gPlayer[p].teamId & 3; int col = gPlayer[p].teamId & 3;
char* name = gProfile[p].name; char* name = gProfile[p].name;
@ -457,10 +382,11 @@ class DBloodStatusBar : public DBaseStatusBar
gTempStr.Format("%s", name); gTempStr.Format("%s", name);
else else
gTempStr.Format("%s [%d]", name, gProfile[p].skill); gTempStr.Format("%s [%d]", name, gProfile[p].skill);
gTempStr.ToUpper();
viewDrawText(4, gTempStr, x + 4, y + 1, -128, 11 + col, 0, 0); int color = CR_UNDEFINED;// todo: remap the colors. (11+col)
SBar_DrawString(this, &tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
gTempStr.Format("%2d", gPlayer[p].fragCount); gTempStr.Format("%2d", gPlayer[p].fragCount);
viewDrawText(4, gTempStr, x + 76, y + 1, -128, 11 + col, 2, 0); SBar_DrawString(this, &tinyf, gTempStr, x + 76, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
} }
} }
@ -476,7 +402,7 @@ class DBloodStatusBar : public DBaseStatusBar
viewDrawPlayerSlots(); viewDrawPlayerSlots();
for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p]) for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p])
{ {
int x = 80 * (i & 3); int x = -160 + 80 * (i & 3);
int y = 9 * (i / 4); int y = 9 * (i / 4);
int col = gPlayer[p].teamId & 3; int col = gPlayer[p].teamId & 3;
char* name = gProfile[p].name; char* name = gProfile[p].name;
@ -485,18 +411,19 @@ class DBloodStatusBar : public DBaseStatusBar
else else
gTempStr.Format("%s [%d]", name, gProfile[p].skill); gTempStr.Format("%s [%d]", name, gProfile[p].skill);
gTempStr.ToUpper(); gTempStr.ToUpper();
viewDrawText(4, gTempStr, x + 4, y + 1, -128, 11 + col, 0, 0); int color = CR_UNDEFINED;// todo: remap the colors.
SBar_DrawString(this, &tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1);
gTempStr.Format("F"); gTempStr = "F";
x += 76; x += 76;
if (gPlayer[p].hasFlag & 2) if (gPlayer[p].hasFlag & 2)
{ {
viewDrawText(4, gTempStr, x, y + 1, -128, 12, 2, 0); SBar_DrawString(this, &tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_GREEN/*12*/, 1., -1, -1, 1, 1);
x -= 6; x -= 6;
} }
if (gPlayer[p].hasFlag & 1) if (gPlayer[p].hasFlag & 1)
viewDrawText(4, gTempStr, x, y + 1, -128, 11, 2, 0); SBar_DrawString(this, &tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_RED/*11*/, 1., -1, -1, 1, 1);
} }
} }
@ -513,22 +440,22 @@ class DBloodStatusBar : public DBaseStatusBar
int x = 1, y = 1; int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || ((int)totalclock & 8)) if (dword_21EFD0[0] == 0 || ((int)totalclock & 8))
{ {
viewDrawText(0, GStrings("TXT_COLOR_BLUE"), x, y, -128, 10, 0, 0, 256); SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
dword_21EFD0[0] = dword_21EFD0[0] - arg; dword_21EFD0[0] = dword_21EFD0[0] - arg;
if (dword_21EFD0[0] < 0) if (dword_21EFD0[0] < 0)
dword_21EFD0[0] = 0; dword_21EFD0[0] = 0;
gTempStr.Format("%-3d", dword_21EFB0[0]); gTempStr.Format("%-3d", dword_21EFB0[0]);
viewDrawText(0, gTempStr, x, y + 10, -128, 10, 0, 0, 256); SBar_DrawString(this, &smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
} }
x = 319; x = -2;
if (dword_21EFD0[1] == 0 || ((int)totalclock & 8)) if (dword_21EFD0[1] == 0 || ((int)totalclock & 8))
{ {
viewDrawText(0, GStrings("TXT_COLOR_RED"), x, y, -128, 7, 2, 0, 512); SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
dword_21EFD0[1] = dword_21EFD0[1] - arg; dword_21EFD0[1] = dword_21EFD0[1] - arg;
if (dword_21EFD0[1] < 0) if (dword_21EFD0[1] < 0)
dword_21EFD0[1] = 0; dword_21EFD0[1] = 0;
gTempStr.Format("%3d", dword_21EFB0[1]); gTempStr.Format("%3d", dword_21EFB0[1]);
viewDrawText(0, gTempStr, x, y + 10, -128, 7, 2, 0, 512); SBar_DrawString(this, &smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
} }
} }
@ -549,7 +476,7 @@ class DBloodStatusBar : public DBaseStatusBar
dword_21EFD0[team] = 0; dword_21EFD0[team] = 0;
if (show) if (show)
DrawStatNumber_Old("%d", dword_21EFB0[team], kSBarNumberInv, 290, team ? 125 : 90, 0, team ? 2 : 10, 512, 65536 * 0.75); DrawStatNumber("%d", dword_21EFB0[team], kSBarNumberInv, -30, team ? 25 : -10, 0, team ? 2 : 10, 512, 65536 * 0.75, DI_SCREEN_RIGHT_CENTER);
} }
} }
@ -587,19 +514,19 @@ class DBloodStatusBar : public DBaseStatusBar
} }
bool meHaveBlueFlag = gMe->hasFlag & 1; bool meHaveBlueFlag = gMe->hasFlag & 1;
DrawStatMaskedSprite_Old(meHaveBlueFlag ? 3558 : 3559, 320, 75, 0, 10, 512, 65536 * 0.35); DrawStatMaskedSprite(meHaveBlueFlag ? 3558 : 3559, 0, 75-100, 0, 10, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER);
if (gBlueFlagDropped) if (gBlueFlagDropped)
DrawStatMaskedSprite_Old(2332, 305, 83, 0, 10, 512, 65536); DrawStatMaskedSprite(2332, 305-320, 83 - 100, 0, 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
else if (blueFlagTaken) else if (blueFlagTaken)
DrawStatMaskedSprite_Old(4097, 307, 77, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536); DrawStatMaskedSprite(4097, 307-320, 77 - 100, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
flashTeamScore(arg, 0, true); flashTeamScore(arg, 0, true);
bool meHaveRedFlag = gMe->hasFlag & 2; bool meHaveRedFlag = gMe->hasFlag & 2;
DrawStatMaskedSprite_Old(meHaveRedFlag ? 3558 : 3559, 320, 110, 0, 2, 512, 65536 * 0.35); DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 0, 10, 0, 2, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER);
if (gRedFlagDropped) if (gRedFlagDropped)
DrawStatMaskedSprite_Old(2332, 305, 117, 0, 2, 512, 65536); DrawStatMaskedSprite(2332, 305-320, 17, 0, 2, 512, 65536, DI_SCREEN_RIGHT_CENTER);
else if (redFlagTaken) else if (redFlagTaken)
DrawStatMaskedSprite_Old(4097, 307, 111, 0, redFlagCarrierColor ? 2 : 10, 512, 65536); DrawStatMaskedSprite(4097, 307-320, 11, 0, redFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
flashTeamScore(arg, 1, true); flashTeamScore(arg, 1, true);
} }
@ -617,18 +544,18 @@ class DBloodStatusBar : public DBaseStatusBar
XSPRITE* pXSprite = pPlayer->pXSprite; XSPRITE* pXSprite = pPlayer->pXSprite;
DrawStatMaskedSprite(2200, 160, 200, 0, nPalette, RS_CENTERBOTTOM); DrawStatMaskedSprite(2200, 160, 200, 0, nPalette, RS_CENTERBOTTOM);
/*
DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172); DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172);
if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0) if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0)
{ {
DrawStatNumber_Old("%3d", pXSprite->health >> 4, 2190, 86, 183, 0, 0); DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 86, 183, 0, 0);
} }
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
DrawStatNumber_Old("%3d", num, 2240, 216, 183, 0, 0); DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0);
} }
for (int i = 9; i >= 1; i--) for (int i = 9; i >= 1; i--)
{ {
@ -637,73 +564,47 @@ class DBloodStatusBar : public DBaseStatusBar
int num = pPlayer->ammoCount[i]; int num = pPlayer->ammoCount[i];
if (i == 6) if (i == 6)
num /= 10; num /= 10;
if (i == pPlayer->weaponAmmo) DrawStatNumber("%3d", num, 2230, x, y, i == pPlayer->weaponAmmo? -128 : 32, 10);
{
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);
} }
DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, pPlayer->weaponAmmo == 10? -128 : 32, 10);
DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, pPlayer->weaponAmmo == 11? -128 : 32, 10);
if (pPlayer->armor[1]) if (pPlayer->armor[1])
{ {
TileHGauge_Old(2207, 44, 174, pPlayer->armor[1], 3200); TileHGauge(2207, 44, 174, pPlayer->armor[1], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, 2230, 50, 177, 0, 0); DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 50, 177, 0, 0);
} }
if (pPlayer->armor[0]) if (pPlayer->armor[0])
{ {
TileHGauge_Old(2209, 44, 182, pPlayer->armor[0], 3200); TileHGauge(2209, 44, 182, pPlayer->armor[0], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, 2230, 50, 185, 0, 0); DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 50, 185, 0, 0);
} }
if (pPlayer->armor[2]) if (pPlayer->armor[2])
{ {
TileHGauge_Old(2208, 44, 190, pPlayer->armor[2], 3200); TileHGauge(2208, 44, 190, pPlayer->armor[2], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, 2230, 50, 193, 0, 0); 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++) for (int i = 0; i < 6; i++)
{ {
int nTile = 2220 + i; int nTile = 2220 + i;
int x = 73 + (i & 1) * 173; double x = 73.5 + (i & 1) * 173;
int y = 171 + (i >> 1) * 11; double y = 171.5 + (i >> 1) * 11;
if (pPlayer->hasKey[i + 1]) if (pPlayer->hasKey[i + 1])
DrawStatSprite_Old(nTile, x, y); DrawStatSprite(nTile, x, y);
else else
DrawStatSprite_Old(nTile, x, y, 40, 5); DrawStatSprite(nTile, x, y, 40, 5);
} }
DrawStatMaskedSprite_Old(2202, 118, 185, pPlayer->isRunning ? 16 : 40); DrawStatMaskedSprite(2202, 118.5, 185.5, pPlayer->isRunning ? 16 : 40);
DrawStatMaskedSprite_Old(2202, 201, 185, pPlayer->isRunning ? 16 : 40); DrawStatMaskedSprite(2202, 201.5, 185.5, pPlayer->isRunning ? 16 : 40);
if (pPlayer->throwPower) if (pPlayer->throwPower)
{ {
TileHGauge_Old(2260, 124, 175, pPlayer->throwPower, 65536); TileHGauge(2260, 124, 175.5, pPlayer->throwPower, 65536);
} }
viewDrawStats(pPlayer, 2, 140); drawInventory(pPlayer, 166, 200 - tilesiz[2200].y);
drawInventory(pPlayer, 160, 200 - tilesiz[2200].y); // Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already.
viewDrawPowerUps(pPlayer); PrintLevelStats(pPlayer, (hud_statscale <= 2 || hud_scale < 70) && double(xdim)/ydim > 1.6? 28 : 56);
*/
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -717,61 +618,54 @@ class DBloodStatusBar : public DBaseStatusBar
PLAYER* pPlayer = gView; PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite; XSPRITE* pXSprite = pPlayer->pXSprite;
DrawStatSprite_Old(2201, 34, 187, 16, nPalette, 256); BeginHUD(320, 200, 1);
DrawStatSprite(2201, 34, 187 - 200, 16, nPalette);
if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0) if (pXSprite->health >= 16 || ((int)totalclock & 16) || pXSprite->health == 0)
{ {
DrawStatNumber_Old("%3d", pXSprite->health >> 4, 2190, 8, 183, 0, 0, 256); DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 8, 183 - 200, 0, 0);
} }
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
DrawStatNumber_Old("%3d", num, 2240, 42, 183, 0, 0, 256); DrawStatNumber("%3d", num, 2240, 42, 183 - 200, 0, 0);
} }
DrawStatSprite_Old(2173, 284, 187, 16, nPalette, 512); DrawStatSprite(2173, 284-320, 187 - 200, 16, nPalette);
if (pPlayer->armor[1]) if (pPlayer->armor[1])
{ {
TileHGauge_Old(2207, 250, 175, pPlayer->armor[1], 3200, 512); TileHGauge(2207, 250-320, 175 - 200, pPlayer->armor[1], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, 2230, 255, 178, 0, 0, 512); DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 255-320, 178 - 200, 0, 0);
} }
if (pPlayer->armor[0]) if (pPlayer->armor[0])
{ {
TileHGauge_Old(2209, 250, 183, pPlayer->armor[0], 3200, 512); TileHGauge(2209, 250-320, 183 - 200, pPlayer->armor[0], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, 2230, 255, 186, 0, 0, 512); DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 255-320, 186 - 200, 0, 0);
} }
if (pPlayer->armor[2]) if (pPlayer->armor[2])
{ {
TileHGauge_Old(2208, 250, 191, pPlayer->armor[2], 3200, 512); TileHGauge(2208, 250-320, 191 - 200, pPlayer->armor[2], 3200);
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, 2230, 255, 194, 0, 0, 512); DrawStatNumber("%3d", pPlayer->armor[2] >> 4, 2230, 255-320, 194 - 200, 0, 0);
} }
DrawPackItemInStatusBar(pPlayer, 286, 186, 302, 183, 512); DrawPackItemInStatusBar(pPlayer, 286-320, 186 - 200, 302-320, 183 - 200);
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
int nTile = 2220 + i; int nTile = 2220 + i;
int x, nStat = 0; int x;
int y = 200 - 6; int y = - 6;
if (i & 1) if (i & 1)
{ {
x = 320 - (78 + (i >> 1) * 10); x = - (78 + (i >> 1) * 10);
nStat |= 512;
} }
else else
{ {
x = 73 + (i >> 1) * 10; x = 73 + (i >> 1) * 10;
nStat |= 256;
} }
if (pPlayer->hasKey[i + 1]) if (pPlayer->hasKey[i + 1])
DrawStatSprite_Old(nTile, x, y, 0, 0, nStat); DrawStatSprite(nTile, x, y, 0, 0);
#if 0
else
DrawStatSprite_Old(nTile, x, y, 40, 5, nStat);
#endif
} }
viewDrawStats(pPlayer, 2, 140); PrintLevelStats(pPlayer, 28);
viewDrawPowerUps(pPlayer);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -785,25 +679,26 @@ class DBloodStatusBar : public DBaseStatusBar
PLAYER* pPlayer = gView; PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite; XSPRITE* pXSprite = pPlayer->pXSprite;
DrawStatMaskedSprite_Old(2169, 12, 195, 0, 0, 256, (int)(65536 * 0.56)); BeginHUD(320, 200, 1);
DrawStatNumber_Old("%d", pXSprite->health >> 4, kSBarNumberHealth, 28, 187, 0, 0, 256); DrawStatMaskedSprite(2169, 12, 195 - 200, 0, 0, 256, (int)(65536 * 0.56));
DrawStatNumber("%d", pXSprite->health >> 4, kSBarNumberHealth, 28, 187 - 200, 0, 0, 256);
if (pPlayer->armor[1]) if (pPlayer->armor[1])
{ {
DrawStatMaskedSprite_Old(2578, 70, 186, 0, 0, 256, (int)(65536 * 0.5)); DrawStatMaskedSprite(2578, 70, 186 - 200, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[1] >> 4, kSBarNumberArmor2, 83, 187, 0, 0, 256, (int)(65536 * 0.65)); DrawStatNumber("%3d", pPlayer->armor[1] >> 4, kSBarNumberArmor2, 83, 187 - 200, 0, 0, 256, (int)(65536 * 0.65));
} }
if (pPlayer->armor[0]) if (pPlayer->armor[0])
{ {
DrawStatMaskedSprite_Old(2586, 112, 195, 0, 0, 256, (int)(65536 * 0.5)); DrawStatMaskedSprite(2586, 112, 195 - 200, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[0] >> 4, kSBarNumberArmor1, 125, 187, 0, 0, 256, (int)(65536 * 0.65)); DrawStatNumber("%3d", pPlayer->armor[0] >> 4, kSBarNumberArmor1, 125, 187 - 200, 0, 0, 256, (int)(65536 * 0.65));
} }
if (pPlayer->armor[2]) if (pPlayer->armor[2])
{ {
DrawStatMaskedSprite_Old(2602, 155, 196, 0, 0, 256, (int)(65536 * 0.5)); DrawStatMaskedSprite(2602, 155, 196 - 200, 0, 0, 256, (int)(65536 * 0.5));
DrawStatNumber_Old("%3d", pPlayer->armor[2] >> 4, kSBarNumberArmor3, 170, 187, 0, 0, 256, (int)(65536 * 0.65)); DrawStatNumber("%3d", pPlayer->armor[2] >> 4, kSBarNumberArmor3, 170, 187 - 200, 0, 0, 256, (int)(65536 * 0.65));
} }
DrawPackItemInStatusBar2(pPlayer, 225, 194, 240, 187, 512, (int)(65536 * 0.7)); DrawPackItemInStatusBar2(pPlayer, 225 - 320, 194 - 200, 240 - 320, 187 - 200, 512, (int)(65536 * 0.7));
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
@ -811,24 +706,23 @@ class DBloodStatusBar : public DBaseStatusBar
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles) if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles)
DrawStatMaskedSprite_Old(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304, 192 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs, DrawStatMaskedSprite(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304-320, -8 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs,
0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale); 0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale);
DrawStatNumber_Old("%3d", num, kSBarNumberAmmo, 267, 187, 0, 0, 512); DrawStatNumber("%3d", num, kSBarNumberAmmo, 267-320, 187 - 200, 0, 0, 512);
} }
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
if (pPlayer->hasKey[i + 1]) if (pPlayer->hasKey[i + 1])
DrawStatMaskedSprite_Old(2552 + i, 260 + 10 * i, 170, 0, 0, 512, (int)(65536 * 0.25)); DrawStatMaskedSprite(2552 + i, -60 + 10 * i, 170 - 200, 0, 0, 0, (int)(65536 * 0.25));
} }
BeginStatusBar(320, 200, 28);
if (pPlayer->throwPower) if (pPlayer->throwPower)
TileHGauge_Old(2260, 124, 175 - 10, pPlayer->throwPower, 65536); TileHGauge(2260, 124, 175 - 210, pPlayer->throwPower, 65536);
else else
drawInventory(pPlayer, 166, 200-tilesiz[2201].y / 2 - 30); drawInventory(pPlayer, 166, 200-tilesiz[2201].y / 2 - 30);
viewDrawStats(pPlayer, 2, 140); PrintLevelStats(pPlayer, 28);
viewDrawPowerUps(pPlayer);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -860,6 +754,7 @@ class DBloodStatusBar : public DBaseStatusBar
} }
else if (gViewSize <= 2) else if (gViewSize <= 2)
{ {
BeginStatusBar(320, 200, 28);
if (pPlayer->throwPower) if (pPlayer->throwPower)
TileHGauge_Old(2260, 124, 175, pPlayer->throwPower, 65536); TileHGauge_Old(2260, 124, 175, pPlayer->throwPower, 65536);
else else
@ -874,9 +769,13 @@ class DBloodStatusBar : public DBaseStatusBar
DrawStatusBar(nPalette); DrawStatusBar(nPalette);
} }
viewDrawPlayerFrags(); // All remaining parts must be done with HUD alignment rules, even when showing a status bar.
if (gGameOptions.nGameType < 1) return; BeginHUD(320, 200, 1);
viewDrawPowerUps(pPlayer);
viewDrawCtfHud(arg);
if (gGameOptions.nGameType >= 1)
{
if (gGameOptions.nGameType == 3) if (gGameOptions.nGameType == 3)
{ {
if (VanillaMode()) if (VanillaMode())
@ -894,6 +793,7 @@ class DBloodStatusBar : public DBaseStatusBar
viewDrawPlayerFrags(); viewDrawPlayerFrags();
} }
} }
}
}; };
void UpdateStatusBar(ClockTicks arg) void UpdateStatusBar(ClockTicks arg)

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "globals.h" #include "globals.h"
#include "screen.h" #include "screen.h"
#include "v_video.h" #include "v_video.h"
#include "view.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -109,9 +110,6 @@ void scrLoadPalette(void)
paletteloaded |= PALETTE_MAIN; paletteloaded |= PALETTE_MAIN;
scrLoadPLUs(); scrLoadPLUs();
paletteloaded |= PALETTE_SHADE | PALETTE_TRANSLUC; paletteloaded |= PALETTE_SHADE | PALETTE_TRANSLUC;
enginePostInit();
} }
void scrSetPalette(int palId) void scrSetPalette(int palId)

View file

@ -1135,6 +1135,7 @@ void viewInit(void)
FontSet(2, 4288, 1); FontSet(2, 4288, 1);
FontSet(3, 4384, 1); FontSet(3, 4384, 1);
FontSet(4, 4480, 0); FontSet(4, 4480, 0);
enginePostInit(); // This must not be done earlier!
lensdata = fileSystem.LoadFile("lens.dat"); lensdata = fileSystem.LoadFile("lens.dat");
dassert(lensdata.Size() == kLensSize * kLensSize * sizeof(int)); dassert(lensdata.Size() == kLensSize * kLensSize * sizeof(int));
@ -1229,7 +1230,7 @@ void UpdateFrame(void)
void viewDrawInterface(ClockTicks arg) void viewDrawInterface(ClockTicks arg)
{ {
if (gViewMode == 3 && videoGetRenderMode() >= REND_POLYMOST) if (gViewMode == 3)
{ {
UpdateFrame(); UpdateFrame();
} }

View file

@ -98,7 +98,7 @@ extern char gInterpolateSprite[];
extern char gInterpolateWall[]; extern char gInterpolateWall[];
extern char gInterpolateSector[]; extern char gInterpolateSector[];
extern LOCATION gPrevSpriteLoc[kMaxSprites]; extern LOCATION gPrevSpriteLoc[kMaxSprites];
extern int gViewSize; extern int gViewSize, gViewMode;
extern int gViewXCenter, gViewYCenter; extern int gViewXCenter, gViewYCenter;
extern int gViewX0, gViewY0, gViewX1, gViewY1; extern int gViewX0, gViewY0, gViewX1, gViewY1;
extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S; extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S;

View file

@ -291,8 +291,11 @@ enum DI_Flags
DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP|DI_SCREEN_LEFT, DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP|DI_SCREEN_LEFT,
DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP|DI_SCREEN_RIGHT, DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP|DI_SCREEN_RIGHT,
DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_LEFT, DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_LEFT,
DI_SCREEN_LEFT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_LEFT,
DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_RIGHT, DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_RIGHT,
DI_SCREEN_RIGHT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_RIGHT,
DI_SCREEN_CENTER = DI_SCREEN_VCENTER|DI_SCREEN_HCENTER, DI_SCREEN_CENTER = DI_SCREEN_VCENTER|DI_SCREEN_HCENTER,
DI_SCREEN_CENTER_TOP = DI_SCREEN_TOP | DI_SCREEN_HCENTER,
DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_HCENTER, DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_HCENTER,
DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET|DI_SCREEN_VOFFSET, DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET|DI_SCREEN_VOFFSET,