diff options
author | 2010-10-24 06:32:07 +0000 | |
---|---|---|
committer | 2010-10-24 06:32:07 +0000 | |
commit | 4cd55f3c0ad2c12fe61a112a2e6fbdbc83fa616b (patch) | |
tree | a3bad59c7a3554f7f206c1ac0a4d2aadae71292d /src | |
parent | 59559fe28278ed77ac11f3471520f210647a191f (diff) |
Use "default" font for artwork elements as well.
Make UI backgrounds a bit more opaque.
Fix crash when passing NULL filename to OSD code.
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/debugint/debugint.c | 2 | ||||
-rw-r--r-- | src/emu/machine.c | 2 | ||||
-rw-r--r-- | src/emu/rendfont.c | 9 | ||||
-rw-r--r-- | src/emu/rendlay.c | 2 | ||||
-rw-r--r-- | src/emu/ui.c | 22 | ||||
-rw-r--r-- | src/emu/ui.h | 14 | ||||
-rw-r--r-- | src/emu/uigfx.c | 6 |
7 files changed, 32 insertions, 25 deletions
diff --git a/src/emu/debugint/debugint.c b/src/emu/debugint/debugint.c index 5fa4987140e..a63b500a0b0 100644 --- a/src/emu/debugint/debugint.c +++ b/src/emu/debugint/debugint.c @@ -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; diff --git a/src/emu/machine.c b/src/emu/machine.c index 1843c0e25a7..aeeed7d2a46 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -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); diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c index 4f027170c10..884fa4352e9 100644 --- a/src/emu/rendfont.c +++ b/src/emu/rendfont.c @@ -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; diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 633d2abce0d..30c52fd05c2 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -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) diff --git a/src/emu/ui.c b/src/emu/ui.c index 9324df20d81..b5feece2ab0 100644 --- a/src/emu/ui.c +++ b/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, '.'); } diff --git a/src/emu/ui.h b/src/emu/ui.h index 679013649f9..2c257e2e6e8 100644 --- a/src/emu/ui.h +++ b/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); diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c index cb366c194c8..112b03c45b6 100644 --- a/src/emu/uigfx.c +++ b/src/emu/uigfx.c @@ -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; |