INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { static DWORD dwFilters; static DWORD dwpFilters; static LPCFOLDERDATA lpFilterRecord; char strText[250]; int i; switch (Msg) { case WM_INITDIALOG: { LPTREEFOLDER folder = GetCurrentFolder(); LPTREEFOLDER lpParent = NULL; LPCFILTER_ITEM g_lpFilterList = GetFilterList(); dwFilters = 0; if (folder != NULL) { char tmp[80]; win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText); Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1); // Mask out non filter flags dwFilters = folder->m_dwFlags & F_MASK; // Display current folder name in dialog titlebar snprintf(tmp,ARRAY_LENGTH(tmp),"Filters for %s Folder",folder->m_lpTitle); win_set_window_text_utf8(hDlg, tmp); if ( GetFilterInherit() ) { BOOL bShowExplanation = FALSE; lpParent = GetFolder( folder->m_nParent ); if( lpParent ) { /* Check the Parent Filters and inherit them on child, * No need to promote all games to parent folder, works as is */ dwpFilters = lpParent->m_dwFlags & F_MASK; /*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/ if( (dwpFilters & F_CLONES) && !(dwFilters & F_CLONES) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_RASTER) && !(dwFilters & F_RASTER) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_WORKING) && !(dwFilters & F_WORKING) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText); bShowExplanation = TRUE; } if( (dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL) ) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText, 250); strcat(strText, " (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText); bShowExplanation = TRUE; } /*Do not or in the Values of the parent, so that the values of the folder still can be set*/ //dwFilters |= dwpFilters; } if( ! bShowExplanation ) { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE ); } } else { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE ); } // Find the matching filter record if it exists lpFilterRecord = FindFilter(folder->m_nFolderId); // initialize and disable appropriate controls for (i = 0; g_lpFilterList[i].m_dwFilterType; i++) { DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters); } } SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT)); return FALSE; } case WM_HELP: // User clicked the ? from the upper right on a control HelpFunction((HWND)((LPHELPINFO)lParam)->hItemHandle, MAMEUICONTEXTHELP, HH_TP_HELP_WM_HELP, GetHelpIDs()); break; case WM_CONTEXTMENU: HelpFunction((HWND)wParam, MAMEUICONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs()); break; case WM_COMMAND: { WORD wID = GET_WM_COMMAND_ID(wParam, lParam); WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam); LPTREEFOLDER folder = GetCurrentFolder(); LPCFILTER_ITEM g_lpFilterList = GetFilterList(); switch (wID) { case IDOK: dwFilters = 0; win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText, FILTERTEXT_LEN); // see which buttons are checked for (i = 0; g_lpFilterList[i].m_dwFilterType; i++) { if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID))) dwFilters |= g_lpFilterList[i].m_dwFilterType; } // Mask out invalid filters dwFilters = ValidateFilters(lpFilterRecord, dwFilters); // Keep non filter flags folder->m_dwFlags &= ~F_MASK; // put in the set filters folder->m_dwFlags |= dwFilters; EndDialog(hDlg, 1); return TRUE; case IDCANCEL: EndDialog(hDlg, 0); return TRUE; default: // Handle unchecking mutually exclusive filters if (wNotifyCode == BN_CLICKED) EnableFilterExclusions(hDlg, wID); } } break; } return 0; }
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: { CenterWindow(hDlg); hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); hBrush = CreateSolidBrush(RGB(240, 240, 240)); DisableVisualStylesFilters(hDlg); LPTREEFOLDER folder = GetCurrentFolder(); LPTREEFOLDER lpParent = NULL; LPCFILTER_ITEM g_lpFilterList = GetFilterList(); dwFilters = 0; if (folder != NULL) { char tmp[80]; win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str()); Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1); // Mask out non filter flags dwFilters = folder->m_dwFlags & F_MASK; // Display current folder name in dialog titlebar snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle); win_set_window_text_utf8(hDlg, tmp); if (GetFilterInherit()) { lpParent = GetFolder(folder->m_nParent); bool bShowExplanation = false; if (lpParent) { std::string strText; /* Check the Parent Filters and inherit them on child, * No need to promote all games to parent folder, works as is */ dwpFilters = lpParent->m_dwFlags & F_MASK; /*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/ if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str()); bShowExplanation = true; } /*Do not or in the Values of the parent, so that the values of the folder still can be set*/ //dwFilters |= dwpFilters; } if(bShowExplanation) { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), true); } } else { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false); } // Find the matching filter record if it exists lpFilterRecord = FindFilter(folder->m_nFolderId); // initialize and disable appropriate controls for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++) { DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters); } } SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT)); return false; } case WM_CTLCOLORDLG: return (LRESULT) hBrush; case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: hDC = (HDC)wParam; SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); return (LRESULT) hBrush; case WM_COMMAND: { WORD wID = GET_WM_COMMAND_ID(wParam, lParam); WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam); LPTREEFOLDER folder = GetCurrentFolder(); LPCFILTER_ITEM g_lpFilterList = GetFilterList(); switch (wID) { case IDOK: dwFilters = 0; g_FilterText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT)); // see which buttons are checked for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++) { if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID))) dwFilters |= g_lpFilterList[i].m_dwFilterType; } // Mask out invalid filters dwFilters = ValidateFilters(lpFilterRecord, dwFilters); // Keep non filter flags folder->m_dwFlags &= ~F_MASK; // put in the set filters folder->m_dwFlags |= dwFilters; DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 1); return true; case IDCANCEL: DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); return true; default: // Handle unchecking mutually exclusive filters if (wNotifyCode == BN_CLICKED) EnableFilterExclusions(hDlg, wID); } break; } } return false; }