1 #include "core/instance.hpp"
2 #include "lua/internal.hpp"
3 #include "fonts/wrapper.hpp"
4 #include "library/framebuffer.hpp"
5 #include "library/lua-framebuffer.hpp"
9 struct render_object_text
: public framebuffer::object
11 render_object_text(int32_t _x
, int32_t _y
, const std::string
& _text
, framebuffer::color _fg
,
12 framebuffer::color _bg
, bool _hdbl
= false, bool _vdbl
= false) throw()
13 : x(_x
), y(_y
), text(_text
), fg(_fg
), bg(_bg
), hdbl(_hdbl
), vdbl(_vdbl
) {}
14 ~render_object_text() throw() {}
15 template<bool X
> void op(struct framebuffer::fb
<X
>& scr
) throw()
17 main_font
.render(scr
, x
, y
, text
, fg
, bg
, hdbl
, vdbl
);
19 void operator()(struct framebuffer::fb
<true>& scr
) throw() { op(scr
); }
20 void operator()(struct framebuffer::fb
<false>& scr
) throw() { op(scr
); }
21 void clone(framebuffer::queue
& q
) const throw(std::bad_alloc
) { q
.clone_helper(this); }
26 framebuffer::color fg
;
27 framebuffer::color bg
;
32 template<bool hdbl
, bool vdbl
>
33 int internal_gui_text(lua::state
& L
, lua::parameters
& P
)
38 framebuffer::color fg
, bg
;
40 if(!core
.lua2
->render_ctx
) return 0;
42 P(x
, y
, text
, P
.optional(fg
, 0xFFFFFFU
), P
.optional(bg
, -1));
44 core
.lua2
->render_ctx
->queue
->create_add
<render_object_text
>(x
, y
, text
, fg
, bg
, hdbl
, vdbl
);
48 lua::functions
LUA_text_fns(lua_func_misc
, "gui", {
49 {"text", internal_gui_text
<false, false>},
50 {"textH", internal_gui_text
<true, false>},
51 {"textV", internal_gui_text
<false, true>},
52 {"textHV", internal_gui_text
<true, true>},