Switch internally to 16-bit graphics instead of 32-bit
[lsnes.git] / lua / gui-text.cpp
blobb85a16190c3826642c3a0c737e00d67eac9bbd05
1 #include "lua-int.hpp"
2 #include "render.hpp"
4 namespace
6 struct render_object_text : public render_object
8 render_object_text(int32_t _x, int32_t _y, const std::string& _text, uint16_t _fg = 0x7FFFU,
9 uint8_t _fgalpha = 32, uint16_t _bg = 0, uint8_t _bgalpha = 0) throw(std::bad_alloc);
10 ~render_object_text() throw();
11 void operator()(struct screen& scr) throw();
12 private:
13 int32_t x;
14 int32_t y;
15 uint16_t fg;
16 uint8_t fgalpha;
17 uint16_t bg;
18 uint8_t bgalpha;
19 std::string text;
22 render_object_text::render_object_text(int32_t _x, int32_t _y, const std::string& _text, uint16_t _fg,
23 uint8_t _fgalpha, uint16_t _bg, uint8_t _bgalpha) throw(std::bad_alloc)
24 : x(_x), y(_y), fg(_fg), fgalpha(_fgalpha), bg(_bg), bgalpha(_bgalpha), text(_text)
28 void render_object_text::operator()(struct screen& scr) throw()
30 render_text(scr, x, y, text, fg, fgalpha, bg, bgalpha);
33 render_object_text::~render_object_text() throw()
37 function_ptr_luafun gui_text("gui.text", [](lua_State* LS, const std::string& fname) -> int {
38 if(!lua_render_ctx)
39 return 0;
40 uint32_t fgc = 0x7FFFU;
41 uint32_t bgc = 0;
42 uint16_t fga = 32;
43 uint16_t bga = 0;
44 int32_t _x = get_numeric_argument<int32_t>(LS, 1, fname.c_str());
45 int32_t _y = get_numeric_argument<int32_t>(LS, 2, fname.c_str());
46 get_numeric_argument<uint32_t>(LS, 4, fgc, fname.c_str());
47 get_numeric_argument<uint16_t>(LS, 5, fga, fname.c_str());
48 get_numeric_argument<uint32_t>(LS, 6, bgc, fname.c_str());
49 get_numeric_argument<uint16_t>(LS, 7, bga, fname.c_str());
50 std::string text = get_string_argument(LS, 3, fname.c_str());
51 lua_render_ctx->queue->add(*new render_object_text(_x, _y, text, fgc, fga, bgc, bga));
52 return 0;
53 });