diff --git a/src/core/devtools/widget/module_list.cpp b/src/core/devtools/widget/module_list.cpp index 46ec8df70..8603ecf87 100644 --- a/src/core/devtools/widget/module_list.cpp +++ b/src/core/devtools/widget/module_list.cpp @@ -13,25 +13,20 @@ using namespace ImGui; namespace Core::Devtools::Widget { +std::filesystem::path ModuleList::game_folder; + void ModuleList::Draw() { { - std::scoped_lock lock(s_modules_mutex); - modules.clear(); - for (const auto& entry : s_modules) { - ModuleInfo info; - info.name = entry.name; - info.is_sys_module = IsSystemModule(entry.path); - modules.push_back(info); - } + std::scoped_lock lock(modules_mutex); } SetNextWindowSize({550.0f, 600.0f}, ImGuiCond_FirstUseEver); - if (!Begin("LLE Module List", &open)) { + if (!Begin("Module List", &open)) { End(); return; } - if (BeginTable("ModuleTable", 2, + if (BeginTable("ModuleTable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg)) { TableSetupColumn("Modulname", ImGuiTableColumnFlags_WidthStretch); @@ -45,9 +40,16 @@ void ModuleList::Draw() { TableSetColumnIndex(1); if (module.is_sys_module) { - TextColored({0.0f, 1.0f, 0.0f, 1.0f}, "System Module"); + TextColored({0.2f, 0.6f, 0.8f, 1.0f}, "System Module"); } else { - TextColored({1.0f, 0.0f, 0.0f, 1.0f}, "Game Module"); + TextColored({0.8f, 0.4f, 0.2f, 1.0f}, "Game Module"); + } + + TableSetColumnIndex(2); + if (module.is_lle) { + TextColored({0.4f, 0.7f, 0.4f, 1.0f}, "LLE"); + } else { + TextColored({0.7f, 0.4f, 0.5f, 1.0f}, "HLE"); } } EndTable(); diff --git a/src/core/devtools/widget/module_list.h b/src/core/devtools/widget/module_list.h index 878039bee..b8feeb160 100644 --- a/src/core/devtools/widget/module_list.h +++ b/src/core/devtools/widget/module_list.h @@ -21,7 +21,13 @@ public: void Draw(); bool open = false; - bool IsSystemModule(const std::filesystem::path& path) { + static std::filesystem::path game_folder; + + static void SetGameFolder(const std::filesystem::path& path) { + game_folder = path; + } + + static bool IsSystemModule(const std::filesystem::path& path) { const auto sys_modules_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir); @@ -34,29 +40,50 @@ public: return path_str.starts_with(sys_path_str); } + static bool IsSystemModule(const std::string& name) { + const auto game_modules_path = game_folder / "sce_module"; + const auto prx_path = game_modules_path / name; + + if (!std::filesystem::exists(prx_path)) { + return true; + } + return false; + } + static void AddModule(const std::string& name, std::filesystem::path path) { if (name == "eboot.bin") { return; } - std::scoped_lock lock(s_modules_mutex); - s_modules.push_back({name, path}); + std::scoped_lock lock(modules_mutex); + modules.push_back({name, IsSystemModule(path), true}); + } + + static void AddModule(std::string& name) { + name = name + ".prx"; + std::scoped_lock lock(modules_mutex); + + bool is_sys_module = IsSystemModule(name); + bool is_lle = false; + auto it = std::find_if(modules.begin(), modules.end(), + [&name, is_sys_module, is_lle](const ModuleInfo& entry) { + return entry.name == name && entry.is_lle == false; + }); + + if (it == modules.end()) { + modules.push_back({name, is_sys_module, is_lle}); + } } private: struct ModuleInfo { std::string name; bool is_sys_module; + bool is_lle; }; - struct ModuleListEntry { - std::string name; - std::filesystem::path path; - }; + static inline std::mutex modules_mutex; - static inline std::vector s_modules; - static inline std::mutex s_modules_mutex; - - std::vector modules; + static inline std::vector modules; }; } // namespace Core::Devtools::Widget \ No newline at end of file diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 5fe4b7ca2..3e6d8c22e 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -329,6 +329,9 @@ bool Linker::Resolve(const std::string& name, Loader::SymbolType sym_type, Modul } if (record) { *return_info = *record; + + Core::Devtools::Widget::ModuleList::AddModule(sr.library); + return true; } diff --git a/src/emulator.cpp b/src/emulator.cpp index ebb34054b..bbb5076a8 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -25,6 +25,7 @@ #include "common/polyfill_thread.h" #include "common/scm_rev.h" #include "common/singleton.h" +#include "core/devtools/widget/module_list.h" #include "core/file_format/psf.h" #include "core/file_format/trp.h" #include "core/file_sys/fs.h" @@ -75,6 +76,8 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector::Instance(); mnt->Mount(game_folder, "/app0", true);