mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Add direct native calls to TexMan's native methods.
This commit is contained in:
parent
ba2b9430f8
commit
3ecda35379
3 changed files with 92 additions and 34 deletions
|
@ -392,7 +392,12 @@ void DThinker::ChangeStatNum (int statnum)
|
||||||
list->AddTail(this);
|
list->AddTail(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DThinker, ChangeStatNum)
|
static void ChangeStatNum(DThinker *thinker, int statnum)
|
||||||
|
{
|
||||||
|
thinker->ChangeStatNum(statnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(DThinker, ChangeStatNum, ChangeStatNum)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(DThinker);
|
PARAM_SELF_PROLOGUE(DThinker);
|
||||||
PARAM_INT(stat);
|
PARAM_INT(stat);
|
||||||
|
|
|
@ -1100,15 +1100,27 @@ void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov)
|
||||||
}
|
}
|
||||||
|
|
||||||
// [ZZ] expose this to ZScript
|
// [ZZ] expose this to ZScript
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, SetCameraToTexture)
|
void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov)
|
||||||
|
{
|
||||||
|
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||||
|
if (textureid.isValid())
|
||||||
|
{
|
||||||
|
// Only proceed if the texture actually has a canvas.
|
||||||
|
FTexture *tex = TexMan[textureid];
|
||||||
|
if (tex && tex->bHasCanvas)
|
||||||
|
{
|
||||||
|
FCanvasTextureInfo::Add(viewpoint, textureid, fov);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
PARAM_OBJECT(viewpoint, AActor);
|
PARAM_OBJECT(viewpoint, AActor);
|
||||||
PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it.
|
PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it.
|
||||||
PARAM_FLOAT(fov);
|
PARAM_FLOAT(fov);
|
||||||
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
SetCameraToTexture(viewpoint, texturename, fov);
|
||||||
if (textureid.isValid())
|
|
||||||
FCanvasTextureInfo::Add(viewpoint, textureid, fov);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,13 +260,18 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
|
||||||
return FTextureID(-1);
|
return FTextureID(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, CheckForTexture)
|
static int CheckForTexture(const FString &name, int type, int flags)
|
||||||
|
{
|
||||||
|
return TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
PARAM_STRING(name);
|
PARAM_STRING(name);
|
||||||
PARAM_INT(type);
|
PARAM_INT(type);
|
||||||
PARAM_INT(flags);
|
PARAM_INT(flags);
|
||||||
ACTION_RETURN_INT(TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex());
|
ACTION_RETURN_INT(CheckForTexture(name, type, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1412,10 +1417,8 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, GetSize)
|
static void GetTextureSize(int texid, int *px, int *py)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_INT(texid);
|
|
||||||
auto tex = TexMan.ByIndex(texid);
|
auto tex = TexMan.ByIndex(texid);
|
||||||
int x, y;
|
int x, y;
|
||||||
if (tex != nullptr)
|
if (tex != nullptr)
|
||||||
|
@ -1424,6 +1427,16 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetSize)
|
||||||
y = tex->GetHeight();
|
y = tex->GetHeight();
|
||||||
}
|
}
|
||||||
else x = y = -1;
|
else x = y = -1;
|
||||||
|
if (px) *px = x;
|
||||||
|
if (py) *py = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_INT(texid);
|
||||||
|
int x, y;
|
||||||
|
GetTextureSize(texid, &x, &y);
|
||||||
if (numret > 0) ret[0].SetInt(x);
|
if (numret > 0) ret[0].SetInt(x);
|
||||||
if (numret > 1) ret[1].SetInt(y);
|
if (numret > 1) ret[1].SetInt(y);
|
||||||
return MIN(numret, 2);
|
return MIN(numret, 2);
|
||||||
|
@ -1434,17 +1447,61 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetSize)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
static void GetScaledSize(int texid, DVector2 *pvec)
|
||||||
|
{
|
||||||
|
auto tex = TexMan.ByIndex(texid);
|
||||||
|
int x, y;
|
||||||
|
if (tex != nullptr)
|
||||||
|
{
|
||||||
|
x = tex->GetScaledWidthDouble();
|
||||||
|
y = tex->GetScaledHeightDouble();
|
||||||
|
}
|
||||||
|
else x = y = -1;
|
||||||
|
if (pvec)
|
||||||
|
{
|
||||||
|
pvec->X = x;
|
||||||
|
pvec->Y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, GetScaledSize)
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledSize, GetScaledSize)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
PARAM_INT(texid);
|
PARAM_INT(texid);
|
||||||
|
DVector2 vec;
|
||||||
|
GetScaledSize(texid, &vec);
|
||||||
|
ACTION_RETURN_VEC2(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
static void GetScaledOffset(int texid, DVector2 *pvec)
|
||||||
|
{
|
||||||
auto tex = TexMan.ByIndex(texid);
|
auto tex = TexMan.ByIndex(texid);
|
||||||
|
int x, y;
|
||||||
if (tex != nullptr)
|
if (tex != nullptr)
|
||||||
{
|
{
|
||||||
ACTION_RETURN_VEC2(DVector2(tex->GetScaledWidthDouble(), tex->GetScaledHeightDouble()));
|
x = tex->GetScaledLeftOffsetDouble(0);
|
||||||
|
y = tex->GetScaledTopOffsetDouble(0);
|
||||||
}
|
}
|
||||||
ACTION_RETURN_VEC2(DVector2(-1, -1));
|
else x = y = -1;
|
||||||
|
if (pvec)
|
||||||
|
{
|
||||||
|
pvec->X = x;
|
||||||
|
pvec->Y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledOffset, GetScaledOffset)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_INT(texid);
|
||||||
|
DVector2 vec;
|
||||||
|
GetScaledOffset(texid, &vec);
|
||||||
|
ACTION_RETURN_VEC2(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1453,34 +1510,18 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetScaledSize)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, GetScaledOffset)
|
static int CheckRealHeight(int texid)
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_INT(texid);
|
|
||||||
auto tex = TexMan.ByIndex(texid);
|
auto tex = TexMan.ByIndex(texid);
|
||||||
if (tex != nullptr)
|
if (tex != nullptr) return tex->CheckRealHeight();
|
||||||
{
|
else return -1;
|
||||||
ACTION_RETURN_VEC2(DVector2(tex->GetScaledLeftOffsetDouble(0), tex->GetScaledTopOffsetDouble(0)));
|
|
||||||
}
|
|
||||||
ACTION_RETURN_VEC2(DVector2(-1, -1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight)
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_TexMan, CheckRealHeight)
|
|
||||||
{
|
{
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
PARAM_INT(texid);
|
PARAM_INT(texid);
|
||||||
auto tex = TexMan.ByIndex(texid);
|
ACTION_RETURN_INT(CheckRealHeight(texid));
|
||||||
if (tex != nullptr)
|
|
||||||
{
|
|
||||||
ACTION_RETURN_INT(tex->CheckRealHeight());
|
|
||||||
}
|
|
||||||
ACTION_RETURN_INT(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue