- exported DrawTexture to scripting.
This uses templates to avoid source duplication of ParseDrawTextureTags. Not tested yet.
This commit is contained in:
parent
a102807737
commit
6dea3eef8e
4 changed files with 91 additions and 4 deletions
|
|
@ -126,6 +126,7 @@ static int PalFromRGB(uint32 rgb)
|
|||
return LastPal;
|
||||
}
|
||||
|
||||
|
||||
void DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, ...)
|
||||
{
|
||||
va_list tags;
|
||||
|
|
@ -141,6 +142,31 @@ void DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, ..
|
|||
DrawTextureParms(img, parms);
|
||||
}
|
||||
|
||||
static int ListGetInt(VMVa_List &tags);
|
||||
|
||||
void DCanvas::DrawTexture(FTexture *img, double x, double y, VMVa_List &args)
|
||||
{
|
||||
DrawParms parms;
|
||||
uint32_t tag = ListGetInt(args);
|
||||
bool res = ParseDrawTextureTags(img, x, y, tag, args, &parms, false);
|
||||
if (!res) return;
|
||||
DrawTextureParms(img, parms);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, DrawTexture)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(texid);
|
||||
PARAM_BOOL(animate);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
|
||||
FTexture *tex = animate ? TexMan(FSetTextureID(texid)) : TexMan[FSetTextureID(texid)];
|
||||
VMVa_List args = { param + 4, 0, numparam - 4 };
|
||||
screen->DrawTexture(tex, x, y, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, DrawHUDTexture)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
|
@ -462,7 +488,50 @@ static inline FColormapStyle * ListGetColormapStyle(va_list &tags)
|
|||
return va_arg(tags, FColormapStyle *);
|
||||
}
|
||||
|
||||
bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list& tags, DrawParms *parms, bool fortext) const
|
||||
static void ListEnd(VMVa_List &tags)
|
||||
{
|
||||
}
|
||||
|
||||
static int ListGetInt(VMVa_List &tags)
|
||||
{
|
||||
if (tags.curindex < tags.numargs && tags.args[tags.curindex].Type == REGT_INT)
|
||||
{
|
||||
return tags.args[tags.curindex++].i;
|
||||
}
|
||||
ThrowAbortException(X_OTHER, "Invalid parameter in draw function, int expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline double ListGetDouble(VMVa_List &tags)
|
||||
{
|
||||
if (tags.curindex < tags.numargs && tags.args[tags.curindex].Type == REGT_FLOAT)
|
||||
{
|
||||
return tags.args[tags.curindex++].f;
|
||||
}
|
||||
ThrowAbortException(X_OTHER, "Invalid parameter in draw function, float expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline FRemapTable* ListGetTranslation(VMVa_List &tags)
|
||||
{
|
||||
ThrowAbortException(X_OTHER, "Invalid tag in draw function");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags)
|
||||
{
|
||||
ThrowAbortException(X_OTHER, "Invalid tag in draw function");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline FColormapStyle * ListGetColormapStyle(VMVa_List &tags)
|
||||
{
|
||||
ThrowAbortException(X_OTHER, "Invalid tag in draw function");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag, T& tags, DrawParms *parms, bool fortext) const
|
||||
{
|
||||
INTBOOL boolval;
|
||||
int intval;
|
||||
|
|
@ -626,7 +695,7 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag
|
|||
parms->cleanmode = DTA_Base;
|
||||
parms->virtWidth = ListGetDouble(tags);
|
||||
break;
|
||||
|
||||
|
||||
case DTA_VirtualHeight:
|
||||
parms->cleanmode = DTA_Base;
|
||||
parms->virtHeight = ListGetInt(tags);
|
||||
|
|
@ -840,7 +909,7 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag
|
|||
}
|
||||
tag = ListGetInt(tags);
|
||||
}
|
||||
va_end (tags);
|
||||
ListEnd(tags);
|
||||
|
||||
if (parms->uclip >= parms->dclip || parms->lclip >= parms->rclip)
|
||||
{
|
||||
|
|
@ -885,6 +954,10 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag
|
|||
}
|
||||
return true;
|
||||
}
|
||||
// explicitly instantiate both versions for v_text.cpp.
|
||||
|
||||
template bool DCanvas::ParseDrawTextureTags<va_list>(FTexture *img, double x, double y, DWORD tag, va_list& tags, DrawParms *parms, bool fortext) const;
|
||||
template bool DCanvas::ParseDrawTextureTags<VMVa_List>(FTexture *img, double x, double y, DWORD tag, VMVa_List& tags, DrawParms *parms, bool fortext) const;
|
||||
|
||||
void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h,
|
||||
double vwidth, double vheight, bool vbottom, bool handleaspect) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue