mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2025-04-06 05:56:41 +02:00
Mods folder button.
This commit is contained in:
parent
0752128d68
commit
b0fcfa87ec
@ -5,6 +5,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <shellapi.h>
|
||||
#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<Button>(footer_container, "Refresh", recompui::ButtonStyle::Primary);
|
||||
refresh_button->add_pressed_callback(std::bind(&ModMenu::refresh_mods, this));
|
||||
|
||||
mods_folder_button = context.create_element<Button>(footer_container, "Open Mods Folder", recompui::ButtonStyle::Primary);
|
||||
mods_folder_button->add_pressed_callback(std::bind(&ModMenu::open_mods_folder, this));
|
||||
} // footer_container
|
||||
} // this
|
||||
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
virtual ~ModMenu();
|
||||
private:
|
||||
void refresh_mods();
|
||||
void open_mods_folder();
|
||||
void mod_toggled(bool enabled);
|
||||
void mod_selected(uint32_t mod_index);
|
||||
void mod_dragged(uint32_t mod_index, EventDrag drag);
|
||||
@ -59,6 +60,7 @@ private:
|
||||
ModDetailsPanel *mod_details_panel = nullptr;
|
||||
Container *footer_container = nullptr;
|
||||
Button *refresh_button = nullptr;
|
||||
Button *mods_folder_button = nullptr;
|
||||
int32_t active_mod_index = -1;
|
||||
std::vector<ModEntryButton *> mod_entry_buttons;
|
||||
std::vector<Element *> mod_entry_spacers;
|
||||
|
Loading…
x
Reference in New Issue
Block a user