mirror of
https://github.com/holub/mame
synced 2025-07-02 00:29:37 +03:00
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 ;-)
This commit is contained in:
parent
e0f73c58ae
commit
d40ca7e901
@ -42,9 +42,12 @@ ui_menu_image_info::~ui_menu_image_info()
|
|||||||
|
|
||||||
void ui_menu_image_info::populate()
|
void ui_menu_image_info::populate()
|
||||||
{
|
{
|
||||||
astring tempstring;
|
item_append(machine().system().description, NULL, MENU_FLAG_DISABLE, NULL);
|
||||||
image_info_astring(machine(), tempstring);
|
item_append("", NULL, MENU_FLAG_DISABLE, NULL);
|
||||||
item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL);
|
|
||||||
|
image_interface_iterator iter(machine().root_device());
|
||||||
|
for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
|
||||||
|
image_info(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,129 +63,44 @@ void ui_menu_image_info::handle()
|
|||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// stripspace
|
// image_info - display image info for a specific
|
||||||
|
// image interface device
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
static char *stripspace(const char *src)
|
void ui_menu_image_info::image_info(device_image_interface *image)
|
||||||
{
|
{
|
||||||
static char buff[512];
|
if (image->exists())
|
||||||
if( src )
|
|
||||||
{
|
{
|
||||||
char *dst;
|
|
||||||
while( *src && isspace(*src) )
|
|
||||||
src++;
|
|
||||||
strcpy(buff, src);
|
|
||||||
dst = buff + strlen(buff);
|
|
||||||
while( dst >= buff && isspace(*--dst) )
|
|
||||||
*dst = '\0';
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// strip_extension
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
static char *strip_extension(const char *filename)
|
|
||||||
{
|
|
||||||
char *newname;
|
|
||||||
char *c;
|
|
||||||
|
|
||||||
// NULL begets NULL
|
|
||||||
if (!filename)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// allocate space for it
|
|
||||||
newname = (char *) malloc(strlen(filename) + 1);
|
|
||||||
if (!newname)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// copy in the name
|
|
||||||
strcpy(newname, filename);
|
|
||||||
|
|
||||||
// search backward for a period, failing if we hit a slash or a colon
|
|
||||||
for (c = newname + strlen(newname) - 1; c >= newname; c--)
|
|
||||||
{
|
|
||||||
// if we hit a period, NULL terminate and break
|
|
||||||
if (*c == '.')
|
|
||||||
{
|
|
||||||
*c = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we hit a slash or colon just stop
|
|
||||||
if (*c == '\\' || *c == '/' || *c == ':')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newname;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// image_info_astring - populate an allocated
|
|
||||||
// string with the image info text
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string)
|
|
||||||
{
|
|
||||||
string.printf("%s\n\n", machine.system().description);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (mess_ram_size > 0)
|
|
||||||
{
|
|
||||||
char buf2[RAM_STRING_BUFLEN];
|
|
||||||
string.catprintf("RAM: %s\n\n", ram_string(buf2, mess_ram_size));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
image_interface_iterator iter(machine.root_device());
|
|
||||||
for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
|
|
||||||
{
|
|
||||||
const char *name = image->filename();
|
|
||||||
if (name != NULL)
|
|
||||||
{
|
|
||||||
const char *base_filename;
|
|
||||||
const char *info;
|
|
||||||
char *base_filename_noextension;
|
|
||||||
|
|
||||||
base_filename = image->basename();
|
|
||||||
base_filename_noextension = strip_extension(base_filename);
|
|
||||||
|
|
||||||
// display device type and filename
|
// display device type and filename
|
||||||
string.catprintf("%s: %s\n", image->device().name(), base_filename);
|
item_append(image->brief_instance_name(), image->basename(), 0, NULL);
|
||||||
|
|
||||||
// display long filename, if present and doesn't correspond to name
|
// if image has been loaded through softlist, let's add some more info
|
||||||
info = image->longname();
|
if (image->software_entry())
|
||||||
if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension)))
|
|
||||||
string.catprintf("%s\n", info);
|
|
||||||
|
|
||||||
// display manufacturer, if available
|
|
||||||
info = image->manufacturer();
|
|
||||||
if (info != NULL)
|
|
||||||
{
|
{
|
||||||
string.catprintf("%s", info);
|
astring string;
|
||||||
info = stripspace(image->year());
|
|
||||||
if (info && *info)
|
// display long filename
|
||||||
string.catprintf(", %s", info);
|
item_append(image->longname(), "", MENU_FLAG_DISABLE, NULL);
|
||||||
string.catprintf("\n");
|
|
||||||
}
|
// display manufacturer and year
|
||||||
|
string.catprintf("%s, %s", image->manufacturer(), image->year());
|
||||||
|
item_append(string, "", MENU_FLAG_DISABLE, NULL);
|
||||||
|
|
||||||
// display supported information, if available
|
// display supported information, if available
|
||||||
switch(image->supported()) {
|
switch (image->supported())
|
||||||
case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported\n"); break;
|
{
|
||||||
case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported\n"); break;
|
case SOFTWARE_SUPPORTED_NO:
|
||||||
default : break;
|
item_append("Not supported", "", MENU_FLAG_DISABLE, NULL);
|
||||||
|
break;
|
||||||
|
case SOFTWARE_SUPPORTED_PARTIAL:
|
||||||
|
item_append("Partially supported", "", MENU_FLAG_DISABLE, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_filename_noextension != NULL)
|
|
||||||
free(base_filename_noextension);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
item_append(image->brief_instance_name(), "[empty]", 0, NULL);
|
||||||
string.catprintf("%s: ---\n", image->device().name());
|
item_append("", NULL, MENU_FLAG_DISABLE, NULL);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
virtual void handle();
|
virtual void handle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void image_info_astring(running_machine &machine, astring &string);
|
void image_info(device_image_interface *image);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __UI_IMGINFO_H__
|
#endif // __UI_IMGINFO_H__
|
||||||
|
Loading…
Reference in New Issue
Block a user