mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-09 22:05:39 +02:00
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
/*
|
|
* ScriptHandler.cpp, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#include "StdInc.h"
|
|
|
|
#include "ScriptHandler.h"
|
|
|
|
#include "../VCMIDirs.h"
|
|
#include "../callback/CDynLibHandler.h"
|
|
#include "../serializer/JsonDeserializer.h"
|
|
#include "../serializer/JsonSerializer.h"
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
namespace scripting
|
|
{
|
|
|
|
ScriptHandler::ScriptHandler()
|
|
{
|
|
boost::filesystem::path filePath = VCMIDirs::get().fullLibraryPath("scripting", "vcmiLua");
|
|
|
|
if(!boost::filesystem::exists(filePath))
|
|
{
|
|
logGlobal->warn("Lua scripting module not found at path: %s - scripting will be unavailable", filePath.string());
|
|
return;
|
|
}
|
|
|
|
lua = CDynLibHandler::getNewScriptingModule(filePath);
|
|
}
|
|
|
|
ScriptHandler::~ScriptHandler() = default;
|
|
|
|
void ScriptHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
|
{
|
|
if(lua)
|
|
lua->loadObject(scope, name, data);
|
|
}
|
|
|
|
void ScriptHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
|
{
|
|
throw std::runtime_error("No legacy data load allowed for scripts");
|
|
}
|
|
|
|
void ScriptHandler::afterLoadFinalization()
|
|
{
|
|
if(lua)
|
|
lua->afterLoadFinalization();
|
|
}
|
|
|
|
std::unique_ptr<Pool> ScriptHandler::createPoolInstance(const Environment * ENV) const
|
|
{
|
|
if(lua)
|
|
return lua->createPoolInstance(ENV);
|
|
return {};
|
|
}
|
|
|
|
std::vector<JsonNode> ScriptHandler::loadLegacyData()
|
|
{
|
|
return std::vector<JsonNode>();
|
|
}
|
|
|
|
}
|
|
|
|
VCMI_LIB_NAMESPACE_END
|