src/mess/filemngr.c
| r2889 | r2890 | |
| 5 | 5 | MESS's clunky built-in file manager |
| 6 | 6 | |
| 7 | 7 | TODO |
| 8 | | - Support image creation; the old file manager did not do this |
| 9 | | well. |
| 10 | | - Should only allow image creation if the device allows |
| 11 | | - Also support creation arguments |
| 8 | - Support image creation arguments |
| 12 | 9 | - Restrict directory listing by file extension |
| 13 | 10 | - Support file manager invocation from the main menu for |
| 14 | 11 | required images |
| r2889 | r2890 | |
| 28 | 25 | CONSTANTS |
| 29 | 26 | ***************************************************************************/ |
| 30 | 27 | |
| 31 | | #define ENABLE_CREATE 0 |
| 32 | | |
| 33 | 28 | #define SLOT_EMPTY "[empty slot]" |
| 34 | 29 | #define SLOT_CREATE "[create]" |
| 35 | 30 | |
| r2889 | r2890 | |
| 330 | 325 | { |
| 331 | 326 | static char filename_buffer[1024]; |
| 332 | 327 | |
| 328 | astring *new_path; |
| 333 | 329 | ui_menu_item item_list[200]; |
| 334 | 330 | int menu_items = 0; |
| 335 | 331 | filecreator_state fc_state; |
| 336 | 332 | UINT32 selected; |
| 337 | 333 | int visible_items; |
| 338 | | int underscore_pos; |
| 334 | int underscore_pos = -1; |
| 339 | 335 | menu_extra extra; |
| 340 | 336 | |
| 341 | 337 | /* disassemble state */ |
| r2889 | r2890 | |
| 365 | 361 | extra.top = ui_get_line_height() + 3.0f * UI_BOX_TB_BORDER; |
| 366 | 362 | extra.render = file_creator_render_extra; |
| 367 | 363 | |
| 368 | | /* if we're selecting the file name, poll the keyboard */ |
| 364 | /* features that are only enabled when selecting the file name */ |
| 369 | 365 | if (selected == 0) |
| 366 | { |
| 367 | /* poll the keyboard */ |
| 370 | 368 | poll_keyboard(filename_buffer, ARRAY_LENGTH(filename_buffer), is_valid_filename_char); |
| 371 | 369 | |
| 372 | | /* put the underscore in the menu */ |
| 373 | | underscore_pos = strlen(filename_buffer); |
| 374 | | snprintf(filename_buffer + underscore_pos, ARRAY_LENGTH(filename_buffer) - underscore_pos, "_"); |
| 370 | /* put the underscore in the menu */ |
| 371 | underscore_pos = strlen(filename_buffer); |
| 372 | snprintf(filename_buffer + underscore_pos, ARRAY_LENGTH(filename_buffer) - underscore_pos, "_"); |
| 373 | } |
| 375 | 374 | |
| 376 | 375 | /* draw the menu */ |
| 377 | 376 | visible_items = ui_menu_draw(item_list, menu_items, selected, &extra); |
| 378 | 377 | |
| 379 | | /* remove the underscore */ |
| 380 | | filename_buffer[underscore_pos] = '\0'; |
| 378 | /* remove the underscore, if present */ |
| 379 | if (underscore_pos >= 0) |
| 380 | filename_buffer[underscore_pos] = '\0'; |
| 381 | 381 | |
| 382 | 382 | /* handle the keys */ |
| 383 | 383 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) |
| 384 | 384 | goto done; |
| 385 | 385 | |
| 386 | 386 | if (input_ui_pressed(machine, IPT_UI_SELECT)) |
| 387 | | fatalerror("NYI"); |
| 387 | { |
| 388 | switch(selected) |
| 389 | { |
| 390 | case 0: |
| 391 | /* create the image */ |
| 392 | new_path = zippath_combine(astring_alloc(), astring_c(current_directory), filename_buffer); |
| 393 | image_create(selected_device, astring_c(new_path), 0, NULL); |
| 394 | astring_free(new_path); |
| 388 | 395 | |
| 396 | /* pop ourselves out */ |
| 397 | ui_menu_stack_pop(); |
| 398 | fc_state.i = ui_menu_stack_pop(); |
| 399 | goto done; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | fc_state.s.selected = selected; |
| 404 | |
| 389 | 405 | done: |
| 390 | | fc_state.s.selected = selected; |
| 391 | 406 | return fc_state.i; |
| 392 | 407 | } |
| 393 | 408 | |
| r2889 | r2890 | |
| 483 | 498 | (*menu_items)++; |
| 484 | 499 | |
| 485 | 500 | info = image_device_getinfo(device->machine->config, device); |
| 486 | | if (ENABLE_CREATE && info.creatable && !zippath_is_zip(directory)) |
| 501 | if (info.creatable && !zippath_is_zip(directory)) |
| 487 | 502 | { |
| 488 | 503 | /* add the "[create]" entry */ |
| 489 | 504 | memset(&item_list[*menu_items], 0, sizeof(item_list[*menu_items])); |