Evdev joystick plugin
[lsnes.git] / lua / gui-text.cpp
blobf8a57b4726bb13f1359c4d2c7f7f39a61f566873
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, premultiplied_color _fg,
9 premultiplied_color _bg) throw()
10 : x(_x), y(_y), text(_text), fg(_fg), bg(_bg) {}
11 ~render_object_text() throw() {}
12 void operator()(struct screen& scr) throw()
14 render_text(scr, x, y, text, fg, bg);
16 private:
17 int32_t x;
18 int32_t y;
19 premultiplied_color fg;
20 premultiplied_color bg;
21 std::string text;
24 function_ptr_luafun gui_text("gui.text", [](lua_State* LS, const std::string& fname) -> int {
25 if(!lua_render_ctx)
26 return 0;
27 int64_t fgc = 0xFFFFFFU;
28 int64_t bgc = -1;
29 int32_t _x = get_numeric_argument<int32_t>(LS, 1, fname.c_str());
30 int32_t _y = get_numeric_argument<int32_t>(LS, 2, fname.c_str());
31 get_numeric_argument<int64_t>(LS, 4, fgc, fname.c_str());
32 get_numeric_argument<int64_t>(LS, 5, bgc, fname.c_str());
33 std::string text = get_string_argument(LS, 3, fname.c_str());
34 premultiplied_color fg(fgc);
35 premultiplied_color bg(bgc);
36 lua_render_ctx->queue->add(*new render_object_text(_x, _y, text, fg, bg));
37 return 0;
38 });