src/emu/uiswlist.c
| r13674 | r13675 | |
| 126 | 126 | return result; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | bool ui_menu_software_list::if_compatible(const char *compatibility, const char *filter) |
| 130 | { |
| 131 | if ((compatibility==NULL) || (filter==NULL)) return TRUE; |
| 132 | astring comp = astring(compatibility,","); |
| 133 | char *filt = core_strdup(filter); |
| 134 | char *token = strtok(filt,","); |
| 135 | while (token!= NULL) |
| 136 | { |
| 137 | if (comp.find(0,astring(token,","))!=-1) return TRUE; |
| 138 | token = strtok (NULL, ","); |
| 139 | } |
| 140 | return FALSE; |
| 141 | } |
| 142 | |
| 129 | 143 | /* populate a specific list */ |
| 130 | 144 | |
| 131 | | ui_menu_software_entry_info *ui_menu_software_list::append_software_entry(software_info *swinfo, char *list_name, device_image_interface* image) |
| 145 | ui_menu_software_entry_info *ui_menu_software_list::append_software_entry(software_info *swinfo, device_image_interface* image) |
| 132 | 146 | { |
| 133 | 147 | ui_menu_software_entry_info *entry = NULL; |
| 134 | 148 | ui_menu_software_entry_info **entryptr; |
| r13674 | r13675 | |
| 138 | 152 | // check if at least one of the parts has the correct interface and add a menu entry only in this case |
| 139 | 153 | for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart)) |
| 140 | 154 | { |
| 141 | | if (strcmp(interface, swpart->interface_) == 0) |
| 155 | const char *compatibility = software_part_get_feature(swpart, "compatibility"); |
| 156 | if ((strcmp(interface, swpart->interface_) == 0) && if_compatible(compatibility, swlist->filter)) |
| 142 | 157 | { |
| 143 | 158 | entry_updated = TRUE; |
| 144 | 159 | // allocate a new entry |
| r13674 | r13675 | |
| 147 | 162 | |
| 148 | 163 | entry->short_name = pool_strdup(swinfo->shortname); |
| 149 | 164 | entry->long_name = pool_strdup(swinfo->longname); |
| 150 | | entry->list_name = list_name; |
| 165 | entry->list_name = swlist->list_name; |
| 151 | 166 | entry->image = image; |
| 152 | 167 | entry->interface = pool_strdup(swpart->interface_); |
| 153 | 168 | break; |
| r13674 | r13675 | |
| 170 | 185 | return entry; |
| 171 | 186 | } |
| 172 | 187 | |
| 173 | | ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, char *_list_name, device_image_interface *_image) : ui_menu(machine, container) |
| 188 | ui_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) |
| 174 | 189 | { |
| 175 | | list_name = _list_name; |
| 190 | swlist = _swlist; |
| 176 | 191 | image = _image; |
| 177 | 192 | entrylist = NULL; |
| 178 | 193 | ordered_by_shortname = true; |
| r13674 | r13675 | |
| 184 | 199 | |
| 185 | 200 | void ui_menu_software_list::populate() |
| 186 | 201 | { |
| 187 | | software_list *list = software_list_open(machine().options(), list_name, false, NULL); |
| 202 | software_list *list = software_list_open(machine().options(), swlist->list_name, false, NULL); |
| 188 | 203 | |
| 189 | 204 | // build up the list of entries for the menu |
| 190 | 205 | if (list) |
| 191 | 206 | { |
| 192 | 207 | for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo)) |
| 193 | | append_software_entry(swinfo, list_name, image); |
| 208 | append_software_entry(swinfo, image); |
| 194 | 209 | |
| 195 | 210 | software_list_close(list); |
| 196 | 211 | } |
| r13674 | r13675 | |
| 241 | 256 | else if (event->iptkey == IPT_UI_SELECT) |
| 242 | 257 | { |
| 243 | 258 | ui_menu_software_entry_info *entry = (ui_menu_software_entry_info *) event->itemref; |
| 244 | | software_list *tmp_list = software_list_open(machine().options(), list_name, false, NULL); |
| 259 | software_list *tmp_list = software_list_open(machine().options(), swlist->list_name, false, NULL); |
| 245 | 260 | software_info *tmp_info = software_list_find(tmp_list, entry->short_name, NULL); |
| 246 | 261 | |
| 247 | 262 | // if the selected software has multiple parts that can be loaded, open the submenu |
| r13674 | r13675 | |
| 384 | 399 | } |
| 385 | 400 | } |
| 386 | 401 | if (found) { |
| 387 | | item_append(list->description, NULL, 0, swlist->list_name); |
| 402 | item_append(list->description, NULL, 0, swlist); |
| 388 | 403 | } |
| 389 | 404 | |
| 390 | 405 | software_list_close(list); |
| r13674 | r13675 | |
| 415 | 430 | if (!haveCompatible) { |
| 416 | 431 | item_append("[compatible lists]", NULL, MENU_FLAG_DISABLE, NULL); |
| 417 | 432 | } |
| 418 | | item_append(list->description, NULL, 0, swlist->list_name); |
| 433 | item_append(list->description, NULL, 0, swlist); |
| 419 | 434 | } |
| 420 | 435 | |
| 421 | 436 | haveCompatible = true; |
| r13674 | r13675 | |
| 436 | 451 | const ui_menu_event *event = process(0); |
| 437 | 452 | |
| 438 | 453 | if (event != NULL && event->iptkey == IPT_UI_SELECT) |
| 439 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (char *)event->itemref, image))); |
| 454 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (software_list_config *)event->itemref, image))); |
| 440 | 455 | } |
src/emu/uiswlist.h
| r13674 | r13675 | |
| 40 | 40 | |
| 41 | 41 | class ui_menu_software_list : public ui_menu { |
| 42 | 42 | public: |
| 43 | | ui_menu_software_list(running_machine &machine, render_container *container, char *list_name, device_image_interface *image); |
| 43 | ui_menu_software_list(running_machine &machine, render_container *container, software_list_config *swlist, device_image_interface *image); |
| 44 | 44 | virtual ~ui_menu_software_list(); |
| 45 | 45 | virtual void populate(); |
| 46 | 46 | virtual void handle(); |
| 47 | 47 | |
| 48 | 48 | private: |
| 49 | | char *list_name; /* currently selected list */ |
| 49 | software_list_config *swlist; /* currently selected list */ |
| 50 | 50 | device_image_interface *image; |
| 51 | 51 | ui_menu_software_entry_info *entrylist; |
| 52 | 52 | char filename_buffer[1024]; |
| 53 | 53 | bool ordered_by_shortname; |
| 54 | 54 | |
| 55 | 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, char *list_name, device_image_interface* image); |
| 56 | ui_menu_software_entry_info *append_software_entry(software_info *swinfo, device_image_interface* image); |
| 57 | 57 | bool swinfo_has_multiple_parts(software_info *swinfo, const char *interface); |
| 58 | bool if_compatible(const char *compatibility, const char *filter); |
| 58 | 59 | }; |
| 59 | 60 | |
| 60 | 61 | class ui_menu_software : public ui_menu { |