src/mess/osd/windows/menu.c
| r2277 | r2278 | |
| 533 | 533 | |
| 534 | 534 | struct file_dialog_params |
| 535 | 535 | { |
| 536 | | const struct IODevice *dev; |
| 536 | const device_config *dev; |
| 537 | 537 | int *create_format; |
| 538 | 538 | option_resolution **create_args; |
| 539 | 539 | }; |
| r2277 | r2278 | |
| 542 | 542 | { |
| 543 | 543 | HWND wnd; |
| 544 | 544 | int format_combo_val; |
| 545 | | const struct IODevice *dev; |
| 545 | const device_config *dev; |
| 546 | const struct IODevice *iodev; |
| 546 | 547 | const struct OptionGuide *guide; |
| 547 | 548 | const char *optspec; |
| 548 | 549 | struct file_dialog_params *params; |
| r2277 | r2278 | |
| 560 | 561 | |
| 561 | 562 | // compute our parameters |
| 562 | 563 | dev = params->dev; |
| 563 | | guide = dev->createimage_optguide; |
| 564 | | optspec = dev->createimage_options[format_combo_val].optspec; |
| 564 | iodev = mess_device_from_core_device(dev); |
| 565 | guide = iodev->createimage_optguide; |
| 566 | optspec = iodev->createimage_options[format_combo_val].optspec; |
| 565 | 567 | |
| 566 | 568 | // set the default extension |
| 567 | 569 | CommDlg_OpenSave_SetDefExt(GetParent(dlgwnd), |
| 568 | | dev->createimage_options[format_combo_val].extensions); |
| 570 | iodev->createimage_options[format_combo_val].extensions); |
| 569 | 571 | |
| 570 | 572 | // enumerate through all of the child windows |
| 571 | 573 | wnd = NULL; |
| r2277 | r2278 | |
| 614 | 616 | { |
| 615 | 617 | option_resolution *resolution; |
| 616 | 618 | struct storeval_optres_params *params; |
| 617 | | const struct IODevice *dev; |
| 619 | const device_config *dev; |
| 620 | const struct IODevice *iodev; |
| 618 | 621 | char buf[16]; |
| 619 | 622 | |
| 620 | 623 | params = (struct storeval_optres_params *) storeval_param; |
| 621 | 624 | dev = params->fdparams->dev; |
| 625 | iodev = mess_device_from_core_device(dev); |
| 622 | 626 | |
| 623 | 627 | // create the resolution, if necessary |
| 624 | 628 | resolution = *(params->fdparams->create_args); |
| 625 | 629 | if (!resolution) |
| 626 | 630 | { |
| 627 | | resolution = option_resolution_create(dev->createimage_optguide, dev->createimage_options[*(params->fdparams->create_format)].optspec); |
| 631 | resolution = option_resolution_create(iodev->createimage_optguide, iodev->createimage_options[*(params->fdparams->create_format)].optspec); |
| 628 | 632 | if (!resolution) |
| 629 | 633 | return; |
| 630 | 634 | *(params->fdparams->create_args) = resolution; |
| r2277 | r2278 | |
| 640 | 644 | // build_option_dialog |
| 641 | 645 | //============================================================ |
| 642 | 646 | |
| 643 | | static dialog_box *build_option_dialog(const struct IODevice *dev, char *filter, size_t filter_len, int *create_format, option_resolution **create_args) |
| 647 | static dialog_box *build_option_dialog(const device_config *dev, char *filter, size_t filter_len, int *create_format, option_resolution **create_args) |
| 644 | 648 | { |
| 645 | 649 | dialog_box *dialog; |
| 646 | 650 | const struct OptionGuide *guide_entry; |
| r2277 | r2278 | |
| 649 | 653 | struct file_dialog_params *params; |
| 650 | 654 | struct storeval_optres_params *storeval_params; |
| 651 | 655 | static const struct dialog_layout filedialog_layout = { 44, 220 }; |
| 656 | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 652 | 657 | |
| 653 | 658 | // make the filter |
| 654 | 659 | pos = 0; |
| 655 | | for (i = 0; dev->createimage_options[i].optspec; i++) |
| 660 | for (i = 0; iodev->createimage_options[i].optspec; i++) |
| 656 | 661 | { |
| 657 | 662 | pos += add_filter_entry(filter + pos, filter_len - pos, |
| 658 | | dev->createimage_options[i].description, |
| 659 | | dev->createimage_options[i].extensions); |
| 663 | iodev->createimage_options[i].description, |
| 664 | iodev->createimage_options[i].extensions); |
| 660 | 665 | } |
| 661 | 666 | |
| 662 | 667 | // create the dialog |
| r2277 | r2278 | |
| 677 | 682 | goto error; |
| 678 | 683 | |
| 679 | 684 | // loop through the entries |
| 680 | | for (guide_entry = dev->createimage_optguide; guide_entry->option_type != OPTIONTYPE_END; guide_entry++) |
| 685 | for (guide_entry = iodev->createimage_optguide; guide_entry->option_type != OPTIONTYPE_END; guide_entry++) |
| 681 | 686 | { |
| 682 | 687 | // make sure that this entry is present on at least one option specification |
| 683 | 688 | found = FALSE; |
| 684 | | for (i = 0; dev->createimage_options[i].optspec; i++) |
| 689 | for (i = 0; iodev->createimage_options[i].optspec; i++) |
| 685 | 690 | { |
| 686 | | if (option_resolution_contains(dev->createimage_options[i].optspec, guide_entry->parameter)) |
| 691 | if (option_resolution_contains(iodev->createimage_options[i].optspec, guide_entry->parameter)) |
| 687 | 692 | { |
| 688 | 693 | found = TRUE; |
| 689 | 694 | break; |
| r2277 | r2278 | |
| 699 | 704 | storeval_params->guide_entry = guide_entry; |
| 700 | 705 | |
| 701 | 706 | // this option is present on at least one of the specs |
| 702 | | switch(guide_entry->option_type) { |
| 703 | | case OPTIONTYPE_INT: |
| 704 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s:", guide_entry->display_name); |
| 705 | | if (win_dialog_add_combobox(dialog, buf, 0, storeval_option_resolution, storeval_params)) |
| 706 | | goto error; |
| 707 | | break; |
| 707 | switch(guide_entry->option_type) |
| 708 | { |
| 709 | case OPTIONTYPE_INT: |
| 710 | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s:", guide_entry->display_name); |
| 711 | if (win_dialog_add_combobox(dialog, buf, 0, storeval_option_resolution, storeval_params)) |
| 712 | goto error; |
| 713 | break; |
| 708 | 714 | |
| 709 | | default: |
| 710 | | break; |
| 715 | default: |
| 716 | break; |
| 711 | 717 | } |
| 712 | 718 | } |
| 713 | 719 | } |
| r2277 | r2278 | |
| 791 | 797 | // build_generic_filter |
| 792 | 798 | //============================================================ |
| 793 | 799 | |
| 794 | | static void build_generic_filter(const struct IODevice *dev, int is_save, char *filter, size_t filter_len) |
| 800 | static void build_generic_filter(const device_config *dev, int is_save, char *filter, size_t filter_len) |
| 795 | 801 | { |
| 796 | 802 | char *s; |
| 797 | 803 | const char *file_extensions; |
| 804 | image_device_info info = image_device_getinfo(dev); |
| 798 | 805 | |
| 799 | 806 | s = filter; |
| 800 | 807 | |
| 801 | 808 | // common image types |
| 802 | | file_extensions = mess_device_get_info_string(&dev->devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS); |
| 809 | file_extensions = info.file_extensions; |
| 803 | 810 | s += add_filter_entry(filter, filter_len, "Common image types", file_extensions); |
| 804 | 811 | |
| 805 | 812 | // all files |
| r2277 | r2278 | |
| 852 | 859 | // add custom dialog elements, if appropriate |
| 853 | 860 | if (is_save && dev->createimage_optguide && dev->createimage_options[0].optspec) |
| 854 | 861 | { |
| 855 | | dialog = build_option_dialog(dev, filter, sizeof(filter) / sizeof(filter[0]), &create_format, &create_args); |
| 862 | dialog = build_option_dialog(img, filter, sizeof(filter) / sizeof(filter[0]), &create_format, &create_args); |
| 856 | 863 | if (!dialog) |
| 857 | 864 | goto done; |
| 858 | 865 | } |
| 859 | 866 | else |
| 860 | 867 | { |
| 861 | 868 | // build a normal filter |
| 862 | | build_generic_filter(dev, is_save, filter, sizeof(filter) / sizeof(filter[0])); |
| 869 | build_generic_filter(img, is_save, filter, sizeof(filter) / sizeof(filter[0])); |
| 863 | 870 | } |
| 864 | 871 | |
| 865 | 872 | // display the dialog |
| r2277 | r2278 | |
| 1206 | 1213 | static void prepare_menus(running_machine *machine, HWND wnd) |
| 1207 | 1214 | { |
| 1208 | 1215 | int i; |
| 1209 | | const struct IODevice *dev; |
| 1210 | 1216 | char buf[MAX_PATH]; |
| 1211 | 1217 | TCHAR t_buf[MAX_PATH]; |
| 1212 | 1218 | const char *s; |
| r2277 | r2278 | |
| 1347 | 1353 | // then set up the actual devices |
| 1348 | 1354 | for (img = image_device_first(machine->config); img != NULL; img = image_device_next(img)) |
| 1349 | 1355 | { |
| 1350 | | dev = mess_device_from_core_device(img); |
| 1356 | const struct IODevice *dev = mess_device_from_core_device(img); |
| 1351 | 1357 | |
| 1352 | 1358 | new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX); |
| 1353 | 1359 | flags_for_exists = MF_STRING; |