mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- implemented the regular Doom status bar.
The DOOM status bar and HUD are complete, except the inventory bar.
This commit is contained in:
parent
0cbbd8d4b1
commit
e791c957d9
12 changed files with 131 additions and 100 deletions
|
@ -2568,14 +2568,8 @@ void D_DoomMain (void)
|
|||
|
||||
P_SetupWeapons_ntohton();
|
||||
|
||||
//SBarInfo support.
|
||||
// This needs special checking because there are two distinct methods of defining status bars.
|
||||
// SBARINFO should only be picked if it is the most recently defined one, so that both
|
||||
// methods can override each other if loaded in sequence.
|
||||
if (gameinfo.statusbarfile > gameinfo.statusbarclassfile)
|
||||
{
|
||||
SBarInfo::Load();
|
||||
}
|
||||
//SBarInfo support. Note that the first SBARINFO lump contains the mugshot definition so it even needs to be read when a regular status bar is being used.
|
||||
SBarInfo::Load();
|
||||
HUD_InitHud();
|
||||
|
||||
if (!batchrun)
|
||||
|
|
|
@ -532,6 +532,7 @@ public:
|
|||
|
||||
// [Nash] set player FOV
|
||||
void SetFOV(float fov);
|
||||
bool HasWeaponsInSlot(int slot) const;
|
||||
};
|
||||
|
||||
// Bookkeeping on players - state.
|
||||
|
|
|
@ -464,7 +464,7 @@ void P_DeinitKeyMessages()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool P_CheckKeys (AActor *owner, int keynum, bool remote)
|
||||
bool P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet)
|
||||
{
|
||||
const char *failtext = NULL;
|
||||
FSoundID *failsound;
|
||||
|
@ -479,6 +479,7 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
|
|||
|
||||
if (!locks[keynum])
|
||||
{
|
||||
if (quiet) return false;
|
||||
if (keynum == 103 && (gameinfo.flags & GI_SHAREWARE))
|
||||
failtext = "$TXT_RETAIL_ONLY";
|
||||
else
|
||||
|
@ -490,6 +491,7 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
|
|||
else
|
||||
{
|
||||
if (locks[keynum]->check(owner)) return true;
|
||||
if (quiet) return false;
|
||||
failtext = remote? locks[keynum]->RemoteMsg : locks[keynum]->Message;
|
||||
failsound = &locks[keynum]->locksound[0];
|
||||
numfailsounds = locks[keynum]->locksound.Size();
|
||||
|
@ -519,6 +521,15 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
|
|||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, CheckKeys)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT(locknum);
|
||||
PARAM_BOOL(remote);
|
||||
PARAM_BOOL_DEF(quiet);
|
||||
ACTION_RETURN_BOOL(P_CheckKeys(self, locknum, remote, quiet));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// These functions can be used to get color information for
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
class AActor;
|
||||
class AInventory;
|
||||
|
||||
bool P_CheckKeys (AActor *owner, int keynum, bool remote);
|
||||
bool P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet = false);
|
||||
void P_InitKeyMessages ();
|
||||
void P_DeinitKeyMessages ();
|
||||
int P_GetMapColorForLock (int lock);
|
||||
|
|
|
@ -530,6 +530,7 @@ enum DI_Flags
|
|||
DI_TEXT_ALIGN = 0x1800000,
|
||||
|
||||
DI_ALPHAMAPPED = 0x2000000,
|
||||
DI_NOSHADOW = 0x4000000,
|
||||
};
|
||||
|
||||
#endif /* __SBAR_H__ */
|
||||
|
|
|
@ -446,6 +446,7 @@ void SBarInfo::Load()
|
|||
{
|
||||
FreeSBarInfoScript();
|
||||
MugShotStates.Clear();
|
||||
|
||||
if(gameinfo.statusbar.IsNotEmpty())
|
||||
{
|
||||
int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true);
|
||||
|
|
|
@ -1846,7 +1846,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
}
|
||||
// This is not really such a great way to draw shadows because they can overlap with previously drawn characters.
|
||||
// This may have to be changed to draw the shadow text up front separately.
|
||||
if (shadowX != 0 || shadowY != 0)
|
||||
if ((shadowX != 0 || shadowY != 0) && !(flags & DI_NOSHADOW))
|
||||
{
|
||||
screen->DrawChar(font, CR_UNTRANSLATED, rx + shadowX, ry + shadowY, ch,
|
||||
DTA_DestWidthF, rw,
|
||||
|
@ -2033,10 +2033,9 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, ReceivedWeapon)
|
|||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetMugshot)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_POINTER(player, player_t);
|
||||
PARAM_STRING(def_face);
|
||||
PARAM_INT(accuracy);
|
||||
PARAM_INT_DEF(stateflags);
|
||||
auto tex = self->mugshot.GetFace(player, def_face, accuracy, (FMugShot::StateFlags)stateflags);
|
||||
PARAM_STRING_DEF(def_face);
|
||||
auto tex = self->mugshot.GetFace(self->CPlayer, def_face, accuracy, (FMugShot::StateFlags)stateflags);
|
||||
ACTION_RETURN_INT(tex ? tex->id.GetIndex() : -1);
|
||||
}
|
||||
|
|
|
@ -707,6 +707,24 @@ void player_t::SendPitchLimits() const
|
|||
}
|
||||
|
||||
|
||||
bool player_t::HasWeaponsInSlot(int slot) const
|
||||
{
|
||||
for (int i = 0; i < weapons.Slots[slot].Size(); i++)
|
||||
{
|
||||
PClassActor *weap = weapons.Slots[slot].GetWeapon(i);
|
||||
if (weap != NULL && mo->FindInventory(weap)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, HasWeaponsInSlot)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
PARAM_INT(slot);
|
||||
ACTION_RETURN_BOOL(self->HasWeaponsInSlot(slot));
|
||||
}
|
||||
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetUserName)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
|
|
|
@ -501,6 +501,7 @@ class Actor : Thinker native
|
|||
native static int FindUniqueTid(int start = 0, int limit = 0);
|
||||
native void SetShade(color col);
|
||||
native clearscope int GetRenderStyle() const;
|
||||
native clearscope bool CheckKeys(int locknum, bool remote, bool quiet = false);
|
||||
|
||||
native clearscope string GetTag(string defstr = "") const;
|
||||
native void SetTag(string defstr = "");
|
||||
|
|
|
@ -373,6 +373,7 @@ usercmd_t original_cmd;
|
|||
native float GetAutoaim() const;
|
||||
native bool GetNoAutostartMap() const;
|
||||
native void SetFOV(float fov);
|
||||
native clearscope bool HasWeaponsInSlot(int slot) const;
|
||||
|
||||
clearscope int fragSum () const
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class DoomStatusBar : BaseStatusBar
|
||||
{
|
||||
HUDFont mHUDFont;
|
||||
HUDFont mIndexFont;
|
||||
//DrawInventoryBarParms diparms;
|
||||
|
||||
|
||||
|
@ -20,6 +21,8 @@ class DoomStatusBar : BaseStatusBar
|
|||
// Create the font used for the fullscreen HUD
|
||||
Font fnt = "HUDFONT_DOOM";
|
||||
mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 1, 1);
|
||||
fnt = "INDEXFONT_DOOM";
|
||||
mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true);
|
||||
}
|
||||
|
||||
override void NewGame ()
|
||||
|
@ -48,11 +51,83 @@ class DoomStatusBar : BaseStatusBar
|
|||
|
||||
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);
|
||||
DrawImage("STBAR", (0, 0), DI_ITEM_OFFSETS);
|
||||
DrawImage("STTPRCNT", (90, 3), DI_ITEM_OFFSETS);
|
||||
DrawImage("STTPRCNT", (221, 3), DI_ITEM_OFFSETS);
|
||||
|
||||
Inventory a1, a2;
|
||||
int amt1;
|
||||
[a1, a2, amt1] = GetCurrentAmmo();
|
||||
DrawString(mHUDFont, FormatNumber(amt1, 3), (44, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
|
||||
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
|
||||
DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
|
||||
|
||||
// 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);
|
||||
bool locks[6];
|
||||
String image;
|
||||
for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true);
|
||||
// key 1
|
||||
if (locks[1] && locks[4]) image = "STKEYS6";
|
||||
else if (locks[1]) image = "STKEYS0";
|
||||
else if (locks[4]) image = "STKEYS3";
|
||||
DrawImage(image, (239, 3), DI_ITEM_OFFSETS);
|
||||
// key 2
|
||||
if (locks[2] && locks[5]) image = "STKEYS7";
|
||||
else if (locks[2]) image = "STKEYS1";
|
||||
else if (locks[5]) image = "STKEYS4";
|
||||
else image = "";
|
||||
DrawImage(image, (239, 13), DI_ITEM_OFFSETS);
|
||||
// key 3
|
||||
if (locks[0] && locks[3]) image = "STKEYS8";
|
||||
else if (locks[0]) image = "STKEYS2";
|
||||
else if (locks[3]) image = "STKEYS5";
|
||||
else image = "";
|
||||
DrawImage(image, (239, 23), DI_ITEM_OFFSETS);
|
||||
|
||||
int maxamt;
|
||||
[amt1, maxamt] = GetAmount("Clip");
|
||||
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 5), DI_TEXT_ALIGN_RIGHT);
|
||||
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 5), DI_TEXT_ALIGN_RIGHT);
|
||||
|
||||
[amt1, maxamt] = GetAmount("Shell");
|
||||
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 11), DI_TEXT_ALIGN_RIGHT);
|
||||
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 11), DI_TEXT_ALIGN_RIGHT);
|
||||
|
||||
[amt1, maxamt] = GetAmount("RocketAmmo");
|
||||
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 17), DI_TEXT_ALIGN_RIGHT);
|
||||
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 17), DI_TEXT_ALIGN_RIGHT);
|
||||
|
||||
[amt1, maxamt] = GetAmount("Cell");
|
||||
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 23), DI_TEXT_ALIGN_RIGHT);
|
||||
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 23), DI_TEXT_ALIGN_RIGHT);
|
||||
|
||||
if (deathmatch || teamplay)
|
||||
{
|
||||
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 3), DI_TEXT_ALIGN_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawImage("STARMS", (104, 0), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 3), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 3), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 3), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 13), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 13), DI_ITEM_OFFSETS);
|
||||
DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 13), DI_ITEM_OFFSETS);
|
||||
}
|
||||
|
||||
if (multiplayer)
|
||||
{
|
||||
DrawImage("STFBANY", (143, 0), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
|
||||
}
|
||||
|
||||
if (CPlayer.mo.InvSel != null)
|
||||
{
|
||||
//drawinventorybar Doom, 7, INDEXFONT, 50, 170;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTexture(GetMugShot(5), (143, 0), DI_ITEM_OFFSETS);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawFullScreenStuff ()
|
||||
|
@ -91,7 +166,7 @@ class DoomStatusBar : BaseStatusBar
|
|||
}
|
||||
if (deathmatch)
|
||||
{
|
||||
DrawString(mHUDFont, FormatNumber(CPlayer.fragSum(), 3), (-3, 1), DI_TEXT_ALIGN_RIGHT);
|
||||
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
// Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod
|
||||
|
@ -122,61 +197,3 @@ class DoomStatusBar : BaseStatusBar
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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.
|
||||
{
|
||||
}
|
||||
*/
|
|
@ -129,6 +129,7 @@ class BaseStatusBar native ui
|
|||
DI_TEXT_ALIGN_CENTER = 0x1000000,
|
||||
|
||||
DI_ALPHAMAPPED = 0x2000000,
|
||||
DI_NOSHADOW = 0x4000000,
|
||||
};
|
||||
|
||||
enum IconType
|
||||
|
@ -151,14 +152,6 @@ class BaseStatusBar native ui
|
|||
HEXENARMOR_AMULET,
|
||||
};
|
||||
|
||||
enum SBGameModes
|
||||
{
|
||||
GAMEMODE_SINGLEPLAYER = 0x1,
|
||||
GAMEMODE_COOPERATIVE = 0x2,
|
||||
GAMEMODE_DEATHMATCH = 0x4,
|
||||
GAMEMODE_TEAMGAME = 0x8
|
||||
};
|
||||
|
||||
enum AmmoModes
|
||||
{
|
||||
AMMO_PRIMARY,
|
||||
|
@ -226,7 +219,7 @@ class BaseStatusBar native ui
|
|||
virtual bool MustDrawLog(int state) { return true; }
|
||||
|
||||
native void RefreshBackground () const;
|
||||
native TextureID GetMugshot(PlayerInfo player, String default_face, int accuracy, int stateflags=MugShot.STANDARD);
|
||||
native TextureID GetMugshot(int accuracy, int stateflags=MugShot.STANDARD, String default_face = "STF");
|
||||
|
||||
// These functions are kept native solely for performance reasons. They get called repeatedly and can drag down performance easily if they get too slow.
|
||||
native Inventory ValidateInvFirst (int numVisible) const;
|
||||
|
@ -338,6 +331,14 @@ class BaseStatusBar native ui
|
|||
return armor? armor.Amount : 0;
|
||||
}
|
||||
|
||||
int, int GetAmount(class<Inventory> item)
|
||||
{
|
||||
let it = CPlayer.mo.FindInventory(item);
|
||||
int ret1 = it? it.Amount : GetDefaultByType(item).Amount;
|
||||
int ret2 = it? it.MaxAmount : GetDefaultByType(item).MaxAmount;
|
||||
return ret1, ret2;
|
||||
}
|
||||
|
||||
int GetMaxAmount(class<Inventory> item)
|
||||
{
|
||||
let it = CPlayer.mo.FindInventory(item);
|
||||
|
@ -393,20 +394,6 @@ class BaseStatusBar native ui
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// checks current game mode against a flag mask
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
bool CheckGameMode(int ValidModes)
|
||||
{
|
||||
return (!multiplayer && (ValidModes & GAMEMODE_SINGLEPLAYER)) ||
|
||||
(deathmatch && (ValidModes & GAMEMODE_DEATHMATCH)) ||
|
||||
(multiplayer && !deathmatch && (ValidModes & GAMEMODE_COOPERATIVE)) ||
|
||||
(teamplay && (ValidModes & GAMEMODE_TEAMGAME));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// checks ammo use of current weapon
|
||||
|
|
Loading…
Reference in a new issue