Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

62 lignes
2.2 KiB

  1. #pragma once
  2. #define SOL_EXCEPTIONS_SAFE_PROPAGATION 1
  3. #define SOL_ALL_SAFETIES_ON 1
  4. //#include "SOL/sol.hpp"
  5. #include "F:/Programmieren/Lua/sol2/single/single/include/sol/sol.hpp"
  6. #include <iostream>
  7. #include <unordered_map>
  8. #include <vector>
  9. #include <tuple>
  10. //#include "C:/SDK_GEN/BL3/SDK/BL3_Basic.hpp"
  11. //#include "C:/SDK_GEN/BL3/SDK/BL3_CoreUObject_classes.hpp"
  12. #include "C:/SDK_GEN/BL3-2021-4-9/SDK.hpp"
  13. #include <Windows.h>
  14. #include "LuaComponent.h"
  15. class BL3Lua
  16. {
  17. public:
  18. BL3Lua();
  19. ~BL3Lua();
  20. bool ExecuteScriptFile(const char* filePath, bool printInGame = false);
  21. bool ExecuteScriptString(const char* scriptCode, bool printInGame = false);
  22. void RunCallbacks(const char* callbackName, sol::object data);
  23. void TDump(sol::object tableToDump);
  24. void ClearCallbacks();
  25. void AddHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func, bool preHook);
  26. void RemoveHook(sol::this_state s, sol::this_environment e, const std::string& hookName, sol::function func);
  27. void RemoveAllHooks();
  28. void AddConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func);
  29. void RemoveConsoleCommand(sol::this_state s, sol::this_environment e, const std::string& command, sol::function func);
  30. void RemoveAllConsoleCommands();
  31. uint32_t RegisterHotkey(sol::this_state s, sol::this_environment e, sol::variadic_args va);
  32. void RemoveHotkey(sol::this_state s, sol::this_environment e, uint32_t, sol::function func);
  33. void RemoveAllHotkeys();
  34. void ValidateHotkeys();
  35. //std::vector<sol::protected_function> GetHooks(const char* hookName);
  36. //void RegisterUtility();
  37. private:
  38. void registerBase();
  39. void loadlibs();
  40. void adjustRequirePath();
  41. void removeAbusableFuncs();
  42. public:
  43. sol::state* lua;
  44. CRITICAL_SECTION luaCritSec;
  45. std::unordered_map<std::string, std::vector<std::tuple<sol::reference, lua_State*, bool>>> procEventHooks;
  46. std::unordered_map<std::string, std::tuple<sol::reference, lua_State*, size_t>> consoleCommands;
  47. std::vector<std::tuple<sol::reference, lua_State*, std::string, std::string, std::string>> registeredHotkeys;
  48. std::vector<LuaComponent*> loadedComponents;
  49. private:
  50. sol::table callbacks;
  51. sol::environment consoleEnvironment;
  52. };