menu: allocate and draw icons only if available. nw

This commit is contained in:
dankan1890 2016-02-17 11:32:06 +01:00
parent 97f515d8c4
commit 32630f09aa
3 changed files with 22 additions and 4 deletions

View File

@ -1309,11 +1309,27 @@ void ui_menu::init_ui(running_machine &machine)
star_texture = mrender.texture_alloc();
star_texture->set_bitmap(*star_bitmap, star_bitmap->cliprect(), TEXFORMAT_ARGB32);
// allocates icons bitmap and texture
for (int i = 0; i < MAX_ICONS_RENDER; i++)
// check and allocate icons
file_enumerator path(machine.ui().options().icons_directory());
const osd_directory_entry *dir;
while ((dir = path.next()) != nullptr)
{
icons_bitmap[i] = auto_alloc(machine, bitmap_argb32);
icons_texture[i] = mrender.texture_alloc();
char drivername[50];
char *dst = drivername;
const char *src;
// build a name for it
src = dir->name;
if (*src != 0 && *src != '.')
{
ui_globals::has_icons = true;
for (int i = 0; i < MAX_ICONS_RENDER; i++)
{
icons_bitmap[i] = auto_alloc(machine, bitmap_argb32);
icons_texture[i] = mrender.texture_alloc();
}
break;
}
}
// create a texture for main menu background

View File

@ -48,6 +48,7 @@ bool ui_globals::redraw_icon = false;
int ui_globals::visible_main_lines = 0;
int ui_globals::visible_sw_lines = 0;
UINT16 ui_globals::panels_status = 0;
bool ui_globals::has_icons = false;
// Custom filter
UINT16 custfltr::main = 0;

View File

@ -208,6 +208,7 @@ struct ui_globals
static bool switch_image, redraw_icon, default_image, reset;
static int visible_main_lines, visible_sw_lines;
static UINT16 panels_status;
static bool has_icons;
};
#define main_struct(name) \