diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index a72d255b0..0afc05967 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -621,7 +621,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) shape->lastParms = new DrawParms(parms); } - if (!img->isHardwareCanvas() && parms.TranslationId != -1) + if (!(img != nullptr && img->isHardwareCanvas()) && parms.TranslationId != -1) dg.mTranslationId = parms.TranslationId; auto osave = offset; diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index 3925f7a8d..54c9cc904 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -289,6 +289,19 @@ void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, VMVa_List drawer->AddShape(img, shape, parms); } +void DrawShapeFill(F2DDrawer *drawer, int color, DShape2D *shape, VMVa_List &args) +{ + DrawParms parms; + uint32_t tag = ListGetInt(args); + + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, false, false); + if (!res) return; + + parms.fillcolor = color; + + drawer->AddShape(nullptr, shape, parms); +} + DEFINE_ACTION_FUNCTION(_Screen, DrawShape) { PARAM_PROLOGUE; @@ -307,6 +320,25 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawShape) return 0; } +DEFINE_ACTION_FUNCTION(_Screen, DrawShapeFill) +{ + PARAM_PROLOGUE; + PARAM_COLOR(color); + PARAM_FLOAT(amount); + PARAM_POINTER(shape, DShape2D); + + PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array + + if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); + + VMVa_List args = { param + 3, 0, numparam - 4, va_reginfo + 3 }; + + color.a = int(amount * 255.0f); + + DrawShapeFill(twod, color, shape, args); + return 0; +} + //========================================================================== // // Clipping rect @@ -682,13 +714,13 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags) //========================================================================== template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext, bool checkimage) { INTBOOL boolval; int intval; bool fillcolorset = false; - if (!fortext) + if (!fortext && checkimage) { if (img == NULL || !img->isValid()) { @@ -1285,8 +1317,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double } // explicitly instantiate both versions for v_text.cpp. -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext); -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext, bool checkimage); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext, bool checkimage); //========================================================================== // @@ -1681,3 +1713,4 @@ DEFINE_ACTION_FUNCTION(_Screen, ClearTransform) twod->ClearTransform(); return 0; } + diff --git a/src/common/2d/v_draw.h b/src/common/2d/v_draw.h index 7b1dfa9b6..f4746af99 100644 --- a/src/common/2d/v_draw.h +++ b/src/common/2d/v_draw.h @@ -259,7 +259,7 @@ inline int active_con_scale(F2DDrawer *drawer) #endif template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext); +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext, bool checkimage = true); template void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 2f76b6b04..4737139a7 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -513,6 +513,7 @@ struct Screen native native static vararg void DrawTexture(TextureID tex, bool animate, double x, double y, ...); native static vararg void DrawShape(TextureID tex, bool animate, Shape2D s, ...); + native static vararg void DrawShapeFill(Color col, double amount, Shape2D s, ...); native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...); native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255);