From b8f0658343a3b337a1228457f767b0fd2be60337 Mon Sep 17 00:00:00 2001 From: Dario Date: Mon, 27 Jan 2025 20:45:48 -0300 Subject: [PATCH] Mods folder button. --- src/ui/ui_mod_menu.cpp | 20 ++++++++++++++++++++ src/ui/ui_mod_menu.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/ui/ui_mod_menu.cpp b/src/ui/ui_mod_menu.cpp index 13d785b..aa77e3d 100644 --- a/src/ui/ui_mod_menu.cpp +++ b/src/ui/ui_mod_menu.cpp @@ -5,6 +5,10 @@ #include +#ifdef WIN32 +#include +#endif + // TODO: // - Set up navigation. // - Add hover and active state for mod entries. @@ -110,6 +114,19 @@ void ModMenu::refresh_mods() { create_mod_list(); } +void ModMenu::open_mods_folder() { + std::filesystem::path mods_directory = recomp::mods::get_mods_directory(); +#if defined(WIN32) + std::wstring path_wstr = mods_directory.wstring(); + ShellExecuteW(NULL, L"open", path_wstr.c_str(), NULL, NULL, SW_SHOWDEFAULT); +#elif defined(__linux__) + std::string command = "xdg-open " + mods_directory.string() + " &"; + std::system(command.c_str()); +#else + static_assert(false, "Not implemented for this platform."); +#endif +} + void ModMenu::mod_toggled(bool enabled) { if (active_mod_index >= 0) { recomp::mods::enable_mod(mod_details[active_mod_index].mod_id, enabled); @@ -360,6 +377,9 @@ ModMenu::ModMenu(Element *parent) : Element(parent) { { refresh_button = context.create_element