Added a variant of love.graphics.captureScreenshot which takes a single filename parameter. Resolves issue #1293.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-07-29 12:54:53 -03:00
parent 2c80cce00b
commit 5ef6730497
6 changed files with 76 additions and 16 deletions
+2 -9
View File
@@ -22,6 +22,7 @@
#include "common/wrap_Data.h"
#include "filesystem/File.h"
#include "filesystem/Filesystem.h"
// Shove the wrap_ImageData.lua code directly into a raw string literal.
static const char imagedata_lua[] =
@@ -276,19 +277,11 @@ int w_ImageData_encode(lua_State *L)
}
love::filesystem::FileData *filedata = nullptr;
luax_catchexcept(L, [&](){ filedata = t->encode(format, filename.c_str()); });
luax_catchexcept(L, [&](){ filedata = t->encode(format, filename.c_str(), hasfilename); });
luax_pushtype(L, filedata);
filedata->release();
if (hasfilename)
{
luax_getfunction(L, "filesystem", "write");
lua_pushvalue(L, 3); // filename
lua_pushvalue(L, -3); // FileData
lua_call(L, 2, 0);
}
return 1;
}