mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
add gui.screenshot
This commit is contained in:
parent
80e45d7f49
commit
5ae4c1b27b
1 changed files with 10 additions and 0 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include "items/Inventories.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "window/Window.hpp"
|
||||
#include "../usertypes/lua_type_canvas.hpp"
|
||||
|
||||
using namespace gui;
|
||||
|
|
@ -1218,7 +1219,16 @@ static int l_get_active_frame(lua::State* L) {
|
|||
return lua::pushstring(L, frame->getId());
|
||||
}
|
||||
|
||||
static int l_screenshot(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
return 0;
|
||||
}
|
||||
auto image = engine->getWindow().takeScreenshot();
|
||||
return lua::newuserdata<lua::LuaCanvas>(L, nullptr, std::move(image));
|
||||
}
|
||||
|
||||
const luaL_Reg guilib[] = {
|
||||
{"screenshot", lua::wrap<l_screenshot>},
|
||||
{"get_viewport", lua::wrap<l_gui_getviewport>},
|
||||
{"getattr", lua::wrap<l_gui_getattr>},
|
||||
{"setattr", lua::wrap<l_gui_setattr>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue