Previous 15994 Revisions Next

r10041 Saturday 15th January, 2011 at 00:40:48 UTC by Fabio Priuli
Added capability of mounting specific parts of a software element from Internal File Manager.
[src/emu]softlist.c

src/emu/softlist.c
r10040r10041
826826const char *software_get_clone(char *swlist, const char *swname)
827827{
828828   software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
829   
829
830830   if (software_list_ptr)
831831   {
832832      software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
833833      return tmp->parentname;
834834   }
835   
835
836836   return NULL;
837837}
838838
r10040r10041
845845UINT32 software_get_support(char *swlist, const char *swname)
846846{
847847   software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
848   
848
849849   if (software_list_ptr)
850850   {
851851      software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
852852      return tmp->supported;
853853   }
854   
854
855855   return 0;
856856}
857857
r10040r10041
16261626{
16271627   const char *short_name;
16281628   const char *interface;
1629   char *list_name;
1630   device_image_interface* image;
16291631};
16301632
1633/* state of a software part */
1634typedef struct _software_part_state software_part_state;
1635struct _software_part_state
1636{
1637   const char *part_name;
1638   const char *interface;
1639};
16311640
1641
1642static void ui_mess_menu_populate_software_parts(running_machine *machine, ui_menu *menu, const char *swlist, const char *swinfo, const char *interface)
1643{
1644   //questo dovrebbe generare la lista di parts
1645   software_list *list = software_list_open(machine->options(), swlist, FALSE, NULL);
1646
1647   if (list)
1648   {
1649      software_info *info = software_list_find(list, swinfo, NULL);
1650
1651      if (info)
1652      {
1653         for (software_part *swpart = software_find_part(info, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1654         {
1655            if (strcmp(interface, swpart->interface_) == 0)
1656            {
1657               software_part_state *entry = (software_part_state *) ui_menu_pool_alloc(menu, sizeof(*entry));
1658               entry->part_name = ui_menu_pool_strdup(menu, swpart->name);
1659               entry->interface = ui_menu_pool_strdup(menu, swpart->interface_);
1660               ui_menu_item_append(menu, info->shortname, swpart->name, 0, entry);
1661            }
1662         }
1663      }
1664
1665      software_list_close(list);
1666   }
1667}
1668
1669void ui_mess_menu_software_parts(running_machine *machine, ui_menu *menu, void *parameter, void *state)
1670{
1671   const ui_menu_event *event;
1672   software_entry_state *sw_state = (software_entry_state *)state;
1673   const char *swlist = sw_state->list_name;
1674   const char *swinfo = sw_state->short_name;
1675   const char *interface = sw_state->interface;
1676
1677   // generate list of available parts
1678   if (!ui_menu_populated(menu))
1679   {
1680      if (sw_state->list_name)
1681      {
1682         ui_mess_menu_populate_software_parts(machine, menu, swlist, swinfo, interface);
1683      }
1684   }
1685
1686   /* process the menu */
1687   event = ui_menu_process(machine, menu, 0);
1688
1689   if (event != NULL && event->iptkey == IPT_UI_SELECT && event->itemref != NULL)
1690   {
1691      software_part_state *entry = (software_part_state *) event->itemref;
1692
1693      // build the name for the part to be loaded
1694      astring temp_name(sw_state->short_name);
1695      temp_name.cat(":");
1696      temp_name.cat(entry->part_name);
1697      printf("%s\n", temp_name.cstr());
1698
1699      sw_state->image->load(temp_name.cstr());
1700   }
1701}
1702
16321703/* populate a specific list */
16331704static void ui_mess_menu_populate_software_entries(running_machine *machine, ui_menu *menu, char *list_name, device_image_interface* image)
16341705{
r10040r10041
16401711      {
16411712         software_entry_state *entry = (software_entry_state *) ui_menu_pool_alloc(menu, sizeof(*entry));
16421713         entry->short_name = ui_menu_pool_strdup(menu, swinfo->shortname);
1714         entry->list_name = list_name;
1715         entry->image = image;
16431716
1644         software_part *part = software_find_part(swinfo, NULL, NULL);
1645         entry->interface = ui_menu_pool_strdup(menu, part->interface_);
1646         if (strcmp(interface,part->interface_)==0) {
1647            ui_menu_item_append(menu, swinfo->shortname, swinfo->longname, 0, entry);
1717         // check if at least one of the parts has the correct interface
1718         for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1719         {
1720            if (strcmp(interface, swpart->interface_) == 0)
1721            {
1722               entry->interface = ui_menu_pool_strdup(menu, swpart->interface_);
1723               ui_menu_item_append(menu, swinfo->shortname, swinfo->longname, 0, entry);
1724               break;
1725            }
16481726         }
16491727      }
16501728
r10040r10041
16521730   }
16531731}
16541732
1733bool swinfo_has_multiple_parts(software_info *swinfo, const char *interface)
1734{
1735   int count = 0;
1736
1737   for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1738   {
1739      if (strcmp(interface, swpart->interface_) == 0)
1740         count++;
1741   }
1742   return (count > 1) ? TRUE : FALSE;
1743}
1744
16551745void ui_mess_menu_software_list(running_machine *machine, ui_menu *menu, void *parameter, void *state)
16561746{
16571747   const ui_menu_event *event;
16581748   software_menu_state *sw_state = (software_menu_state *)state;
16591749
1660   if (!ui_menu_populated(menu)) {
1661      if (sw_state->list_name) {
1662         ui_mess_menu_populate_software_entries(machine, menu, sw_state->list_name,sw_state->image);
1750   if (!ui_menu_populated(menu))
1751   {
1752      if (sw_state->list_name)
1753      {
1754         ui_mess_menu_populate_software_entries(machine, menu, sw_state->list_name, sw_state->image);
16631755      }
16641756   }
16651757
r10040r10041
16701762   {
16711763      device_image_interface *image = sw_state->image;
16721764      software_entry_state *entry = (software_entry_state *) event->itemref;
1673      if (image != NULL)
1674         image->load(entry->short_name);
1765      software_list *tmp_list = software_list_open(mame_options(), sw_state->list_name, FALSE, NULL);
1766      software_info *tmp_info = software_list_find(tmp_list, entry->short_name, NULL);
1767
1768      // if the selected software has multiple parts that can be loaded, open the submenu
1769      if (swinfo_has_multiple_parts(tmp_info, image->image_config().image_interface()))
1770      {
1771         ui_menu *child_menu = ui_menu_alloc(machine, &machine->render().ui_container(), ui_mess_menu_software_parts, entry);
1772         software_entry_state *child_menustate = (software_entry_state *)ui_menu_alloc_state(child_menu, sizeof(*child_menustate), NULL);
1773         child_menustate->short_name = entry->short_name;
1774         child_menustate->interface = image->image_config().image_interface();
1775         child_menustate->list_name = sw_state->list_name;
1776         child_menustate->image = image;
1777         ui_menu_stack_push(child_menu);
1778      }
16751779      else
1676         popmessage("No matching device found for interface '%s'!", entry->interface);
1780      {
1781         // otherwise, load the file
1782         if (image != NULL)
1783            image->load(entry->short_name);
1784         else
1785            popmessage("No matching device found for interface '%s'!", entry->interface);
1786      }
16771787   }
16781788}
16791789

Previous 15994 Revisions Next


© 1998-2018 The MESS Team