mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
srb2::Draw: add button and small_button methods
This commit is contained in:
parent
dadb150b25
commit
9fa2e3da5f
2 changed files with 70 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "doomdef.h" // skincolornum_t
|
||||
#include "doomtype.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "i_time.h"
|
||||
#include "k_hud.h"
|
||||
#include "m_fixed.h"
|
||||
#include "r_draw.h"
|
||||
|
|
@ -84,6 +85,53 @@ void Chain::string(const char* str, INT32 flags, Font font) const
|
|||
V_DrawStringScaled(x, y, FloatToFixed(scale_), FRACUNIT, FRACUNIT, flags, colormap_, font_to_fontno(font), str);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
patch_t** get_button_patch(Draw::Button type, int ver)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
#define X(x) \
|
||||
case Draw::Button::x:\
|
||||
return kp_button_ ## x
|
||||
|
||||
X(a)[ver];
|
||||
X(b)[ver];
|
||||
X(c)[ver];
|
||||
X(x)[ver];
|
||||
X(y)[ver];
|
||||
X(z)[ver];
|
||||
X(start);
|
||||
X(l);
|
||||
X(r);
|
||||
X(up);
|
||||
X(down);
|
||||
X(right);
|
||||
X(left);
|
||||
|
||||
#undef X
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
||||
void Chain::button(Button type, int ver, std::optional<bool> press) const
|
||||
{
|
||||
const auto _ = Clipper(*this);
|
||||
|
||||
if (press)
|
||||
{
|
||||
K_drawButton(FloatToFixed(x_), FloatToFixed(y_), flags_, get_button_patch(type, ver), *press);
|
||||
}
|
||||
else
|
||||
{
|
||||
K_drawButtonAnim(x_, y_, flags_, get_button_patch(type, ver), I_GetTime());
|
||||
}
|
||||
}
|
||||
|
||||
Chain::Clipper::Clipper(const Chain& chain)
|
||||
{
|
||||
V_SetClipRect(
|
||||
|
|
|
|||
|
|
@ -54,6 +54,23 @@ public:
|
|||
kBoth,
|
||||
};
|
||||
|
||||
enum class Button
|
||||
{
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
start,
|
||||
l,
|
||||
r,
|
||||
up,
|
||||
down,
|
||||
right,
|
||||
left,
|
||||
};
|
||||
|
||||
class TextElement
|
||||
{
|
||||
public:
|
||||
|
|
@ -146,6 +163,9 @@ public:
|
|||
|
||||
void fill(UINT8 color) const;
|
||||
|
||||
void button(Button type, std::optional<bool> press = {}) const { button(type, 0, press); }
|
||||
void small_button(Button type, std::optional<bool> press = {}) const { button(type, 1, press); }
|
||||
|
||||
private:
|
||||
constexpr Chain() {}
|
||||
explicit Chain(float x, float y) : x_(x), y_(y) {}
|
||||
|
|
@ -178,6 +198,7 @@ public:
|
|||
const UINT8* colormap_ = nullptr;
|
||||
|
||||
void string(const char* str, INT32 flags, Font font) const;
|
||||
void button(Button type, int ver, std::optional<bool> press = {}) const;
|
||||
|
||||
friend Draw;
|
||||
};
|
||||
|
|
@ -222,6 +243,7 @@ public:
|
|||
VOID_METHOD(patch);
|
||||
VOID_METHOD(thumbnail);
|
||||
VOID_METHOD(fill);
|
||||
VOID_METHOD(button);
|
||||
|
||||
#undef VOID_METHOD
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue