From: <sag...@us...> - 2013-12-26 18:32:15
|
Revision: 3529 http://sourceforge.net/p/modplug/code/3529 Author: saga-games Date: 2013-12-26 18:32:07 +0000 (Thu, 26 Dec 2013) Log Message: ----------- [Fix] Now the MRU list should be finally working... I think. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-26 18:32:07 UTC (rev 3529) @@ -2621,19 +2621,32 @@ } +// Hack-ish way to get the file menu (this is necessary because the MDI document icon next to the File menu is a sub menu, too). +CMenu *CMainFrame::GetFileMenu() const +//------------------------------------ +{ + CMenu *mainMenu = GetMenu(); + CMenu *fileMenu = mainMenu ? mainMenu->GetSubMenu(0) : nullptr; + if(fileMenu) + { + if(fileMenu->GetMenuItemID(1) != ID_FILE_OPEN) + fileMenu = mainMenu->GetSubMenu(1); + ASSERT(fileMenu->GetMenuItemID(1) == ID_FILE_OPEN); + } + ASSERT(fileMenu); + return fileMenu; +} + + void CMainFrame::CreateTemplateModulesMenu() //------------------------------------------ { static_assert(nMaxItemsInTemplateModulesMenu == ID_FILE_OPENTEMPLATE_LASTINRANGE - ID_FILE_OPENTEMPLATE + 1, "Make sure that there's a proper range for menu commands in resources."); HMENU hMenu = CreateFileMenu(nMaxItemsInTemplateModulesMenu, s_TemplateModulePaths, MPT_PATHSTRING("TemplateModules\\"), ID_FILE_OPENTEMPLATE); - CMenu* const pMainMenu = GetMenu(); - CMenu* pFileMenu = (pMainMenu) ? pMainMenu->GetSubMenu(0) : nullptr; + CMenu *pFileMenu = GetFileMenu(); if (hMenu && pFileMenu && m_InputHandler) { - if (pFileMenu->GetMenuItemID(1) != ID_FILE_OPEN) - pFileMenu = pMainMenu->GetSubMenu(1); - ASSERT(pFileMenu->GetMenuItemID(1) == ID_FILE_OPEN); VERIFY(pFileMenu->RemoveMenu(2, MF_BYPOSITION)); VERIFY(pFileMenu->InsertMenu(2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)hMenu, m_InputHandler->GetMenuText(ID_FILE_OPENTEMPLATE))); } @@ -2645,7 +2658,7 @@ void CMainFrame::UpdateMRUList() //------------------------------ { - CMenu *pMenu = (CMainFrame::GetMainFrame())->GetMenu()->GetSubMenu(0); + CMenu *pMenu = GetFileMenu(); static int firstMenu = -1; if(firstMenu == -1) { @@ -2697,10 +2710,10 @@ s += path; } else { - // Shorten path - size_t start = path.find_first_of(L"\\/"); + // Shorten path ("C:\Foo\VeryLongString...\Bar.it" => "C:\Foo\...\Bar.it") + size_t start = path.find_first_of(L"\\/", path.find_first_of(L"\\/") + 1); size_t end = path.find_last_of(L"\\/"); - if(start != end) + if(start < end) { s += path.substr(0, start + 1) + L"..." + path.substr(end); } else Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-26 18:32:07 UTC (rev 3529) @@ -396,6 +396,7 @@ void CreateExampleModulesMenu(); void CreateTemplateModulesMenu(); + CMenu *GetFileMenu() const; /// Creates submenu whose items are filenames of files in both /// AppDirectory\pszFolderName\ (usually C:\program files\OpenMPT\pszFolderName\) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-26 18:32:07 UTC (rev 3529) @@ -86,6 +86,10 @@ { if(!filename.empty()) { + if(CMainFrame::GetMainFrame() && addToMru) + { + CMainFrame::GetMainFrame()->UpdateMRUList(); + } if(PathFileExistsW(filename.AsNative().c_str()) == FALSE) { Reporting::Error(L"Unable to open \"" + filename.ToWide() + L"\": file does not exist."); @@ -606,8 +610,8 @@ } -void CTrackApp::AddToRecentFileList(const mpt::PathString &path) -//-------------------------------------------------------------- +void CTrackApp::AddToRecentFileList(const mpt::PathString path) +//------------------------------------------------------------- { RemoveMruItem(path); TrackerSettings::Instance().mruFiles.insert(TrackerSettings::Instance().mruFiles.begin(), path); Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-12-26 18:32:07 UTC (rev 3529) @@ -178,7 +178,7 @@ #endif MPT_DEPRECATED_PATH virtual void AddToRecentFileList(LPCTSTR lpszPathName); - void AddToRecentFileList(const mpt::PathString &path); + void AddToRecentFileList(const mpt::PathString path); /// Removes item from MRU-list; most recent item has index zero. void RemoveMruItem(const size_t item); void RemoveMruItem(const mpt::PathString &path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |