shelves/new_menus/src/emu/ui/filemngr.c
| r29299 | r29300 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | ui/filemngr.c |
| 4 | | |
| 5 | | MESS's clunky built-in file manager |
| 6 | | |
| 7 | | TODO |
| 8 | | - Restrict directory listing by file extension |
| 9 | | - Support file manager invocation from the main menu for |
| 10 | | required images |
| 11 | | |
| 12 | | *********************************************************************/ |
| 13 | | |
| 14 | | #include <stdio.h> |
| 15 | | #include <ctype.h> |
| 16 | | #include <stdlib.h> |
| 17 | | |
| 18 | | #include "emu.h" |
| 19 | | #include "ui/ui.h" |
| 20 | | #include "ui/swlist.h" |
| 21 | | #include "ui/filemngr.h" |
| 22 | | #include "ui/filesel.h" |
| 23 | | |
| 24 | | |
| 25 | | /*************************************************************************** |
| 26 | | FILE MANAGER |
| 27 | | ***************************************************************************/ |
| 28 | | |
| 29 | | //------------------------------------------------- |
| 30 | | // ctor |
| 31 | | //------------------------------------------------- |
| 32 | | |
| 33 | | ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 34 | | { |
| 35 | | } |
| 36 | | |
| 37 | | |
| 38 | | //------------------------------------------------- |
| 39 | | // dtor |
| 40 | | //------------------------------------------------- |
| 41 | | |
| 42 | | ui_menu_file_manager::~ui_menu_file_manager() |
| 43 | | { |
| 44 | | } |
| 45 | | |
| 46 | | |
| 47 | | //------------------------------------------------- |
| 48 | | // custom_render - perform our special rendering |
| 49 | | //------------------------------------------------- |
| 50 | | |
| 51 | | void ui_menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 52 | | { |
| 53 | | const char *path; |
| 54 | | |
| 55 | | // access the path |
| 56 | | path = selected_device ? selected_device->filename() : NULL; |
| 57 | | extra_text_render(container, top, bottom, |
| 58 | | origx1, origy1, origx2, origy2, NULL, path); |
| 59 | | } |
| 60 | | |
| 61 | | |
| 62 | | //------------------------------------------------- |
| 63 | | // populate |
| 64 | | //------------------------------------------------- |
| 65 | | |
| 66 | | void ui_menu_file_manager::populate() |
| 67 | | { |
| 68 | | astring buffer; |
| 69 | | astring tmp_name; |
| 70 | | |
| 71 | | // cycle through all devices for this system |
| 72 | | image_interface_iterator iter(machine().root_device()); |
| 73 | | for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) |
| 74 | | { |
| 75 | | // get the image type/id |
| 76 | | buffer.printf( |
| 77 | | "%s (%s)", |
| 78 | | image->device().name(), image->brief_instance_name()); |
| 79 | | |
| 80 | | // get the base name |
| 81 | | if (image->basename() != NULL) |
| 82 | | { |
| 83 | | tmp_name.cpy(image->basename()); |
| 84 | | |
| 85 | | // if the image has been loaded through softlist, also show the loaded part |
| 86 | | if (image->part_entry() != NULL) |
| 87 | | { |
| 88 | | const software_part *tmp = image->part_entry(); |
| 89 | | if (tmp->name() != NULL) |
| 90 | | { |
| 91 | | tmp_name.cat(" ("); |
| 92 | | tmp_name.cat(tmp->name()); |
| 93 | | // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it |
| 94 | | if (image->get_feature("part_id") != NULL) |
| 95 | | { |
| 96 | | tmp_name.cat(": "); |
| 97 | | tmp_name.cat(image->get_feature("part_id")); |
| 98 | | } |
| 99 | | tmp_name.cat(")"); |
| 100 | | } |
| 101 | | } |
| 102 | | } |
| 103 | | else |
| 104 | | tmp_name.cpy("---"); |
| 105 | | |
| 106 | | // record the menu item |
| 107 | | item_append(buffer, tmp_name.cstr(), 0, (void *) image); |
| 108 | | } |
| 109 | | |
| 110 | | custombottom = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; |
| 111 | | } |
| 112 | | |
| 113 | | |
| 114 | | //------------------------------------------------- |
| 115 | | // handle |
| 116 | | //------------------------------------------------- |
| 117 | | |
| 118 | | void ui_menu_file_manager::handle() |
| 119 | | { |
| 120 | | // update the selected device |
| 121 | | selected_device = (device_image_interface *) get_selection(); |
| 122 | | |
| 123 | | // process the menu |
| 124 | | const ui_menu_event *event = process(0); |
| 125 | | if (event != NULL && event->iptkey == IPT_UI_SELECT) |
| 126 | | { |
| 127 | | selected_device = (device_image_interface *) event->itemref; |
| 128 | | if (selected_device != NULL) |
| 129 | | { |
| 130 | | ui_menu::stack_push(selected_device->get_selection_menu(machine(), container)); |
| 131 | | |
| 132 | | // reset the existing menu |
| 133 | | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 134 | | } |
| 135 | | } |
| 136 | | } |
| 137 | | |
| 138 | | |