Previous 199869 Revisions Next

r34363 Monday 12th January, 2015 at 21:46:22 UTC by Fabio Priuli
ui: simplified Image Information code and made it fully display for
systems with many image devices. [Fabio Priuli]

out of whatsnew: compare old and new with a system like smssdisp
to see what the "fully display" refers to ;-)
[src/emu/ui]imginfo.c imginfo.h

trunk/src/emu/ui/imginfo.c
r242874r242875
4242
4343void ui_menu_image_info::populate()
4444{
45   astring tempstring;
46   image_info_astring(machine(), tempstring);
47   item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL);
45   item_append(machine().system().description, NULL, MENU_FLAG_DISABLE, NULL);
46   item_append("", NULL, MENU_FLAG_DISABLE, NULL);
47
48   image_interface_iterator iter(machine().root_device());
49   for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
50         image_info(image);
4851}
4952
5053
r242874r242875
6063
6164
6265//-------------------------------------------------
63//  stripspace
66//  image_info - display image info for a specific
67//  image interface device
6468//-------------------------------------------------
6569
66static char *stripspace(const char *src)
70void ui_menu_image_info::image_info(device_image_interface *image)
6771{
68   static char buff[512];
69   if( src )
72   if (image->exists())
7073   {
71      char *dst;
72      while( *src && isspace(*src) )
73         src++;
74      strcpy(buff, src);
75      dst = buff + strlen(buff);
76      while( dst >= buff && isspace(*--dst) )
77         *dst = '\0';
78      return buff;
79   }
80   return NULL;
81}
74      // display device type and filename
75      item_append(image->brief_instance_name(), image->basename(), 0, NULL);
8276
83
84//-------------------------------------------------
85//  strip_extension
86//-------------------------------------------------
87
88static char *strip_extension(const char *filename)
89{
90   char *newname;
91   char *c;
92
93   // NULL begets NULL
94   if (!filename)
95      return NULL;
96
97   // allocate space for it
98   newname = (char *) malloc(strlen(filename) + 1);
99   if (!newname)
100      return NULL;
101
102   // copy in the name
103   strcpy(newname, filename);
104
105   // search backward for a period, failing if we hit a slash or a colon
106   for (c = newname + strlen(newname) - 1; c >= newname; c--)
107   {
108      // if we hit a period, NULL terminate and break
109      if (*c == '.')
77      // if image has been loaded through softlist, let's add some more info
78      if (image->software_entry())
11079      {
111         *c = 0;
112         break;
113      }
80         astring string;
11481
115      // if we hit a slash or colon just stop
116      if (*c == '\\' || *c == '/' || *c == ':')
117         break;
118   }
82         // display long filename
83         item_append(image->longname(), "", MENU_FLAG_DISABLE, NULL);
84         
85         // display manufacturer and year
86         string.catprintf("%s, %s", image->manufacturer(), image->year());
87         item_append(string, "", MENU_FLAG_DISABLE, NULL);
11988
120   return newname;
121}
122
123
124//-------------------------------------------------
125//  image_info_astring - populate an allocated
126//  string with the image info text
127//-------------------------------------------------
128
129void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string)
130{
131   string.printf("%s\n\n", machine.system().description);
132
133#if 0
134   if (mess_ram_size > 0)
135   {
136      char buf2[RAM_STRING_BUFLEN];
137      string.catprintf("RAM: %s\n\n", ram_string(buf2, mess_ram_size));
138   }
139#endif
140
141   image_interface_iterator iter(machine.root_device());
142   for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
143   {
144      const char *name = image->filename();
145      if (name != NULL)
146      {
147         const char *base_filename;
148         const char *info;
149         char *base_filename_noextension;
150
151         base_filename = image->basename();
152         base_filename_noextension = strip_extension(base_filename);
153
154         // display device type and filename
155         string.catprintf("%s: %s\n", image->device().name(), base_filename);
156
157         // display long filename, if present and doesn't correspond to name
158         info = image->longname();
159         if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension)))
160            string.catprintf("%s\n", info);
161
162         // display manufacturer, if available
163         info = image->manufacturer();
164         if (info != NULL)
89         // display supported information, if available
90         switch (image->supported())
16591         {
166            string.catprintf("%s", info);
167            info = stripspace(image->year());
168            if (info && *info)
169               string.catprintf(", %s", info);
170            string.catprintf("\n");
92            case SOFTWARE_SUPPORTED_NO:
93               item_append("Not supported", "", MENU_FLAG_DISABLE, NULL);
94               break;
95            case SOFTWARE_SUPPORTED_PARTIAL:
96               item_append("Partially supported", "", MENU_FLAG_DISABLE, NULL);
97               break;
98            default:
99               break;
171100         }
172
173         // display supported information, if available
174         switch(image->supported()) {
175            case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported\n"); break;
176            case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported\n"); break;
177            default : break;
178         }
179
180         if (base_filename_noextension != NULL)
181            free(base_filename_noextension);
182101      }
183      else
184      {
185         string.catprintf("%s: ---\n", image->device().name());
186      }
187102   }
103   else
104      item_append(image->brief_instance_name(), "[empty]", 0, NULL);
105   item_append("", NULL, MENU_FLAG_DISABLE, NULL);
188106}
trunk/src/emu/ui/imginfo.h
r242874r242875
2323   virtual void handle();
2424
2525private:
26   void image_info_astring(running_machine &machine, astring &string);
26   void image_info(device_image_interface *image);
2727};
2828
2929#endif // __UI_IMGINFO_H__


Previous 199869 Revisions Next


© 1997-2024 The MAME Team