mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
- scriptified the AltHUD'S powerup drawer.
This commit is contained in:
parent
ddaab4d2ab
commit
fe39236ee1
4 changed files with 56 additions and 47 deletions
|
@ -2996,3 +2996,4 @@ DEFINE_GLOBAL(gametic)
|
||||||
DEFINE_GLOBAL(demoplayback)
|
DEFINE_GLOBAL(demoplayback)
|
||||||
DEFINE_GLOBAL(automapactive);
|
DEFINE_GLOBAL(automapactive);
|
||||||
DEFINE_GLOBAL(Net_Arbitrator);
|
DEFINE_GLOBAL(Net_Arbitrator);
|
||||||
|
DEFINE_GLOBAL(netgame);
|
|
@ -353,41 +353,6 @@ static void DrawLatency(int y)
|
||||||
VMValue params[] = { althud, y };
|
VMValue params[] = { althud, y };
|
||||||
VMCall(func, params, countof(params), nullptr, 0);
|
VMCall(func, params, countof(params), nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (!ST_IsLatencyVisible())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i, localdelay = 0, arbitratordelay = 0;
|
|
||||||
for (i = 0; i < BACKUPTICS; i++) localdelay += netdelay[0][i];
|
|
||||||
for (i = 0; i < BACKUPTICS; i++) arbitratordelay += netdelay[nodeforplayer[Net_Arbitrator]][i];
|
|
||||||
localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
|
|
||||||
arbitratordelay = ((arbitratordelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
|
|
||||||
int color = CR_GREEN;
|
|
||||||
if (MAX(localdelay, arbitratordelay) > 200)
|
|
||||||
{
|
|
||||||
color = CR_YELLOW;
|
|
||||||
}
|
|
||||||
if (MAX(localdelay, arbitratordelay) > 400)
|
|
||||||
{
|
|
||||||
color = CR_ORANGE;
|
|
||||||
}
|
|
||||||
if (MAX(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE))
|
|
||||||
{
|
|
||||||
color = CR_RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
char tempstr[32];
|
|
||||||
|
|
||||||
const int millis = (level.time % TICRATE) * (1000 / TICRATE);
|
|
||||||
mysnprintf(tempstr, sizeof(tempstr), "a:%dms - l:%dms", arbitratordelay, localdelay);
|
|
||||||
|
|
||||||
const int characterCount = (int)strlen(tempstr);
|
|
||||||
const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border
|
|
||||||
|
|
||||||
DrawHudText(SmallFont, color, tempstr, hudwidth - width, y, 0x10000);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -396,18 +361,20 @@ static void DrawLatency(int y)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void DrawPowerups(player_t *CPlayer)
|
static void DrawPowerups(player_t *CPlayer, int y)
|
||||||
{
|
{
|
||||||
|
IFVM(AltHud, DrawPowerups)
|
||||||
|
{
|
||||||
|
VMValue params[] = { althud, CPlayer, y };
|
||||||
|
VMCall(func, params, countof(params), nullptr, 0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
// Each icon gets a 32x32 block to draw itself in.
|
// Each icon gets a 32x32 block to draw itself in.
|
||||||
int x, y;
|
int x, y;
|
||||||
AInventory *item;
|
AInventory *item;
|
||||||
const int yshift = SmallFont->GetHeight();
|
|
||||||
const int POWERUPICONSIZE = 32;
|
const int POWERUPICONSIZE = 32;
|
||||||
|
|
||||||
x = hudwidth -20;
|
x = hudwidth -20;
|
||||||
y = POWERUPICONSIZE * 5/4
|
|
||||||
+ (ST_IsTimeVisible() ? yshift : 0)
|
|
||||||
+ (ST_IsLatencyVisible() ? yshift : 0);
|
|
||||||
|
|
||||||
for (item = CPlayer->mo->Inventory; item != NULL; item = item->Inventory)
|
for (item = CPlayer->mo->Inventory; item != NULL; item = item->Inventory)
|
||||||
{
|
{
|
||||||
|
@ -443,6 +410,7 @@ static void DrawPowerups(player_t *CPlayer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -481,6 +449,7 @@ void DrawHUD()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
// No HUD in the title level!
|
// No HUD in the title level!
|
||||||
if (gamestate == GS_TITLELEVEL || !CPlayer) return;
|
if (gamestate == GS_TITLELEVEL || !CPlayer) return;
|
||||||
|
|
||||||
|
@ -500,7 +469,9 @@ void DrawHUD()
|
||||||
|
|
||||||
DrawTime(SmallFont->GetHeight());
|
DrawTime(SmallFont->GetHeight());
|
||||||
DrawLatency(SmallFont->GetHeight()*2); // to be fixed when fully scripted.
|
DrawLatency(SmallFont->GetHeight()*2); // to be fixed when fully scripted.
|
||||||
DrawPowerups(CPlayer);
|
const int POWERUPICONSIZE = 32;
|
||||||
|
DrawPowerups(CPlayer, SmallFont->GetHeight() * 2 + POWERUPICONSIZE * 5 / 4); // to be fixed when fully scripted.
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@ struct _ native // These are the global variables, the struct is only here to av
|
||||||
native readonly @GameInfoStruct gameinfo;
|
native readonly @GameInfoStruct gameinfo;
|
||||||
native play @PlayerInfo players[MAXPLAYERS];
|
native play @PlayerInfo players[MAXPLAYERS];
|
||||||
native readonly bool playeringame[MAXPLAYERS];
|
native readonly bool playeringame[MAXPLAYERS];
|
||||||
|
native readonly ui bool netgame;
|
||||||
|
|
||||||
native readonly bool automapactive;
|
native readonly bool automapactive;
|
||||||
native play uint gameaction;
|
native play uint gameaction;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class AltHud ui
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void DrawImageToBox(TextureID tex, int x, int y, int w, int h, double trans = 0.75)
|
void DrawImageToBox(TextureID tex, int x, int y, int w, int h, double trans = 0.75, bool animate = false)
|
||||||
{
|
{
|
||||||
double scale1, scale2;
|
double scale1, scale2;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class AltHud ui
|
||||||
w = (int)(texsize.X * scale1);
|
w = (int)(texsize.X * scale1);
|
||||||
h = (int)(texsize.Y * scale1);
|
h = (int)(texsize.Y * scale1);
|
||||||
|
|
||||||
screen.DrawTexture(tex, false, x, y,
|
screen.DrawTexture(tex, animate, x, y,
|
||||||
DTA_KeepRatio, true,
|
DTA_KeepRatio, true,
|
||||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans,
|
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans,
|
||||||
DTA_DestWidth, w, DTA_DestHeight, h, DTA_CenterBottomOffset, 1);
|
DTA_DestWidth, w, DTA_DestHeight, h, DTA_CenterBottomOffset, 1);
|
||||||
|
@ -799,9 +799,9 @@ class AltHud ui
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
native static int, int, int GetLatency();
|
native static int, int, int GetLatency();
|
||||||
|
|
||||||
static void DrawLatency(int y)
|
void DrawLatency(int y)
|
||||||
{
|
{
|
||||||
if ((hud_showlag > 0) && (hud_showlag != 1 || netgame) && (hud_showlag <= 2)
|
if ((hud_showlag == 1 && netgame) || hud_showlag == 2)
|
||||||
{
|
{
|
||||||
int severity, localdelay, arbitratordelay;
|
int severity, localdelay, arbitratordelay;
|
||||||
[severity, localdelay, arbitratordelay] = GetLatency();
|
[severity, localdelay, arbitratordelay] = GetLatency();
|
||||||
|
@ -809,12 +809,48 @@ class AltHud ui
|
||||||
|
|
||||||
String tempstr = String.Format("a:%dms - l:%dms", arbitratordelay, localdelay);
|
String tempstr = String.Format("a:%dms - l:%dms", arbitratordelay, localdelay);
|
||||||
|
|
||||||
const int characterCount = tempstr.Length();
|
int characterCount = tempstr.Length();
|
||||||
const int width = SmallFont.GetCharWidth("0") * characterCount + 2; // small offset from screen's border
|
int width = SmallFont.GetCharWidth("0") * characterCount + 2; // small offset from screen's border
|
||||||
|
|
||||||
DrawHudText(SmallFont, color, tempstr, hudwidth - width, y, 1);
|
DrawHudText(SmallFont, color, tempstr, hudwidth - width, y, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// draw the overlay
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void DrawPowerups(PlayerInfo CPlayer, int y)
|
||||||
|
{
|
||||||
|
// Each icon gets a 32x32 block to draw itself in.
|
||||||
|
int x, y;
|
||||||
|
Inventory item;
|
||||||
|
|
||||||
|
x = hudwidth - POWERUPICONSIZE - 4;
|
||||||
|
|
||||||
|
for (item = CPlayer.mo.Inv; item != NULL; item = item.Inv)
|
||||||
|
{
|
||||||
|
let power = Powerup(item);
|
||||||
|
if (power)
|
||||||
|
{
|
||||||
|
let icon = power.GetPowerupIcon();
|
||||||
|
if (icon.isValid())
|
||||||
|
{
|
||||||
|
if (!power.isBlinking())
|
||||||
|
DrawImageToBox(icon, x, y, POWERUPICONSIZE, POWERUPICONSIZE, 1, true);
|
||||||
|
x -= POWERUPICONSIZE;
|
||||||
|
if (x < -hudwidth / 2)
|
||||||
|
{
|
||||||
|
x = hudwidth - 20;
|
||||||
|
y += POWERUPICONSIZE * 3 / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue