2015-03-18 22:00:27 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2015-03-18 22:00:27 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-11-05 12:29:29 +00:00
|
|
|
#include "DolphinWX/Config/PathConfigPane.h"
|
|
|
|
|
2015-03-18 22:00:27 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/dirdlg.h>
|
|
|
|
#include <wx/filepicker.h>
|
|
|
|
#include <wx/gbsizer.h>
|
|
|
|
#include <wx/listbox.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
|
2015-05-08 21:28:03 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2015-03-18 22:00:27 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "DiscIO/NANDContentLoader.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Config/ConfigMain.h"
|
2015-03-18 22:00:27 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
2016-11-05 12:29:29 +00:00
|
|
|
#include "DolphinWX/WxEventUtils.h"
|
2015-03-18 22:00:27 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
PathConfigPane::PathConfigPane(wxWindow* panel, wxWindowID id) : wxPanel(panel, id)
|
2015-03-18 22:00:27 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
InitializeGUI();
|
|
|
|
LoadGUIValues();
|
2016-11-05 12:29:29 +00:00
|
|
|
BindEvents();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::InitializeGUI()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_iso_paths_listbox = new wxListBox(this, wxID_ANY);
|
|
|
|
m_recursive_iso_paths_checkbox = new wxCheckBox(this, wxID_ANY, _("Search Subfolders"));
|
|
|
|
m_add_iso_path_button = new wxButton(this, wxID_ANY, _("Add..."));
|
|
|
|
m_remove_iso_path_button = new wxButton(this, wxID_ANY, _("Remove"));
|
|
|
|
m_remove_iso_path_button->Disable();
|
|
|
|
|
|
|
|
m_default_iso_filepicker = new wxFilePickerCtrl(
|
|
|
|
this, wxID_ANY, wxEmptyString, _("Choose a default ISO:"),
|
2016-12-17 13:48:49 +00:00
|
|
|
_("All GC/Wii files (elf, dol, gcm, iso, tgc, wbfs, ciso, gcz, wad)") +
|
|
|
|
wxString::Format("|*.elf;*.dol;*.gcm;*.iso;*.tgc;*.wbfs;*.ciso;*.gcz;*.wad|%s",
|
2016-06-24 08:43:46 +00:00
|
|
|
wxGetTranslation(wxALL_FILES)),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL | wxFLP_OPEN | wxFLP_SMALL);
|
|
|
|
m_dvd_root_dirpicker =
|
|
|
|
new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, _("Choose a DVD root directory:"),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL | wxDIRP_SMALL);
|
|
|
|
m_apploader_path_filepicker = new wxFilePickerCtrl(
|
|
|
|
this, wxID_ANY, wxEmptyString,
|
|
|
|
_("Choose file to use as apploader: (applies to discs constructed from directories only)"),
|
|
|
|
_("apploader (.img)") + wxString::Format("|*.img|%s", wxGetTranslation(wxALL_FILES)),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL | wxFLP_OPEN | wxFLP_SMALL);
|
|
|
|
m_nand_root_dirpicker =
|
|
|
|
new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, _("Choose a NAND root directory:"),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL | wxDIRP_SMALL);
|
2016-06-25 15:24:43 +00:00
|
|
|
m_dump_path_dirpicker =
|
|
|
|
new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, _("Choose a dump directory:"),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL | wxDIRP_SMALL);
|
2016-07-27 07:32:27 +00:00
|
|
|
m_wii_sdcard_filepicker = new wxFilePickerCtrl(
|
|
|
|
this, wxID_ANY, wxEmptyString, _("Choose an SD Card file:"), wxFileSelectorDefaultWildcardStr,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL | wxDIRP_SMALL);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-08-02 06:22:37 +00:00
|
|
|
const int space5 = FromDIP(5);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxBoxSizer* const iso_button_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2016-08-02 06:22:37 +00:00
|
|
|
iso_button_sizer->Add(m_recursive_iso_paths_checkbox, 0, wxALIGN_CENTER_VERTICAL);
|
2016-06-24 08:43:46 +00:00
|
|
|
iso_button_sizer->AddStretchSpacer();
|
2016-08-02 06:22:37 +00:00
|
|
|
iso_button_sizer->Add(m_add_iso_path_button, 0, wxALIGN_CENTER_VERTICAL);
|
|
|
|
iso_button_sizer->Add(m_remove_iso_path_button, 0, wxALIGN_CENTER_VERTICAL);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* const iso_listbox_sizer =
|
|
|
|
new wxStaticBoxSizer(wxVERTICAL, this, _("ISO Directories"));
|
2016-08-02 06:22:37 +00:00
|
|
|
iso_listbox_sizer->Add(m_iso_paths_listbox, 1, wxEXPAND);
|
|
|
|
iso_listbox_sizer->AddSpacer(space5);
|
|
|
|
iso_listbox_sizer->Add(iso_button_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
iso_listbox_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-08-02 06:22:37 +00:00
|
|
|
wxGridBagSizer* const picker_sizer = new wxGridBagSizer(space5, space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("Default ISO:")), wxGBPosition(0, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_default_iso_filepicker, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("DVD Root:")), wxGBPosition(1, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_dvd_root_dirpicker, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("Apploader:")), wxGBPosition(2, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_apploader_path_filepicker, wxGBPosition(2, 1), wxDefaultSpan, wxEXPAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("Wii NAND Root:")), wxGBPosition(3, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_nand_root_dirpicker, wxGBPosition(3, 1), wxDefaultSpan, wxEXPAND);
|
2016-06-25 15:24:43 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("Dump Path:")), wxGBPosition(4, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_dump_path_dirpicker, wxGBPosition(4, 1), wxDefaultSpan, wxEXPAND);
|
2016-07-27 07:32:27 +00:00
|
|
|
picker_sizer->Add(new wxStaticText(this, wxID_ANY, _("SD Card Path:")), wxGBPosition(5, 0),
|
2016-08-02 06:22:37 +00:00
|
|
|
wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
|
|
|
|
picker_sizer->Add(m_wii_sdcard_filepicker, wxGBPosition(5, 1), wxDefaultSpan, wxEXPAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
picker_sizer->AddGrowableCol(1);
|
|
|
|
|
|
|
|
// Populate the Paths page
|
|
|
|
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
2016-08-02 06:22:37 +00:00
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(iso_listbox_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
|
|
|
main_sizer->Add(picker_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
|
|
|
main_sizer->AddSpacer(space5);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
SetSizer(main_sizer);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::LoadGUIValues()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
const SConfig& startup_params = SConfig::GetInstance();
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
m_recursive_iso_paths_checkbox->SetValue(SConfig::GetInstance().m_RecursiveISOFolder);
|
|
|
|
m_default_iso_filepicker->SetPath(StrToWxStr(startup_params.m_strDefaultISO));
|
|
|
|
m_dvd_root_dirpicker->SetPath(StrToWxStr(startup_params.m_strDVDRoot));
|
|
|
|
m_apploader_path_filepicker->SetPath(StrToWxStr(startup_params.m_strApploader));
|
|
|
|
m_nand_root_dirpicker->SetPath(StrToWxStr(SConfig::GetInstance().m_NANDPath));
|
2016-06-25 15:24:43 +00:00
|
|
|
m_dump_path_dirpicker->SetPath(StrToWxStr(SConfig::GetInstance().m_DumpPath));
|
2016-07-27 07:32:27 +00:00
|
|
|
m_wii_sdcard_filepicker->SetPath(StrToWxStr(SConfig::GetInstance().m_strWiiSDCardPath));
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Update selected ISO paths
|
|
|
|
for (const std::string& folder : SConfig::GetInstance().m_ISOFolder)
|
|
|
|
m_iso_paths_listbox->Append(StrToWxStr(folder));
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2016-11-05 12:29:29 +00:00
|
|
|
void PathConfigPane::BindEvents()
|
2015-03-18 22:00:27 +00:00
|
|
|
{
|
2016-11-05 12:29:29 +00:00
|
|
|
m_iso_paths_listbox->Bind(wxEVT_LISTBOX, &PathConfigPane::OnISOPathSelectionChanged, this);
|
|
|
|
m_recursive_iso_paths_checkbox->Bind(wxEVT_CHECKBOX,
|
|
|
|
&PathConfigPane::OnRecursiveISOCheckBoxChanged, this);
|
|
|
|
m_add_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnAddISOPath, this);
|
|
|
|
m_remove_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnRemoveISOPath, this);
|
|
|
|
m_default_iso_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnDefaultISOChanged,
|
|
|
|
this);
|
|
|
|
m_dvd_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDVDRootChanged, this);
|
|
|
|
m_apploader_path_filepicker->Bind(wxEVT_FILEPICKER_CHANGED,
|
|
|
|
&PathConfigPane::OnApploaderPathChanged, this);
|
|
|
|
m_nand_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnNANDRootChanged, this);
|
|
|
|
m_dump_path_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDumpPathChanged, this);
|
|
|
|
m_wii_sdcard_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnSdCardPathChanged,
|
|
|
|
this);
|
|
|
|
|
|
|
|
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnISOPathSelectionChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_remove_iso_path_button->Enable(m_iso_paths_listbox->GetSelection() != wxNOT_FOUND);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnRecursiveISOCheckBoxChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_RecursiveISOFolder = m_recursive_iso_paths_checkbox->IsChecked();
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AddPendingEvent(wxCommandEvent(wxDOLPHIN_CFG_REFRESH_LIST));
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnAddISOPath(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxDirDialog dialog(this, _("Choose a directory to add"), wxGetHomeDir(),
|
|
|
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
|
|
|
|
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
if (m_iso_paths_listbox->FindString(dialog.GetPath()) != wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
WxUtils::ShowErrorDialog(_("The chosen directory is already in the list."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddPendingEvent(wxCommandEvent(wxDOLPHIN_CFG_REFRESH_LIST));
|
|
|
|
m_iso_paths_listbox->Append(dialog.GetPath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveISOPathChanges();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnRemoveISOPath(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
AddPendingEvent(wxCommandEvent(wxDOLPHIN_CFG_REFRESH_LIST));
|
|
|
|
m_iso_paths_listbox->Delete(m_iso_paths_listbox->GetSelection());
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// This seems to not be activated on Windows when it should be. wxw bug?
|
2015-03-18 22:00:27 +00:00
|
|
|
#ifdef _WIN32
|
2016-06-24 08:43:46 +00:00
|
|
|
OnISOPathSelectionChanged(wxCommandEvent());
|
2015-03-18 22:00:27 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
SaveISOPathChanges();
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnDefaultISOChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strDefaultISO = WxStrToStr(m_default_iso_filepicker->GetPath());
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnDVDRootChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strDVDRoot = WxStrToStr(m_dvd_root_dirpicker->GetPath());
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathConfigPane::OnApploaderPathChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strApploader = WxStrToStr(m_apploader_path_filepicker->GetPath());
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2016-07-27 07:32:27 +00:00
|
|
|
void PathConfigPane::OnSdCardPathChanged(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
std::string sd_card_path = WxStrToStr(m_wii_sdcard_filepicker->GetPath());
|
|
|
|
SConfig::GetInstance().m_strWiiSDCardPath = sd_card_path;
|
|
|
|
File::SetUserPath(F_WIISDCARD_IDX, sd_card_path);
|
|
|
|
}
|
|
|
|
|
2015-03-18 22:00:27 +00:00
|
|
|
void PathConfigPane::OnNANDRootChanged(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string nand_path = SConfig::GetInstance().m_NANDPath =
|
|
|
|
WxStrToStr(m_nand_root_dirpicker->GetPath());
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
File::SetUserPath(D_WIIROOT_IDX, nand_path);
|
|
|
|
m_nand_root_dirpicker->SetPath(StrToWxStr(nand_path));
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
DiscIO::CNANDContentManager::Access().ClearCache();
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-11-09 01:52:45 +00:00
|
|
|
wxCommandEvent update_event{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, GetId()};
|
|
|
|
update_event.SetEventObject(this);
|
|
|
|
AddPendingEvent(update_event);
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-25 15:24:43 +00:00
|
|
|
void PathConfigPane::OnDumpPathChanged(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
std::string dump_path = SConfig::GetInstance().m_DumpPath =
|
|
|
|
WxStrToStr(m_dump_path_dirpicker->GetPath());
|
|
|
|
|
|
|
|
m_dump_path_dirpicker->SetPath(StrToWxStr(dump_path));
|
|
|
|
}
|
|
|
|
|
2015-03-18 22:00:27 +00:00
|
|
|
void PathConfigPane::SaveISOPathChanges()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_ISOFolder.clear();
|
2015-03-18 22:00:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
for (unsigned int i = 0; i < m_iso_paths_listbox->GetCount(); i++)
|
|
|
|
SConfig::GetInstance().m_ISOFolder.push_back(WxStrToStr(m_iso_paths_listbox->GetStrings()[i]));
|
2015-03-18 22:00:27 +00:00
|
|
|
}
|