|
- #pragma once
- #define SOL_EXCEPTIONS_SAFE_PROPAGATION 1
- #define SOL_ALL_SAFETIES_ON 1
- //#include "SOL/sol.hpp"
- #include "F:/Programmieren/Lua/sol2/single/single/include/sol/sol.hpp"
- #include <iostream>
- #include <unordered_map>
- #include <vector>
- #include <tuple>
- //#include "C:/SDK_GEN/BL3/SDK/BL3_Basic.hpp"
- //#include "C:/SDK_GEN/BL3/SDK/BL3_CoreUObject_classes.hpp"
- #include "C:/SDK_GEN/BL3-2021-4-9/SDK.hpp"
- #include <Windows.h>
-
- #include "LuaComponent.h"
-
- class BL3Lua
- {
- public:
- BL3Lua();
- ~BL3Lua();
- bool ExecuteScriptFile(const char* filePath, bool printInGame = false);
- bool ExecuteScriptString(const char* scriptCode, bool printInGame = false);
- void RunCallbacks(const char* callbackName, sol::object data);
- void TDump(sol::object tableToDump);
- void ClearCallbacks();
- void AddHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func, bool preHook);
- void RemoveHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func);
- void RemoveAllHooks();
-
- void AddConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func);
- void RemoveConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func);
- void RemoveAllConsoleCommands();
-
- uint32_t RegisterHotkey(sol::this_state s, sol::this_environment e, sol::variadic_args va);
- void RemoveHotkey(sol::this_state s, sol::this_environment e, uint32_t, sol::function func);
- void RemoveAllHotkeys();
-
- void ValidateHotkeys();
-
- //std::vector<sol::protected_function> GetHooks(const char* hookName);
- //void RegisterUtility();
-
- private:
- void registerBase();
- void loadlibs();
- void adjustRequirePath();
- void removeAbusableFuncs();
- public:
- sol::state* lua;
- CRITICAL_SECTION luaCritSec;
- std::unordered_map<std::string, std::vector<std::tuple<sol::reference, lua_State*, bool>>> procEventHooks;
- std::unordered_map<std::string, std::tuple<sol::reference, lua_State*, size_t>> consoleCommands;
- std::vector<std::tuple<sol::reference, lua_State*, std::string, std::string, std::string>> registeredHotkeys;
-
- std::vector<LuaComponent*> loadedComponents;
- private:
- sol::table callbacks;
- sol::environment consoleEnvironment;
- };
|