srb2::Draw: add cache_patch static class method

This commit is contained in:
James R 2024-01-18 02:01:18 -08:00
parent 311cf5ceea
commit 6347afb63f
2 changed files with 8 additions and 6 deletions

View file

@ -132,11 +132,6 @@ void Chain::patch(patch_t* patch) const
V_DrawStretchyFixedPatch(FloatToFixed(x_), FloatToFixed(y_), h * scale_, v * scale_, flags_, patch, colormap_);
}
void Chain::patch(const char* name) const
{
patch(static_cast<patch_t*>(W_CachePatchName(name, PU_CACHE)));
}
void Chain::thumbnail(UINT16 mapnum) const
{
const auto _ = Clipper(*this);
@ -240,6 +235,11 @@ Chain::Clipper::~Clipper()
V_ClearClipRect();
}
patch_t* Draw::cache_patch(const char* name)
{
return static_cast<patch_t*>(W_CachePatchName(name, PU_CACHE));
}
int Draw::font_to_fontno(Font font)
{
switch (font)

View file

@ -171,7 +171,7 @@ public:
TextElement text() const { return TextElement().font(font_).flags(flags_); }
void patch(patch_t* patch) const;
void patch(const char* name) const;
void patch(const char* name) const { patch(Draw::cache_patch(name)); }
void thumbnail(UINT16 mapnum) const;
@ -217,6 +217,8 @@ public:
friend Draw;
};
static patch_t* cache_patch(const char* name);
constexpr Draw() {}
explicit Draw(float x, float y) : chain_(x, y) {}
Draw(const Chain& chain) : chain_(chain) {}