#include "lua-int.hpp" #include "render.hpp" namespace { struct render_object_text : public render_object { render_object_text(int32_t _x, int32_t _y, const std::string& _text, uint32_t _fg = 0xFFFFFFFFU, uint16_t _fgalpha = 255, uint32_t _bg = 0, uint16_t _bgalpha = 0) throw(std::bad_alloc); ~render_object_text() throw(); void operator()(struct screen& scr) throw(); private: int32_t x; int32_t y; uint32_t fg; uint16_t fgalpha; uint32_t bg; uint16_t bgalpha; std::string text; }; render_object_text::render_object_text(int32_t _x, int32_t _y, const std::string& _text, uint32_t _fg, uint16_t _fgalpha, uint32_t _bg, uint16_t _bgalpha) throw(std::bad_alloc) : x(_x), y(_y), fg(_fg), fgalpha(_fgalpha), bg(_bg), bgalpha(_bgalpha), text(_text) { } void render_object_text::operator()(struct screen& scr) throw() { render_text(scr, x, y, text, fg, fgalpha, bg, bgalpha); } render_object_text::~render_object_text() throw() { } function_ptr_luafun gui_text("gui.text", [](lua_State* LS, const std::string& fname) -> int { if(!lua_render_ctx) return 0; uint32_t x255 = 255; uint32_t fgc = (x255 << lua_render_ctx->rshift) | (x255 << lua_render_ctx->gshift) | (x255 << lua_render_ctx->bshift); uint32_t bgc = 0; uint16_t fga = 256; uint16_t bga = 0; int32_t _x = get_numeric_argument(LS, 1, fname.c_str()); int32_t _y = get_numeric_argument(LS, 2, fname.c_str()); get_numeric_argument(LS, 4, fgc, fname.c_str()); get_numeric_argument(LS, 5, fga, fname.c_str()); get_numeric_argument(LS, 6, bgc, fname.c_str()); get_numeric_argument(LS, 7, bga, fname.c_str()); std::string text = get_string_argument(LS, 3, fname.c_str()); lua_render_ctx->queue->add(*new render_object_text(_x, _y, text, fgc, fga, bgc, bga)); return 0; }); }