mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-06-20 05:44:36 +00:00
17e6da40f8
1. Follows advice from https://sol2.readthedocs.io/en/latest/functions.html to use `set_function` when binding functions. 2. Adds autocomplete support for userdata methods. 3. Simplifies property bindings and improves string handling.
26 lines
802 B
C++
26 lines
802 B
C++
#include "lua/modules/render.hpp"
|
|
|
|
#include <sol/sol.hpp>
|
|
|
|
#include "engine/dx.h"
|
|
#include "engine/render/text_render.hpp"
|
|
#include "lua/metadoc.hpp"
|
|
#include "utils/display.h"
|
|
|
|
namespace devilution {
|
|
|
|
sol::table LuaRenderModule(sol::state_view &lua)
|
|
{
|
|
sol::table table = lua.create_table();
|
|
LuaSetDocFn(table, "string", "(text: string, x: integer, y: integer)",
|
|
"Renders a string at the given coordinates",
|
|
[](std::string_view text, int x, int y) { DrawString(GlobalBackBuffer(), text, { x, y }); });
|
|
LuaSetDocFn(table, "screen_width", "()",
|
|
"Returns the screen width", []() { return gnScreenWidth; });
|
|
LuaSetDocFn(table, "screen_height", "()",
|
|
"Returns the screen height", []() { return gnScreenHeight; });
|
|
return table;
|
|
}
|
|
|
|
} // namespace devilution
|