- ammo and weapon display ported.

This commit is contained in:
Christoph Oelckers 2020-08-13 20:14:53 +02:00
parent b50bdb1ca1
commit 188b2d2daa
7 changed files with 246 additions and 295 deletions

View file

@ -91,7 +91,6 @@ SetFragBar(PLAYERp pp)
TRAVERSE_CONNECT(i)
{
PlayerUpdateKills(Player + i, 0);
DisplayFragNames(Player + i);
}
}

View file

@ -53,11 +53,9 @@ void MoveSectorObjects(SECTOR_OBJECTp sop, short locktics);
#define TEXT_INFO_YOFF (10)
inline int TEXT_INFO_LINE(int line) { return (TEXT_INFO_Y + ((line)*TEXT_INFO_YOFF)); }
void DisplayFragNames(PLAYERp pp);
void DisplayMiniBarSmString(PLAYERp pp, short xs, short ys, short pal, const char* buffer);
void DisplaySmString(PLAYERp pp, short xs, short ys, short pal, const char* buffer);
void DisplayMiniBarNumber(short xs, short ys, int number);
void DisplaySummaryString(PLAYERp pp, short xs, short ys, short color, short shade, const char* buffer);
void DisplayPanelNumber(PLAYERp pp, short xs, short ys, int number);
void PutStringInfo(PLAYERp pp, const char* string);
void PutStringInfoLine(PLAYERp pp, const char* string);

View file

@ -84,7 +84,6 @@ typedef struct
} PANEL_SHRAP, *PANEL_SHRAPp;
PANEL_SPRITEp pSpawnFullScreenSprite(PLAYERp pp, short pic, short pri, int x, int y);
void DisplayFragNumbers(PLAYERp pp_kill_chg);
void PanelInvTestSuicide(PANEL_SPRITEp psp);
void InsertPanelSprite(PLAYERp pp, PANEL_SPRITEp psp);
@ -102,7 +101,6 @@ int DoPanelJump(PANEL_SPRITEp psp);
int DoBeginPanelJump(PANEL_SPRITEp psp);
void SpawnHeartBlood(PANEL_SPRITEp psp);
void SpawnUziShell(PANEL_SPRITEp psp);
void PlayerUpdateWeaponSummary(PLAYERp pp,short UpdateWeaponNum);
SWBOOL pWeaponUnHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state);
SWBOOL pWeaponHideKeys(PANEL_SPRITEp psp, PANEL_STATEp state);
@ -401,22 +399,11 @@ void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value)
short x,y;
short WeaponNum;
#define PANEL_AMMO_BOX_X 197
#define PANEL_AMMO_XOFF 1
#define PANEL_AMMO_YOFF 4
#define AMMO_ERASE 2404
if (Prediction)
return;
if (DamageData[UpdateWeaponNum].max_ammo == -1)
{
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
// erase old info
pSpawnFullScreenSprite(pp, AMMO_ERASE, PRI_MID, PANEL_AMMO_BOX_X, PANEL_BOX_Y);
//pSpawnFullScreenSprite(pp, AMMO_ERASE, PRI_FRONT_MAX+1, PANEL_AMMO_BOX_X, PANEL_BOX_Y);
return;
}
@ -443,101 +430,6 @@ void PlayerUpdateAmmo(PLAYERp pp, short UpdateWeaponNum, short value)
{
pp->WpnAmmo[WeaponNum] = DamageData[WeaponNum].max_ammo;
}
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
PlayerUpdateWeaponSummary(pp, WeaponNum);
if (UpdateWeaponNum != u->WeaponNum)
return;
// erase old info
pSpawnFullScreenSprite(pp, AMMO_ERASE, PRI_MID, PANEL_AMMO_BOX_X, PANEL_BOX_Y);
x = PANEL_AMMO_BOX_X + PANEL_AMMO_XOFF;
y = PANEL_BOX_Y + PANEL_AMMO_YOFF;
DisplayPanelNumber(pp, x, y, pp->WpnAmmo[WeaponNum]);
}
void PlayerUpdateWeaponSummary(PLAYERp pp, short UpdateWeaponNum)
{
USERp u = User[pp->PlayerSprite];
short x,y;
short pos;
short column;
short WeaponNum,wpntmp;
short color,shade;
#define WSUM_X 93
#define WSUM_Y PANEL_BOX_Y+1
#define WSUM_XOFF 25
#define WSUM_YOFF 6
static short wsum_xoff[3] = {0,36,66};
static const char *wsum_fmt1[3] = {"%d:", "%d:", "%d:"};
static const char *wsum_fmt2[3] = {"%3d/%-3d", "%2d/%-2d", "%2d/%-2d"};
static short wsum_back_pic[3] = {2405, 2406, 2406};
if (Prediction)
return;
WeaponNum = UpdateWeaponNum;
if (DamageData[WeaponNum].with_weapon != -1)
{
WeaponNum = DamageData[WeaponNum].with_weapon;
}
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
pos = WeaponNum-1;
column = pos/3;
if (column > 2) column = 2;
x = WSUM_X + wsum_xoff[column];
y = WSUM_Y + (WSUM_YOFF * (pos%3));
// erase old info
pSpawnFullScreenSprite(pp, wsum_back_pic[column], PRI_MID, x, y);
if (UpdateWeaponNum == u->WeaponNum)
{
shade = 0;
color = 0;
}
else
{
shade = 11;
color = 0;
}
wpntmp = WeaponNum+1;
if (wpntmp > 9)
wpntmp = 0;
sprintf(ds, wsum_fmt1[column], wpntmp);
if (TEST(pp->WpnFlags, BIT(WeaponNum)))
DisplaySummaryString(pp, x, y, 1, shade, ds);
else
DisplaySummaryString(pp, x, y, 2, shade+6, ds);
sprintf(ds, wsum_fmt2[column], pp->WpnAmmo[WeaponNum], DamageData[WeaponNum].max_ammo);
DisplaySummaryString(pp, x+6, y, color, shade, ds);
}
void PlayerUpdateWeaponSummaryAll(PLAYERp pp)
{
short i;
if (Prediction)
return;
for (i = WPN_STAR; i <= WPN_HEART; i++)
{
PlayerUpdateWeaponSummary(pp, i);
}
}
void PlayerUpdateWeapon(PLAYERp pp, short WeaponNum)
@ -549,12 +441,6 @@ void PlayerUpdateWeapon(PLAYERp pp, short WeaponNum)
return;
u->WeaponNum = WeaponNum;
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
PlayerUpdateAmmo(pp, u->WeaponNum, 0);
PlayerUpdateWeaponSummaryAll(pp);
}
void PlayerUpdateKills(PLAYERp pp, short value)
@ -586,9 +472,6 @@ void PlayerUpdateKills(PLAYERp pp, short value)
opp->Kills = 0;
if (opp->Kills < -99)
opp->Kills = -99;
if (numplayers >= 2)
DisplayFragNumbers(opp);
}
}
}
@ -598,9 +481,6 @@ void PlayerUpdateKills(PLAYERp pp, short value)
pp->Kills = 0;
if (pp->Kills < -99)
pp->Kills = -99;
if (numplayers >= 2)
DisplayFragNumbers(pp);
}
void PlayerUpdateArmor(PLAYERp pp, short value)
@ -718,30 +598,6 @@ void PlayerUpdateKeys(PLAYERp pp)
}
}
void PlayerUpdateTimeLimit(PLAYERp pp)
{
int seconds;
if (Prediction)
return;
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
if (gNet.MultiGameType != MULTI_GAME_COMMBAT)
return;
if (!gNet.TimeLimit)
return;
// erase old info
pSpawnFullScreenSprite(pp, KEYS_ERASE, PRI_MID, PANEL_KEYS_BOX_X, PANEL_BOX_Y);
seconds = gNet.TimeLimitClock/120;
sprintf(ds,"%03d:%02d",seconds/60, seconds%60);
DisplaySummaryString(pp, PANEL_KEYS_BOX_X+1, PANEL_BOX_Y+6, 0, 0, ds);
}
void PlayerUpdatePanelInfo(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite];
@ -754,8 +610,6 @@ void PlayerUpdatePanelInfo(PLAYERp pp)
PlayerUpdateWeapon(pp, u->WeaponNum);
PlayerUpdateKeys(pp);
PlayerUpdateArmor(pp, 0);
PlayerUpdateWeaponSummaryAll(pp);
PlayerUpdateTimeLimit(pp);
}
int WeaponOperate(PLAYERp pp)

View file

@ -198,7 +198,6 @@ void pToggleCrosshair(void);
void pKillSprite(PANEL_SPRITEp psp);
void InitChops(PLAYERp pp);
void ChopsSetRetract(PLAYERp pp);
void PlayerUpdateTimeLimit(PLAYERp pp);
END_SW_NS

View file

@ -7827,11 +7827,6 @@ void MultiPlayLimits(void)
{
gNet.TimeLimitClock -= synctics;
if ((gNet.TimeLimitClock%120) <= 3)
{
PlayerUpdateTimeLimit(Player + screenpeek);
}
if (gNet.TimeLimitClock <= 0)
Done = TRUE;
}

View file

@ -37,6 +37,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "player.h"
#include "v_2ddrawer.h"
#include "statusbar.h"
#include "network.h"
BEGIN_SW_NS
@ -47,10 +48,25 @@ class DSWStatusBar : public DBaseStatusBar
enum
{
PANEL_HEALTH_BOX_X = 20,
PANEL_BOX_Y = (174-6),
PANEL_BOX_Y = (174 - 6),
PANEL_HEALTH_XOFF = 2,
PANEL_HEALTH_YOFF = 4,
PANEL_AMMO_BOX_X = 197,
PANEL_AMMO_XOFF = 1,
PANEL_AMMO_YOFF = 4,
WSUM_X = 93,
WSUM_Y = PANEL_BOX_Y+1,
WSUM_XOFF = 25,
WSUM_YOFF = 6,
PANEL_KEYS_BOX_X = 276,
PANEL_KEYS_XOFF = 0,
PANEL_KEYS_YOFF = 2,
FRAG_YOFF = 2,
};
enum
@ -65,6 +81,12 @@ class DSWStatusBar : public DBaseStatusBar
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplayPanelNumber(double xs, double ys, int number)
{
char buffer[32];
@ -85,11 +107,227 @@ class DSWStatusBar : public DBaseStatusBar
}
}
void DrawStatusbarHealth(int value)
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplaySummaryString(double xs, double ys, int color, int shade, const char* buffer)
{
double x = PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF;
double y = PANEL_BOX_Y + PANEL_HEALTH_YOFF;
DisplayPanelNumber(x, y, value);
double x;
const char* ptr;
char ch;
int font_pic;
static const short font_base[] = { PANEL_SM_FONT_G, PANEL_SM_FONT_Y, PANEL_SM_FONT_R };
assert(color < 3);
for (ptr = buffer, x = xs; *ptr; ptr++)
{
ch = *ptr;
if (ch == ' ')
{
x += 4;
continue;
}
switch (ch)
{
case '\\':
ch = '0' - 1; // one pic before 0
break;
case ':':
ch = '9' + 1; // one pic after nine
break;
}
font_pic = font_base[color] + (ch - '0');
DrawGraphic(tileGetTexture(font_pic), x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1, shadeToLight(shade));
x += tilesiz[font_pic].x + 1;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplayTimeLimit(PLAYERp pp)
{
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || !gNet.TimeLimit)
return;
int seconds = gNet.TimeLimitClock / 120;
sprintf(ds, "%03d:%02d", seconds / 60, seconds % 60);
DisplaySummaryString(PANEL_KEYS_BOX_X + 1, PANEL_BOX_Y + 6, 0, 0, ds);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplayFragString(PLAYERp pp, double xs, double ys, const char* buffer)
{
double x;
const char* ptr;
const int FRAG_FIRST_ASCII = ('!');
const int FRAG_FIRST_TILE = 2930;
for (ptr = buffer, x = xs; *ptr; ptr++)
{
if (*ptr == ' ')
continue;
assert(*ptr >= '!' && *ptr <= '}');
auto tex = tileGetTexture(FRAG_FIRST_TILE + (*ptr - FRAG_FIRST_ASCII));
DrawGraphic(tex, x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, User[pp->SpriteP - sprite]->spal));
x += 4;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplayFragNumbers()
{
// must draw this in HUD mode!
for (int pnum = 0; pnum < 4; pnum++)
{
char buffer[32];
short xs, ys;
short frag_bar;
static int xoffs[] =
{
69, 147, 225, 303
};
ys = FRAG_YOFF;
// frag bar 0 or 1
frag_bar = ((pnum) / 4);
// move y down according to frag bar number
ys = ys + (tilesiz[FRAG_BAR].y - 2) * frag_bar;
// move x over according to the number of players
xs = xoffs[MOD4(pnum)];
mysnprintf(buffer, 32, "%03d", Player[pnum].Kills);
DisplayFragString(&Player[pnum], xs, ys, buffer);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DisplayFragNames()
{
// must draw this in HUD mode!
for (int pnum = 0; pnum < 4; pnum++)
{
short xs, ys;
short frag_bar;
static int xoffs[] =
{
7, 85, 163, 241
};
ys = FRAG_YOFF;
// frag bar 0 or 1
frag_bar = ((pnum) / 4);
// move y down according to frag bar number
ys = ys + (tilesiz[FRAG_BAR].y - 2) * frag_bar;
// move x over according to the number of players
xs = xoffs[MOD4(pnum)];
DisplayFragString(&Player[pnum], xs, ys, Player[pnum].PlayerName);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void PlayerUpdateWeaponSummary(PLAYERp pp, int UpdateWeaponNum)
{
USERp u = User[pp->PlayerSprite];
int x, y;
int pos;
int column;
int WeaponNum, wpntmp;
int color, shade;
char ds[32];
WeaponNum = UpdateWeaponNum;
if (DamageData[WeaponNum].with_weapon != -1)
{
WeaponNum = DamageData[WeaponNum].with_weapon;
}
if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek)
return;
static short wsum_xoff[3] = { 0,36,66 };
static const char* wsum_fmt2[3] = { "%3d/%-3d", "%2d/%-2d", "%2d/%-2d" };
pos = WeaponNum - 1;
column = pos / 3;
if (column > 2) column = 2;
x = WSUM_X + wsum_xoff[column];
y = WSUM_Y + (WSUM_YOFF * (pos % 3));
if (UpdateWeaponNum == u->WeaponNum)
{
shade = 0;
color = 0;
}
else
{
shade = 11;
color = 0;
}
wpntmp = WeaponNum + 1;
if (wpntmp > 9)
wpntmp = 0;
mysnprintf(ds, 32, "%d:", wpntmp);
if (TEST(pp->WpnFlags, BIT(WeaponNum)))
DisplaySummaryString(x, y, 1, shade, ds);
else
DisplaySummaryString(x, y, 2, shade + 6, ds);
mysnprintf(ds, 32, wsum_fmt2[column], pp->WpnAmmo[WeaponNum], DamageData[WeaponNum].max_ammo);
DisplaySummaryString(x + 6, y, color, shade, ds);
}
void PlayerUpdateWeaponSummaryAll(PLAYERp pp)
{
for (int i = WPN_STAR; i <= WPN_HEART; i++)
{
PlayerUpdateWeaponSummary(pp, i);
}
}
@ -100,7 +338,9 @@ class DSWStatusBar : public DBaseStatusBar
BeginStatusBar(320, 200, tileHeight(STATUS_BAR));
DrawGraphic(tileGetTexture(STATUS_BAR), 0, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1);
DrawStatusbarHealth(u->Health);
DisplayPanelNumber(PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF, PANEL_BOX_Y + PANEL_HEALTH_YOFF, u->Health);
DisplayPanelNumber(PANEL_AMMO_BOX_X + PANEL_AMMO_XOFF, PANEL_BOX_Y + PANEL_AMMO_YOFF, pp->WpnAmmo[u->WeaponNum]);
PlayerUpdateWeaponSummaryAll(pp);
}

View file

@ -47,42 +47,6 @@ BEGIN_SW_NS
#define PANEL_SM_FONT_Y 3613
#define PANEL_SM_FONT_R 3625
void DisplaySummaryString(PLAYERp pp, short xs, short ys, short color, short shade, const char *buffer)
{
short size,x;
const char *ptr;
char ch;
PANEL_SPRITEp nsp;
short font_pic;
static short font_base[] = {PANEL_SM_FONT_G, PANEL_SM_FONT_Y, PANEL_SM_FONT_R};
for (ptr = buffer, x = xs; *ptr; ptr++, x += size)
{
ch = *ptr;
if (ch == ' ')
{
size = 4;
continue;
}
switch (ch)
{
case '\\':
ch = '0' - 1; // one pic before 0
break;
case ':':
ch = '9' + 1; // one pic after nine
break;
}
ASSERT(color < 3);
font_pic = font_base[color] + (ch - '0');
nsp = pSpawnFullScreenSprite(pp, font_pic, PRI_FRONT_MAX, x, ys);
nsp->shade = shade;
size = tilesiz[font_pic].x + 1;
}
}
PANEL_SPRITEp pClearTextLineID(PLAYERp pp, short id, int y, short pri)
{
PANEL_SPRITEp psp=NULL, next;
@ -315,104 +279,6 @@ void DisplaySmString(PLAYERp pp, short xs, short ys, short pal, const char *buff
}
}
void DisplayFragString(PLAYERp pp, short xs, short ys, const char *buffer)
{
short size=4,x;
const char *ptr;
PANEL_SPRITEp nsp;
// ID is base + (0-3)
short id = ID_TEXT + MOD4(pp->pnum);
PLAYERp my_pp = Player + myconnectindex;
#define FRAG_FIRST_ASCII ('!') //exclamation point
#define FRAG_FIRST_TILE 2930 //exclamation point
//pClearTextLineID(my_pp, id, ys, PRI_FRONT_MAX);
for (ptr = buffer, x = xs; *ptr; ptr++, x += size)
{
if (*ptr == ' ')
continue;
ASSERT(*ptr >= '!' && *ptr <= '}');
nsp = pSpawnFullScreenSprite(my_pp, FRAG_FIRST_TILE + (*ptr - FRAG_FIRST_ASCII), PRI_FRONT_MAX, x, ys);
nsp->ID = id;
//nsp->pal = PALETTE_PLAYER0 + pp->TeamColor;
//if (pp->SpriteP)
nsp->pal = User[pp->SpriteP - sprite]->spal;
}
}
void DisplayFragNumbers(PLAYERp pp)
{
char buffer[32];
short xs, ys;
short frag_bar;
short pnum = pp - Player;
static int xoffs[] =
{
69, 147, 225, 303
};
PLAYERp my_pp = Player + myconnectindex;
// black tile to erase frag count
#define FRAG_ERASE_NAME 2375
#define FRAG_ERASE_NUMBER 2376
#define FRAG_YOFF 2
//xs = FRAG_XOFF;
ys = FRAG_YOFF;
// frag bar 0 or 1
frag_bar = ((pnum)/4);
// move y down according to frag bar number
ys = ys + (tilesiz[FRAG_BAR].y-2) * frag_bar;
// move x over according to the number of players
xs = xoffs[MOD4(pnum)];
sprintf(buffer, "%03d", pp->Kills);
// erase old kill count
pSpawnFullScreenSprite(my_pp, FRAG_ERASE_NUMBER, PRI_MID+1, xs-1, ys);
DisplayFragString(pp, xs, ys, buffer);
}
void DisplayFragNames(PLAYERp pp)
{
short xs, ys;
short frag_bar;
short pnum = pp - Player;
static int xoffs[] =
{
7, 85, 163, 241
};
PLAYERp my_pp = Player + myconnectindex;
//xs = FRAG_XOFF;
ys = FRAG_YOFF;
// frag bar 0 or 1
frag_bar = ((pnum)/4);
// move y down according to frag bar number
ys = ys + (tilesiz[FRAG_BAR].y-2) * frag_bar;
// move x over according to the number of players
xs = xoffs[MOD4(pnum)];
// erase old kill count
pSpawnFullScreenSprite(my_pp, FRAG_ERASE_NAME, PRI_MID+1, xs-1, ys);
DisplayFragString(pp, xs, ys, pp->PlayerName);
}
short GlobInfoStringTime = TEXT_INFO_TIME;
void PutStringInfo(PLAYERp pp, const char *string)
{