mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-10 03:40:04 +00:00
Simplify the popup menu. You can reuse the popup menu. So, no need to create/delete each time. Also, deleting stuff from a for each iterator is generally a bad idea.
This commit is contained in:
parent
458dbbd15d
commit
0c8bda4f41
@ -43,6 +43,7 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent)
|
|||||||
m_sortColumn = 1;
|
m_sortColumn = 1;
|
||||||
m_sortAscending = true;
|
m_sortAscending = true;
|
||||||
m_popup = new wxMenu();
|
m_popup = new wxMenu();
|
||||||
|
InitPopupMenu();
|
||||||
|
|
||||||
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);
|
||||||
@ -56,6 +57,24 @@ GameViewer::~GameViewer()
|
|||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameViewer::InitPopupMenu()
|
||||||
|
{
|
||||||
|
wxMenuItem* boot_item = new wxMenuItem(m_popup, 0, _T("Boot"));
|
||||||
|
#if defined (_WIN32)
|
||||||
|
// wxMenuItem::Set(Get)Font only available for the wxMSW port
|
||||||
|
wxFont font = GetFont();
|
||||||
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
|
boot_item->SetFont(font);
|
||||||
|
#endif
|
||||||
|
m_popup->Append(boot_item);
|
||||||
|
m_popup->Append(1, _T("Configure"));
|
||||||
|
m_popup->Append(2, _T("Remove Game"));
|
||||||
|
|
||||||
|
Bind(wxEVT_MENU, &GameViewer::BootGame, this, 0);
|
||||||
|
Bind(wxEVT_MENU, &GameViewer::ConfigureGame, this, 1);
|
||||||
|
Bind(wxEVT_MENU, &GameViewer::RemoveGame, this, 2);
|
||||||
|
}
|
||||||
|
|
||||||
void GameViewer::DoResize(wxSize size)
|
void GameViewer::DoResize(wxSize size)
|
||||||
{
|
{
|
||||||
SetSize(size);
|
SetSize(size);
|
||||||
@ -198,25 +217,6 @@ void GameViewer::DClick(wxListEvent& event)
|
|||||||
|
|
||||||
void GameViewer::RightClick(wxListEvent& event)
|
void GameViewer::RightClick(wxListEvent& event)
|
||||||
{
|
{
|
||||||
for (wxMenuItem *item : m_popup->GetMenuItems()) {
|
|
||||||
m_popup->Destroy(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMenuItem* boot_item = new wxMenuItem(m_popup, 0, _T("Boot"));
|
|
||||||
#if defined (_WIN32)
|
|
||||||
// wxMenuItem::Set(Get)Font only available for the wxMSW port
|
|
||||||
wxFont font = GetFont();
|
|
||||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
|
||||||
boot_item->SetFont(font);
|
|
||||||
#endif
|
|
||||||
m_popup->Append(boot_item);
|
|
||||||
m_popup->Append(1, _T("Configure"));
|
|
||||||
m_popup->Append(2, _T("Remove Game"));
|
|
||||||
|
|
||||||
Bind(wxEVT_MENU, &GameViewer::BootGame, this, 0);
|
|
||||||
Bind(wxEVT_MENU, &GameViewer::ConfigureGame, this, 1);
|
|
||||||
Bind(wxEVT_MENU, &GameViewer::RemoveGame, this, 2);
|
|
||||||
|
|
||||||
PopupMenu(m_popup, event.GetPoint());
|
PopupMenu(m_popup, event.GetPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ public:
|
|||||||
GameViewer(wxWindow* parent);
|
GameViewer(wxWindow* parent);
|
||||||
~GameViewer();
|
~GameViewer();
|
||||||
|
|
||||||
|
void InitPopupMenu();
|
||||||
|
|
||||||
void DoResize(wxSize size);
|
void DoResize(wxSize size);
|
||||||
|
|
||||||
void LoadGames();
|
void LoadGames();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user