branches/new_menus/src/emu/ui/swlist.h
| r29308 | r29309 | |
| 12 | 12 | #ifndef __UI_SWLIST_H__ |
| 13 | 13 | #define __UI_SWLIST_H__ |
| 14 | 14 | |
| 15 | | #include "softlist.h" |
| 16 | | |
| 17 | 15 | // ======================> ui_menu_software_parts |
| 18 | 16 | |
| 19 | 17 | class ui_menu_software_parts : public ui_menu { |
| 20 | 18 | public: |
| 21 | 19 | enum { T_ENTRY, T_FMGR }; |
| 22 | | ui_menu_software_parts(running_machine &machine, render_container *container, device_image_interface *image, software_list_device *swlist, software_info *info, const char *interface, software_part **part); |
| 20 | 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); |
| 21 | virtual ~ui_menu_software_parts(); |
| 23 | 22 | virtual void populate(); |
| 24 | 23 | virtual void handle(); |
| 25 | 24 | |
| r29308 | r29309 | |
| 30 | 29 | }; |
| 31 | 30 | |
| 32 | 31 | // variables |
| 33 | | device_image_interface *m_image; |
| 34 | | software_list_device * m_swlist; |
| 35 | | software_info * m_info; |
| 32 | const software_info * m_info; |
| 36 | 33 | const char * m_interface; |
| 37 | | software_part ** m_selected_part; |
| 34 | const software_part ** m_selected_part; |
| 35 | bool m_opt_fmgr; |
| 36 | int * m_result; |
| 38 | 37 | }; |
| 39 | 38 | |
| 40 | 39 | |
| r29308 | r29309 | |
| 42 | 41 | |
| 43 | 42 | class ui_menu_software_list : public ui_menu { |
| 44 | 43 | public: |
| 45 | | ui_menu_software_list(running_machine &machine, render_container *container, device_image_interface *image, software_list_device *swlist, const char *interface, astring &result); |
| 44 | ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result); |
| 46 | 45 | virtual ~ui_menu_software_list(); |
| 47 | 46 | virtual void populate(); |
| 48 | 47 | virtual void handle(); |
| r29308 | r29309 | |
| 56 | 55 | }; |
| 57 | 56 | |
| 58 | 57 | // variables |
| 59 | | device_image_interface * m_image; |
| 60 | 58 | software_list_device * m_swlist; // currently selected list |
| 61 | 59 | const char * m_interface; |
| 62 | 60 | astring & m_result; |
| r29308 | r29309 | |
| 67 | 65 | // functions |
| 68 | 66 | int compare_entries(const entry_info *e1, const entry_info *e2, bool shortname); |
| 69 | 67 | entry_info *append_software_entry(const software_info *swinfo); |
| 70 | | void select_entry(entry_info *entry); |
| 71 | 68 | }; |
| 72 | 69 | |
| 73 | 70 | |
| 71 | |
| 74 | 72 | #endif /* __UI_SWLIST_H__ */ |
branches/new_menus/src/emu/ui/emenubar.c
| r29308 | r29309 | |
| 39 | 39 | // MENUBAR IMPLEMENTATION |
| 40 | 40 | //************************************************************************** |
| 41 | 41 | |
| 42 | astring ui_emu_menubar::s_softlist_result; |
| 43 | device_image_interface *ui_emu_menubar::s_softlist_image; |
| 44 | |
| 45 | |
| 42 | 46 | //------------------------------------------------- |
| 43 | 47 | // ctor |
| 44 | 48 | //------------------------------------------------- |
| r29308 | r29309 | |
| 50 | 54 | |
| 51 | 55 | |
| 52 | 56 | //------------------------------------------------- |
| 57 | // handle |
| 58 | //------------------------------------------------- |
| 59 | |
| 60 | void ui_emu_menubar::handle(render_container *container) |
| 61 | { |
| 62 | // check to see if we have a softlist selection |
| 63 | if (s_softlist_result.len() > 0) |
| 64 | { |
| 65 | // do the load |
| 66 | s_softlist_image->load(s_softlist_result); |
| 67 | |
| 68 | // clear out state |
| 69 | s_softlist_image = NULL; |
| 70 | s_softlist_result.reset(); |
| 71 | } |
| 72 | |
| 73 | // call inherited method |
| 74 | ui_menubar::handle(container); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | //------------------------------------------------- |
| 53 | 79 | // start_menu |
| 54 | 80 | //------------------------------------------------- |
| 55 | 81 | |
| r29308 | r29309 | |
| 554 | 580 | |
| 555 | 581 | void ui_emu_menubar::select_from_software_list(device_image_interface *image, software_list_device *swlist) |
| 556 | 582 | { |
| 557 | | astring result; |
| 558 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container(), image, swlist, NULL, result))); |
| 583 | s_softlist_image = image; |
| 584 | machine().ui().set_handler(ui_menu::ui_handler, 0); |
| 585 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container(), swlist, image->image_interface(), s_softlist_result))); |
| 559 | 586 | } |
| 560 | 587 | |
| 561 | 588 | |
branches/new_menus/src/emu/ui/swlist.c
| r29308 | r29309 | |
| 30 | 30 | // ctor |
| 31 | 31 | //------------------------------------------------- |
| 32 | 32 | |
| 33 | | ui_menu_software_parts::ui_menu_software_parts(running_machine &machine, render_container *container, device_image_interface *image, software_list_device *swlist, software_info *info, const char *interface, software_part **part) |
| 33 | ui_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) |
| 34 | 34 | : ui_menu(machine, container) |
| 35 | 35 | { |
| 36 | | m_image = image; |
| 37 | | m_swlist = swlist; |
| 38 | 36 | m_info = info; |
| 39 | 37 | m_interface = interface; |
| 40 | 38 | m_selected_part = part; |
| 39 | m_opt_fmgr = opt_fmgr; |
| 40 | m_result = result; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | //------------------------------------------------- |
| 45 | // dtor |
| 46 | //------------------------------------------------- |
| 47 | |
| 48 | ui_menu_software_parts::~ui_menu_software_parts() |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | |
| 53 | //------------------------------------------------- |
| 45 | 54 | // populate |
| 46 | 55 | //------------------------------------------------- |
| 47 | 56 | |
| r29308 | r29309 | |
| 62 | 71 | item_append(m_info->shortname(), menu_part_name.cstr(), 0, entry); |
| 63 | 72 | } |
| 64 | 73 | } |
| 74 | |
| 75 | if (m_opt_fmgr) |
| 76 | { |
| 77 | software_part_menu_entry *entry = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry)); |
| 78 | entry->type = T_FMGR; |
| 79 | entry->part = 0; |
| 80 | item_append("[file manager]", 0, 0, entry); |
| 81 | } |
| 65 | 82 | } |
| 66 | 83 | |
| 67 | 84 | |
| r29308 | r29309 | |
| 76 | 93 | |
| 77 | 94 | if (event != NULL && event->iptkey == IPT_UI_SELECT && event->itemref != NULL) |
| 78 | 95 | { |
| 79 | | // we have the part |
| 80 | | software_part_menu_entry *entry = (software_part_menu_entry *) event->itemref; |
| 81 | | |
| 82 | | // load the image |
| 83 | | astring image_name; |
| 84 | | image_name.printf("%s:%s:%s", m_swlist->list_name(), m_info->shortname(), entry->part->name()); |
| 85 | | m_image->load(image_name); |
| 86 | | |
| 87 | | // and exit |
| 96 | software_part_menu_entry *entry = (software_part_menu_entry *) event->itemref; |
| 97 | *m_result = entry->type; |
| 98 | *m_selected_part = entry->part; |
| 88 | 99 | ui_menu::stack_pop(machine()); |
| 89 | 100 | } |
| 90 | 101 | } |
| r29308 | r29309 | |
| 98 | 109 | // ctor |
| 99 | 110 | //------------------------------------------------- |
| 100 | 111 | |
| 101 | | ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, device_image_interface *image, software_list_device *swlist, const char *interface, astring &result) |
| 112 | ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result) |
| 102 | 113 | : ui_menu(machine, container), m_result(result) |
| 103 | 114 | { |
| 104 | | m_image = image; |
| 105 | 115 | m_swlist = swlist; |
| 106 | 116 | m_interface = interface; |
| 107 | 117 | m_entrylist = NULL; |
| r29308 | r29309 | |
| 119 | 129 | |
| 120 | 130 | |
| 121 | 131 | //------------------------------------------------- |
| 122 | | // select_entry |
| 123 | | //------------------------------------------------- |
| 124 | | |
| 125 | | void ui_menu_software_list::select_entry(entry_info *entry) |
| 126 | | { |
| 127 | | software_info *swi; |
| 128 | | software_part *swp; |
| 129 | | |
| 130 | | swi = m_swlist->find(entry->short_name); |
| 131 | | |
| 132 | | if (swi->has_multiple_parts(m_interface)) |
| 133 | | { |
| 134 | | // multi part software; need to spawn another menu |
| 135 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, m_image, m_swlist, swi, m_interface, &swp))); |
| 136 | | } |
| 137 | | else |
| 138 | | { |
| 139 | | // single part software; just get the part |
| 140 | | swp = swi->first_part(); |
| 141 | | |
| 142 | | // and load it |
| 143 | | astring image_name; |
| 144 | | image_name.printf("%s:%s:%s", m_swlist->list_name(), swi->shortname(), swp->name()); |
| 145 | | m_image->load(image_name); |
| 146 | | } |
| 147 | | } |
| 148 | | |
| 149 | | //------------------------------------------------- |
| 150 | 132 | // compare_entries |
| 151 | 133 | //------------------------------------------------- |
| 152 | 134 | |
| r29308 | r29309 | |
| 276 | 258 | // handle selections |
| 277 | 259 | else if (event->iptkey == IPT_UI_SELECT) |
| 278 | 260 | { |
| 279 | | // we're done (at least with this menu |
| 280 | | ui_menu::stack_pop(machine()); |
| 281 | | |
| 282 | | // select this entry |
| 283 | 261 | entry_info *entry = (entry_info *) event->itemref; |
| 284 | | select_entry(entry); |
| 262 | m_result = entry->short_name; |
| 263 | ui_menu::stack_pop(machine()); |
| 285 | 264 | } |
| 286 | 265 | else if (event->iptkey == IPT_SPECIAL) |
| 287 | 266 | { |
| r29308 | r29309 | |
| 372 | 351 | // reset the char buffer also in this case |
| 373 | 352 | if (m_filename_buffer[0] != '\0') |
| 374 | 353 | memset(m_filename_buffer, '\0', ARRAY_LENGTH(m_filename_buffer)); |
| 354 | m_result = m_filename_buffer; |
| 375 | 355 | ui_menu::stack_pop(machine()); |
| 376 | 356 | } |
| 377 | 357 | } |
| 378 | 358 | } |
| 359 | |