mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Use "default" font for artwork elements as well.
Make UI backgrounds a bit more opaque. Fix crash when passing NULL filename to OSD code.
This commit is contained in:
parent
59559fe282
commit
4cd55f3c0a
@ -899,7 +899,7 @@ void debugint_init(running_machine *machine)
|
||||
{
|
||||
unicode_char ch;
|
||||
int chw;
|
||||
debug_font = machine->render().font_alloc("ui.bdf"); //ui_get_font();
|
||||
debug_font = machine->render().font_alloc("ui.bdf"); //ui_get_font(machine);
|
||||
debug_font_width = 0;
|
||||
debug_font_height = 15;
|
||||
|
||||
|
@ -274,7 +274,6 @@ void running_machine::start()
|
||||
state_save_allow_registration(this, true);
|
||||
palette_init(this);
|
||||
m_render = auto_alloc(this, render_manager(*this));
|
||||
ui_init(this);
|
||||
generic_machine_init(this);
|
||||
generic_video_init(this);
|
||||
generic_sound_init(this);
|
||||
@ -286,6 +285,7 @@ void running_machine::start()
|
||||
|
||||
// init the osd layer
|
||||
m_osd.init(*this);
|
||||
ui_init(this);
|
||||
|
||||
// initialize the base time (needed for doing record/playback)
|
||||
time(&m_base_time);
|
||||
|
@ -131,7 +131,7 @@ render_font::render_font(render_manager &manager, const char *filename)
|
||||
}
|
||||
|
||||
// if the filename is 'default' default to 'ui.bdf' for backwards compatibility
|
||||
if (mame_stricmp(filename, "default") == 0)
|
||||
if (filename != NULL && mame_stricmp(filename, "default") == 0)
|
||||
filename = "ui.bdf";
|
||||
|
||||
// attempt to load the cached version of the font first
|
||||
@ -325,6 +325,13 @@ void render_font::get_scaled_bitmap_and_bounds(bitmap_t &dest, float height, flo
|
||||
if (dest.width < bounds.max_x - bounds.min_x || dest.height < bounds.max_y - bounds.min_y)
|
||||
return;
|
||||
|
||||
// if no texture, fill the target
|
||||
if (gl.texture == NULL)
|
||||
{
|
||||
bitmap_fill(&dest, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// scale the font
|
||||
INT32 origwidth = dest.width;
|
||||
INT32 origheight = dest.height;
|
||||
|
@ -827,7 +827,7 @@ void layout_element::component::draw_text(running_machine &machine, bitmap_t &de
|
||||
UINT32 a = m_color.a * 255.0;
|
||||
|
||||
// get the width of the string
|
||||
render_font *font = machine.render().font_alloc();
|
||||
render_font *font = machine.render().font_alloc("default");
|
||||
float aspect = 1.0f;
|
||||
INT32 width;
|
||||
while (1)
|
||||
|
22
src/emu/ui.c
22
src/emu/ui.c
@ -239,9 +239,6 @@ int ui_init(running_machine *machine)
|
||||
/* make sure we clean up after ourselves */
|
||||
machine->add_notifier(MACHINE_NOTIFY_EXIT, ui_exit);
|
||||
|
||||
/* allocate the font and messagebox string */
|
||||
ui_font = machine->render().font_alloc(options_get_string(machine->options(), OPTION_UI_FONT));
|
||||
|
||||
/* initialize the other UI bits */
|
||||
ui_menu_init(machine);
|
||||
ui_gfx_init(machine);
|
||||
@ -410,8 +407,11 @@ void ui_update_and_render(running_machine *machine, render_container *container)
|
||||
ui_get_font - return the UI font
|
||||
-------------------------------------------------*/
|
||||
|
||||
render_font *ui_get_font(void)
|
||||
render_font *ui_get_font(running_machine &machine)
|
||||
{
|
||||
/* allocate the font and messagebox string */
|
||||
if (ui_font == NULL)
|
||||
ui_font = machine.render().font_alloc(options_get_string(machine.options(), OPTION_UI_FONT));
|
||||
return ui_font;
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ render_font *ui_get_font(void)
|
||||
|
||||
float ui_get_line_height(running_machine &machine)
|
||||
{
|
||||
INT32 raw_font_pixel_height = ui_font->pixel_height();
|
||||
INT32 raw_font_pixel_height = ui_get_font(machine)->pixel_height();
|
||||
render_target &ui_target = machine.render().ui_target();
|
||||
INT32 target_pixel_height = ui_target.height();
|
||||
float one_to_one_line_height;
|
||||
@ -468,7 +468,7 @@ float ui_get_line_height(running_machine &machine)
|
||||
|
||||
float ui_get_char_width(running_machine &machine, unicode_char ch)
|
||||
{
|
||||
return ui_font->char_width(ui_get_line_height(machine), machine.render().ui_aspect(), ch);
|
||||
return ui_get_font(machine)->char_width(ui_get_line_height(machine), machine.render().ui_aspect(), ch);
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +479,7 @@ float ui_get_char_width(running_machine &machine, unicode_char ch)
|
||||
|
||||
float ui_get_string_width(running_machine &machine, const char *s)
|
||||
{
|
||||
return ui_font->utf8string_width(ui_get_line_height(machine), machine.render().ui_aspect(), s);
|
||||
return ui_get_font(machine)->utf8string_width(ui_get_line_height(machine), machine.render().ui_aspect(), s);
|
||||
}
|
||||
|
||||
|
||||
@ -666,7 +666,7 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
|
||||
|
||||
if (draw != DRAW_NONE)
|
||||
{
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, linechar);
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_get_font(machine), linechar);
|
||||
curx += ui_get_char_width(machine, linechar);
|
||||
}
|
||||
linestart += linecharcount;
|
||||
@ -675,11 +675,11 @@ void ui_draw_text_full(render_container *container, const char *origs, float x,
|
||||
/* append ellipses if needed */
|
||||
if (wrap == WRAP_TRUNCATE && *s != 0 && draw != DRAW_NONE)
|
||||
{
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_get_font(machine), '.');
|
||||
curx += ui_get_char_width(machine, '.');
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_get_font(machine), '.');
|
||||
curx += ui_get_char_width(machine, '.');
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_font, '.');
|
||||
container->add_char(curx, cury, lineheight, machine.render().ui_aspect(), fgcolor, *ui_get_font(machine), '.');
|
||||
curx += ui_get_char_width(machine, '.');
|
||||
}
|
||||
|
||||
|
14
src/emu/ui.h
14
src/emu/ui.h
@ -37,18 +37,18 @@
|
||||
#define ARGB_WHITE MAKE_ARGB(0xff,0xff,0xff,0xff)
|
||||
#define ARGB_BLACK MAKE_ARGB(0xff,0x00,0x00,0x00)
|
||||
#define UI_BORDER_COLOR MAKE_ARGB(0xff,0xff,0xff,0xff)
|
||||
#define UI_BACKGROUND_COLOR MAKE_ARGB(0xe0,0x10,0x10,0x30)
|
||||
#define UI_GFXVIEWER_BG_COLOR MAKE_ARGB(0xe0,0x10,0x10,0x30)
|
||||
#define UI_GREEN_COLOR MAKE_ARGB(0xe0,0x10,0x60,0x10)
|
||||
#define UI_YELLOW_COLOR MAKE_ARGB(0xe0,0x60,0x60,0x10)
|
||||
#define UI_BACKGROUND_COLOR MAKE_ARGB(0xef,0x10,0x10,0x30)
|
||||
#define UI_GFXVIEWER_BG_COLOR MAKE_ARGB(0xef,0x10,0x10,0x30)
|
||||
#define UI_GREEN_COLOR MAKE_ARGB(0xef,0x10,0x60,0x10)
|
||||
#define UI_YELLOW_COLOR MAKE_ARGB(0xef,0x60,0x60,0x10)
|
||||
#define UI_RED_COLOR MAKE_ARGB(0xf0,0x60,0x10,0x10)
|
||||
#define UI_UNAVAILABLE_COLOR MAKE_ARGB(0xff,0x40,0x40,0x40)
|
||||
#define UI_TEXT_COLOR MAKE_ARGB(0xff,0xff,0xff,0xff)
|
||||
#define UI_TEXT_BG_COLOR MAKE_ARGB(0xe0,0x00,0x00,0x00)
|
||||
#define UI_TEXT_BG_COLOR MAKE_ARGB(0xef,0x00,0x00,0x00)
|
||||
#define UI_SUBITEM_COLOR MAKE_ARGB(0xff,0xff,0xff,0xff)
|
||||
#define UI_CLONE_COLOR MAKE_ARGB(0xff,0x80,0x80,0x80)
|
||||
#define UI_SELECTED_COLOR MAKE_ARGB(0xff,0xff,0xff,0x00)
|
||||
#define UI_SELECTED_BG_COLOR MAKE_ARGB(0xe0,0x80,0x80,0x00)
|
||||
#define UI_SELECTED_BG_COLOR MAKE_ARGB(0xef,0x80,0x80,0x00)
|
||||
#define UI_MOUSEOVER_COLOR MAKE_ARGB(0xff,0xff,0xff,0x80)
|
||||
#define UI_MOUSEOVER_BG_COLOR MAKE_ARGB(0x70,0x40,0x40,0x00)
|
||||
#define UI_MOUSEDOWN_COLOR MAKE_ARGB(0xff,0xff,0xff,0x80)
|
||||
@ -133,7 +133,7 @@ void ui_set_startup_text(running_machine *machine, const char *text, int force);
|
||||
void ui_update_and_render(running_machine *machine, render_container *container);
|
||||
|
||||
/* returns the current UI font */
|
||||
render_font *ui_get_font(void);
|
||||
render_font *ui_get_font(running_machine &machine);
|
||||
|
||||
/* returns the line height of the font used by the UI system */
|
||||
float ui_get_line_height(running_machine &machine);
|
||||
|
@ -242,7 +242,7 @@ static void palette_handler(running_machine *machine, render_container *containe
|
||||
int total = state->palette.which ? colortable_palette_get_size(machine->colortable) : machine->total_colors();
|
||||
const char *title = state->palette.which ? "COLORTABLE" : "PALETTE";
|
||||
const rgb_t *raw_color = palette_entry_list_raw(machine->palette);
|
||||
render_font *ui_font = ui_get_font();
|
||||
render_font *ui_font = ui_get_font(*machine);
|
||||
float cellwidth, cellheight;
|
||||
float chwidth, chheight;
|
||||
float titlewidth;
|
||||
@ -427,7 +427,7 @@ static void palette_handle_keys(running_machine *machine, ui_gfx_state *state)
|
||||
|
||||
static void gfxset_handler(running_machine *machine, render_container *container, ui_gfx_state *state)
|
||||
{
|
||||
render_font *ui_font = ui_get_font();
|
||||
render_font *ui_font = ui_get_font(*machine);
|
||||
int set = state->gfxset.set;
|
||||
gfx_element *gfx = machine->gfx[set];
|
||||
float fullwidth, fullheight;
|
||||
@ -840,7 +840,7 @@ static void gfxset_draw_item(running_machine *machine, const gfx_element *gfx, i
|
||||
|
||||
static void tilemap_handler(running_machine *machine, render_container *container, ui_gfx_state *state)
|
||||
{
|
||||
render_font *ui_font = ui_get_font();
|
||||
render_font *ui_font = ui_get_font(*machine);
|
||||
float chwidth, chheight;
|
||||
render_bounds mapboxbounds;
|
||||
render_bounds boxbounds;
|
||||
|
Loading…
Reference in New Issue
Block a user