Previous 15994 Revisions Next

r2278 Saturday 5th April, 2008 at 18:54:31 UTC by Nathan Woods
[Windows] Device cleanups
[src/mess/osd/windows]menu.c

src/mess/osd/windows/menu.c
r2277r2278
533533
534534struct file_dialog_params
535535{
536   const struct IODevice *dev;
536   const device_config *dev;
537537   int *create_format;
538538   option_resolution **create_args;
539539};
r2277r2278
542542{
543543   HWND wnd;
544544   int format_combo_val;
545   const struct IODevice *dev;
545   const device_config *dev;
546   const struct IODevice *iodev;
546547   const struct OptionGuide *guide;
547548   const char *optspec;
548549   struct file_dialog_params *params;
r2277r2278
560561
561562   // compute our parameters
562563   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;
565567
566568   // set the default extension
567569   CommDlg_OpenSave_SetDefExt(GetParent(dlgwnd),
568      dev->createimage_options[format_combo_val].extensions);
570      iodev->createimage_options[format_combo_val].extensions);
569571
570572   // enumerate through all of the child windows
571573   wnd = NULL;
r2277r2278
614616{
615617   option_resolution *resolution;
616618   struct storeval_optres_params *params;
617   const struct IODevice *dev;
619   const device_config *dev;
620   const struct IODevice *iodev;
618621   char buf[16];
619622
620623   params = (struct storeval_optres_params *) storeval_param;
621624   dev = params->fdparams->dev;
625   iodev = mess_device_from_core_device(dev);
622626
623627   // create the resolution, if necessary
624628   resolution = *(params->fdparams->create_args);
625629   if (!resolution)
626630   {
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);
628632      if (!resolution)
629633         return;
630634      *(params->fdparams->create_args) = resolution;
r2277r2278
640644//   build_option_dialog
641645//============================================================
642646
643static dialog_box *build_option_dialog(const struct IODevice *dev, char *filter, size_t filter_len, int *create_format, option_resolution **create_args)
647static dialog_box *build_option_dialog(const device_config *dev, char *filter, size_t filter_len, int *create_format, option_resolution **create_args)
644648{
645649   dialog_box *dialog;
646650   const struct OptionGuide *guide_entry;
r2277r2278
649653   struct file_dialog_params *params;
650654   struct storeval_optres_params *storeval_params;
651655   static const struct dialog_layout filedialog_layout = { 44, 220 };
656   const struct IODevice *iodev = mess_device_from_core_device(dev);
652657
653658   // make the filter
654659   pos = 0;
655   for (i = 0; dev->createimage_options[i].optspec; i++)
660   for (i = 0; iodev->createimage_options[i].optspec; i++)
656661   {
657662      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);
660665   }
661666
662667   // create the dialog
r2277r2278
677682      goto error;
678683
679684   // 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++)
681686   {
682687      // make sure that this entry is present on at least one option specification
683688      found = FALSE;
684      for (i = 0; dev->createimage_options[i].optspec; i++)
689      for (i = 0; iodev->createimage_options[i].optspec; i++)
685690      {
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))
687692         {
688693            found = TRUE;
689694            break;
r2277r2278
699704         storeval_params->guide_entry = guide_entry;
700705
701706         // 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;
708714
709         default:
710            break;
715            default:
716               break;
711717         }
712718      }
713719   }
r2277r2278
791797//   build_generic_filter
792798//============================================================
793799
794static void build_generic_filter(const struct IODevice *dev, int is_save, char *filter, size_t filter_len)
800static void build_generic_filter(const device_config *dev, int is_save, char *filter, size_t filter_len)
795801{
796802   char *s;
797803   const char *file_extensions;
804   image_device_info info = image_device_getinfo(dev);
798805
799806   s = filter;
800807
801808   // common image types
802   file_extensions = mess_device_get_info_string(&dev->devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS);
809   file_extensions = info.file_extensions;
803810   s += add_filter_entry(filter, filter_len, "Common image types", file_extensions);
804811
805812   // all files
r2277r2278
852859   // add custom dialog elements, if appropriate
853860   if (is_save && dev->createimage_optguide && dev->createimage_options[0].optspec)
854861   {
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);
856863      if (!dialog)
857864         goto done;
858865   }
859866   else
860867   {
861868      // 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]));
863870   }
864871
865872   // display the dialog
r2277r2278
12061213static void prepare_menus(running_machine *machine, HWND wnd)
12071214{
12081215   int i;
1209   const struct IODevice *dev;
12101216   char buf[MAX_PATH];
12111217   TCHAR t_buf[MAX_PATH];
12121218   const char *s;
r2277r2278
13471353   // then set up the actual devices
13481354   for (img = image_device_first(machine->config); img != NULL; img = image_device_next(img))
13491355   {
1350      dev = mess_device_from_core_device(img);
1356      const struct IODevice *dev = mess_device_from_core_device(img);
13511357
13521358      new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX);
13531359      flags_for_exists = MF_STRING;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team