lua: sub folders support, check for .lua file extension, refactor and simplify internals. (#1775)

This commit is contained in:
Quentin
2023-07-22 13:05:43 +02:00
committed by GitHub
parent 093abc72da
commit fa8043be2a
15 changed files with 288 additions and 300 deletions

View File

@ -18,8 +18,8 @@ namespace big
{
g_lua_manager->for_each_module([](auto& module) {
if (ImGui::Selectable(module->module_name().c_str(),
!selected_module.expired() && selected_module.lock().get() == module.get()))
selected_module = module;
!selected_module.expired() && selected_module.lock().get() == module.get()))
selected_module = module;
});
ImGui::EndListBox();
@ -37,13 +37,12 @@ namespace big
if (components::button("Reload"))
{
auto name = selected_module.lock()->module_name();
auto id = selected_module.lock()->module_id();
const std::filesystem::path module_path = selected_module.lock()->module_path();
const auto id = selected_module.lock()->module_id();
g_lua_manager->unload_module(id);
g_lua_manager->queue_load_module(name, [](std::weak_ptr<big::lua_module> loaded_module) {
selected_module = loaded_module;
});
g_lua_manager->load_module(module_path);
selected_module = g_lua_manager->get_module(id);
}
}
@ -51,7 +50,8 @@ namespace big
if (components::button("Reload All"))
{
g_lua_manager->m_schedule_reload_modules = true;
g_lua_manager->unload_all_modules();
g_lua_manager->load_all_modules();
}
ImGui::SameLine();
ImGui::Checkbox("Auto Reload Changed Scripts", &g.lua.enable_auto_reload_changed_scripts);