Tweaks to level stats display in HUD.

This commit is contained in:
Mari the Deer 2023-07-29 12:25:53 +02:00
commit ea86ab99d0
9 changed files with 151 additions and 45 deletions

View file

@ -171,20 +171,22 @@ Class SWWMStatusBar : BaseStatusBar
Array<KeyGet> keyflash;
int oldkills, olditems, oldsecrets;
int oldtkills, oldtitems, oldtsecrets;
int killflash, itemflash, secretflash;
int tkillflash, titemflash, tsecretflash;
int oldpkills, oldpitems, oldpsecrets;
transient int killflash, itemflash, secretflash;
transient int tkillflash, titemflash, tsecretflash;
transient int pkillflash, pitemflash, psecretflash;
// top stuff colors
int tclabel, tcvalue, tcextra, tccompl, tcsucks;
String tclabel_s, tcextra_s;
int AmmoFlash[18]; // flash when new ammo is received
transient int AmmoFlash[18]; // flash when new ammo is received
int AmmoOldAmounts[18]; // to detect when to flash
int AmmoMaxFlash[18]; // flash when ammo max amount changes
transient int AmmoMaxFlash[18]; // flash when ammo max amount changes
int AmmoOldMaxAmounts[18]; // to detect when to flash
Class<SWWMAmmo> AmmoSlots[18]; // ammo type on each slot
String AmmoNames[18]; // ammo 4-letter names
int HealthFlash; // flash when healing
transient int HealthFlash; // flash when healing
int LastHealth; // to detect when to flash
int LagHealth[10]; // for delayed decay bar

View file

@ -68,6 +68,27 @@ extend Class SWWMStatusBar
oldtsecrets = level.total_secrets;
tsecretflash = gametic+25;
}
if ( level.total_monsters > 0 )
{
int pkills = (level.killed_monsters*100)/level.total_monsters;
if ( pkills != oldpkills )
pkillflash = gametic+25;
oldpkills = pkills;
}
if ( level.total_items > 0 )
{
int pitems = (level.found_items*100)/level.total_items;
if ( pitems != oldpitems )
pitemflash = gametic+25;
oldpitems = pitems;
}
if ( level.total_secrets > 0 )
{
int psecrets = (level.found_secrets*100)/level.total_secrets;
if ( psecrets != oldpsecrets )
psecretflash = gametic+25;
oldpsecrets = psecrets;
}
// purge expired key flashes
for ( int i=0; i<keyflash.Size(); i++ )
{
@ -859,6 +880,7 @@ extend Class SWWMStatusBar
}
// draw stats and timer when automap is open
int fstats = swwm_forcestats;
bool pstats = swwm_percentstats;
if ( automapactive || (fstats > 0) )
{
xx = int(ss.x-(margin+2));
@ -873,65 +895,141 @@ extend Class SWWMStatusBar
int iof;
if ( ((iof = ln.RightIndexOf(" - by: ")) != -1) || ((iof = ln.RightIndexOf(" - by ")) != -1) || ((iof = ln.RightIndexOf(" - ")) != -1) )
ln.Truncate(iof);
if ( !label || ((level.clusterflags&level.CLUSTER_HUB) && (label == 2)) ) str = ln;
else str = String.Format("%s - %s",level.mapname.MakeUpper(),ln);
Screen.DrawText(mSmallFontOutline,tclabel,xx-mSmallFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( !label || ((level.clusterflags&level.CLUSTER_HUB) && (label == 2)) )
{
str = ln;
Screen.DrawText(mSmallFontOutline,tcvalue,xx-mSmallFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
}
else
{
str = level.mapname.MakeUpper()..": ";
int labelw = MiniHUDFontOutline.StringWidth(str);
int namew = mSmallFontOutline.StringWidth(ln);
Screen.DrawText(MiniHUDFontOutline,tclabel,xx-(labelw+namew),yy+4,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
Screen.DrawText(mSmallFontOutline,tcvalue,xx-namew,yy,ln,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
}
yy += mSmallFontOutline.GetHeight()+4;
}
if ( (level.total_monsters > 0) && am_showmonsters && !deathmatch )
{
str = String.Format("\c"..tclabel_s.."K \c-%d\c"..tcextra_s.."/\c-%d",level.killed_monsters,level.total_monsters);
Screen.DrawText(MiniHUDFontOutline,(level.killed_monsters>=level.total_monsters)?tccompl:tcvalue,xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( killflash && (gametic < killflash) )
int pct = (level.killed_monsters*100)/level.total_monsters;
if ( pstats ) str = String.Format("\c"..tclabel_s.."K \c-%3d\c"..tcextra_s.."%%\c-",pct);
else str = String.Format("\c"..tclabel_s.."K \c-%d\c"..tcextra_s.."/\c-%d",level.killed_monsters,level.total_monsters);
int basew = MiniHUDFontOutline.StringWidth(str);
if ( pstats )
{
double alph = max((killflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.killed_monsters,level.total_monsters);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
int dcnt = 2-int(Log10(clamp(pct,1,999)));
for ( int j=0; j<dcnt; j++ )
Screen.DrawChar(MiniHUDFontOutline,(level.killed_monsters>=level.total_monsters)?tccompl:tcvalue,(xx-basew)+8+j*4,yy,0x30,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(160,0,0,0));
}
if ( tkillflash && (gametic < tkillflash) )
Screen.DrawText(MiniHUDFontOutline,(level.killed_monsters>=level.total_monsters)?tccompl:tcvalue,xx-basew,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( pstats )
{
double alph = max((tkillflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_monsters);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
if ( pkillflash && (gametic < pkillflash) )
{
double alph = max((pkillflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%3d%%",pct);
int pctpos = str.IndexOf("%");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(pctpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
else
{
if ( killflash && (gametic < killflash) )
{
double alph = max((killflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.killed_monsters,level.total_monsters);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
if ( tkillflash && (gametic < tkillflash) )
{
double alph = max((tkillflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_monsters);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
yy += MiniHUDFontOutline.GetHeight()+2;
}
if ( (level.total_items > 0) && am_showitems && !deathmatch )
{
str = String.Format("\c"..tclabel_s.."I \c-%d\c"..tcextra_s.."/\c-%d",level.found_items,level.total_items);
Screen.DrawText(MiniHUDFontOutline,(level.found_items>=level.total_items)?tccompl:tcvalue,xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( itemflash && (gametic < itemflash) )
int pct = (level.found_items*100)/level.total_items;
if ( pstats ) str = String.Format("\c"..tclabel_s.."I \c-%3d\c"..tcextra_s.."%%\c-",pct);
else str = String.Format("\c"..tclabel_s.."I \c-%d\c"..tcextra_s.."/\c-%d",level.found_items,level.total_items);
int basew = MiniHUDFontOutline.StringWidth(str);
if ( pstats )
{
double alph = max((itemflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.found_items,level.total_items);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
int dcnt = 2-int(Log10(clamp(pct,1,999)));
for ( int j=0; j<dcnt; j++ )
Screen.DrawChar(MiniHUDFontOutline,(level.found_items>=level.total_items)?tccompl:tcvalue,(xx-basew)+8+j*4,yy,0x30,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(160,0,0,0));
}
if ( titemflash && (gametic < titemflash) )
Screen.DrawText(MiniHUDFontOutline,(level.found_items>=level.total_items)?tccompl:tcvalue,xx-basew,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( pstats )
{
double alph = max((titemflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_items);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
if ( pitemflash && (gametic < pitemflash) )
{
double alph = max((pitemflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%3d%%",pct);
int pctpos = str.IndexOf("%");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(pctpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
else
{
if ( itemflash && (gametic < itemflash) )
{
double alph = max((itemflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.found_items,level.total_items);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
if ( titemflash && (gametic < titemflash) )
{
double alph = max((titemflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_items);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
yy += MiniHUDFontOutline.GetHeight()+2;
}
if ( (level.total_secrets > 0) && am_showsecrets && !deathmatch )
{
str = String.Format("\c"..tclabel_s.."S \c-%d\c"..tcextra_s.."/\c-%d",level.found_secrets,level.total_secrets);
Screen.DrawText(MiniHUDFontOutline,(level.found_secrets>=level.total_secrets)?tccompl:tcvalue,xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( secretflash && (gametic < secretflash) )
int pct = (level.found_secrets*100)/level.total_secrets;
if ( pstats ) str = String.Format("\c"..tclabel_s.."S \c-%3d\c"..tcextra_s.."%%\c-",pct);
else str = String.Format("\c"..tclabel_s.."S \c-%d\c"..tcextra_s.."/\c-%d",level.found_secrets,level.total_secrets);
int basew = MiniHUDFontOutline.StringWidth(str);
if ( pstats )
{
double alph = max((secretflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.found_secrets,level.total_secrets);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
int dcnt = 2-int(Log10(clamp(pct,1,999)));
for ( int j=0; j<dcnt; j++ )
Screen.DrawChar(MiniHUDFontOutline,(level.found_secrets>=level.total_secrets)?tccompl:tcvalue,(xx-basew)+8+j*4,yy,0x30,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(160,0,0,0));
}
if ( tsecretflash && (gametic < tsecretflash) )
Screen.DrawText(MiniHUDFontOutline,(level.found_secrets>=level.total_secrets)?tccompl:tcvalue,xx-basew,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( pstats )
{
double alph = max((tsecretflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_secrets);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
if ( psecretflash && (gametic < psecretflash) )
{
double alph = max((psecretflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%3d%%",pct);
int pctpos = str.IndexOf("%");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(pctpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
else
{
if ( secretflash && (gametic < secretflash) )
{
double alph = max((secretflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d/%d",level.found_secrets,level.total_secrets);
int slashpos = str.IndexOf("/");
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str.Left(slashpos),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
if ( tsecretflash && (gametic < tsecretflash) )
{
double alph = max((tsecretflash-(gametic+FracTic))/25.,0.)**1.5;
str = String.Format("%d",level.total_secrets);
Screen.DrawText(MiniHUDFontOutline,mhudfontcol[MCR_FLASH],xx-MiniHUDFontOutline.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
}
yy += MiniHUDFontOutline.GetHeight()+2;
}