- one more bit of scriptification.

This commit is contained in:
Christoph Oelckers 2017-03-22 18:38:09 +01:00
parent 1423d5f42a
commit f0e4f54c80
4 changed files with 50 additions and 47 deletions

View file

@ -387,8 +387,6 @@ public:
void RefreshBackground () const;
void GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const;
public:
AInventory *ValidateInvFirst (int numVisible) const;
void DrawCrosshair ();

View file

@ -1068,8 +1068,24 @@ public:
}
}
if (CPlayer->ReadyWeapon != NULL)
{
ammo1 = CPlayer->ReadyWeapon->Ammo1;
ammo2 = CPlayer->ReadyWeapon->Ammo2;
if (ammo1 == NULL)
{
ammo1 = ammo2;
ammo2 = NULL;
}
}
else
{
ammo1 = ammo2 = NULL;
}
ammocount1 = ammo1 != NULL ? ammo1->Amount : 0;
ammocount2 = ammo2 != NULL ? ammo2->Amount : 0;
//prepare ammo counts
wrapper->GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2);
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
if(state != HUD_AltHud)

View file

@ -1377,49 +1377,6 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, ValidateInvFirst)
}
//============================================================================
//
// DBaseStatusBar :: GetCurrentAmmo
//
// Returns the types and amounts of ammo used by the current weapon. If the
// weapon only uses one type of ammo, it is always returned as ammo1.
//
//============================================================================
void DBaseStatusBar::GetCurrentAmmo (AInventory *&ammo1, AInventory *&ammo2, int &ammocount1, int &ammocount2) const
{
if (CPlayer->ReadyWeapon != NULL)
{
ammo1 = CPlayer->ReadyWeapon->Ammo1;
ammo2 = CPlayer->ReadyWeapon->Ammo2;
if (ammo1 == NULL)
{
ammo1 = ammo2;
ammo2 = NULL;
}
}
else
{
ammo1 = ammo2 = NULL;
}
ammocount1 = ammo1 != NULL ? ammo1->Amount : 0;
ammocount2 = ammo2 != NULL ? ammo2->Amount : 0;
}
DEFINE_ACTION_FUNCTION(DBaseStatusBar, GetCurrentAmmo)
{
PARAM_SELF_PROLOGUE(DBaseStatusBar);
AInventory *ammo1, *ammo2;
int ammocount1, ammocount2;
self->GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2);
if (numret >= 1) ret[0].SetPointer(ammo1, ATAG_OBJECT);
if (numret >= 2) ret[1].SetPointer(ammo2, ATAG_OBJECT);
if (numret >= 3) ret[2].SetInt(ammocount1);
if (numret >= 4) ret[3].SetInt(ammocount2);
return MIN(numret, 4);
}
//============================================================================
//
// CCMD showpop

View file

@ -79,6 +79,38 @@ class BaseStatusBar native ui
virtual void SetMugShotState (String state_name, bool wait_till_done=false, bool reset=false) {}
native void RefreshBackground () const;
native Inventory, Inventory, int, int GetCurrentAmmo () const;
native Inventory ValidateInvFirst (int numVisible) const;
//============================================================================
//
// DBaseStatusBar :: GetCurrentAmmo
//
// Returns the types and amounts of ammo used by the current weapon. If the
// weapon only uses one type of ammo, it is always returned as ammo1.
//
//============================================================================
Inventory, Inventory, int, int GetCurrentAmmo () const
{
Ammo ammo1, ammo2;
if (CPlayer.ReadyWeapon != NULL)
{
ammo1 = CPlayer.ReadyWeapon.Ammo1;
ammo2 = CPlayer.ReadyWeapon.Ammo2;
if (ammo1 == NULL)
{
ammo1 = ammo2;
ammo2 = NULL;
}
}
else
{
ammo1 = ammo2 = NULL;
}
let ammocount1 = ammo1 != NULL ? ammo1.Amount : 0;
let ammocount2 = ammo2 != NULL ? ammo2.Amount : 0;
return ammo1, ammo2, ammocount1, ammocount2;
}
}