- moved the scalar class properties of PClassInventory into AInventory.

What's left is the non-scalars, they will need different treatment to get them out of the way.
This commit is contained in:
Christoph Oelckers 2017-02-08 16:57:48 +01:00
parent 2ca0e34785
commit eebe09fb59
5 changed files with 43 additions and 46 deletions

View File

@ -29,8 +29,6 @@ IMPLEMENT_CLASS(PClassInventory, false, false)
PClassInventory::PClassInventory()
{
GiveQuest = 0;
AltHUDIcon.SetNull();
}
void PClassInventory::DeriveData(PClass *newclass)
@ -40,8 +38,6 @@ void PClassInventory::DeriveData(PClass *newclass)
PClassInventory *newc = static_cast<PClassInventory *>(newclass);
newc->PickupMsg = PickupMsg;
newc->GiveQuest = GiveQuest;
newc->AltHUDIcon = AltHUDIcon;
newc->ForbiddenToPlayerClass = ForbiddenToPlayerClass;
newc->RestrictedToPlayerClass = RestrictedToPlayerClass;
}
@ -98,8 +94,8 @@ DEFINE_FIELD(AInventory, DropTime)
DEFINE_FIELD(AInventory, SpawnPointClass)
DEFINE_FIELD(AInventory, PickupFlash)
DEFINE_FIELD(AInventory, PickupSound)
DEFINE_FIELD(AInventory, GiveQuest)
DEFINE_FIELD(PClassInventory, PickupMsg)
DEFINE_FIELD(PClassInventory, GiveQuest)
//===========================================================================
//
@ -163,7 +159,8 @@ void AInventory::Serialize(FSerializer &arc)
("icon", Icon, def->Icon)
("pickupsound", PickupSound, def->PickupSound)
("spawnpointclass", SpawnPointClass, def->SpawnPointClass)
("droptime", DropTime, def->DropTime);
("droptime", DropTime, def->DropTime)
("givequest", GiveQuest, def->GiveQuest);
}
//===========================================================================

View File

@ -60,8 +60,6 @@ public:
void Finalize(FStateDefinitions &statedef);
FString PickupMsg;
int GiveQuest; // Optionally give one of the quest items.
FTextureID AltHUDIcon;
TArray<PClassPlayerPawn *> RestrictedToPlayerClass;
TArray<PClassPlayerPawn *> ForbiddenToPlayerClass;
};
@ -104,6 +102,8 @@ public:
FTextureID Icon; // Icon to show on status bar or HUD
int DropTime; // Countdown after dropping
PClassActor *SpawnPointClass; // For respawning like Heretic's mace
int GiveQuest; // Optionally give one of the quest items.
FTextureID AltHUDIcon;
DWORD ItemFlags;
PClassActor *PickupFlash; // actor to spawn as pickup flash

View File

@ -122,16 +122,6 @@ static int statspace;
DVector2 AM_GetPosition();
int active_con_scaletext();
FTextureID GetHUDIcon(PClassInventory *cls)
{
return cls->AltHUDIcon;
}
void SetHUDIcon(PClassInventory *cls, FTextureID tex)
{
cls->AltHUDIcon = tex;
}
//---------------------------------------------------------------------------
//
// Draws an image into a box with its bottom center at the bottom
@ -437,7 +427,7 @@ static void SetKeyTypes()
static void DrawOneKey(int xo, int & x, int & y, int & c, AInventory * inv)
{
FTextureID icon = FNullTextureID();
FTextureID AltIcon = GetHUDIcon(inv->GetClass());
FTextureID AltIcon = inv->AltHUDIcon;
if (!AltIcon.Exists()) return;
@ -516,27 +506,27 @@ static int DrawKeys(player_t * CPlayer, int x, int y)
// Drawing Ammo
//
//---------------------------------------------------------------------------
static TArray<PClassInventory *> orderedammos;
static TArray<PClassActor *> orderedammos;
static void AddAmmoToList(AWeapon * weapdef)
{
for(int i=0; i<2;i++)
for (int i = 0; i < 2; i++)
{
PClassInventory * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
auto ti = i == 0 ? weapdef->AmmoType1 : weapdef->AmmoType2;
if (ti)
{
auto ammodef=(AInventory*)GetDefaultByType(ti);
auto ammodef = (AInventory*)GetDefaultByType(ti);
if (ammodef && !(ammodef->ItemFlags&IF_INVBAR))
{
unsigned int j;
for(j=0;j<orderedammos.Size();j++)
for (j = 0; j < orderedammos.Size(); j++)
{
if (ti == orderedammos[j]) break;
}
if (j==orderedammos.Size()) orderedammos.Push(ti);
if (j == orderedammos.Size()) orderedammos.Push(ti);
}
}
}
@ -646,11 +636,11 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
for(i=orderedammos.Size()-1;i>=0;i--)
{
PClassInventory * type = orderedammos[i];
auto type = orderedammos[i];
auto ammoitem = CPlayer->mo->FindInventory(type);
auto inv = ammoitem? ammoitem : (AInventory*)GetDefaultByType(orderedammos[i]);
FTextureID AltIcon = GetHUDIcon(type);
FTextureID AltIcon = inv->AltHUDIcon;
FTextureID icon = !AltIcon.isNull()? AltIcon : inv->Icon;
if (!icon.isValid()) continue;
@ -682,7 +672,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
//---------------------------------------------------------------------------
FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale=NULL) // This function is also used by SBARINFO
{
FTextureID picnum, AltIcon = GetHUDIcon(item->GetClass());
FTextureID picnum, AltIcon = item->AltHUDIcon;
FState * state=NULL, *ReadyState;
picnum.SetNull();
@ -816,7 +806,7 @@ static void DrawInventory(player_t * CPlayer, int x,int y)
{
if (rover->Amount>0)
{
FTextureID AltIcon = GetHUDIcon(rover->GetClass());
FTextureID AltIcon = rover->AltHUDIcon;
if (AltIcon.Exists() && (rover->Icon.isValid() || AltIcon.isValid()) )
{
@ -1285,7 +1275,7 @@ void HUD_InitHud()
}
else tex.SetInvalid();
if (ti) SetHUDIcon(static_cast<PClassInventory*>(ti), tex);
if (ti) ((AInventory*)GetDefaultByType(ti))->AltHUDIcon = tex;
}
}
}

View File

@ -1734,31 +1734,47 @@ DEFINE_CLASS_PROPERTY(amount, I, Inventory)
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(icon, S, Inventory)
static void SetIcon(FTextureID &icon, Baggage &bag, const char *i)
{
PROP_STRING_PARM(i, 0);
if (i == NULL || i[0] == '\0')
{
defaults->Icon.SetNull();
icon.SetNull();
}
else
{
defaults->Icon = TexMan.CheckForTexture(i, FTexture::TEX_MiscPatch);
if (!defaults->Icon.isValid())
icon = TexMan.CheckForTexture(i, FTexture::TEX_MiscPatch);
if (!icon.isValid())
{
// Don't print warnings if the item is for another game or if this is a shareware IWAD.
// Strife's teaser doesn't contain all the icon graphics of the full game.
if ((info->GameFilter == GAME_Any || info->GameFilter & gameinfo.gametype) &&
if ((bag.Info->GameFilter == GAME_Any || bag.Info->GameFilter & gameinfo.gametype) &&
!(gameinfo.flags&GI_SHAREWARE) && Wads.GetLumpFile(bag.Lumpnum) != 0)
{
bag.ScriptPosition.Message(MSG_WARNING,
"Icon '%s' for '%s' not found\n", i, info->TypeName.GetChars());
"Icon '%s' for '%s' not found\n", i, bag.Info->TypeName.GetChars());
}
}
}
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(icon, S, Inventory)
{
PROP_STRING_PARM(i, 0);
SetIcon(defaults->Icon, bag, i);
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(althudicon, S, Inventory)
{
PROP_STRING_PARM(i, 0);
SetIcon(defaults->AltHUDIcon, bag, i);
}
//==========================================================================
//
//==========================================================================
@ -1845,8 +1861,7 @@ DEFINE_CLASS_PROPERTY(usesound, S, Inventory)
DEFINE_CLASS_PROPERTY(givequest, I, Inventory)
{
PROP_INT_PARM(i, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassInventory)));
static_cast<PClassInventory *>(info)->GiveQuest = i;
defaults->GiveQuest = i;
}
//==========================================================================
@ -2651,7 +2666,6 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn)
PROP_STRING_PARM(type, 3);
color.a = BYTE(255 * clamp<double>(a, 0.f, 1.f));
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
static_cast<PClassPlayerPawn *>(info)->PainFlashes.Insert(type, color);
}
}
@ -2702,7 +2716,6 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, invulnerabilitymode, S, PlayerPawn)
DEFINE_CLASS_PROPERTY_PREFIX(player, healradiustype, S, PlayerPawn)
{
PROP_STRING_PARM(str, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
defaults->HealingRadiusType = str;
}
@ -2711,7 +2724,6 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, healradiustype, S, PlayerPawn)
//==========================================================================
DEFINE_CLASS_PROPERTY_PREFIX(player, hexenarmor, FFFFF, PlayerPawn)
{
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
for (int i = 0; i < 5; i++)
{
PROP_DOUBLE_PARM(val, i);
@ -2724,7 +2736,6 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, hexenarmor, FFFFF, PlayerPawn)
//==========================================================================
DEFINE_CLASS_PROPERTY_PREFIX(player, portrait, S, PlayerPawn)
{
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
PROP_STRING_PARM(val, 0);
defaults->Portrait = val;
}
@ -2736,7 +2747,6 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, weaponslot, ISsssssssssssssssssssssssssssss
{
PROP_INT_PARM(slot, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn)));
if (slot < 0 || slot > 9)
{
I_Error("Slot must be between 0 and 9.");

View File

@ -24,7 +24,7 @@ class Inventory : Actor native
native bool bCreateCopyMoved;
native bool bInitEffectFailed;
native meta String PickupMsg;
native meta int GiveQuest;
native /*meta*/ int GiveQuest;
Default
{