From 9f8f25fef2a8d98d3a2ac076da3f038d26d14c1c Mon Sep 17 00:00:00 2001 From: "avihal@gmail.com" Date: Mon, 7 Mar 2011 16:58:24 +0000 Subject: [PATCH] Menu: recent-ISO-list (dynamic list with automatic menu IDs) was clashing with other fixed menu IDs (specifically, the first item on the recent ISOs list got an "automatic" id of 100 (decimal) which happened to clash with multitap 2 menu item. Result: when clicking multitap2 menu item, the first iso gets selected instead - multitap2 menu was b0rked). Solution: reserve 100 IDs for the recent ISO list and use them. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4396 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/App.h | 3 ++- pcsx2/gui/AppRes.cpp | 8 ++++---- pcsx2/gui/RecentIsoList.cpp | 11 +++++++++-- pcsx2/gui/RecentIsoList.h | 6 ++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index b168b17a6c..031f444bb4 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -86,7 +86,8 @@ enum MenuIdentifiers MenuId_Src_NoDisc, MenuId_Boot_Iso, // Opens submenu with Iso browser, and recent isos. MenuId_IsoSelector, // Contains a submenu of selectable "favorite" isos - MenuId_IsoBrowse, // Open dialog, runs selected iso. + MenuId_RecentIsos_reservedStart, + MenuId_IsoBrowse = MenuId_RecentIsos_reservedStart + 100, // Open dialog, runs selected iso. MenuId_Boot_CDVD, MenuId_Boot_CDVD2, MenuId_Boot_ELF, diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 52db60fc93..8d0d6f60b7 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -66,11 +66,11 @@ const wxImage& LoadImageAny( return dest = onFail.Get(); } -RecentIsoList::RecentIsoList() +RecentIsoList::RecentIsoList(int firstIdForMenuItems_or_wxID_ANY) { Menu = new wxMenu(); Menu->Append( MenuId_IsoBrowse, _("Browse..."), _("Browse for an Iso that is not in your recent history.") ); - Manager = new RecentIsoManager( Menu ); + Manager = new RecentIsoManager( Menu, firstIdForMenuItems_or_wxID_ANY ); } pxAppResources::pxAppResources() @@ -81,13 +81,13 @@ pxAppResources::~pxAppResources() throw() {} wxMenu& Pcsx2App::GetRecentIsoMenu() { - if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList(); + if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList( MenuId_RecentIsos_reservedStart ); return *m_RecentIsoList->Menu; } RecentIsoManager& Pcsx2App::GetRecentIsoManager() { - if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList(); + if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList( MenuId_RecentIsos_reservedStart ); return *m_RecentIsoList->Manager; } diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index 7e3a50aae5..47dc7bf3a1 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -28,8 +28,9 @@ extern wxString GetMsg_IsoImageChanged(); // selecting another iso would be undesirable). -RecentIsoManager::RecentIsoManager( wxMenu* menu ) +RecentIsoManager::RecentIsoManager( wxMenu* menu, int firstIdForMenuItems_or_wxID_ANY ) : m_Menu( menu ) + , m_firstIdForMenuItems_or_wxID_ANY ( firstIdForMenuItems_or_wxID_ANY ) , m_MaxLength( g_Conf->RecentIsoCount ) { m_cursel = 0; @@ -160,11 +161,17 @@ void RecentIsoManager::Add( const wxString& src ) } } +//id here is the position index at the list of recent ISOs void RecentIsoManager::InsertIntoMenu( int id ) { if( m_Menu == NULL ) return; RecentItem& curitem( m_Items[id] ); - curitem.ItemPtr = m_Menu->Append( wxID_ANY, Path::GetFilename(curitem.Filename), curitem.Filename, wxITEM_RADIO ); + + int wxid=wxID_ANY; + if (this->m_firstIdForMenuItems_or_wxID_ANY != wxID_ANY) + wxid = this->m_firstIdForMenuItems_or_wxID_ANY + id; + + curitem.ItemPtr = m_Menu->Append( wxid, Path::GetFilename(curitem.Filename), curitem.Filename, wxITEM_RADIO ); if( m_cursel == id ) curitem.ItemPtr->Check(); diff --git a/pcsx2/gui/RecentIsoList.h b/pcsx2/gui/RecentIsoList.h index d7ea719159..e339542370 100644 --- a/pcsx2/gui/RecentIsoList.h +++ b/pcsx2/gui/RecentIsoList.h @@ -44,10 +44,12 @@ protected: uint m_MaxLength; int m_cursel; + int m_firstIdForMenuItems_or_wxID_ANY; + wxMenuItem* m_Separator; public: - RecentIsoManager( wxMenu* menu ); + RecentIsoManager( wxMenu* menu , int firstIdForMenuItems_or_wxID_ANY ); virtual ~RecentIsoManager() throw(); void RemoveAllFromMenu(); @@ -73,7 +75,7 @@ struct RecentIsoList ScopedPtr Manager; ScopedPtr Menu; - RecentIsoList(); + RecentIsoList(int firstIdForMenuItems_or_wxID_ANY); virtual ~RecentIsoList() throw() { } };