- store texture IDs in the sprite set.

This commit is contained in:
Christoph Oelckers 2022-12-31 18:02:24 +01:00
parent 1bace1d508
commit 6924869895
4 changed files with 5 additions and 5 deletions

View file

@ -249,14 +249,14 @@ void FActorInfo::ResolveTextures(const char* clsname, DCoreActor* defaults)
SpriteSet.Resize(SpriteSetNames.Size());
for (unsigned i = 0; i < SpriteSet.Size(); i++)
{
SpriteSet[i] = tileForName(SpriteSetNames[i]);
SpriteSet[i] = TexMan.CheckForTexture(SpriteSetNames[i], ETextureType::Any);
// This should later be enabled to user content.
//if (SpriteSet[i] == -1) Printf(TEXTCOLOR_RED "Unknown texture '%s' in sprite set for class %s\n", SpriteSetNames[i].GetChars(), clsname);
}
if (SpriteSet.Size() > 0)
{
if (defaults->spritesetindex < 0 || defaults->spritesetindex >= (int)SpriteSet.Size()) defaults->spritesetindex = 0;
defaults->spr.picnum = SpriteSet[defaults->spritesetindex]; // Unless picnum is specified it will be set to the given image of the sprite set.
defaults->spr.setspritetexture(SpriteSet[defaults->spritesetindex]); // Unless picnum is specified it will be set to the given image of the sprite set.
}
SpriteSetNames.Reset();
}

View file

@ -21,7 +21,7 @@ enum EDefaultFlags
struct FActorInfo
{
TArray<FInternalLightAssociation *> LightAssociations;
TArray<int> SpriteSet;
TArray<FTextureID> SpriteSet;
PClassActor *Replacement = nullptr;
PClassActor *Replacee = nullptr;
DVector2 DefaultScale = { 0, 0 };

View file

@ -797,7 +797,7 @@ void tspritetype_setSpritePic(tspritetype* targ, DCoreActor* self, unsigned z)
auto& spriteset = static_cast<PClassActor*>(self->GetClass())->ActorInfo()->SpriteSet;
if (z < spriteset.Size())
{
targ->picnum = spriteset[z];
targ->setspritetexture(spriteset[z]);
}
else if (z == ~0)
{

View file

@ -311,7 +311,7 @@ void setSpritesetImage(DDukeActor* self, unsigned int index)
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Bad sprite set index %d (max. allowed is %d", index, spriteset.Size() - 1);
}
self->spritesetindex = index;
self->spr.picnum = spriteset[index];
self->spr.setspritetexture(spriteset[index]);
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, SetSpritesetImage, setSpritesetImage)