Updates recent files / recent directories menu @param menu Menu handle of the main window's menu @param strs Strings to add to the menu @param mitem Menu ID of the recent files / directory menu @param baseid Menu ID of the first subitem
| 631 | /// @param mitem Menu ID of the recent files / directory menu |
| 632 | /// @param baseid Menu ID of the first subitem |
| 633 | void UpdateRMenu(HMENU menu, char **strs, unsigned int mitem, unsigned int baseid) |
| 634 | { |
| 635 | // UpdateRMenu(recentmenu, recent_files, MENU_RECENT_FILES, MENU_FIRST_RECENT_FILE); |
| 636 | |
| 637 | MENUITEMINFO moo; |
| 638 | int x; |
| 639 | |
| 640 | moo.cbSize = sizeof(moo); |
| 641 | moo.fMask = MIIM_SUBMENU | MIIM_STATE; |
| 642 | |
| 643 | GetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); |
| 644 | moo.hSubMenu = menu; |
| 645 | moo.fState = strs[0] ? MFS_ENABLED : MFS_GRAYED; |
| 646 | |
| 647 | SetMenuItemInfo(GetSubMenu(fceumenu, 0), mitem, FALSE, &moo); |
| 648 | |
| 649 | // Remove all recent files submenus |
| 650 | for(x = 0; x < MAX_NUMBER_OF_RECENT_FILES; x++) |
| 651 | { |
| 652 | RemoveMenu(menu, baseid + x, MF_BYCOMMAND); |
| 653 | } |
| 654 | |
| 655 | // Recreate the menus |
| 656 | for(x = MAX_NUMBER_OF_RECENT_FILES - 1; x >= 0; x--) |
| 657 | { |
| 658 | // Skip empty strings |
| 659 | if(!strs[x]) |
| 660 | continue; |
| 661 | |
| 662 | std::string tmp = strs[x]; |
| 663 | std::string archiveName, fileName, fileToOpen; |
| 664 | FCEU_SplitArchiveFilename(tmp,archiveName,fileName,fileToOpen); |
| 665 | if(archiveName != "") |
| 666 | tmp = archiveName + " <" + fileName + ">"; |
| 667 | |
| 668 | //clamp this string to 128 chars |
| 669 | if(tmp.size()>128) |
| 670 | tmp = tmp.substr(0,128); |
| 671 | |
| 672 | moo.cbSize = sizeof(moo); |
| 673 | moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; |
| 674 | |
| 675 | //// Fill in the menu text. |
| 676 | //if(strlen(strs[x]) < 128) |
| 677 | //{ |
| 678 | // sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x]); |
| 679 | //} |
| 680 | //else |
| 681 | //{ |
| 682 | // sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, strs[x] + strlen( strs[x] ) - 127); |
| 683 | //} |
| 684 | |
| 685 | // Insert the menu item |
| 686 | moo.cch = tmp.size(); |
| 687 | moo.fType = 0; |
| 688 | moo.wID = baseid + x; |
| 689 | moo.dwTypeData = (LPSTR)tmp.c_str(); |
| 690 | InsertMenuItem(menu, 0, 1, &moo); |
no test coverage detected