Add TexMan.SetCameraTextureAspectRatio

Allows ZScript to change the aspect ratio of a camera texture.
This commit is contained in:
emily 2021-07-03 12:20:19 +02:00 committed by Rachael Alexanderson
commit 20d16381f8
3 changed files with 27 additions and 0 deletions

View file

@ -78,6 +78,30 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
return 0;
}
static void SetCameraTextureAspectRatio(const FString &texturename, double aspectScale, bool useTextureRatio)
{
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
if (textureid.isValid())
{
// Only proceed if the texture actually has a canvas.
auto tex = TexMan.GetGameTexture(textureid);
if (tex && tex->isHardwareCanvas())
{
static_cast<FCanvasTexture *>(tex->GetTexture())->SetAspectRatio(aspectScale, useTextureRatio);
}
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraTextureAspectRatio, SetCameraTextureAspectRatio)
{
PARAM_PROLOGUE;
PARAM_STRING(texturename);
PARAM_FLOAT(aspect);
PARAM_BOOL(useTextureRatio);
SetCameraTextureAspectRatio(texturename, aspect, useTextureRatio);
return 0;
}
//=====================================================================================
//
// sector_t exports