Previous 15994 Revisions Next

r11092 Wednesday 6th April, 2011 at 16:22:49 UTC by Fabio Priuli
softlist.c: rewritten part of the Internal UI handling for softlists to match the code used by the file selector (this will allow more improvements soon). [Fabio Priuli]
[src/emu]softlist.c

src/emu/softlist.c
r11091r11092
18451845    MENU SUPPORT
18461846***************************************************************************/
18471847
1848/* state of the software menu */
1849typedef struct _software_menu_state software_menu_state;
1850struct _software_menu_state
1851{
1852   char *list_name;   /* currently selected list */
1853   device_image_interface* image;
1854};
1855
18561848/* state of a software entry */
18571849typedef struct _software_entry_state software_entry_state;
18581850struct _software_entry_state
18591851{
1852   software_entry_state *next;
1853   
18601854   const char *short_name;
1855   const char *long_name;
18611856   const char *interface;
18621857   char *list_name;
18631858   device_image_interface* image;
18641859};
18651860
1861/* state of the software menu */
1862typedef struct _software_menu_state software_menu_state;
1863struct _software_menu_state
1864{
1865   char *list_name;   /* currently selected list */
1866   device_image_interface* image;
1867   software_entry_state *entrylist;
1868};
1869
18661870/* state of a software part */
18671871typedef struct _software_part_state software_part_state;
18681872struct _software_part_state
r11091r11092
19421946}
19431947
19441948/* populate a specific list */
1945static void ui_mess_menu_populate_software_entries(running_machine &machine, ui_menu *menu, char *list_name, device_image_interface* image)
1949
1950static software_entry_state *append_software_entry(ui_menu *menu, software_menu_state *menustate,
1951                                          software_info *swinfo, char *list_name, device_image_interface* image)
19461952{
1947   software_list *list = software_list_open(machine.options(), list_name, FALSE, NULL);
1953   software_entry_state *entry = NULL;
1954   software_entry_state **entryptr;
19481955   const char *interface = image->image_config().image_interface();
1949   if (list)
1956   
1957   // check if at least one of the parts has the correct interface and add a menu entry only in this case
1958   for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
19501959   {
1951      for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
1960      if (strcmp(interface, swpart->interface_) == 0)
19521961      {
1953         software_entry_state *entry = (software_entry_state *) ui_menu_pool_alloc(menu, sizeof(*entry));
1962         // allocate a new entry
1963         entry = (software_entry_state *) ui_menu_pool_alloc(menu, sizeof(*entry));
1964         memset(entry, 0, sizeof(*entry));
1965
19541966         entry->short_name = ui_menu_pool_strdup(menu, swinfo->shortname);
1967         entry->long_name = ui_menu_pool_strdup(menu, swinfo->longname);
19551968         entry->list_name = list_name;
19561969         entry->image = image;
1957
1958         // check if at least one of the parts has the correct interface
1959         for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1960         {
1961            if (strcmp(interface, swpart->interface_) == 0)
1962            {
1963               entry->interface = ui_menu_pool_strdup(menu, swpart->interface_);
1964               ui_menu_item_append(menu, swinfo->shortname, swinfo->longname, 0, entry);
1965               break;
1966            }
1967         }
1970         entry->interface = ui_menu_pool_strdup(menu, swpart->interface_);
1971         break;
19681972      }
1973   }
19691974
1975   // find the end of the list
1976   entryptr = &menustate->entrylist;
1977   while ((*entryptr != NULL) /*&& (compare_software_entries(entry, *entryptr) >= 0)*/)
1978      entryptr = &(*entryptr)->next;
1979   
1980   // insert the entry
1981   entry->next = *entryptr;
1982   *entryptr = entry;
1983
1984   return entry;
1985}
1986
1987
1988static void ui_mess_menu_populate_software_entries(running_machine &machine, ui_menu *menu, software_menu_state *menustate)
1989{
1990   software_list *list = software_list_open(machine.options(), menustate->list_name, FALSE, NULL);
1991
1992   // build up the list of entries for the menu
1993   if (list)
1994   {
1995      for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
1996         append_software_entry(menu, menustate, swinfo, menustate->list_name, menustate->image);
1997
19701998      software_list_close(list);
19711999   }
2000
2001   // append all of the menu entries
2002   for (software_entry_state *entry = menustate->entrylist; entry != NULL; entry = entry->next)
2003      ui_menu_item_append(menu, entry->short_name, entry->long_name, 0, entry);
19722004}
19732005
19742006bool swinfo_has_multiple_parts(software_info *swinfo, const char *interface)
r11091r11092
19922024   {
19932025      if (sw_state->list_name)
19942026      {
1995         ui_mess_menu_populate_software_entries(machine, menu, sw_state->list_name, sw_state->image);
2027         ui_mess_menu_populate_software_entries(machine, menu, sw_state);
19962028      }
19972029   }
19982030
r11091r11092
20352067   bool haveCompatible = FALSE;
20362068   const char *interface = image->image_config().image_interface();
20372069
2070   // Add original software lists for this system
20382071   for (const device_config *dev = machine.config().m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
20392072   {
20402073      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
r11091r11092
20652098      }
20662099   }
20672100
2101   // Add compatible software lists for this system
20682102   for (const device_config *dev = machine.config().m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
20692103   {
20702104      software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config();
r11091r11092
21172151      software_menu_state *child_menustate = (software_menu_state *)ui_menu_alloc_state(child_menu, sizeof(*child_menustate), NULL);
21182152      child_menustate->list_name = (char *)event->itemref;
21192153      child_menustate->image = image;
2154      child_menustate->entrylist = NULL;
21202155      ui_menu_stack_push(child_menu);
21212156   }
21222157}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team