2023-06-06 07:40:40 +00:00
|
|
|
#pragma once
|
|
|
|
#include "bindings/gui/gui_element.hpp"
|
|
|
|
#include "lua_patch.hpp"
|
|
|
|
#include "sol.hpp"
|
2023-07-02 00:59:02 +02:00
|
|
|
#include "core/data/menu_event.hpp"
|
2023-07-05 00:30:57 +02:00
|
|
|
#include <services/gui/gui_service.hpp>
|
2023-06-06 07:40:40 +00:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class script;
|
|
|
|
|
|
|
|
class lua_module
|
|
|
|
{
|
2023-07-13 09:36:13 +02:00
|
|
|
std::unique_ptr<sol::state> m_state;
|
2023-07-02 22:32:46 +02:00
|
|
|
|
2023-06-06 07:40:40 +00:00
|
|
|
std::string m_module_name;
|
|
|
|
rage::joaat_t m_module_id;
|
|
|
|
|
2023-07-02 22:32:46 +02:00
|
|
|
std::chrono::time_point<std::chrono::file_clock> m_last_write_time;
|
|
|
|
|
2023-06-06 07:40:40 +00:00
|
|
|
public:
|
|
|
|
std::vector<script*> m_registered_scripts;
|
|
|
|
std::vector<std::shared_ptr<lua_patch>> m_registered_patches;
|
2023-07-05 00:30:57 +02:00
|
|
|
|
|
|
|
std::vector<big::tabs> m_owned_tabs;
|
|
|
|
|
|
|
|
std::unordered_map<big::tabs, std::vector<big::tabs>> m_tab_to_sub_tabs;
|
|
|
|
|
2023-07-17 14:55:42 +02:00
|
|
|
std::vector<std::shared_ptr<lua::gui::gui_element>> m_independent_gui;
|
2023-06-06 07:40:40 +00:00
|
|
|
std::unordered_map<rage::joaat_t, std::vector<std::shared_ptr<lua::gui::gui_element>>> m_gui;
|
2023-07-16 23:32:34 +02:00
|
|
|
std::unordered_map<menu_event, std::vector<sol::protected_function>> m_event_callbacks;
|
2023-06-06 07:40:40 +00:00
|
|
|
std::vector<void*> m_allocated_memory;
|
|
|
|
|
|
|
|
lua_module(std::string module_name);
|
|
|
|
~lua_module();
|
2023-06-27 20:13:05 +02:00
|
|
|
|
2023-07-02 22:32:46 +02:00
|
|
|
rage::joaat_t module_id() const;
|
|
|
|
const std::string& module_name() const;
|
|
|
|
const std::chrono::time_point<std::chrono::file_clock> last_write_time() const;
|
2023-06-27 20:13:05 +02:00
|
|
|
|
2023-07-13 09:36:13 +02:00
|
|
|
// used for sandboxing and limiting to only our custom search path for the lua require function
|
|
|
|
void set_folder_for_lua_require();
|
|
|
|
|
|
|
|
void sandbox_lua_os_library();
|
|
|
|
void sandbox_lua_loads();
|
2023-06-27 20:13:05 +02:00
|
|
|
|
|
|
|
void init_lua_api();
|
2023-06-06 07:40:40 +00:00
|
|
|
};
|
|
|
|
}
|