mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- added a script export for ACS's ReplaceTextures function.
This commit is contained in:
parent
3d9673af44
commit
4e1300ecbe
5 changed files with 86 additions and 50 deletions
|
@ -114,13 +114,6 @@ FRandom pr_acs ("ACS");
|
|||
#define HUDMSG_VISIBILITY_MASK (0x00070000)
|
||||
// See HUDMSG visibility enumerations in sbar.h
|
||||
|
||||
// Flags for ReplaceTextures
|
||||
#define NOT_BOTTOM 1
|
||||
#define NOT_MIDDLE 2
|
||||
#define NOT_TOP 4
|
||||
#define NOT_FLOOR 8
|
||||
#define NOT_CEILING 16
|
||||
|
||||
// LineAttack flags
|
||||
#define FHF_NORANDOMPUFFZ 1
|
||||
#define FHF_NOIMPACTDECAL 2
|
||||
|
@ -3322,47 +3315,6 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
|
|||
}
|
||||
}
|
||||
|
||||
void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags)
|
||||
{
|
||||
const char *fromname = FBehavior::StaticLookupString (fromnamei);
|
||||
const char *toname = FBehavior::StaticLookupString (tonamei);
|
||||
FTextureID picnum1, picnum2;
|
||||
|
||||
if (fromname == NULL)
|
||||
return;
|
||||
|
||||
if ((flags ^ (NOT_BOTTOM | NOT_MIDDLE | NOT_TOP)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture (fromname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture (toname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &side : level.sides)
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
static BYTE bits[]={NOT_TOP, NOT_MIDDLE, NOT_BOTTOM};
|
||||
if (!(flags & bits[j]) && side.GetTexture(j) == picnum1)
|
||||
{
|
||||
side.SetTexture(j, picnum2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((flags ^ (NOT_FLOOR | NOT_CEILING)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture (fromname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture (toname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (!(flags & NOT_FLOOR) && sec.GetTexture(sector_t::floor) == picnum1)
|
||||
sec.SetTexture(sector_t::floor, picnum2);
|
||||
if (!(flags & NOT_CEILING) && sec.GetTexture(sector_t::ceiling) == picnum1)
|
||||
sec.SetTexture(sector_t::ceiling, picnum2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int DLevelScript::DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force)
|
||||
{
|
||||
PClassActor *info = PClass::FindActor(FBehavior::StaticLookupString (type));
|
||||
|
@ -8352,9 +8304,14 @@ scriptwait:
|
|||
break;
|
||||
|
||||
case PCD_REPLACETEXTURES:
|
||||
ReplaceTextures (STACK(3), STACK(2), STACK(1));
|
||||
{
|
||||
const char *fromname = FBehavior::StaticLookupString(STACK(3));
|
||||
const char *toname = FBehavior::StaticLookupString(STACK(2));
|
||||
|
||||
P_ReplaceTextures(fromname, toname, STACK(1));
|
||||
sp -= 3;
|
||||
break;
|
||||
}
|
||||
|
||||
case PCD_SETLINEBLOCKING:
|
||||
{
|
||||
|
|
|
@ -913,7 +913,6 @@ protected:
|
|||
static void ChangeFlat (int tag, int name, bool floorOrCeiling);
|
||||
static int CountPlayers ();
|
||||
static void SetLineTexture (int lineid, int side, int position, int name);
|
||||
static void ReplaceTextures (int fromname, int toname, int flags);
|
||||
static int DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force);
|
||||
static int DoSpawn(int type, int x, int y, int z, int tid, int angle, bool force);
|
||||
static bool DoCheckActorTexture(int tid, AActor *activator, int string, bool floor);
|
||||
|
|
|
@ -441,4 +441,15 @@ enum EDmgFlags
|
|||
//
|
||||
bool P_AlignFlat (int linenum, int side, int fc);
|
||||
|
||||
enum ETexReplaceFlags
|
||||
{
|
||||
NOT_BOTTOM = 1,
|
||||
NOT_MIDDLE = 2,
|
||||
NOT_TOP = 4,
|
||||
NOT_FLOOR = 8,
|
||||
NOT_CEILING = 16
|
||||
};
|
||||
|
||||
void P_ReplaceTextures(const char *fromname, const char *toname, int flags);
|
||||
|
||||
#endif // __P_LOCAL__
|
||||
|
|
|
@ -2120,6 +2120,63 @@ bool P_AlignFlat (int linenum, int side, int fc)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// P_ReplaceTextures
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
|
||||
{
|
||||
FTextureID picnum1, picnum2;
|
||||
|
||||
if (fromname == nullptr)
|
||||
return;
|
||||
|
||||
if ((flags ^ (NOT_BOTTOM | NOT_MIDDLE | NOT_TOP)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture(fromname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture(toname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &side : level.sides)
|
||||
{
|
||||
for (int j = 0; j<3; j++)
|
||||
{
|
||||
static uint8_t bits[] = { NOT_TOP, NOT_MIDDLE, NOT_BOTTOM };
|
||||
if (!(flags & bits[j]) && side.GetTexture(j) == picnum1)
|
||||
{
|
||||
side.SetTexture(j, picnum2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((flags ^ (NOT_FLOOR | NOT_CEILING)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture(fromname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture(toname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (!(flags & NOT_FLOOR) && sec.GetTexture(sector_t::floor) == picnum1)
|
||||
sec.SetTexture(sector_t::floor, picnum2);
|
||||
if (!(flags & NOT_CEILING) && sec.GetTexture(sector_t::ceiling) == picnum1)
|
||||
sec.SetTexture(sector_t::ceiling, picnum2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_TexMan, ReplaceTextures)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_STRING(from);
|
||||
PARAM_STRING(to);
|
||||
PARAM_INT(flags);
|
||||
P_ReplaceTextures(from, to, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// P_BuildPolyBSP
|
||||
|
|
|
@ -28,8 +28,20 @@ struct TexMan
|
|||
ShortNameOnly = 16,
|
||||
DontCreate = 32
|
||||
};
|
||||
|
||||
enum ETexReplaceFlags
|
||||
{
|
||||
NOT_BOTTOM = 1,
|
||||
NOT_MIDDLE = 2,
|
||||
NOT_TOP = 4,
|
||||
NOT_FLOOR = 8,
|
||||
NOT_CEILING = 16,
|
||||
NOT_WALL = 7,
|
||||
NOT_FLAT = 24
|
||||
};
|
||||
|
||||
native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny);
|
||||
native static void ReplaceTextures(String from, String to, int flags);
|
||||
}
|
||||
|
||||
enum DrawTextureTags
|
||||
|
|
Loading…
Reference in a new issue