-Exhumed: changed key display on status bar to be controlled from the status bar itself.

First of 6 externally controlled status bar indicators.
This commit is contained in:
Christoph Oelckers 2021-05-13 12:58:30 +02:00
parent 317238147b
commit 35c07500c3
2 changed files with 44 additions and 98 deletions

View file

@ -41,6 +41,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS
extern short nStatusSeqOffset;
struct PlayerSave
{
int x;
@ -1429,11 +1431,11 @@ sectdone:
int var_44 = 0;
// item lotags start at 6 (1-5 reserved?) so 0-offset them
int var_6C = var_70 - 6;
int itemtype = var_70 - 6;
if (var_6C <= 54)
if (itemtype <= 54)
{
switch (var_6C)
switch (itemtype)
{
do_default:
default:
@ -2276,98 +2278,18 @@ do_default_b:
break;
}
// Lots of repeated code for door key handling
case 39: // Power key
{
int ecx = 4096;
var_88 = -1;
if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36, 0);
}
PlayerList[nPlayer].keys |= ecx;
if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}
break;
}
case 40: // Time key
{
int ecx = 4096 << 1;
var_88 = -1;
if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 2, 0);
}
PlayerList[nPlayer].keys |= ecx;
if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}
break;
}
case 41: // War key
{
int ecx = 4096 << 2;
var_88 = -1;
if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 4, 0);
}
PlayerList[nPlayer].keys |= ecx;
if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}
break;
}
case 42: // Earth key
{
int ecx = 4096 << 3;
int keybit = 4096 << (itemtype - 39);
var_88 = -1;
if (PlayerList[nPlayer].keys != ecx)
if (!(PlayerList[nPlayer].keys & keybit))
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 6, 0);
}
PlayerList[nPlayer].keys |= ecx;
PlayerList[nPlayer].keys |= keybit;
if (nTotalPlayers > 1)
{

View file

@ -211,16 +211,6 @@ void RefreshStatus()
int val = 37;
for (int i = 0; i < 4; i++)
{
if (nKeys & 0x1000) {
BuildStatusAnim(val, 0);
}
nKeys >>= 1;
val += 2;
}
SetPlayerItem(nLocalPlayer, nPlayerItem[nLocalPlayer]);
SetHealthFrame(0);
SetMagicFrame();
@ -525,6 +515,12 @@ class DExhumedStatusBar : public DBaseStatusBar
HAS_OBJECT_POINTERS
TObjPtr<DHUDFont*> textfont, numberFont;
int keyanims[4];
enum EConst
{
KeySeq = 36,
};
public:
DExhumedStatusBar()
@ -636,7 +632,7 @@ private:
for (int i = nFirstAnim; i >= 0; i = StatusAnim[i].nPrevAnim)
{
int nSequence = nStatusSeqOffset + StatusAnim[i].s1;
DrawStatusSequence(nSequence, StatusAnim[i].s2, StatusAnim[i].s1 >= 37 && StatusAnim[i].s1 <= 43 ? 0.5 : 0, 0.5);
DrawStatusSequence(nSequence, StatusAnim[i].s2, 0, 0);
}
}
@ -874,6 +870,14 @@ private:
return;
}
for (int i = 0; i < 4; i++)
{
if (PlayerList[nLocalPlayer].keys & (4096 << i))
{
DrawStatusSequence(nStatusSeqOffset + KeySeq + 2 * i, keyanims[i], 0.5, 0.5);
}
}
if (/*!bFullScreen &&*/ nNetTime)
{
DrawStatusSequence(nStatusSeqOffset + 127, 0, 0);
@ -956,15 +960,35 @@ private:
}
void Tick() override
{
for (int i = 0; i < 4; i++)
{
int seq = nStatusSeqOffset + KeySeq + 2 * i;
if (PlayerList[nLocalPlayer].keys & (4096 << i))
{
if (keyanims[i] < SeqSize[seq] - 1)
{
seq_MoveSequence(-1, seq, 0); // this plays the pickup sound.
keyanims[i]++;
}
}
else
{
keyanims[i] = 0;
}
}
}
public:
void UpdateStatusBar()
{
Tick(); // temporary.
if (hud_size <= Hud_full)
{
DrawStatus();
}
}
PrintLevelStats(hud_size == Hud_Nothing ? 0 : hud_size == Hud_full? 22 : 40);
}
};