mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-04-27 20:51:40 +00:00
Mods folder button.
This commit is contained in:
parent
6ddd650cf2
commit
b8f0658343
2 changed files with 22 additions and 0 deletions
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <shellapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - Set up navigation.
|
// - Set up navigation.
|
||||||
// - Add hover and active state for mod entries.
|
// - Add hover and active state for mod entries.
|
||||||
|
|
@ -110,6 +114,19 @@ void ModMenu::refresh_mods() {
|
||||||
create_mod_list();
|
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) {
|
void ModMenu::mod_toggled(bool enabled) {
|
||||||
if (active_mod_index >= 0) {
|
if (active_mod_index >= 0) {
|
||||||
recomp::mods::enable_mod(mod_details[active_mod_index].mod_id, enabled);
|
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 = context.create_element<Button>(footer_container, "Refresh", recompui::ButtonStyle::Primary);
|
||||||
refresh_button->add_pressed_callback(std::bind(&ModMenu::refresh_mods, this));
|
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
|
} // footer_container
|
||||||
} // this
|
} // this
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual ~ModMenu();
|
virtual ~ModMenu();
|
||||||
private:
|
private:
|
||||||
void refresh_mods();
|
void refresh_mods();
|
||||||
|
void open_mods_folder();
|
||||||
void mod_toggled(bool enabled);
|
void mod_toggled(bool enabled);
|
||||||
void mod_selected(uint32_t mod_index);
|
void mod_selected(uint32_t mod_index);
|
||||||
void mod_dragged(uint32_t mod_index, EventDrag drag);
|
void mod_dragged(uint32_t mod_index, EventDrag drag);
|
||||||
|
|
@ -59,6 +60,7 @@ private:
|
||||||
ModDetailsPanel *mod_details_panel = nullptr;
|
ModDetailsPanel *mod_details_panel = nullptr;
|
||||||
Container *footer_container = nullptr;
|
Container *footer_container = nullptr;
|
||||||
Button *refresh_button = nullptr;
|
Button *refresh_button = nullptr;
|
||||||
|
Button *mods_folder_button = nullptr;
|
||||||
int32_t active_mod_index = -1;
|
int32_t active_mod_index = -1;
|
||||||
std::vector<ModEntryButton *> mod_entry_buttons;
|
std::vector<ModEntryButton *> mod_entry_buttons;
|
||||||
std::vector<Element *> mod_entry_spacers;
|
std::vector<Element *> mod_entry_spacers;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue