mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +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 "doomdef.h" // skincolornum_t
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "i_time.h"
|
||||||
#include "k_hud.h"
|
#include "k_hud.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "r_draw.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);
|
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)
|
Chain::Clipper::Clipper(const Chain& chain)
|
||||||
{
|
{
|
||||||
V_SetClipRect(
|
V_SetClipRect(
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,23 @@ public:
|
||||||
kBoth,
|
kBoth,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class Button
|
||||||
|
{
|
||||||
|
a,
|
||||||
|
b,
|
||||||
|
c,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
start,
|
||||||
|
l,
|
||||||
|
r,
|
||||||
|
up,
|
||||||
|
down,
|
||||||
|
right,
|
||||||
|
left,
|
||||||
|
};
|
||||||
|
|
||||||
class TextElement
|
class TextElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -146,6 +163,9 @@ public:
|
||||||
|
|
||||||
void fill(UINT8 color) const;
|
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:
|
private:
|
||||||
constexpr Chain() {}
|
constexpr Chain() {}
|
||||||
explicit Chain(float x, float y) : x_(x), y_(y) {}
|
explicit Chain(float x, float y) : x_(x), y_(y) {}
|
||||||
|
|
@ -178,6 +198,7 @@ public:
|
||||||
const UINT8* colormap_ = nullptr;
|
const UINT8* colormap_ = nullptr;
|
||||||
|
|
||||||
void string(const char* str, INT32 flags, Font font) const;
|
void string(const char* str, INT32 flags, Font font) const;
|
||||||
|
void button(Button type, int ver, std::optional<bool> press = {}) const;
|
||||||
|
|
||||||
friend Draw;
|
friend Draw;
|
||||||
};
|
};
|
||||||
|
|
@ -222,6 +243,7 @@ public:
|
||||||
VOID_METHOD(patch);
|
VOID_METHOD(patch);
|
||||||
VOID_METHOD(thumbnail);
|
VOID_METHOD(thumbnail);
|
||||||
VOID_METHOD(fill);
|
VOID_METHOD(fill);
|
||||||
|
VOID_METHOD(button);
|
||||||
|
|
||||||
#undef VOID_METHOD
|
#undef VOID_METHOD
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue