mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-28 12:40:06 +00:00
Add headers for all .cpp
files in mwlua; move packages initilaization from LuaManager to luabindings.cpp
This commit is contained in:
parent
fe48348486
commit
4562b8c06b
@ -1,5 +1,6 @@
|
|||||||
#include "luabindings.hpp"
|
#include "luabindings.hpp"
|
||||||
|
|
||||||
|
#include <components/lua/luastate.hpp>
|
||||||
#include <components/lua/utilpackage.hpp>
|
#include <components/lua/utilpackage.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
@ -13,15 +14,15 @@ namespace MWLua
|
|||||||
|
|
||||||
using CameraMode = MWRender::Camera::Mode;
|
using CameraMode = MWRender::Camera::Mode;
|
||||||
|
|
||||||
sol::table initCameraPackage(const Context& context)
|
sol::table initCameraPackage(sol::state_view& lua)
|
||||||
{
|
{
|
||||||
MWRender::Camera* camera = MWBase::Environment::get().getWorld()->getCamera();
|
MWRender::Camera* camera = MWBase::Environment::get().getWorld()->getCamera();
|
||||||
MWRender::RenderingManager* renderingManager = MWBase::Environment::get().getWorld()->getRenderingManager();
|
MWRender::RenderingManager* renderingManager = MWBase::Environment::get().getWorld()->getRenderingManager();
|
||||||
|
|
||||||
sol::table api(context.mLua->sol(), sol::create);
|
sol::table api(lua, sol::create);
|
||||||
api["MODE"] = LuaUtil::makeStrictReadOnly(
|
api["MODE"] = LuaUtil::makeStrictReadOnly(
|
||||||
context.mLua->sol().create_table_with("Static", CameraMode::Static, "FirstPerson", CameraMode::FirstPerson,
|
lua.create_table_with("Static", CameraMode::Static, "FirstPerson", CameraMode::FirstPerson, "ThirdPerson",
|
||||||
"ThirdPerson", CameraMode::ThirdPerson, "Vanity", CameraMode::Vanity, "Preview", CameraMode::Preview));
|
CameraMode::ThirdPerson, "Vanity", CameraMode::Vanity, "Preview", CameraMode::Preview));
|
||||||
|
|
||||||
api["getMode"] = [camera]() -> int { return static_cast<int>(camera->getMode()); };
|
api["getMode"] = [camera]() -> int { return static_cast<int>(camera->getMode()); };
|
||||||
api["getQueuedMode"] = [camera]() -> sol::optional<int> {
|
api["getQueuedMode"] = [camera]() -> sol::optional<int> {
|
||||||
|
11
apps/openmw/mwlua/camerabindings.hpp
Normal file
11
apps/openmw/mwlua/camerabindings.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef MWLUA_CAMERABINDINGS_H
|
||||||
|
#define MWLUA_CAMERABINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initCameraPackage(sol::state_view& lua);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_CAMERABINDINGS_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "luabindings.hpp"
|
#include "cellbindings.hpp"
|
||||||
|
|
||||||
#include <components/esm/esmbridge.hpp>
|
#include <components/esm/esmbridge.hpp>
|
||||||
#include <components/esm/records.hpp>
|
#include <components/esm/records.hpp>
|
||||||
|
12
apps/openmw/mwlua/cellbindings.hpp
Normal file
12
apps/openmw/mwlua/cellbindings.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef MWLUA_CELLBINDINGS_H
|
||||||
|
#define MWLUA_CELLBINDINGS_H
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void initCellBindingsForLocalScripts(const Context&);
|
||||||
|
void initCellBindingsForGlobalScripts(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_CELLBINDINGS_H
|
@ -1,9 +1,10 @@
|
|||||||
#include "luabindings.hpp"
|
#include "inputbindings.hpp"
|
||||||
|
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#include <SDL_gamecontroller.h>
|
#include <SDL_gamecontroller.h>
|
||||||
#include <SDL_mouse.h>
|
#include <SDL_mouse.h>
|
||||||
|
|
||||||
|
#include <components/lua/luastate.hpp>
|
||||||
#include <components/sdlutil/events.hpp>
|
#include <components/sdlutil/events.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
13
apps/openmw/mwlua/inputbindings.hpp
Normal file
13
apps/openmw/mwlua/inputbindings.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MWLUA_INPUTBINDINGS_H
|
||||||
|
#define MWLUA_INPUTBINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initInputPackage(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_INPUTBINDINGS_H
|
@ -3,11 +3,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include <components/esm/attr.hpp>
|
#include <components/esm/attr.hpp>
|
||||||
#include <components/esm3/activespells.hpp>
|
|
||||||
#include <components/esm3/loadalch.hpp>
|
#include <components/esm3/loadalch.hpp>
|
||||||
#include <components/esm3/loadskil.hpp>
|
#include <components/esm3/loadskil.hpp>
|
||||||
|
|
||||||
#include <components/lua/l10n.hpp>
|
#include <components/lua/l10n.hpp>
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
|
#include <components/lua/utilpackage.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/statemanager.hpp"
|
#include "../mwbase/statemanager.hpp"
|
||||||
@ -22,7 +23,16 @@
|
|||||||
#include "luamanagerimp.hpp"
|
#include "luamanagerimp.hpp"
|
||||||
#include "worldview.hpp"
|
#include "worldview.hpp"
|
||||||
|
|
||||||
|
#include "camerabindings.hpp"
|
||||||
|
#include "cellbindings.hpp"
|
||||||
|
#include "debugbindings.hpp"
|
||||||
|
#include "inputbindings.hpp"
|
||||||
#include "magicbindings.hpp"
|
#include "magicbindings.hpp"
|
||||||
|
#include "nearbybindings.hpp"
|
||||||
|
#include "objectbindings.hpp"
|
||||||
|
#include "postprocessingbindings.hpp"
|
||||||
|
#include "types/types.hpp"
|
||||||
|
#include "uibindings.hpp"
|
||||||
|
|
||||||
namespace MWLua
|
namespace MWLua
|
||||||
{
|
{
|
||||||
@ -54,7 +64,7 @@ namespace MWLua
|
|||||||
// api["resume"] = []() {};
|
// api["resume"] = []() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table initCorePackage(const Context& context)
|
static sol::table initCorePackage(const Context& context)
|
||||||
{
|
{
|
||||||
auto* lua = context.mLua;
|
auto* lua = context.mLua;
|
||||||
sol::table api(lua->sol(), sol::create);
|
sol::table api(lua->sol(), sol::create);
|
||||||
@ -96,7 +106,7 @@ namespace MWLua
|
|||||||
return LuaUtil::makeReadOnly(api);
|
return LuaUtil::makeReadOnly(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table initWorldPackage(const Context& context)
|
static sol::table initWorldPackage(const Context& context)
|
||||||
{
|
{
|
||||||
sol::table api(context.mLua->sol(), sol::create);
|
sol::table api(context.mLua->sol(), sol::create);
|
||||||
WorldView* worldView = context.mWorldView;
|
WorldView* worldView = context.mWorldView;
|
||||||
@ -137,33 +147,48 @@ namespace MWLua
|
|||||||
return LuaUtil::makeReadOnly(api);
|
return LuaUtil::makeReadOnly(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table initGlobalStoragePackage(const Context& context, LuaUtil::LuaStorage* globalStorage)
|
std::map<std::string, sol::object> initCommonPackages(const Context& context)
|
||||||
{
|
{
|
||||||
sol::table res(context.mLua->sol(), sol::create);
|
sol::state_view lua = context.mLua->sol();
|
||||||
res["globalSection"]
|
WorldView* w = context.mWorldView;
|
||||||
= [globalStorage](std::string_view section) { return globalStorage->getMutableSection(section); };
|
return {
|
||||||
res["allGlobalSections"] = [globalStorage]() { return globalStorage->getAllSections(); };
|
{ "openmw.async",
|
||||||
return LuaUtil::makeReadOnly(res);
|
LuaUtil::getAsyncPackageInitializer(
|
||||||
|
lua, [w] { return w->getSimulationTime(); }, [w] { return w->getGameTime(); }) },
|
||||||
|
{ "openmw.core", initCorePackage(context) },
|
||||||
|
{ "openmw.types", initTypesPackage(context) },
|
||||||
|
{ "openmw.util", LuaUtil::initUtilPackage(lua) },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table initLocalStoragePackage(const Context& context, LuaUtil::LuaStorage* globalStorage)
|
std::map<std::string, sol::object> initGlobalPackages(const Context& context)
|
||||||
{
|
{
|
||||||
sol::table res(context.mLua->sol(), sol::create);
|
initObjectBindingsForGlobalScripts(context);
|
||||||
res["globalSection"]
|
initCellBindingsForGlobalScripts(context);
|
||||||
= [globalStorage](std::string_view section) { return globalStorage->getReadOnlySection(section); };
|
return {
|
||||||
return LuaUtil::makeReadOnly(res);
|
{ "openmw.world", initWorldPackage(context) },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table initPlayerStoragePackage(
|
std::map<std::string, sol::object> initLocalPackages(const Context& context)
|
||||||
const Context& context, LuaUtil::LuaStorage* globalStorage, LuaUtil::LuaStorage* playerStorage)
|
|
||||||
{
|
{
|
||||||
sol::table res(context.mLua->sol(), sol::create);
|
initObjectBindingsForLocalScripts(context);
|
||||||
res["globalSection"]
|
initCellBindingsForLocalScripts(context);
|
||||||
= [globalStorage](std::string_view section) { return globalStorage->getReadOnlySection(section); };
|
LocalScripts::initializeSelfPackage(context);
|
||||||
res["playerSection"]
|
return {
|
||||||
= [playerStorage](std::string_view section) { return playerStorage->getMutableSection(section); };
|
{ "openmw.nearby", initNearbyPackage(context) },
|
||||||
res["allPlayerSections"] = [playerStorage]() { return playerStorage->getAllSections(); };
|
};
|
||||||
return LuaUtil::makeReadOnly(res);
|
}
|
||||||
|
|
||||||
|
std::map<std::string, sol::object> initPlayerPackages(const Context& context)
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
{ "openmw.camera", initCameraPackage(context.mLua->sol()) },
|
||||||
|
{ "openmw.debug", initDebugPackage(context) },
|
||||||
|
{ "openmw.input", initInputPackage(context) },
|
||||||
|
{ "openmw.postprocessing", initPostprocessingPackage(context) },
|
||||||
|
{ "openmw.ui", initUserInterfacePackage(context) },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,25 @@
|
|||||||
#ifndef MWLUA_LUABINDINGS_H
|
#ifndef MWLUA_LUABINDINGS_H
|
||||||
#define MWLUA_LUABINDINGS_H
|
#define MWLUA_LUABINDINGS_H
|
||||||
|
|
||||||
#include <components/lua/scriptscontainer.hpp>
|
#include <map>
|
||||||
#include <components/lua/storage.hpp>
|
#include <sol/forward.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class CellStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWLua
|
namespace MWLua
|
||||||
{
|
{
|
||||||
|
// Initialize Lua packages that are available for all scripts.
|
||||||
|
std::map<std::string, sol::object> initCommonPackages(const Context&);
|
||||||
|
|
||||||
sol::table initCorePackage(const Context&);
|
// Initialize Lua packages that are available only for global scripts.
|
||||||
sol::table initWorldPackage(const Context&);
|
std::map<std::string, sol::object> initGlobalPackages(const Context&);
|
||||||
sol::table initPostprocessingPackage(const Context&);
|
|
||||||
|
|
||||||
sol::table initGlobalStoragePackage(const Context&, LuaUtil::LuaStorage* globalStorage);
|
// Initialize Lua packages that are available only for local scripts (including player scripts).
|
||||||
sol::table initLocalStoragePackage(const Context&, LuaUtil::LuaStorage* globalStorage);
|
std::map<std::string, sol::object> initLocalPackages(const Context&);
|
||||||
sol::table initPlayerStoragePackage(
|
|
||||||
const Context&, LuaUtil::LuaStorage* globalStorage, LuaUtil::LuaStorage* playerStorage);
|
|
||||||
|
|
||||||
// Implemented in nearbybindings.cpp
|
// Initialize Lua packages that are available only for local scripts on the player.
|
||||||
sol::table initNearbyPackage(const Context&);
|
std::map<std::string, sol::object> initPlayerPackages(const Context&);
|
||||||
|
|
||||||
// Implemented in objectbindings.cpp
|
|
||||||
void initObjectBindingsForLocalScripts(const Context&);
|
|
||||||
void initObjectBindingsForGlobalScripts(const Context&);
|
|
||||||
|
|
||||||
// Implemented in cellbindings.cpp
|
|
||||||
void initCellBindingsForLocalScripts(const Context&);
|
|
||||||
void initCellBindingsForGlobalScripts(const Context&);
|
|
||||||
|
|
||||||
// Implemented in camerabindings.cpp
|
|
||||||
sol::table initCameraPackage(const Context&);
|
|
||||||
|
|
||||||
// Implemented in uibindings.cpp
|
|
||||||
sol::table initUserInterfacePackage(const Context&);
|
|
||||||
|
|
||||||
// Implemented in inputbindings.cpp
|
|
||||||
sol::table initInputPackage(const Context&);
|
|
||||||
|
|
||||||
// openmw.self package is implemented in localscripts.cpp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MWLUA_LUABINDINGS_H
|
#endif // MWLUA_LUABINDINGS_H
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
#include <components/l10n/manager.hpp>
|
#include <components/l10n/manager.hpp>
|
||||||
|
|
||||||
#include <components/lua/asyncpackage.hpp>
|
|
||||||
#include <components/lua/utilpackage.hpp>
|
|
||||||
|
|
||||||
#include <components/lua_ui/content.hpp>
|
#include <components/lua_ui/content.hpp>
|
||||||
#include <components/lua_ui/util.hpp>
|
#include <components/lua_ui/util.hpp>
|
||||||
|
|
||||||
@ -31,7 +28,6 @@
|
|||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/scene.hpp"
|
#include "../mwworld/scene.hpp"
|
||||||
|
|
||||||
#include "debugbindings.hpp"
|
|
||||||
#include "luabindings.hpp"
|
#include "luabindings.hpp"
|
||||||
#include "playerscripts.hpp"
|
#include "playerscripts.hpp"
|
||||||
#include "types/types.hpp"
|
#include "types/types.hpp"
|
||||||
@ -88,31 +84,21 @@ namespace MWLua
|
|||||||
localContext.mIsGlobal = false;
|
localContext.mIsGlobal = false;
|
||||||
localContext.mSerializer = mLocalSerializer.get();
|
localContext.mSerializer = mLocalSerializer.get();
|
||||||
|
|
||||||
initObjectBindingsForGlobalScripts(context);
|
for (const auto& [name, package] : initCommonPackages(context))
|
||||||
initCellBindingsForGlobalScripts(context);
|
mLua.addCommonPackage(name, package);
|
||||||
initObjectBindingsForLocalScripts(localContext);
|
for (const auto& [name, package] : initGlobalPackages(context))
|
||||||
initCellBindingsForLocalScripts(localContext);
|
mGlobalScripts.addPackage(name, package);
|
||||||
LocalScripts::initializeSelfPackage(localContext);
|
|
||||||
|
mLocalPackages = initLocalPackages(localContext);
|
||||||
|
mPlayerPackages = initPlayerPackages(localContext);
|
||||||
|
mPlayerPackages.insert(mLocalPackages.begin(), mLocalPackages.end());
|
||||||
|
|
||||||
LuaUtil::LuaStorage::initLuaBindings(mLua.sol());
|
LuaUtil::LuaStorage::initLuaBindings(mLua.sol());
|
||||||
|
mGlobalScripts.addPackage(
|
||||||
mLua.addCommonPackage("openmw.async",
|
"openmw.storage", LuaUtil::LuaStorage::initGlobalPackage(mLua.sol(), &mGlobalStorage));
|
||||||
LuaUtil::getAsyncPackageInitializer(
|
mLocalPackages["openmw.storage"] = LuaUtil::LuaStorage::initLocalPackage(mLua.sol(), &mGlobalStorage);
|
||||||
mLua.sol(), [this] { return mWorldView.getSimulationTime(); },
|
mPlayerPackages["openmw.storage"]
|
||||||
[this] { return mWorldView.getGameTime(); }));
|
= LuaUtil::LuaStorage::initPlayerPackage(mLua.sol(), &mGlobalStorage, &mPlayerStorage);
|
||||||
mLua.addCommonPackage("openmw.util", LuaUtil::initUtilPackage(mLua.sol()));
|
|
||||||
mLua.addCommonPackage("openmw.core", initCorePackage(context));
|
|
||||||
mLua.addCommonPackage("openmw.types", initTypesPackage(context));
|
|
||||||
mGlobalScripts.addPackage("openmw.world", initWorldPackage(context));
|
|
||||||
mGlobalScripts.addPackage("openmw.storage", initGlobalStoragePackage(context, &mGlobalStorage));
|
|
||||||
|
|
||||||
mCameraPackage = initCameraPackage(localContext);
|
|
||||||
mUserInterfacePackage = initUserInterfacePackage(localContext);
|
|
||||||
mInputPackage = initInputPackage(localContext);
|
|
||||||
mNearbyPackage = initNearbyPackage(localContext);
|
|
||||||
mLocalStoragePackage = initLocalStoragePackage(localContext, &mGlobalStorage);
|
|
||||||
mPlayerStoragePackage = initPlayerStoragePackage(localContext, &mGlobalStorage, &mPlayerStorage);
|
|
||||||
mPostprocessingPackage = initPostprocessingPackage(localContext);
|
|
||||||
mDebugPackage = initDebugPackage(localContext);
|
|
||||||
|
|
||||||
initConfiguration();
|
initConfiguration();
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
@ -147,7 +133,7 @@ namespace MWLua
|
|||||||
|
|
||||||
MWWorld::Ptr newPlayerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr newPlayerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if (!(getId(mPlayer) == getId(newPlayerPtr)))
|
if (!(getId(mPlayer) == getId(newPlayerPtr)))
|
||||||
throw std::logic_error("Player Refnum was changed unexpectedly");
|
throw std::logic_error("Player RefNum was changed unexpectedly");
|
||||||
if (!mPlayer.isInCell() || !newPlayerPtr.isInCell() || mPlayer.getCell() != newPlayerPtr.getCell())
|
if (!mPlayer.isInCell() || !newPlayerPtr.isInCell() || mPlayer.getCell() != newPlayerPtr.getCell())
|
||||||
{
|
{
|
||||||
mPlayer = newPlayerPtr; // player was moved to another cell, update ptr in registry
|
mPlayer = newPlayerPtr; // player was moved to another cell, update ptr in registry
|
||||||
@ -352,12 +338,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
scripts = std::make_shared<PlayerScripts>(&mLua, LObject(getId(ptr)));
|
scripts = std::make_shared<PlayerScripts>(&mLua, LObject(getId(ptr)));
|
||||||
scripts->setAutoStartConf(mConfiguration.getPlayerConf());
|
scripts->setAutoStartConf(mConfiguration.getPlayerConf());
|
||||||
scripts->addPackage("openmw.ui", mUserInterfacePackage);
|
for (const auto& [name, package] : mPlayerPackages)
|
||||||
scripts->addPackage("openmw.camera", mCameraPackage);
|
scripts->addPackage(name, package);
|
||||||
scripts->addPackage("openmw.input", mInputPackage);
|
|
||||||
scripts->addPackage("openmw.storage", mPlayerStoragePackage);
|
|
||||||
scripts->addPackage("openmw.postprocessing", mPostprocessingPackage);
|
|
||||||
scripts->addPackage("openmw.debug", mDebugPackage);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -365,9 +347,9 @@ namespace MWLua
|
|||||||
if (!autoStartConf.has_value())
|
if (!autoStartConf.has_value())
|
||||||
autoStartConf = mConfiguration.getLocalConf(type, ptr.getCellRef().getRefId(), getId(ptr));
|
autoStartConf = mConfiguration.getLocalConf(type, ptr.getCellRef().getRefId(), getId(ptr));
|
||||||
scripts->setAutoStartConf(std::move(*autoStartConf));
|
scripts->setAutoStartConf(std::move(*autoStartConf));
|
||||||
scripts->addPackage("openmw.storage", mLocalStoragePackage);
|
for (const auto& [name, package] : mLocalPackages)
|
||||||
|
scripts->addPackage(name, package);
|
||||||
}
|
}
|
||||||
scripts->addPackage("openmw.nearby", mNearbyPackage);
|
|
||||||
scripts->setSerializer(mLocalSerializer.get());
|
scripts->setSerializer(mLocalSerializer.get());
|
||||||
|
|
||||||
MWWorld::RefData& refData = ptr.getRefData();
|
MWWorld::RefData& refData = ptr.getRefData();
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#ifndef MWLUA_LUAMANAGERIMP_H
|
#ifndef MWLUA_LUAMANAGERIMP_H
|
||||||
#define MWLUA_LUAMANAGERIMP_H
|
#define MWLUA_LUAMANAGERIMP_H
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
#include <components/lua/storage.hpp>
|
#include <components/lua/storage.hpp>
|
||||||
|
|
||||||
#include <components/lua_ui/resources.hpp>
|
#include <components/lua_ui/resources.hpp>
|
||||||
|
|
||||||
#include <components/misc/color.hpp>
|
#include <components/misc/color.hpp>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include "../mwbase/luamanager.hpp"
|
#include "../mwbase/luamanager.hpp"
|
||||||
|
|
||||||
@ -157,14 +155,8 @@ namespace MWLua
|
|||||||
LuaUtil::ScriptsConfiguration mConfiguration;
|
LuaUtil::ScriptsConfiguration mConfiguration;
|
||||||
LuaUtil::LuaState mLua;
|
LuaUtil::LuaState mLua;
|
||||||
LuaUi::ResourceManager mUiResourceManager;
|
LuaUi::ResourceManager mUiResourceManager;
|
||||||
sol::table mNearbyPackage;
|
std::map<std::string, sol::object> mLocalPackages;
|
||||||
sol::table mUserInterfacePackage;
|
std::map<std::string, sol::object> mPlayerPackages;
|
||||||
sol::table mCameraPackage;
|
|
||||||
sol::table mInputPackage;
|
|
||||||
sol::table mLocalStoragePackage;
|
|
||||||
sol::table mPlayerStoragePackage;
|
|
||||||
sol::table mPostprocessingPackage;
|
|
||||||
sol::table mDebugPackage;
|
|
||||||
|
|
||||||
GlobalScripts mGlobalScripts{ &mLua };
|
GlobalScripts mGlobalScripts{ &mLua };
|
||||||
std::set<LocalScripts*> mActiveLocalScripts;
|
std::set<LocalScripts*> mActiveLocalScripts;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "luabindings.hpp"
|
#include "nearbybindings.hpp"
|
||||||
|
|
||||||
#include <components/detournavigator/navigator.hpp>
|
#include <components/detournavigator/navigator.hpp>
|
||||||
#include <components/detournavigator/navigatorutils.hpp>
|
#include <components/detournavigator/navigatorutils.hpp>
|
||||||
|
13
apps/openmw/mwlua/nearbybindings.hpp
Normal file
13
apps/openmw/mwlua/nearbybindings.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MWLUA_NEARBYBINDINGS_H
|
||||||
|
#define MWLUA_NEARBYBINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initNearbyPackage(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_NEARBYBINDINGS_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "luabindings.hpp"
|
#include "objectbindings.hpp"
|
||||||
|
|
||||||
#include <components/esm3/loadfact.hpp>
|
#include <components/esm3/loadfact.hpp>
|
||||||
#include <components/esm3/loadnpc.hpp>
|
#include <components/esm3/loadnpc.hpp>
|
||||||
|
12
apps/openmw/mwlua/objectbindings.hpp
Normal file
12
apps/openmw/mwlua/objectbindings.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef MWLUA_OBJECTBINDINGS_H
|
||||||
|
#define MWLUA_OBJECTBINDINGS_H
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void initObjectBindingsForLocalScripts(const Context&);
|
||||||
|
void initObjectBindingsForGlobalScripts(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_OBJECTBINDINGS_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "luabindings.hpp"
|
#include "postprocessingbindings.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwrender/postprocessor.hpp"
|
#include "../mwrender/postprocessor.hpp"
|
||||||
|
13
apps/openmw/mwlua/postprocessingbindings.hpp
Normal file
13
apps/openmw/mwlua/postprocessingbindings.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MWLUA_POSTPROCESSINGBINDINGS_H
|
||||||
|
#define MWLUA_POSTPROCESSINGBINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initPostprocessingPackage(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_POSTPROCESSINGBINDINGS_H
|
@ -1,3 +1,5 @@
|
|||||||
|
#include "uibindings.hpp"
|
||||||
|
|
||||||
#include <components/lua_ui/alignment.hpp>
|
#include <components/lua_ui/alignment.hpp>
|
||||||
#include <components/lua_ui/content.hpp>
|
#include <components/lua_ui/content.hpp>
|
||||||
#include <components/lua_ui/element.hpp>
|
#include <components/lua_ui/element.hpp>
|
||||||
|
13
apps/openmw/mwlua/uibindings.hpp
Normal file
13
apps/openmw/mwlua/uibindings.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MWLUA_UIBINDINGS_H
|
||||||
|
#define MWLUA_UIBINDINGS_H
|
||||||
|
|
||||||
|
#include <sol/forward.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
sol::table initUserInterfacePackage(const Context&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MWLUA_UIBINDINGS_H
|
@ -316,7 +316,7 @@ namespace LuaUtil
|
|||||||
{
|
{
|
||||||
if (!package.is<sol::function>())
|
if (!package.is<sol::function>())
|
||||||
package = makeReadOnly(std::move(package));
|
package = makeReadOnly(std::move(package));
|
||||||
mCommonPackages.emplace(std::move(packageName), std::move(package));
|
mCommonPackages.insert_or_assign(std::move(packageName), std::move(package));
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::protected_function_result LuaState::runInNewSandbox(const std::string& path, const std::string& namePrefix,
|
sol::protected_function_result LuaState::runInNewSandbox(const std::string& path, const std::string& namePrefix,
|
||||||
|
@ -35,7 +35,7 @@ namespace LuaUtil
|
|||||||
|
|
||||||
void ScriptsContainer::addPackage(std::string packageName, sol::object package)
|
void ScriptsContainer::addPackage(std::string packageName, sol::object package)
|
||||||
{
|
{
|
||||||
mAPI.emplace(std::move(packageName), makeReadOnly(std::move(package)));
|
mAPI.insert_or_assign(std::move(packageName), makeReadOnly(std::move(package)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptsContainer::addCustomScript(int scriptId, std::string_view initData)
|
bool ScriptsContainer::addCustomScript(int scriptId, std::string_view initData)
|
||||||
|
@ -138,6 +138,34 @@ namespace LuaUtil
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sol::table LuaStorage::initGlobalPackage(lua_State* lua, LuaStorage* globalStorage)
|
||||||
|
{
|
||||||
|
sol::table res(lua, sol::create);
|
||||||
|
res["globalSection"]
|
||||||
|
= [globalStorage](std::string_view section) { return globalStorage->getMutableSection(section); };
|
||||||
|
res["allGlobalSections"] = [globalStorage]() { return globalStorage->getAllSections(); };
|
||||||
|
return LuaUtil::makeReadOnly(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
sol::table LuaStorage::initLocalPackage(lua_State* lua, LuaStorage* globalStorage)
|
||||||
|
{
|
||||||
|
sol::table res(lua, sol::create);
|
||||||
|
res["globalSection"]
|
||||||
|
= [globalStorage](std::string_view section) { return globalStorage->getReadOnlySection(section); };
|
||||||
|
return LuaUtil::makeReadOnly(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
sol::table LuaStorage::initPlayerPackage(lua_State* lua, LuaStorage* globalStorage, LuaStorage* playerStorage)
|
||||||
|
{
|
||||||
|
sol::table res(lua, sol::create);
|
||||||
|
res["globalSection"]
|
||||||
|
= [globalStorage](std::string_view section) { return globalStorage->getReadOnlySection(section); };
|
||||||
|
res["playerSection"]
|
||||||
|
= [playerStorage](std::string_view section) { return playerStorage->getMutableSection(section); };
|
||||||
|
res["allPlayerSections"] = [playerStorage]() { return playerStorage->getAllSections(); };
|
||||||
|
return LuaUtil::makeReadOnly(res);
|
||||||
|
}
|
||||||
|
|
||||||
void LuaStorage::clearTemporaryAndRemoveCallbacks()
|
void LuaStorage::clearTemporaryAndRemoveCallbacks()
|
||||||
{
|
{
|
||||||
auto it = mData.begin();
|
auto it = mData.begin();
|
||||||
|
@ -14,6 +14,9 @@ namespace LuaUtil
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void initLuaBindings(lua_State*);
|
static void initLuaBindings(lua_State*);
|
||||||
|
static sol::table initGlobalPackage(lua_State* lua, LuaStorage* globalStorage);
|
||||||
|
static sol::table initLocalPackage(lua_State* lua, LuaStorage* globalStorage);
|
||||||
|
static sol::table initPlayerPackage(lua_State* lua, LuaStorage* globalStorage, LuaStorage* playerStorage);
|
||||||
|
|
||||||
explicit LuaStorage(lua_State* lua)
|
explicit LuaStorage(lua_State* lua)
|
||||||
: mLua(lua)
|
: mLua(lua)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user