* Populates the hotkey ListView according to the rules set * by the current filter. * * @param hwndDlg Handle of the Map Input dialog. **/
| 184 | * @param hwndDlg Handle of the Map Input dialog. |
| 185 | **/ |
| 186 | void PopulateMappingDisplay(HWND hwndDlg) |
| 187 | { |
| 188 | // Get the ListView handle. |
| 189 | HWND hwndListView = GetDlgItem(hwndDlg, LV_MAPPING); |
| 190 | |
| 191 | // Get the number of items in the ListView. |
| 192 | int num = SendMessage(hwndListView, LVM_GETITEMCOUNT, 0, 0); |
| 193 | |
| 194 | // Get the selected filter. |
| 195 | int filter = (int)SendDlgItemMessage(hwndDlg, COMBO_FILTER, CB_GETCURSEL, 0, 0); |
| 196 | |
| 197 | int* conflictTable = 0; |
| 198 | |
| 199 | // Get the filter type. |
| 200 | if (filter == EMUCMDTYPE_MAX + 3) |
| 201 | { |
| 202 | // Set up the conflict table. |
| 203 | conflictTable = (int*)malloc(sizeof(int)*EMUCMD_MAX); |
| 204 | memset(conflictTable, 0, sizeof(int)*EMUCMD_MAX); |
| 205 | |
| 206 | PopulateConflictTable(conflictTable); |
| 207 | } |
| 208 | |
| 209 | LVITEM lvi; |
| 210 | |
| 211 | |
| 212 | int newItemCount = 0; |
| 213 | |
| 214 | // Populate display. |
| 215 | for(int i = 0, idx = 0; i < EMUCMD_MAX; ++i) |
| 216 | { |
| 217 | // Check if the current key should be displayed |
| 218 | // according to the current filter. |
| 219 | if(ShouldDisplayMapping(i, filter, conflictTable)) |
| 220 | { |
| 221 | memset(&lvi, 0, sizeof(lvi)); |
| 222 | lvi.mask = LVIF_TEXT | LVIF_PARAM; |
| 223 | lvi.iItem = idx; |
| 224 | lvi.iSubItem = 0; |
| 225 | lvi.pszText = (char*)FCEUI_CommandTypeNames[FCEUI_CommandTable[i].type]; |
| 226 | lvi.lParam = (LPARAM)FCEUI_CommandTable[i].cmd; |
| 227 | |
| 228 | if(newItemCount<num) |
| 229 | SendMessage(hwndListView, LVM_SETITEM, (WPARAM)0, (LPARAM)&lvi); |
| 230 | else |
| 231 | SendMessage(hwndListView, LVM_INSERTITEM, (WPARAM)0, (LPARAM)&lvi); |
| 232 | |
| 233 | newItemCount++; |
| 234 | |
| 235 | memset(&lvi, 0, sizeof(lvi)); |
| 236 | lvi.mask = LVIF_TEXT; |
| 237 | lvi.iItem = idx; |
| 238 | lvi.iSubItem = 1; |
| 239 | lvi.pszText = (char*)FCEUI_CommandTable[i].name; |
| 240 | |
| 241 | SendMessage(hwndListView, LVM_SETITEM, (WPARAM)0, (LPARAM)&lvi); |
| 242 | |
| 243 | memset(&lvi, 0, sizeof(lvi)); |
no test coverage detected