Extend tpt.screenshot to return created filename and optionally, PPM format
This commit is contained in:
parent
f65ea547e7
commit
ced44c8be2
@ -2021,7 +2021,22 @@ int screenshotIndex = 0;
|
|||||||
int luatpt_screenshot(lua_State* l)
|
int luatpt_screenshot(lua_State* l)
|
||||||
{
|
{
|
||||||
int captureUI = luaL_optint(l, 1, 0);
|
int captureUI = luaL_optint(l, 1, 0);
|
||||||
|
int fileType = luaL_optint(l, 2, 0);
|
||||||
std::vector<char> data;
|
std::vector<char> data;
|
||||||
|
if(fileType) {
|
||||||
|
if(captureUI)
|
||||||
|
{
|
||||||
|
VideoBuffer screenshot(ui::Engine::Ref().g->DumpFrame());
|
||||||
|
data = format::VideoBufferToPPM(screenshot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VideoBuffer screenshot(luacon_ren->DumpFrame());
|
||||||
|
data = format::VideoBufferToPPM(screenshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(captureUI)
|
if(captureUI)
|
||||||
{
|
{
|
||||||
VideoBuffer screenshot(ui::Engine::Ref().g->DumpFrame());
|
VideoBuffer screenshot(ui::Engine::Ref().g->DumpFrame());
|
||||||
@ -2032,11 +2047,14 @@ int luatpt_screenshot(lua_State* l)
|
|||||||
VideoBuffer screenshot(luacon_ren->DumpFrame());
|
VideoBuffer screenshot(luacon_ren->DumpFrame());
|
||||||
data = format::VideoBufferToPNG(screenshot);
|
data = format::VideoBufferToPNG(screenshot);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
std::stringstream filename;
|
std::stringstream filename;
|
||||||
filename << "screenshot_";
|
filename << "screenshot_";
|
||||||
filename << std::setfill('0') << std::setw(6) << (screenshotIndex++);
|
filename << std::setfill('0') << std::setw(6) << (screenshotIndex++);
|
||||||
filename << ".png";
|
if(fileType) { filename << ".ppm"; }
|
||||||
|
else { filename << ".png"; }
|
||||||
Client::Ref().WriteFile(data, filename.str());
|
Client::Ref().WriteFile(data, filename.str());
|
||||||
return 0;
|
lua_pushstring(l, filename.str().c_str());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user