mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
Add Remove Game option to Gameviewer
Can right click game to remove from list and installation
This commit is contained in:
parent
934856c350
commit
dab71d01c1
2 changed files with 79 additions and 3 deletions
|
@ -10,8 +10,12 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent)
|
||||||
|
|
||||||
m_path = "/dev_hdd0/game/";
|
m_path = "/dev_hdd0/game/";
|
||||||
|
|
||||||
|
m_popup = new wxMenu();
|
||||||
|
m_popup->Append(0, _T("Remove Game"));
|
||||||
|
|
||||||
Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this);
|
Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this);
|
||||||
Bind(wxEVT_LIST_COL_CLICK, &GameViewer::OnColClick, this);
|
Bind(wxEVT_LIST_COL_CLICK, &GameViewer::OnColClick, this);
|
||||||
|
Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &GameViewer::RightClick, this);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -84,6 +88,7 @@ void GameViewer::LoadGames()
|
||||||
m_games.push_back(info->name);
|
m_games.push_back(info->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dir.Close();
|
||||||
|
|
||||||
//ConLog.Write("path: %s", m_path.wx_str());
|
//ConLog.Write("path: %s", m_path.wx_str());
|
||||||
//ConLog.Write("folders count: %d", m_games.GetCount());
|
//ConLog.Write("folders count: %d", m_games.GetCount());
|
||||||
|
@ -163,3 +168,71 @@ void GameViewer::DClick(wxListEvent& event)
|
||||||
}
|
}
|
||||||
Emu.Run();
|
Emu.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameViewer::RightClick(wxListEvent& event)
|
||||||
|
{
|
||||||
|
m_popup->Destroy(m_popup->FindItemByPosition(0));
|
||||||
|
|
||||||
|
wxMenuItem *pMenuItemA = m_popup->Append(event.GetIndex(), _T("Remove Game"));
|
||||||
|
Bind(wxEVT_MENU, &GameViewer::RemoveGame, this, event.GetIndex());
|
||||||
|
PopupMenu(m_popup, event.GetPoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
class WxDirDeleteTraverser : public wxDirTraverser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual wxDirTraverseResult OnFile(const wxString& filename)
|
||||||
|
{
|
||||||
|
if (!wxRemoveFile(filename)){
|
||||||
|
ConLog.Error("Couldn't delete File: %s", fmt::ToUTF8(filename).c_str());
|
||||||
|
}
|
||||||
|
return wxDIR_CONTINUE;
|
||||||
|
}
|
||||||
|
virtual wxDirTraverseResult OnDir(const wxString& dirname)
|
||||||
|
{
|
||||||
|
wxDir dir(dirname);
|
||||||
|
dir.Traverse(*this);
|
||||||
|
if (!wxRmDir(dirname)){
|
||||||
|
//this get triggered a few times while clearing folders
|
||||||
|
//but if this gets reimplented we should probably warn
|
||||||
|
//if directories can't be removed
|
||||||
|
}
|
||||||
|
return wxDIR_CONTINUE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void GameViewer::RemoveGame(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxString GameName = this->GetItemText(event.GetId(), 5);
|
||||||
|
|
||||||
|
Emu.GetVFS().Init(m_path);
|
||||||
|
vfsDir dir(m_path);
|
||||||
|
if (!dir.IsOpened()) return;
|
||||||
|
|
||||||
|
std::string sPath = dir.GetPath();
|
||||||
|
std::string sGameFolder = GameName.mb_str().data();
|
||||||
|
|
||||||
|
Emu.GetVFS().UnMountAll();
|
||||||
|
|
||||||
|
sPath.erase(0, 1);
|
||||||
|
|
||||||
|
RemoveFolder(sPath + sGameFolder);
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameViewer::RemoveFolder(std::string localPath)
|
||||||
|
{
|
||||||
|
//TODO: replace wxWidgetsSpecific filesystem stuff
|
||||||
|
if (wxDirExists(fmt::FromUTF8(localPath))){
|
||||||
|
WxDirDeleteTraverser deleter;
|
||||||
|
wxDir dir(localPath);
|
||||||
|
dir.Traverse(deleter);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -242,7 +242,7 @@ class GameViewer : public wxListView
|
||||||
std::vector<std::string> m_games;
|
std::vector<std::string> m_games;
|
||||||
std::vector<GameInfo> m_game_data;
|
std::vector<GameInfo> m_game_data;
|
||||||
ColumnsArr m_columns;
|
ColumnsArr m_columns;
|
||||||
|
wxMenu* m_popup;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ListSortInfo SortInfo;
|
ListSortInfo SortInfo;
|
||||||
|
@ -260,7 +260,10 @@ public:
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
void RemoveGame(wxCommandEvent& event);
|
||||||
|
bool RemoveFolder(std::string localPath);
|
||||||
private:
|
private:
|
||||||
virtual void DClick(wxListEvent& event);
|
virtual void DClick(wxListEvent& event);
|
||||||
void OnColClick(wxListEvent& event);
|
virtual void OnColClick(wxListEvent& event);
|
||||||
|
virtual void RightClick(wxListEvent& event);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue