mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-18 02:49:03 -06:00
Add the ability to change the screenshot folder at runtime (#1172)
This commit is contained in:
@@ -925,6 +925,9 @@ void setSgctDelegateFunctions() {
|
||||
|
||||
return currentWindow->swapGroupFrameNumber();
|
||||
};
|
||||
sgctDelegate.setScreenshotFolder = [](std::string path) {
|
||||
Settings::instance().setCapturePath(std::move(path));
|
||||
};
|
||||
}
|
||||
|
||||
void checkCommandLineForSettings(int& argc, char** argv, bool& hasSGCT, bool& hasProfile,
|
||||
|
||||
@@ -100,6 +100,8 @@ struct WindowDelegate {
|
||||
Frustum (*frustumMode)() = []() { return Frustum::Mono; };
|
||||
|
||||
uint64_t (*swapGroupFrameNumber)() = []() { return uint64_t(0); };
|
||||
|
||||
void (*setScreenshotFolder)(std::string) = [](std::string) {};
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -1522,6 +1522,13 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
|
||||
"",
|
||||
"Remove all registered virtual properties"
|
||||
},
|
||||
{
|
||||
"setScreenshotFolder",
|
||||
&luascriptfunctions::setScreenshotFolder,
|
||||
{},
|
||||
"string",
|
||||
"Sets the folder used for storing screenshots or session recording frames"
|
||||
},
|
||||
{
|
||||
"addTag",
|
||||
&luascriptfunctions::addTag,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace openspace::luascriptfunctions {
|
||||
|
||||
@@ -182,6 +183,27 @@ int removeAllVirtualProperties(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setScreenshotFolder(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setScreenshotFolder");
|
||||
|
||||
std::string arg = ghoul::lua::value<std::string>(L);
|
||||
lua_pop(L, 0);
|
||||
|
||||
std::string folder = FileSys.absolutePath(arg);
|
||||
if (!std::filesystem::exists(folder)) {
|
||||
std::filesystem::create_directory(folder);
|
||||
}
|
||||
|
||||
FileSys.registerPathToken(
|
||||
"${SCREENSHOTS}",
|
||||
folder,
|
||||
ghoul::filesystem::FileSystem::Override::Yes
|
||||
);
|
||||
|
||||
global::windowDelegate->setScreenshotFolder(folder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* addTag()
|
||||
|
||||
Reference in New Issue
Block a user