Add "Open Game Folder" Option" (#2595)

This commit is contained in:
Megamouse 2017-03-27 00:11:08 +02:00 committed by Ivan
parent 3ec1fe9ee7
commit 51cd98c9f4
2 changed files with 28 additions and 1 deletions

View File

@ -70,11 +70,12 @@ void GameViewer::InitPopupMenu()
m_popup->Append(1, _T("Configure"));
m_popup->Append(2, _T("Remove Game"));
m_popup->Append(3, _T("Remove Custom Configuration"));
m_popup->Append(4, _T("Open Game Folder"));
Bind(wxEVT_MENU, &GameViewer::BootGame, this, 0);
Bind(wxEVT_MENU, &GameViewer::ConfigureGame, this, 1);
Bind(wxEVT_MENU, &GameViewer::RemoveGame, this, 2);
Bind(wxEVT_MENU, &GameViewer::RemoveGameConfig, this, 3);
Bind(wxEVT_MENU, &GameViewer::OpenGameFolder, this, 4);
}
void GameViewer::DoResize(wxSize size)
@ -259,6 +260,31 @@ void GameViewer::RemoveGameConfig(wxCommandEvent& event)
Refresh();
}
void GameViewer::OpenGameFolder(wxCommandEvent& event)
{
long i = GetFirstSelected();
if (i < 0) return;
const std::string& spath = Emu.GetGameDir() + m_game_data[i].root;
#ifdef _WIN32
std::string command = "explorer " + spath;
std::string oldc("/"), newc("\\");
size_t pos = 0;
while ((pos = command.find(oldc, pos)) != std::string::npos) {
command.replace(pos, oldc.length(), newc);
pos += newc.length();
}
wxExecute(fmt::FromUTF8(command));
#elif __APPLE__
std::string command = "open " + spath;
wxExecute(fmt::FromUTF8(command));
#elif __Linux
std::string command = "xdg-open " + spath;
wxExecute(fmt::FromUTF8(command));
#endif
}
ColumnsArr::ColumnsArr()
{
Init();

View File

@ -88,6 +88,7 @@ public:
void ConfigureGame(wxCommandEvent& event);
void RemoveGame(wxCommandEvent& event);
void RemoveGameConfig(wxCommandEvent& event);
void OpenGameFolder(wxCommandEvent & event);
private:
virtual void DClick(wxListEvent& event);