- started port of Doom status bar to ZScript.

Fullscreen HUD done with the exception of key and inventory bar. I also used the opportunity to make it a bit more resistant against badly designed inventory icons.
This commit is contained in:
Christoph Oelckers 2017-03-25 21:40:17 +01:00
parent 3e67a8bafa
commit 488fface50
8 changed files with 236 additions and 14 deletions

View file

@ -234,8 +234,6 @@ FString shotfile;
AActor* bodyque[BODYQUESIZE];
int bodyqueslot;
void R_ExecuteSetViewSize (FViewWindow &viewwindow);
FString savename;
FString BackupSaveName;

View file

@ -327,6 +327,9 @@ void DBaseStatusBar::SetSize(int reltop, int hres, int vres)
RelTop = reltop;
HorizontalResolution = hres;
VerticalResolution = vres;
int x, y;
V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y);
defaultScale = { (double)x, (double)y };
CallSetScaled(st_scale);
}
@ -1397,11 +1400,8 @@ void DBaseStatusBar::SerializeMessages(FSerializer &arc)
void DBaseStatusBar::ScreenSizeChanged ()
{
st_scale.Callback ();
int x, y;
V_CalcCleanFacs(HorizontalResolution, VerticalResolution, SCREENWIDTH, SCREENHEIGHT, &x, &y);
defaultScale = { (double)x, (double)y };
// We need to recalculate the sizing info
SetSize(RelTop, HorizontalResolution, VerticalResolution);
for (size_t i = 0; i < countof(Messages); ++i)
{

View file

@ -63,7 +63,6 @@ void PolyRenderer::RenderView(player_t *player)
int width = SCREENWIDTH;
int height = SCREENHEIGHT;
int stHeight = gST_Y;
float trueratio;
ActiveRatio(width, height, &trueratio);
//viewport->SetViewport(&Thread, width, height, trueratio);

View file

@ -26,8 +26,8 @@ gameinfo
defaultbloodparticlecolor = "ff 00 00"
backpacktype = "Backpack"
armoricons = "ARM1A0", 0.5, "ARM2A0"
statusbar = "sbarinfo/doom.txt"
//statusbarclass = "DoomStatusBar"
//statusbar = "sbarinfo/doom.txt"
statusbarclass = "DoomStatusBar"
intermissionmusic = "$MUSIC_DM2INT"
intermissioncounter = true
weaponslot = 1, "Fist", "Chainsaw"

View file

@ -33,6 +33,7 @@ version "2.5"
#include "zscript/statscreen/statscreen_coop.txt"
#include "zscript/statusbar/statusbar.txt"
#include "zscript/statusbar/doom_sbar.txt"
#include "zscript/statusbar/strife_sbar.txt"
#include "zscript/statusbar/sbarinfowrapper.txt"

View file

@ -373,6 +373,27 @@ usercmd_t original_cmd;
native float GetAutoaim() const;
native bool GetNoAutostartMap() const;
native void SetFOV(float fov);
clearscope int fragSum () const
{
int i;
int allfrags = 0;
int playernum = mo.PlayerNumber();
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i]
&& i!=playernum)
{
allfrags += frags[i];
}
}
// JDC hack - negative frags.
allfrags -= frags[playernum];
return allfrags;
}
}
struct PlayerClass native

View file

@ -0,0 +1,203 @@
class DoomStatusBar : BaseStatusBar
{
// it is not really needed to precache all textures but should be good practice to reduce execution time.
enum eImg
{
imgMEDIA0,
imgPSTRA0,
imgSTBAR,
imgSTTPRCNT,
imgSTKEYS0,
imgSTKEYS1,
imgSTKEYS2,
imgSTKEYS3,
imgSTKEYS4,
imgSTKEYS5,
imgSTKEYS6,
imgSTKEYS7,
imgSTKEYS8,
imgSTARMS,
imgSTGNUM2,
imgSTGNUM3,
imgSTGNUM4,
imgSTGNUM5,
imgSTGNUM6,
imgSTGNUM7,
imgSTYSNUM2,
imgSTYSNUM3,
imgSTYSNUM4,
imgSTYSNUM5,
imgSTYSNUM6,
imgSTYSNUM7,
imgSTFBANY,
NUMIMG
}
TextureID Images[NUMIMG];
int HUDFontSpacing;
override void Init()
{
Super.Init();
SetSize(32, 320, 200);
DoCommonInit();
}
override void NewGame ()
{
DoCommonInit ();
if (CPlayer != NULL)
{
AttachToPlayer (CPlayer);
}
}
override void Draw (int state, double TicFrac)
{
Super.Draw (state, TicFrac);
if (state == HUD_StatusBar)
{
BeginStatusBar(320, 200, 32);
DrawMainBar (TicFrac);
}
else if (state == HUD_Fullscreen)
{
BeginHUD(320, 200, 1., false);
DrawFullScreenStuff ();
}
}
void DoCommonInit ()
{
static const String LumpNames[] =
{
"MEDIA0", "PSTRA0", "STBAR", "STTPRCNT", "STKEYS0",
"STKEYS1", "STKEYS2", "STKEYS3", "STKEYS4", "STKEYS5", "STKEYS6", "STKEYS7", "STKEYS8",
"STARMS",
"STGNUM2", "STGNUM3", "STGNUM4", "STGNUM5", "STGNUM6", "STGNUM7",
"STYSNUM2", "STYSNUM3", "STYSNUM4", "STYSNUM5", "STYSNUM6", "STYSNUM7",
"STFBANY"
};
for(int i = 0; i < NUMIMG; i++)
{
Images[i] = TexMan.CheckForTexture(LumpNames[i], TexMan.TYPE_MiscPatch);
}
Font fnt = "HUDFONT_DOOM";
if (fnt != null) HudFontSpacing = fnt.GetCharWidth("0");
}
protected void DrawMainBar (double TicFrac)
{
//DrawTexture(Images[imgINVBACK], (0, 0), true, 1.0, itemAlign:ALIGN_OFFSETS);
//DrawTexture(Images[imgINVTOP], (0, -8), true, 1.0, itemAlign:ALIGN_OFFSETS);
// Health
//DrawString("Indexfont_Strife_Green", FormatNumber(CPlayer.health, 3, 5, 0), (86, -6), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, 0, 7, true, 1, 1);
}
protected void DrawFullScreenStuff ()
{
Vector2 iconbox = (40, 20);
// Draw health
let berserk = CPlayer.mo.FindInventory("PowerStrength");
DrawTexture(Images[berserk? imgPSTRA0 : imgMEDIA0], (20, -2), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.health, 3, 0, 0), (44, -20), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
let armor = CPlayer.mo.FindInventory("BasicArmor");
if (armor != null)
{
DrawTexture(armor.Icon, (20, -22), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
DrawString("HUDFONT_DOOM", FormatNumber(armor.Amount, 3, 0, 0), (44, -40), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
}
Inventory ammotype1, ammotype2;
int ammoamount1, ammoamount2;
[ammotype1, ammotype2, ammoamount1, ammoamount2] = GetCurrentAmmo();
int invY = -20;
if (ammotype1 != null)
{
DrawTexture(ammotype1.Icon, (-14, -4), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount1, 3, 0, 0), (-25, -20), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
invY -= 20;
}
if (ammotype2 != null && ammotype2 != ammotype1)
{
DrawTexture(ammotype2.Icon, (-14, invY + 17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount2, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
invY -= 20;
}
if (CPlayer.inventorytics == 0 && CPlayer.mo.InvSel != null)
{
DrawTexture(CPlayer.mo.InvSel.Icon, (-14, invY + 17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.mo.InvSel.Amount, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
}
if (deathmatch)
{
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.fragSum(), 3, 0, 0), (-3, -1), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_TOP, HUdFontSpacing, true, 2, 2);
}
//drawkeybar 100, vertical, reverserows, auto, -10, 2, 0, 3, auto;
}
}
/*
statusbar normal // Standard Doom Status bar
{
drawimage "STBAR", 0, 168;
drawimage "STTPRCNT", 90, 171;
drawimage "STTPRCNT", 221, 171;
drawnumber 3, HUDFONT_DOOM, untranslated, ammo1, 44, 171;
drawnumber 3, HUDFONT_DOOM, untranslated, health, 90, 171;
drawnumber 3, HUDFONT_DOOM, untranslated, armor, 221, 171;
//keys
drawswitchableimage keyslot 2 && 5, "nullimage", "STKEYS0", "STKEYS3", "STKEYS6", 239, 171;
drawswitchableimage keyslot 3 && 6, "nullimage", "STKEYS1", "STKEYS4", "STKEYS7", 239, 181;
drawswitchableimage keyslot 1 && 4, "nullimage", "STKEYS2", "STKEYS5", "STKEYS8", 239, 191;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Clip), 288, 173;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Shell), 288, 179;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(RocketAmmo), 288, 185;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Cell), 288, 191;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Clip), 314, 173;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Shell), 314, 179;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(RocketAmmo), 314, 185;
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Cell), 314, 191;
gamemode deathmatch, teamgame
{
drawnumber 2, HUDFONT_DOOM, untranslated, frags, 138, 171;
}
gamemode cooperative, singleplayer
{
drawimage "STARMS", 104, 168;
drawswitchableimage weaponslot 2, "STGNUM2", "STYSNUM2", 111, 172;
drawswitchableimage weaponslot 3, "STGNUM3", "STYSNUM3", 123, 172;
drawswitchableimage weaponslot 4, "STGNUM4", "STYSNUM4", 135, 172;
drawswitchableimage weaponslot 5, "STGNUM5", "STYSNUM5", 111, 182;
drawswitchableimage weaponslot 6, "STGNUM6", "STYSNUM6", 123, 182;
drawswitchableimage weaponslot 7, "STGNUM7", "STYSNUM7", 135, 182;
}
gamemode cooperative, deathmatch, teamgame
{
drawimage translatable "STFBANY", 143, 169;
}
drawselectedinventory alternateonempty, INDEXFONT, 143, 168
{
drawmugshot "STF", 5, 143, 168;
}
}
statusbar inventory // Standard bar overlay (ZDoom Addition)
{
drawinventorybar Doom, 7, INDEXFONT, 50, 170;
}
statusbar inventoryfullscreen, fullscreenoffsets // ZDoom HUD overlay.
{
drawinventorybar Doom, translucent, 7, INDEXFONT, -106+center, -31;
}
*/

View file

@ -78,21 +78,22 @@ class StrifeStatusBar : BaseStatusBar
if (state == HUD_StatusBar)
{
fullscreenoffsets = false;
BeginStatusBar(320, 200, 32);
DrawMainBar (TicFrac);
}
else
{
if (state == HUD_Fullscreen)
{
fullscreenoffsets = true;
BeginHUD(320, 200, 1., false);
DrawFullScreenStuff ();
}
// Draw pop screen (log, keys, and status)
if (CurrentPop != POP_None && PopHeight < 0)
{
fullscreenoffsets = false;
// This uses direct low level draw commands and would otherwise require calling
// BeginStatusBar(320, 200, false, true);
DrawPopScreen (screen.GetHeight(), TicFrac);
}
}
@ -440,7 +441,6 @@ class StrifeStatusBar : BaseStatusBar
}
}
}
fullscreenoffsets = false;
}
protected void DrawPopScreen (int bottom, double TicFrac)