Previous 15994 Revisions Next

r13912 Saturday 7th January, 2012 at 09:04:48 UTC by Olivier Galibert
uiimage/diimage: Dumbify the menus and add a control layer [O. Galibert]
[src/emu]diimage.c diimage.h softlist.c softlist.h uiimage.c uiimage.h uiswlist.c uiswlist.h

src/emu/diimage.c
r13911r13912
4040#include "emu.h"
4141#include "ui.h"
4242#include "zippath.h"
43#include "uimenu.h"
44#include "uiimage.h"
45#include "uiswlist.h"
4346
44
4547//**************************************************************************
4648//  DEVICE CONFIG IMAGE INTERFACE
4749//**************************************************************************
r13911r13912
107109
108110//-------------------------------------------------
109111//  find_device_type - search trough list of
110//  device types to extact data
112//  device types to extract data
111113//-------------------------------------------------
112114
113115const image_device_type_info *device_image_interface::find_device_type(iodevice_t type)
r13911r13912
10321034      m_brief_instance_name = device_brieftypename(image_type());
10331035   }
10341036}
1037
1038/*-------------------------------------------------
1039    get_selection_menu - create the menu stack
1040    for ui-level image selection
1041-------------------------------------------------*/
1042
1043class ui_menu_control_device_image : public ui_menu {
1044public:
1045   ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *image);
1046   virtual ~ui_menu_control_device_image();
1047   virtual void populate();
1048   virtual void handle();
1049     
1050private:
1051   enum {
1052      START_FILE, START_OTHER_PART, START_SOFTLIST, SELECT_PARTLIST, SELECT_ONE_PART, SELECT_OTHER_PART, SELECT_FILE, CREATE_FILE, CREATE_CONFIRM, DO_CREATE, SELECT_SOFTLIST
1053   };
1054   int state;
1055
1056   device_image_interface *image;
1057   astring current_directory;
1058   astring current_file;
1059   int submenu_result;
1060   bool create_confirmed;
1061   bool softlist_done;
1062   const software_list *swl;
1063   const software_info *swi;
1064   const software_part *swp;
1065   const software_list_config *slc;
1066   astring software_info_name;
1067
1068   void test_create(bool &can_create, bool &need_confirm);
1069   void load_software_part();
1070};
1071
1072ui_menu *device_image_interface::get_selection_menu(running_machine &machine, render_container *container)
1073{
1074   return auto_alloc_clear(machine, ui_menu_control_device_image(machine, container, this));
1075}
1076
1077ui_menu_control_device_image::ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu(machine, container)
1078{
1079   image = _image;
1080
1081   slc = 0;
1082   swi = image->software_entry();
1083   swp = image->part_entry();
1084
1085   if(swi)
1086   {
1087      state = START_OTHER_PART;
1088      current_directory.cpy(image->working_directory());
1089   }
1090   else
1091   {
1092      state = START_FILE;
1093
1094      /* if the image exists, set the working directory to the parent directory */
1095      if (image->exists())
1096      {
1097         current_file.cpy(image->filename());
1098         zippath_parent(current_directory, current_file);
1099      } else
1100         current_directory.cpy(image->working_directory());
1101
1102      /* check to see if the path exists; if not clear it */
1103      if (zippath_opendir(current_directory, NULL) != FILERR_NONE)
1104         current_directory.reset();
1105   }
1106}
1107
1108ui_menu_control_device_image::~ui_menu_control_device_image()
1109{
1110}
1111
1112
1113
1114
1115/*-------------------------------------------------
1116    create_new_image - creates a new disk image
1117-------------------------------------------------*/
1118
1119void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm)
1120{
1121   astring path;
1122   osd_directory_entry *entry;
1123   osd_dir_entry_type file_type;
1124
1125   /* assemble the full path */
1126   zippath_combine(path, current_directory, current_file);
1127
1128   /* does a file or a directory exist at the path */
1129   entry = osd_stat(path);
1130   file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE;
1131   if (entry != NULL)
1132      free(entry);
1133
1134   switch(file_type)
1135   {
1136      case ENTTYPE_NONE:
1137         /* no file/dir here - always create */
1138         can_create = true;
1139         need_confirm = false;
1140         break;
1141
1142      case ENTTYPE_FILE:
1143         /* a file exists here - ask for permission from the user */
1144         can_create = true;
1145         need_confirm = true;
1146         break;
1147
1148      case ENTTYPE_DIR:
1149         /* a directory exists here - we can't save over it */
1150         ui_popup_time(5, "Cannot save over directory");
1151         can_create = false;
1152         need_confirm = false;
1153         break;
1154
1155      default:
1156         fatalerror("Unexpected");
1157         can_create = false;
1158         need_confirm = false;
1159         break;
1160   }
1161}
1162
1163void ui_menu_control_device_image::load_software_part()
1164{
1165   astring temp_name(swi->shortname);
1166   temp_name.cat(":");
1167   temp_name.cat(swp->name);
1168   image->load(temp_name.cstr());
1169}
1170
1171void ui_menu_control_device_image::populate()
1172{
1173}
1174
1175void ui_menu_control_device_image::handle()
1176{
1177   switch(state) {
1178   case START_FILE: {
1179      bool can_create = false;
1180      if(image->is_creatable()) {
1181         zippath_directory *directory = NULL;
1182         file_error err = zippath_opendir(current_directory, &directory);
1183         can_create = err == FILERR_NONE && !zippath_is_zip(directory);
1184         if(directory)
1185            zippath_closedir(directory);
1186      }
1187      submenu_result = -1;
1188      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, true, can_create, &submenu_result)));
1189      state = SELECT_FILE;
1190      break;
1191   }
1192
1193   case START_SOFTLIST:
1194      slc = 0;
1195      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &slc)));
1196      state = SELECT_SOFTLIST;
1197      break;
1198
1199   case START_OTHER_PART: {
1200      submenu_result = -1;
1201      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface_, &swp, true, &submenu_result)));
1202      state = SELECT_OTHER_PART;
1203      break;
1204   }
1205
1206   case SELECT_SOFTLIST:
1207      if(!slc) {
1208         ui_menu::stack_pop(machine());
1209         break;
1210      }
1211      software_info_name = "";
1212      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, slc, image->image_interface(), software_info_name)));
1213      state = SELECT_PARTLIST;
1214      break;
1215
1216   case SELECT_PARTLIST:
1217      swl = software_list_open(machine().options(), slc->list_name, false, NULL);
1218      swi = software_list_find(swl, software_info_name, NULL);
1219      if(swinfo_has_multiple_parts(swi, image->image_interface())) {
1220         submenu_result = -1;
1221         swp = 0;
1222         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result)));
1223         state = SELECT_ONE_PART;
1224      } else {
1225         image->load(software_info_name);
1226         software_list_close(swl);
1227         ui_menu::stack_pop(machine());
1228      }
1229      break;
1230
1231   case SELECT_ONE_PART:
1232      switch(submenu_result) {
1233      case ui_menu_software_parts::T_ENTRY: {
1234         load_software_part();
1235         software_list_close(swl);
1236         ui_menu::stack_pop(machine());
1237         break;
1238      }
1239
1240      case -1: // return to list
1241         software_list_close(swl);
1242         state = SELECT_SOFTLIST;
1243         break;
1244         
1245      }
1246      break;
1247
1248   case SELECT_OTHER_PART:
1249      switch(submenu_result) {
1250      case ui_menu_software_parts::T_ENTRY: {
1251         load_software_part();
1252         ui_menu::stack_pop(machine());
1253         break;
1254      }
1255
1256      case ui_menu_software_parts::T_FMGR:
1257         state = START_FILE;
1258         handle();
1259         break;
1260
1261      case -1: // return to system
1262         ui_menu::stack_pop(machine());
1263         break;
1264         
1265      }
1266      break;
1267
1268   case SELECT_FILE:
1269      switch(submenu_result) {
1270      case ui_menu_file_selector::R_EMPTY:
1271         image->unload();
1272         ui_menu::stack_pop(machine());
1273         break;
1274
1275      case ui_menu_file_selector::R_FILE:
1276         image->load(current_file);
1277         ui_menu::stack_pop(machine());
1278         break;
1279
1280      case ui_menu_file_selector::R_CREATE:
1281         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, image, current_directory, current_file)));
1282         state = CREATE_FILE;
1283         break;
1284
1285      case ui_menu_file_selector::R_SOFTLIST:
1286         state = START_SOFTLIST;
1287         handle();
1288         break;
1289
1290      case -1: // return to system
1291         ui_menu::stack_pop(machine());
1292         break;
1293      }
1294      break;
1295
1296   case CREATE_FILE: {
1297      bool can_create, need_confirm;
1298      test_create(can_create, need_confirm);
1299      if(can_create) {
1300         if(need_confirm) {
1301            ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, &create_confirmed)));
1302            state = CREATE_CONFIRM;
1303         } else {
1304            astring path;
1305            zippath_combine(path, current_directory, current_file);
1306            int err = image->create(path, 0, NULL);
1307            if (err != 0)
1308               popmessage("Error: %s", image->error());
1309            ui_menu::stack_pop(machine());           
1310         }
1311      } else {
1312         state = START_FILE;
1313         handle();
1314      }         
1315      break;
1316   }
1317
1318   case CREATE_CONFIRM: {
1319      state = create_confirmed ? DO_CREATE : START_FILE;
1320      handle();
1321      break;
1322   }
1323
1324   case DO_CREATE: {
1325      astring path;
1326      zippath_combine(path, current_directory, current_file);
1327      int err = image->create(path, 0, NULL);
1328      if (err != 0)
1329         popmessage("Error: %s", image->error());
1330      ui_menu::stack_pop(machine());
1331      break;
1332   }
1333   }
1334}
src/emu/diimage.h
r13911r13912
182182   virtual const char *file_extensions() const = 0;
183183   virtual const option_guide *create_option_guide() const = 0;
184184
185   virtual class ui_menu *get_selection_menu(running_machine &machine, class render_container *container);
186
185187   const image_device_format *device_get_indexed_creatable_format(int index);
186188   const image_device_format *device_get_named_creatable_format(const char *format_name);
187189   const option_guide *device_get_creation_option_guide() { return create_option_guide(); }
src/emu/uiimage.c
r13911r13912
149149    confirm save as menu
150150-------------------------------------------------*/
151151
152ui_menu_confirm_save_as::ui_menu_confirm_save_as(running_machine &machine, render_container *container, int *_yes) : ui_menu(machine, container)
152ui_menu_confirm_save_as::ui_menu_confirm_save_as(running_machine &machine, render_container *container, bool *_yes) : ui_menu(machine, container)
153153{
154154   yes = _yes;
155   *yes = false;
155156}
156157
157158ui_menu_confirm_save_as::~ui_menu_confirm_save_as()
r13911r13912
160161
161162void ui_menu_confirm_save_as::populate()
162163{
163   item_append("File Already Exists - Overide?", NULL, MENU_FLAG_DISABLE, NULL);
164   item_append("File Already Exists - Override?", NULL, MENU_FLAG_DISABLE, NULL);
164165   item_append(MENU_SEPARATOR_ITEM, NULL, MENU_FLAG_DISABLE, NULL);
165166   item_append("No", NULL, 0, ITEMREF_NO);
166167   item_append("Yes", NULL, 0, ITEMREF_YES);
r13911r13912
179180   if ((event != NULL) && (event->iptkey == IPT_UI_SELECT))
180181   {
181182      if (event->itemref == ITEMREF_YES)
182         *yes = TRUE;
183         *yes = true;
183184
184185      /* no matter what, pop out */
185186      ui_menu::stack_pop(machine());
r13911r13912
224225void ui_menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
225226{
226227   extra_text_render(container, top, bottom, origx1, origy1, origx2, origy2,
227      manager->current_directory,
228      current_directory,
228229      NULL);
229230}
230231
r13911r13912
235236    creator menu
236237-------------------------------------------------*/
237238
238ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, ui_menu_file_manager *parent) : ui_menu(machine, container)
239ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *_image, astring &_current_directory, astring &_current_file) : ui_menu(machine, container), current_directory(_current_directory), current_file(_current_file)
239240{
240   manager = parent;
241   image = _image;
241242}
242243
243244ui_menu_file_create::~ui_menu_file_create()
r13911r13912
247248void ui_menu_file_create::populate()
248249{
249250   astring buffer;
250   device_image_interface *device = manager->selected_device;
251251   const image_device_format *format;
252252   const char *new_image_name;
253253
r13911r13912
264264   item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME);
265265
266266   /* do we support multiple formats? */
267   format = device->device_get_creatable_formats();
267   format = image->device_get_creatable_formats();
268268   if (ENABLE_FORMATS && (format != NULL))
269269   {
270270      item_append("Image Format:", current_format->m_description, 0, ITEMREF_FORMAT);
r13911r13912
279279}
280280
281281
282
283282/*-------------------------------------------------
284    create_new_image - creates a new disk image
285-------------------------------------------------*/
286
287int ui_menu_file_create::create_new_image(device_image_interface *image, const char *directory, const char *filename, int *yes)
288{
289   astring path;
290   osd_directory_entry *entry;
291   osd_dir_entry_type file_type;
292   int do_create, err;
293   int result = FALSE;
294
295   /* assemble the full path */
296   zippath_combine(path, directory, filename);
297
298   /* does a file or a directory exist at the path */
299   entry = osd_stat(path);
300   file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE;
301   if (entry != NULL)
302      free(entry);
303
304   /* special case */
305   if ((file_type == ENTTYPE_FILE) && *yes)
306      file_type = ENTTYPE_NONE;
307
308   switch(file_type)
309   {
310      case ENTTYPE_NONE:
311         /* no file/dir here - always create */
312         do_create = TRUE;
313         break;
314
315      case ENTTYPE_FILE:
316         /* a file exists here - ask for permission from the user */
317         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, yes)));
318         do_create = FALSE;
319         break;
320
321      case ENTTYPE_DIR:
322         /* a directory exists here - we can't save over it */
323         ui_popup_time(ERROR_MESSAGE_TIME, "Cannot save over directory");
324         do_create = FALSE;
325         break;
326
327      default:
328         fatalerror("Unexpected");
329         do_create = FALSE;
330         break;
331   }
332
333   /* create the image, if appropriate */
334   if (do_create)
335   {
336      err = image->create(path, 0, NULL);
337      if (err != 0)
338         popmessage("Error: %s", image->error());
339      else
340         result = TRUE;
341   }
342
343   return result;
344}
345
346
347
348/*-------------------------------------------------
349283    menu_file_create - file creator menu
350284-------------------------------------------------*/
351285
352286void ui_menu_file_create::handle()
353287{
354   const ui_menu_event *event;
355   ui_menu_event fake_event;
288   /* process the menu */
289   const ui_menu_event *event = process(0);
356290
357   if (confirm_save_as_yes)
358   {
359      /* we just returned from a "confirm save as" dialog and the user said "yes" - fake an event */
360      memset(&fake_event, 0, sizeof(fake_event));
361      fake_event.iptkey = IPT_UI_SELECT;
362      fake_event.itemref = ITEMREF_CREATE;
363      event = &fake_event;
364   }
365   else
366   {
367      /* process the menu */
368      event = process(0);
369   }
370
371291   /* process the event */
372292   if (event != NULL)
373293   {
r13911r13912
377297         case IPT_UI_SELECT:
378298            if ((event->itemref == ITEMREF_CREATE) || (event->itemref == ITEMREF_NEW_IMAGE_NAME))
379299            {
380               if (create_new_image(
381                  manager->selected_device,
382                  manager->current_directory,
383                  filename_buffer,
384                  &confirm_save_as_yes))
385               {
386                  /* success - pop out twice to device view */
387                  ui_menu::stack_pop(machine());
388                  ui_menu::stack_pop(machine());
389               }
300               current_file.cpy(filename_buffer);
301               ui_menu::stack_pop(machine());
390302            }
391303            break;
392304
r13911r13912
398310                  ARRAY_LENGTH(filename_buffer),
399311                  event->unichar,
400312                  is_valid_filename_char);
313               reset(UI_MENU_RESET_REMEMBER_POSITION);
401314            }
402315            break;
403316      }
r13911r13912
419332{
420333   extra_text_render(container, top, bottom,
421334      origx1, origy1, origx2, origy2,
422      manager->current_directory,
335      current_directory,
423336      NULL);
424337}
425338
r13911r13912
523436   }
524437
525438   /* determine the full path */
526   zippath_combine(
527      buffer,
528      manager->current_directory,
529      dirent->name);
439   zippath_combine(buffer, current_directory, dirent->name);
530440
531441   /* create the file selector entry */
532442   entry = append_entry(
r13911r13912
587497    allocates all menu items for a directory
588498-------------------------------------------------*/
589499
590ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, ui_menu_file_manager *parent) : ui_menu(machine, container)
500ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *_image, astring &_current_directory, astring &_current_file, bool _has_empty, bool _has_softlist, bool _has_create, int *_result) : ui_menu(machine, container), current_directory(_current_directory), current_file(_current_file)
591501{
592   manager = parent;
502   image = _image;
503   has_empty = _has_empty;
504   has_softlist = _has_softlist;
505   has_create = _has_create;
506   result = _result;
593507}
594508
595509ui_menu_file_selector::~ui_menu_file_selector()
r13911r13912
605519   const file_selector_entry *selected_entry = NULL;
606520   int i;
607521   const char *volume_name;
608   device_image_interface *device = manager->selected_device;
609   const char *path = manager->current_directory;
522   const char *path = current_directory;
610523
524   if(path[0])
525      fprintf(stderr, "curdir=%s\n", path);
526
611527   /* open the directory */
612528   err = zippath_opendir(path, &directory);
613529   if (err != FILERR_NONE)
r13911r13912
616532   /* clear out the menu entries */
617533   entrylist = NULL;
618534
619   /* add the "[empty slot]" entry */
620   append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL);
535   if (has_empty)
536   {
537      /* add the "[empty slot]" entry */
538      append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL);
539   }
621540
622   if (device->is_creatable() && !zippath_is_zip(directory))
541   if (has_create)
623542   {
624543      /* add the "[create]" entry */
625544      append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL);
626545   }
627546
628   /* add the "[software list]" entry */
629   append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL);
547   if (has_softlist)
548      /* add the "[software list]" entry */
549      append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL);
630550
631551   /* add the drives */
632552   i = 0;
r13911r13912
650570            selected_entry = entry;
651571
652572         /* do we have to select this file? */
653         if (!mame_stricmp(manager->current_file, dirent->name))
573         if (!mame_stricmp(current_file, dirent->name))
654574            selected_entry = entry;
655575      }
656576   }
r13911r13912
671591      zippath_closedir(directory);
672592}
673593
674/*-------------------------------------------------
675    check_path - performs a quick check to see if
676    a path exists
677-------------------------------------------------*/
678594
679static file_error check_path(const char *path)
680{
681   return zippath_opendir(path, NULL);
682}
683
684
685
686595/*-------------------------------------------------
687596    menu_file_selector - file selector menu
688597-------------------------------------------------*/
r13911r13912
706615         {
707616            case SELECTOR_ENTRY_TYPE_EMPTY:
708617               /* empty slot - unload */
709               manager->selected_device->unload();
618               *result = R_EMPTY;
710619               ui_menu::stack_pop(machine());
711620               break;
712621
713622            case SELECTOR_ENTRY_TYPE_CREATE:
714623               /* create */
715               ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, manager)));
624               *result = R_CREATE;
625               ui_menu::stack_pop(machine());
716626               break;
717627            case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST:
718               ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, manager->selected_device)));
628               *result = R_SOFTLIST;
629               ui_menu::stack_pop(machine());
719630               break;
720631            case SELECTOR_ENTRY_TYPE_DRIVE:
721632            case SELECTOR_ENTRY_TYPE_DIRECTORY:
722633               /* drive/directory - first check the path */
723               err = check_path(entry->fullpath);
634               err = zippath_opendir(entry->fullpath, NULL);
724635               if (err != FILERR_NONE)
725636               {
726637                  /* this path is problematic; present the user with an error and bail */
727638                  ui_popup_time(1, "Error accessing %s", entry->fullpath);
728639                  break;
729640               }
730               manager->current_directory.cpy(entry->fullpath);
641               current_directory.cpy(entry->fullpath);
731642               reset((ui_menu_reset_options)0);
732643               break;
733644
734645            case SELECTOR_ENTRY_TYPE_FILE:
735646               /* file */
736               manager->selected_device->load(entry->fullpath);
647               current_file.cpy(entry->fullpath);
648               *result = R_FILE;
737649               ui_menu::stack_pop(machine());
738650               break;
739651         }
r13911r13912
830742    FILE MANAGER
831743***************************************************************************/
832744
833/*-------------------------------------------------
834    fix_working_directory - checks the working
835    directory for this device to ensure that it
836    "makes sense"
837-------------------------------------------------*/
838745
839void ui_menu_file_manager::fix_working_directory(device_image_interface *image)
840{
841   /* if the image exists, set the working directory to the parent directory */
842   if (image->exists())
843   {
844      astring astr;
845      zippath_parent(astr, image->filename());
846      image->set_working_directory(astr);
847   }
848
849   /* check to see if the path exists; if not clear it */
850   if (check_path(image->working_directory()) != FILERR_NONE)
851      image->set_working_directory("");
852}
853
854
855
856746/*-------------------------------------------------
857747    file_manager_render_extra - perform our
858748    special rendering
r13911r13912
954844      selected_device = (device_image_interface *) event->itemref;
955845      if (selected_device != NULL)
956846      {
957         /* ensure that the working directory for this device exists */
958         fix_working_directory(selected_device);
847         ui_menu::stack_push(selected_device->get_selection_menu(machine(), container));
959848
960         /* set up current_directory and current_file - depends on whether we have an image */
961         current_directory.cpy(selected_device->working_directory());
962         current_file.cpy(selected_device->exists() ? selected_device->basename() : "");
963
964849         /* reset the existing menu */
965850         reset(UI_MENU_RESET_REMEMBER_POSITION);
966
967         /* push the menu */
968         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, this)));
969851      }
970852   }
971853}
src/emu/uiimage.h
r13911r13912
3333   virtual void populate();
3434   virtual void handle();
3535   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
36
37private:
38   void fix_working_directory(device_image_interface *image);
3936};
4037
4138class ui_menu_mess_tape_control : public ui_menu {
r13911r13912
6663
6764class ui_menu_confirm_save_as : public ui_menu {
6865public:
69   ui_menu_confirm_save_as(running_machine &machine, render_container *container, int *yes);
66   ui_menu_confirm_save_as(running_machine &machine, render_container *container, bool *yes);
7067   virtual ~ui_menu_confirm_save_as();
7168   virtual void populate();
7269   virtual void handle();
7370
7471private:
75   int *yes;
72   bool *yes;
7673};
7774
7875class ui_menu_file_create : public ui_menu {
7976public:
80   ui_menu_file_create(running_machine &machine, render_container *container, ui_menu_file_manager *parent);
77   ui_menu_file_create(running_machine &machine, render_container *container, device_image_interface *image, astring &current_directory, astring &current_file);
8178   virtual ~ui_menu_file_create();
8279   virtual void populate();
8380   virtual void handle();
8481   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
8582
8683private:
87   ui_menu_file_manager *manager;
84   device_image_interface *image;
85   astring &current_directory, &current_file;
8886   const image_device_format *current_format;
8987   int confirm_save_as_yes;
9088   char filename_buffer[1024];
91
92   int create_new_image(device_image_interface *image, const char *directory, const char *filename, int *yes);
9389};
9490
9591class ui_menu_file_selector : public ui_menu {
9692public:
97   ui_menu_file_selector(running_machine &machine, render_container *container, ui_menu_file_manager *parent);
93   enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE };
94   ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring &current_directory, astring &current_file, bool has_empty, bool has_softlist, bool has_create, int *result);
9895   virtual ~ui_menu_file_selector();
9996   virtual void populate();
10097   virtual void handle();
r13911r13912
118115      const char *fullpath;
119116   };
120117
121   ui_menu_file_manager *manager;
118   device_image_interface *image;
119   astring &current_directory, &current_file;
120   bool has_empty, has_softlist, has_create;
121   int *result;
122
122123   file_selector_entry *entrylist;
123124   char filename_buffer[1024];
124125
src/emu/uiswlist.c
r13911r13912
2828    TYPE DEFINITIONS
2929***************************************************************************/
3030
31ui_menu_software_parts::ui_menu_software_parts(running_machine &machine, render_container *container, ui_menu_software_entry_info *_entry) : ui_menu(machine, container)
31ui_menu_software_parts::ui_menu_software_parts(running_machine &machine, render_container *container, const software_info *_info, const char *_interface, const software_part **part, bool _opt_fmgr, int *_result) : ui_menu(machine, container)
3232{
33   entry = _entry;
33   info = _info;
34   interface = _interface;
35   selected_part = part;
36   opt_fmgr = _opt_fmgr;
37   result = _result;
3438}
3539
3640void ui_menu_software_parts::populate()
3741{
38   if(entry->list_name) {
39      software_list *list = software_list_open(machine().options(), entry->list_name, false, NULL);
40
41      if (list)
42   for (const software_part *swpart = software_find_part(info, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
43   {
44      if (strcmp(interface, swpart->interface_) == 0)
4245      {
43         software_info *info = software_list_find(list, entry->short_name, NULL);
44
45         if (info)
46         software_part_menu_entry *entry = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry));
47         // check if the available parts have specific part_id to be displayed (e.g. "Map Disc", "Bonus Disc", etc.)
48         // if not, we simply display "part_name"; if yes we display "part_name (part_id)"
49         astring menu_part_name(swpart->name);
50         if (software_part_get_feature(swpart, "part_id") != NULL)
4651         {
47            for (software_part *swpart = software_find_part(info, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
48            {
49               if (strcmp(entry->interface, swpart->interface_) == 0)
50               {
51                  software_part_info *entry = (software_part_info *) m_pool_alloc(sizeof(*entry));
52                  // check if the available parts have specific part_id to be displayed (e.g. "Map Disc", "Bonus Disc", etc.)
53                  // if not, we simply display "part_name"; if yes we display "part_name (part_id)"
54                  astring menu_part_name(swpart->name);
55                  if (software_part_get_feature(swpart, "part_id") != NULL)
56                  {
57                     menu_part_name.cat(" (");
58                     menu_part_name.cat(software_part_get_feature(swpart, "part_id"));
59                     menu_part_name.cat(")");
60                  }
61                  entry->part_name = pool_strdup(swpart->name);   // part_name is later used to build up the filename to load, so we use swpart->name!
62                  entry->interface = pool_strdup(swpart->interface_);
63                  item_append(info->shortname, menu_part_name.cstr(), 0, entry);
64               }
65            }
52            menu_part_name.cat(" (");
53            menu_part_name.cat(software_part_get_feature(swpart, "part_id"));
54            menu_part_name.cat(")");
6655         }
67
68         software_list_close(list);
56         entry->type = T_ENTRY;
57         entry->part = swpart;
58         item_append(info->shortname, menu_part_name.cstr(), 0, entry);
6959      }
7060   }
61   if(opt_fmgr) {
62      software_part_menu_entry *entry = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry));
63      entry->type = T_FMGR;
64      entry->part = 0;
65      item_append("[file manager]", 0, 0, entry);
66   }
7167}
7268
7369ui_menu_software_parts::~ui_menu_software_parts()
r13911r13912
8177
8278   if (event != NULL && event->iptkey == IPT_UI_SELECT && event->itemref != NULL)
8379   {
84      software_part_info *pentry = (software_part_info *) event->itemref;
85
86      // build the name for the part to be loaded
87      astring temp_name(entry->short_name);
88      temp_name.cat(":");
89      temp_name.cat(pentry->part_name);
90      //printf("%s\n", temp_name.cstr());
91
92      entry->image->load(temp_name.cstr());
80      software_part_menu_entry *entry = (software_part_menu_entry *) event->itemref;
81      *result = entry->type;
82      *selected_part = entry->part;
83      ui_menu::stack_pop(machine());
9384   }
9485}
9586
96int ui_menu_software_list::compare_entries(const ui_menu_software_entry_info *e1, const ui_menu_software_entry_info *e2, bool shortname)
87int ui_menu_software_list::compare_entries(const entry_info *e1, const entry_info *e2, bool shortname)
9788{
9889   int result;
9990   const char *e1_basename;
r13911r13912
128119
129120/* populate a specific list */
130121
131ui_menu_software_entry_info *ui_menu_software_list::append_software_entry(software_info *swinfo, device_image_interface* image)
122ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry(const software_info *swinfo)
132123{
133   ui_menu_software_entry_info *entry = NULL;
134   ui_menu_software_entry_info **entryptr;
135   const char *interface = image->image_interface();
124   entry_info *entry = NULL;
125   entry_info **entryptr;
136126   bool entry_updated = FALSE;
137127
138128   // check if at least one of the parts has the correct interface and add a menu entry only in this case
139   for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
129   for (const software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
140130   {
141131      if ((strcmp(interface, swpart->interface_) == 0) && is_software_compatible(swpart, swlist))
142132      {
143133         entry_updated = TRUE;
144134         // allocate a new entry
145         entry = (ui_menu_software_entry_info *) m_pool_alloc(sizeof(*entry));
135         entry = (entry_info *) m_pool_alloc(sizeof(*entry));
146136         memset(entry, 0, sizeof(*entry));
147137
148138         entry->short_name = pool_strdup(swinfo->shortname);
149139         entry->long_name = pool_strdup(swinfo->longname);
150         entry->list_name = swlist->list_name;
151         entry->image = image;
152         entry->interface = pool_strdup(swpart->interface_);
153140         break;
154141      }
155142   }
r13911r13912
170157   return entry;
171158}
172159
173ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_config *_swlist, device_image_interface *_image) : ui_menu(machine, container)
160ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, const software_list_config *_swlist, const char *_interface, astring &_result) : ui_menu(machine, container), result(_result)
174161{
175162   swlist = _swlist;
176   image = _image;
163   interface = _interface;
177164   entrylist = NULL;
178165   ordered_by_shortname = true;
179166}
r13911r13912
184171
185172void ui_menu_software_list::populate()
186173{
187   software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
174   const software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
188175
189176   // build up the list of entries for the menu
190177   if (list)
191178   {
192      for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
193         append_software_entry(swinfo, image);
179      for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
180         append_software_entry(swinfo);
194181
195182      software_list_close(list);
196183   }
r13911r13912
199186   item_append("Switch Item Ordering", NULL, 0, (void *)1);
200187
201188   // append all of the menu entries
202   for (ui_menu_software_entry_info *entry = entrylist; entry != NULL; entry = entry->next)
189   for (entry_info *entry = entrylist; entry != NULL; entry = entry->next)
203190      item_append(entry->short_name, entry->long_name, 0, entry);
204191}
205192
206bool ui_menu_software_list::swinfo_has_multiple_parts(software_info *swinfo, const char *interface)
207{
208   int count = 0;
209
210   for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
211   {
212      if (strcmp(interface, swpart->interface_) == 0)
213         count++;
214   }
215   return (count > 1) ? true : false;
216}
217
218193void ui_menu_software_list::handle()
219194{
220   const ui_menu_software_entry_info *entry;
221   const ui_menu_software_entry_info *selected_entry = NULL;
195   const entry_info *entry;
196   const entry_info *selected_entry = NULL;
222197   int bestmatch = 0;
223198
224199   /* process the menu */
r13911r13912
240215      /* handle selections */
241216      else if (event->iptkey == IPT_UI_SELECT)
242217      {
243         ui_menu_software_entry_info *entry = (ui_menu_software_entry_info *) event->itemref;
244         software_list *tmp_list = software_list_open(machine().options(), swlist->list_name, false, NULL);
245         software_info *tmp_info = software_list_find(tmp_list, entry->short_name, NULL);
246
247         // if the selected software has multiple parts that can be loaded, open the submenu
248         if (swinfo_has_multiple_parts(tmp_info, image->image_interface()))
249         {
250            ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, entry)));
251         }
252         else
253         {
254            // otherwise, load the file
255            image->load(entry->short_name);
256         }
257         software_list_close(tmp_list);
258
259         // reset the char buffer when pressing IPT_UI_SELECT
260         if (filename_buffer[0] != '\0')
261            memset(filename_buffer, '\0', ARRAY_LENGTH(filename_buffer));
218         entry_info *entry = (entry_info *) event->itemref;
219         result = entry->short_name;
220         ui_menu::stack_pop(machine());
262221      }
263222      else if (event->iptkey == IPT_SPECIAL)
264223      {
r13911r13912
287246
288247         if (update_selected)
289248         {
290            const ui_menu_software_entry_info *cur_selected;
249            const entry_info *cur_selected;
291250
292251            // if the current selection is a software entry, start search from here
293252            if ((FPTR)event->itemref != 1)
294               cur_selected= (const ui_menu_software_entry_info *)get_selection();
253               cur_selected= (const entry_info *)get_selection();
295254            // else (if we are on the 'Switch Order' entry) start from the beginning
296255            else
297256               cur_selected= entrylist;
r13911r13912
354313}
355314
356315/* list of available software lists - i.e. cartridges, floppies */
357ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, device_image_interface* _image) : ui_menu(machine, container)
316ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, const char *_interface, const software_list_config **_result) : ui_menu(machine, container)
358317{
359   image = _image;
318   interface = _interface;
319   result = _result;
360320}
361321
362322void ui_menu_software::populate()
363323{
364324   bool haveCompatible = false;
365   const char *interface = image->image_interface();
366325
367326   // Add original software lists for this system
368327   for (const device_t *dev = machine().config().devicelist().first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
369328   {
370      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
329      const software_list_config *swlist = (const software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
371330
372331      if (swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM)
373332      {
374         software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
333         const software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
375334
376335         if (list)
377336         {
378337            bool found = false;
379            for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
338            for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
380339            {
381               software_part *part = software_find_part(swinfo, NULL, NULL);
340               const software_part *part = software_find_part(swinfo, NULL, NULL);
382341               if (strcmp(interface,part->interface_)==0) {
383342                  found = true;
384343               }
385344            }
386345            if (found) {
387               item_append(list->description, NULL, 0, swlist);
346               item_append(list->description, NULL, 0, (void *)swlist);
388347            }
389348
390349            software_list_close(list);
r13911r13912
395354   // Add compatible software lists for this system
396355   for (const device_t *dev = machine().config().devicelist().first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
397356   {
398      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
357      const software_list_config *swlist = (const software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
399358
400359      if (swlist->list_type == SOFTWARE_LIST_COMPATIBLE_SYSTEM)
401360      {
402         software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
361         const software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL);
403362
404363         if (list)
405364         {
406365            bool found = false;
407            for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
366            for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
408367            {
409               software_part *part = software_find_part(swinfo, NULL, NULL);
368               const software_part *part = software_find_part(swinfo, NULL, NULL);
410369               if (strcmp(interface,part->interface_)==0) {
411370                  found = true;
412371               }
r13911r13912
415374               if (!haveCompatible) {
416375                  item_append("[compatible lists]", NULL, MENU_FLAG_DISABLE, NULL);
417376               }
418               item_append(list->description, NULL, 0, swlist);
377               item_append(list->description, NULL, 0, (void *)swlist);
419378            }
420379
421380            haveCompatible = true;
r13911r13912
435394   /* process the menu */
436395   const ui_menu_event *event = process(0);
437396
438   if (event != NULL && event->iptkey == IPT_UI_SELECT)
439      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (software_list_config *)event->itemref, image)));
397   if (event != NULL && event->iptkey == IPT_UI_SELECT) {
398      //      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (software_list_config *)event->itemref, image)));
399      *result = (software_list_config *)event->itemref;
400      ui_menu::stack_pop(machine());
401   }     
440402}
src/emu/uiswlist.h
r13911r13912
1212#ifndef __UISWLIST_H__
1313#define __UISWLIST_H__
1414
15struct ui_menu_software_entry_info {
16   ui_menu_software_entry_info *next;
17
18   const char *short_name;
19   const char *long_name;
20   const char *interface;
21   char *list_name;
22   device_image_interface* image;
23};
24
2515class ui_menu_software_parts : public ui_menu {
2616public:
27   ui_menu_software_parts(running_machine &machine, render_container *container, ui_menu_software_entry_info *entry);
17   enum { T_ENTRY, T_FMGR };
18   ui_menu_software_parts(running_machine &machine, render_container *container, const software_info *info, const char *interface, const software_part **part, bool opt_fmgr, int *result);
2819   virtual ~ui_menu_software_parts();
2920   virtual void populate();
3021   virtual void handle();
3122
3223private:
33   struct software_part_info {
34      const char *part_name;
35      const char *interface;
24   struct software_part_menu_entry {
25      int type;
26      const software_part *part;
3627   };
3728
38   ui_menu_software_entry_info *entry;
29   const software_info *info;
30   const char *interface;
31   const software_part **selected_part;
32   bool opt_fmgr;
33   int *result;
3934};
4035
4136class ui_menu_software_list : public ui_menu {
4237public:
43   ui_menu_software_list(running_machine &machine, render_container *container, software_list_config *swlist, device_image_interface *image);
38   ui_menu_software_list(running_machine &machine, render_container *container, const software_list_config *swlist, const char *interface, astring &result);
4439   virtual ~ui_menu_software_list();
4540   virtual void populate();
4641   virtual void handle();
4742
4843private:
49   software_list_config *swlist;   /* currently selected list */
50   device_image_interface *image;
51   ui_menu_software_entry_info *entrylist;
44   struct entry_info {
45      entry_info *next;
46
47      const char *short_name;
48      const char *long_name;
49   };
50
51   const software_list_config *swlist;   /* currently selected list */
52   const char *interface;
53   astring &result;
54   entry_info *entrylist;
5255   char filename_buffer[1024];
5356   bool ordered_by_shortname;
5457
55   int compare_entries(const ui_menu_software_entry_info *e1, const ui_menu_software_entry_info *e2, bool shortname);
56   ui_menu_software_entry_info *append_software_entry(software_info *swinfo, device_image_interface* image);
57   bool swinfo_has_multiple_parts(software_info *swinfo, const char *interface);
58   int compare_entries(const entry_info *e1, const entry_info *e2, bool shortname);
59   entry_info *append_software_entry(const software_info *swinfo);
5860};
5961
6062class ui_menu_software : public ui_menu {
6163public:
62   ui_menu_software(running_machine &machine, render_container *container, device_image_interface *device);
64   ui_menu_software(running_machine &machine, render_container *container, const char *interface, const software_list_config **result);
6365   virtual ~ui_menu_software();
6466   virtual void populate();
6567   virtual void handle();
6668
6769private:
68   device_image_interface *image;
70   const char *interface;
71   const software_list_config **result;
6972};
7073
7174#endif   /* __UISWLIST_H__ */
src/emu/softlist.c
r13911r13912
975975 software_list_get_count
976976 -------------------------------------------------*/
977977
978static int software_list_get_count(software_list *swlist)
978static int software_list_get_count(const software_list *swlist)
979979{
980980   int count = 0;
981981
982   for (software_info *swinfo = software_list_find(swlist, "*", NULL); swinfo != NULL; swinfo = software_list_find(swlist, "*", swinfo))
982   for (const software_info *swinfo = software_list_find(swlist, "*", NULL); swinfo != NULL; swinfo = software_list_find(swlist, "*", swinfo))
983983      count++;
984984
985985   return count;
r13911r13912
993993
994994const char *software_get_clone(emu_options &options, char *swlist, const char *swname)
995995{
996   software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
996   const software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
997997   const char *retval = NULL;
998998   if (software_list_ptr)
999999   {
1000      software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
1000      const software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
10011001      retval = core_strdup(tmp->parentname);
10021002      software_list_close(software_list_ptr);
10031003   }
r13911r13912
10131013
10141014UINT32 software_get_support(emu_options &options, char *swlist, const char *swname)
10151015{
1016   software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
1016   const software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
10171017   UINT32 retval = 0;
10181018
10191019   if (software_list_ptr)
10201020   {
1021      software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
1021      const software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
10221022      retval = tmp->supported;
10231023      software_list_close(software_list_ptr);
10241024   }
r13911r13912
11321132    software_list_close
11331133-------------------------------------------------*/
11341134
1135void software_list_close(software_list *swlist)
1135void software_list_close(const software_list *swlist)
11361136{
11371137   if (swlist == NULL)
11381138      return;
r13911r13912
11471147 software_list_get_description
11481148 -------------------------------------------------*/
11491149
1150const char *software_list_get_description(software_list *swlist)
1150const char *software_list_get_description(const software_list *swlist)
11511151{
11521152   return swlist->description;
11531153}
r13911r13912
12791279    software_list_find
12801280-------------------------------------------------*/
12811281
1282software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev)
1282const software_info *software_list_find(const software_list *swlist, const char *look_for, const software_info *prev)
12831283{
12841284   if (swlist == NULL)
12851285      return NULL;
r13911r13912
12881288      return NULL;
12891289
12901290   /* If we haven't read in the xml file yet, then do it now */
1291   /* Just-in-time parsing, hence the const-cast */
12911292   if ( ! swlist->software_info_list )
1292      software_list_parse( swlist, swlist->error_proc, NULL );
1293      software_list_parse( const_cast<software_list *>(swlist), swlist->error_proc, NULL );
12931294
12941295   for ( prev = prev ? prev->next : swlist->software_info_list; prev; prev = prev->next )
12951296   {
r13911r13912
13001301   return prev;
13011302}
13021303
1304software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev)
1305{
1306   return const_cast<software_info *>(software_list_find(const_cast<const software_list *>(swlist),
1307                                            look_for,
1308                                            const_cast<const software_info *>(prev)));
1309}
13031310
13041311/*-------------------------------------------------
13051312    software_find_romdata (for validation purposes)
r13911r13912
13571364    software_find_part
13581365-------------------------------------------------*/
13591366
1360software_part *software_find_part(software_info *sw, const char *partname, const char *interface)
1367const software_part *software_find_part(const software_info *sw, const char *partname, const char *interface)
13611368{
1362   software_part *part = sw ? sw->partdata : NULL;
1369   const software_part *part = sw ? sw->partdata : NULL;
13631370
13641371    /* If neither partname nor interface supplied, then we just return the first entry */
13651372   if ( partname || interface )
r13911r13912
14041411   return part;
14051412}
14061413
1414software_part *software_find_part(software_info *sw, const char *partname, const char *interface)
1415{
1416   return const_cast<software_part *>(software_find_part(const_cast<const software_info *>(sw), partname, interface));
1417}
14071418
14081419/*-------------------------------------------------
14091420    software_part_next
14101421-------------------------------------------------*/
14111422
1412software_part *software_part_next(software_part *part)
1423const software_part *software_part_next(const software_part *part)
14131424{
14141425   if ( part && part->name )
14151426   {
r13911r13912
14221433   return part;
14231434}
14241435
1436software_part *software_part_next(software_part *part)
1437{
1438   return const_cast<software_part *>(software_part_next(const_cast<const software_part *>(part)));
1439}
1440
14251441/*-------------------------------------------------
14261442    software_display_matches
14271443-------------------------------------------------*/
r13911r13912
17541770    software_part_get_feature
17551771 -------------------------------------------------*/
17561772
1757const char *software_part_get_feature(software_part *part, const char *feature_name)
1773const char *software_part_get_feature(const software_part *part, const char *feature_name)
17581774{
1759   feature_list *feature;
1775   const feature_list *feature;
17601776
17611777   if (part == NULL)
17621778      return NULL;
r13911r13912
18031819    is_software_compatible
18041820 -------------------------------------------------*/
18051821
1806bool is_software_compatible(software_part *swpart, software_list_config *swlist)
1822bool is_software_compatible(const software_part *swpart, const software_list_config *swlist)
18071823{
18081824   const char *compatibility = software_part_get_feature(swpart, "compatibility");
18091825   const char *filter = swlist->filter;
r13911r13912
18191835   return FALSE;
18201836}
18211837
1838/*-------------------------------------------------
1839    swinfo_has_multiple_parts
1840 -------------------------------------------------*/
1841
1842bool swinfo_has_multiple_parts(const software_info *swinfo, const char *interface)
1843{
1844   int count = 0;
1845
1846   for (const software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1847   {
1848      if (strcmp(interface, swpart->interface_) == 0)
1849         count++;
1850   }
1851   return (count > 1) ? true : false;
1852}
1853
18221854/***************************************************************************
18231855    DEVICE INTERFACE
18241856***************************************************************************/
src/emu/softlist.h
r13911r13912
107107
108108/* Handling a software list */
109109software_list *software_list_open(emu_options &options, const char *listname, int is_preload, void (*error_proc)(const char *message));
110void software_list_close(software_list *swlist);
110void software_list_close(const software_list *swlist);
111111software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev);
112const char *software_list_get_description(software_list *swlist);
112const char *software_list_get_description(const software_list *swlist);
113113void software_list_parse(software_list *swlist, void (*error_proc)(const char *message), void *param);
114114
115115software_part *software_find_part(software_info *sw, const char *partname, const char *interface_);
116116software_part *software_part_next(software_part *part);
117117
118const software_info *software_list_find(const software_list *swlist, const char *look_for, const software_info *prev);
119const software_part *software_find_part(const software_info *sw, const char *partname, const char *interface_);
120const software_part *software_part_next(const software_part *part);
121
118122/* helpers */
119123const char *software_get_clone(emu_options &options, char *swlist, const char *swname);
120124UINT32 software_get_support(emu_options &options, char *swlist, const char *swname);
121const char *software_part_get_feature(software_part *part, const char *feature_name);
125const char *software_part_get_feature(const software_part *part, const char *feature_name);
122126
123127bool load_software_part(emu_options &options, device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name);
124128
r13911r13912
128132
129133void validate_softlists(emu_options &options);
130134
131bool is_software_compatible(software_part *swpart, software_list_config *swlist);
135bool is_software_compatible(const software_part *swpart, const software_list_config *swlist);
136bool swinfo_has_multiple_parts(const software_info *swinfo, const char *interface);
137
132138/*********************************************************************
133139
134140    Driver software list configuration

Previous 15994 Revisions Next


© 1998-2018 The MESS Team