Previous 199869 Revisions Next

r34417 Friday 16th January, 2015 at 16:14:36 UTC by Fabio Priuli
ui: re-arranged File Manager a little bit, so that image devices are grouped
by owner, like Inputs / Dips / Configs menus. nw.
[src/emu/ui]filemngr.c filemngr.h

trunk/src/emu/ui/filemngr.c
r242928r242929
5959}
6060
6161
62void ui_menu_file_manager::fill_image_line(device_image_interface *img, astring &instance, astring &filename)
63{
64   // get the image type/id
65   instance.printf("%s (%s)", img->instance_name(), img->brief_instance_name());
66   
67   // get the base name
68   if (img->basename() != NULL)
69   {
70      filename.cpy(img->basename());
71     
72      // if the image has been loaded through softlist, also show the loaded part
73      if (img->part_entry() != NULL)
74      {
75         const software_part *tmp = img->part_entry();
76         if (tmp->name() != NULL)
77         {
78            filename.cat(" (");
79            filename.cat(tmp->name());
80            // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
81            if (img->get_feature("part_id") != NULL)
82            {
83               filename.cat(": ");
84               filename.cat(img->get_feature("part_id"));
85            }
86            filename.cat(")");
87         }
88      }
89   }
90   else
91      filename.cpy("---");
92}
93
6294//-------------------------------------------------
6395//  populate
6496//-------------------------------------------------
6597
6698void ui_menu_file_manager::populate()
6799{
68   astring buffer;
69   bool first = true;
100   astring buffer, tmp_inst, tmp_name;
101   bool first_entry = true;
102   astring prev_owner;
70103
71104   // 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())
105   device_iterator iter(machine().root_device());
106   tagmap_t<UINT8> devtags;
107   for (device_t *dev = iter.first(); dev != NULL; dev = iter.next())
74108   {
75      if (first)
76         first = false;
77      else
78         item_append("", NULL, MENU_FLAG_DISABLE, NULL);
109      bool tag_appended = false;
110      if (devtags.add(dev->tag(), 1, FALSE) == TMERR_DUPLICATE)
111         continue;
79112
80      // get the image type/id
81      buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name());
82      item_append(buffer, "", MENU_FLAG_DISABLE, NULL);
83      item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL);
84
85      // get the base name
86      if (image->basename() != NULL)
87      {
88         buffer.cpy(image->basename());
89
90         // if the image has been loaded through softlist, also show the loaded part
91         if (image->part_entry() != NULL)
113      // check whether it owns an image interface
114      image_interface_iterator subiter(*dev);
115      if (subiter.count() > 0)
116      {         
117         // if so, cycle through all its image interfaces
118         image_interface_iterator subiter(*dev);
119         for (device_image_interface *scan = subiter.first(); scan != NULL; scan = subiter.next())
92120         {
93            const software_part *tmp = image->part_entry();
94            if (tmp->name() != NULL)
95            {
96               buffer.cat(" (");
97               buffer.cat(tmp->name());
98               // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
99               if (image->get_feature("part_id") != NULL)
121            // if it is a children device, and not something further down the device tree, we want it in the menu!
122            if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0)
123               if (devtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE)
100124               {
101                  buffer.cat(": ");
102                  buffer.cat(image->get_feature("part_id"));
125                  // check whether we already had some devices with the same owner: if not, output the owner tag!
126                  if (!tag_appended)
127                  {
128                     if (first_entry)
129                        first_entry = false;
130                     else
131                        item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
132                     buffer.printf("[root%s]", dev->tag());
133                     item_append(buffer, NULL, 0, NULL);
134                     tag_appended = true;
135                  }
136                  // finally, append the image interface to the menu
137                  fill_image_line(scan, tmp_inst, tmp_name);
138                  item_append(tmp_inst, tmp_name, 0, (void *) scan);
103139               }
104               buffer.cat(")");
105            }
106140         }
107141      }
108      else
109         buffer.cpy("---");
110
111      // record the menu item
112      item_append("Mounted File", buffer, 0, (void *) image);
113142   }
114143   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
115144   item_append("Reset",  NULL, 0, (void *)1);
trunk/src/emu/ui/filemngr.h
r242928r242929
2525   virtual void populate();
2626   virtual void handle();
2727   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
28
29   void fill_image_line(device_image_interface *img, astring &instance, astring &filename);
2830};
2931
3032#endif  /* __UI_FILEMNGR_H__ */


Previous 199869 Revisions Next


© 1997-2024 The MAME Team