UI menu interface changes

- all ui functions now expect a render_container
- removed all macros referencing render_container_get_ui
- ui_menu_alloc now is passed a container to which to render the menu.
This is a first round of changes to allow using ui_* functions in a more generic way.
This commit is contained in:
Couriersud 2010-01-27 23:52:28 +00:00
parent 6660655ce5
commit 77cc6538e1
15 changed files with 164 additions and 156 deletions

View File

@ -508,7 +508,7 @@ void cheat_set_global_enable(running_machine *machine, int enable)
to render text to render text
-------------------------------------------------*/ -------------------------------------------------*/
void cheat_render_text(running_machine *machine) void cheat_render_text(running_machine *machine, render_container *container)
{ {
cheat_private *cheatinfo = machine->cheat_data; cheat_private *cheatinfo = machine->cheat_data;
if (cheatinfo != NULL) if (cheatinfo != NULL)
@ -520,7 +520,7 @@ void cheat_render_text(running_machine *machine)
if (cheatinfo->output[linenum].len() != 0) if (cheatinfo->output[linenum].len() != 0)
{ {
/* output the text */ /* output the text */
ui_draw_text_full(cheatinfo->output[linenum], ui_draw_text_full(container, cheatinfo->output[linenum],
0.0f, (float)linenum * ui_get_line_height(), 1.0f, 0.0f, (float)linenum * ui_get_line_height(), 1.0f,
cheatinfo->justify[linenum], WRAP_NEVER, DRAW_OPAQUE, cheatinfo->justify[linenum], WRAP_NEVER, DRAW_OPAQUE,
ARGB_WHITE, ARGB_BLACK, NULL, NULL); ARGB_WHITE, ARGB_BLACK, NULL, NULL);

View File

@ -40,7 +40,7 @@ void cheat_set_global_enable(running_machine *machine, int enable);
/* ----- cheat UI helpers ----- */ /* ----- cheat UI helpers ----- */
/* render any text overlays */ /* render any text overlays */
void cheat_render_text(running_machine *machine); void cheat_render_text(running_machine *machine, render_container *container);
/* return data about the next menu entry, or the first entry if previous == NULL */ /* return data about the next menu entry, or the first entry if previous == NULL */
void *cheat_get_next_menu_entry(running_machine *machine, void *previous, const char **description, const char **state, UINT32 *flags); void *cheat_get_next_menu_entry(running_machine *machine, void *previous, const char **description, const char **state, UINT32 *flags);

View File

@ -10,6 +10,7 @@
**************************************************************************/ **************************************************************************/
#include "emu.h" #include "emu.h"
#include "render.h"
#include "uimenu.h" #include "uimenu.h"
@ -22,7 +23,7 @@
static MACHINE_START( empty ) static MACHINE_START( empty )
{ {
/* force the UI to show the game select screen */ /* force the UI to show the game select screen */
ui_menu_force_game_select(machine); ui_menu_force_game_select(machine, render_container_get_ui());
} }

View File

@ -77,10 +77,10 @@
#include "emuopts.h" #include "emuopts.h"
#include "osdepend.h" #include "osdepend.h"
#include "config.h" #include "config.h"
#include "cheat.h"
#include "debugger.h" #include "debugger.h"
#include "profiler.h" #include "profiler.h"
#include "render.h" #include "render.h"
#include "cheat.h"
#include "ui.h" #include "ui.h"
#include "uimenu.h" #include "uimenu.h"
#include "uiinput.h" #include "uiinput.h"
@ -540,7 +540,7 @@ void mame_schedule_exit(running_machine *machine)
if (started_empty && options_get_string(mame_options(), OPTION_GAMENAME)[0] != 0) if (started_empty && options_get_string(mame_options(), OPTION_GAMENAME)[0] != 0)
{ {
options_set_string(mame_options(), OPTION_GAMENAME, "", OPTION_PRIORITY_CMDLINE); options_set_string(mame_options(), OPTION_GAMENAME, "", OPTION_PRIORITY_CMDLINE);
ui_menu_force_game_select(machine); ui_menu_force_game_select(machine, render_container_get_ui());
} }
/* otherwise, exit for real */ /* otherwise, exit for real */

View File

@ -145,11 +145,8 @@ enum
***************************************************************************/ ***************************************************************************/
/* convenience macros for adding items to the UI container */ /* convenience macros for adding items to the UI container */
#define render_ui_add_point(x0,y0,diam,argb,flags) render_container_add_line(render_container_get_ui(), x0, y0, x0, y0, diam, argb, flags) #define render_container_add_point(c, x0,y0,diam,argb,flags) render_container_add_line(c, x0, y0, x0, y0, diam, argb, flags)
#define render_ui_add_line(x0,y0,x1,y1,diam,argb,flags) render_container_add_line(render_container_get_ui(), x0, y0, x1, y1, diam, argb, flags) #define render_container_add_rect(c, x0,y0,x1,y1,argb,flags) render_container_add_quad(c, x0, y0, x1, y1, argb, NULL, flags)
#define render_ui_add_rect(x0,y0,x1,y1,argb,flags) render_container_add_quad(render_container_get_ui(), x0, y0, x1, y1, argb, NULL, flags)
#define render_ui_add_quad(x0,y0,x1,y1,argb,tex,flags) render_container_add_quad(render_container_get_ui(), x0, y0, x1, y1, argb, tex, flags)
#define render_ui_add_char(x0,y0,ht,asp,argb,font,ch) render_container_add_char(render_container_get_ui(), x0, y0, ht, asp, argb, font, ch)
/* convenience macros for adding items to a screen container */ /* convenience macros for adding items to a screen container */
#define render_screen_add_point(scr,x0,y0,diam,argb,flags) render_container_add_line(render_container_get_screen(scr), x0, y0, x0, y0, diam, argb, flags) #define render_screen_add_point(scr,x0,y0,diam,argb,flags) render_container_add_line(render_container_get_screen(scr), x0, y0, x0, y0, diam, argb, flags)

View File

@ -14,8 +14,8 @@
#include "video/vector.h" #include "video/vector.h"
#include "machine/laserdsc.h" #include "machine/laserdsc.h"
#include "profiler.h" #include "profiler.h"
#include "cheat.h"
#include "render.h" #include "render.h"
#include "cheat.h"
#include "rendfont.h" #include "rendfont.h"
#include "ui.h" #include "ui.h"
#include "uiinput.h" #include "uiinput.h"
@ -54,7 +54,7 @@ enum
static render_font *ui_font; static render_font *ui_font;
/* current UI handler */ /* current UI handler */
static UINT32 (*ui_handler_callback)(running_machine *, UINT32); static UINT32 (*ui_handler_callback)(running_machine *, render_container *, UINT32);
static UINT32 ui_handler_param; static UINT32 ui_handler_param;
/* flag to track single stepping */ /* flag to track single stepping */
@ -91,11 +91,11 @@ static astring &disclaimer_string(running_machine *machine, astring &buffer);
static astring &warnings_string(running_machine *machine, astring &buffer); static astring &warnings_string(running_machine *machine, astring &buffer);
/* UI handlers */ /* UI handlers */
static UINT32 handler_messagebox(running_machine *machine, UINT32 state); static UINT32 handler_messagebox(running_machine *machine, render_container *container, UINT32 state);
static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state); static UINT32 handler_messagebox_ok(running_machine *machine, render_container *container, UINT32 state);
static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state); static UINT32 handler_messagebox_anykey(running_machine *machine, render_container *container, UINT32 state);
static UINT32 handler_ingame(running_machine *machine, UINT32 state); static UINT32 handler_ingame(running_machine *machine, render_container *container, UINT32 state);
static UINT32 handler_load_save(running_machine *machine, UINT32 state); static UINT32 handler_load_save(running_machine *machine, render_container *container, UINT32 state);
/* slider controls */ /* slider controls */
static slider_state *slider_alloc(running_machine *machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg); static slider_state *slider_alloc(running_machine *machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg);
@ -135,7 +135,7 @@ static INT32 slider_crossoffset(running_machine *machine, void *arg, astring *st
pair for the current UI handler pair for the current UI handler
-------------------------------------------------*/ -------------------------------------------------*/
INLINE UINT32 ui_set_handler(UINT32 (*callback)(running_machine *, UINT32), UINT32 param) INLINE UINT32 ui_set_handler(UINT32 (*callback)(running_machine *, render_container *, UINT32), UINT32 param)
{ {
ui_handler_callback = callback; ui_handler_callback = callback;
ui_handler_param = param; ui_handler_param = param;
@ -340,10 +340,10 @@ void ui_set_startup_text(running_machine *machine, const char *text, int force)
render it; called by video.c render it; called by video.c
-------------------------------------------------*/ -------------------------------------------------*/
void ui_update_and_render(running_machine *machine) void ui_update_and_render(running_machine *machine, render_container *container)
{ {
/* always start clean */ /* always start clean */
render_container_empty(render_container_get_ui()); render_container_empty(container);
/* if we're paused, dim the whole screen */ /* if we're paused, dim the whole screen */
if (mame_get_phase(machine) >= MAME_PHASE_RESET && (single_step || mame_is_paused(machine))) if (mame_get_phase(machine) >= MAME_PHASE_RESET && (single_step || mame_is_paused(machine)))
@ -354,19 +354,19 @@ void ui_update_and_render(running_machine *machine)
if (alpha > 255) if (alpha > 255)
alpha = 255; alpha = 255;
if (alpha >= 0) if (alpha >= 0)
render_ui_add_rect(0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_rect(container, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
/* render any cheat stuff at the bottom */ /* render any cheat stuff at the bottom */
cheat_render_text(machine); cheat_render_text(machine, container);
/* call the current UI handler */ /* call the current UI handler */
assert(ui_handler_callback != NULL); assert(ui_handler_callback != NULL);
ui_handler_param = (*ui_handler_callback)(machine, ui_handler_param); ui_handler_param = (*ui_handler_callback)(machine, container, ui_handler_param);
/* display any popup messages */ /* display any popup messages */
if (osd_ticks() < popup_text_end) if (osd_ticks() < popup_text_end)
ui_draw_text_box(messagebox_text, JUSTIFY_CENTER, 0.5f, 0.9f, messagebox_backcolor); ui_draw_text_box(container, messagebox_text, JUSTIFY_CENTER, 0.5f, 0.9f, messagebox_backcolor);
else else
popup_text_end = 0; popup_text_end = 0;
@ -462,13 +462,13 @@ float ui_get_string_width(const char *s)
color color
-------------------------------------------------*/ -------------------------------------------------*/
void ui_draw_outlined_box(float x0, float y0, float x1, float y1, rgb_t backcolor) void ui_draw_outlined_box(render_container *container, float x0, float y0, float x1, float y1, rgb_t backcolor)
{ {
render_ui_add_rect(x0, y0, x1, y1, backcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_rect(container, x0, y0, x1, y1, backcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(x0, y0, x1, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(container, x0, y0, x1, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(x1, y0, x1, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(container, x1, y0, x1, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(x1, y1, x0, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(container, x1, y1, x0, y1, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(x0, y1, x0, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(container, x0, y1, x0, y0, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
@ -476,9 +476,9 @@ void ui_draw_outlined_box(float x0, float y0, float x1, float y1, rgb_t backcolo
ui_draw_text - simple text renderer ui_draw_text - simple text renderer
-------------------------------------------------*/ -------------------------------------------------*/
void ui_draw_text(const char *buf, float x, float y) void ui_draw_text(render_container *container, const char *buf, float x, float y)
{ {
ui_draw_text_full(buf, x, y, 1.0f - x, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); ui_draw_text_full(container, buf, x, y, 1.0f - x, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
} }
@ -488,7 +488,7 @@ void ui_draw_text(const char *buf, float x, float y)
and full size computation and full size computation
-------------------------------------------------*/ -------------------------------------------------*/
void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight) void ui_draw_text_full(render_container *container, const char *origs, float x, float y, float origwrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight)
{ {
float lineheight = ui_get_line_height(); float lineheight = ui_get_line_height();
const char *ends = origs + strlen(origs); const char *ends = origs + strlen(origs);
@ -625,7 +625,7 @@ void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth,
/* if opaque, add a black box */ /* if opaque, add a black box */
if (draw == DRAW_OPAQUE) if (draw == DRAW_OPAQUE)
render_ui_add_rect(curx, cury, curx + curwidth, cury + lineheight, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_rect(container, curx, cury, curx + curwidth, cury + lineheight, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* loop from the line start and add the characters */ /* loop from the line start and add the characters */
while (linestart < s) while (linestart < s)
@ -638,7 +638,7 @@ void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth,
if (draw != DRAW_NONE) if (draw != DRAW_NONE)
{ {
render_ui_add_char(curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, linechar); render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, linechar);
curx += ui_get_char_width(linechar); curx += ui_get_char_width(linechar);
} }
linestart += linecharcount; linestart += linecharcount;
@ -647,11 +647,11 @@ void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth,
/* append ellipses if needed */ /* append ellipses if needed */
if (wrap == WRAP_TRUNCATE && *s != 0 && draw != DRAW_NONE) if (wrap == WRAP_TRUNCATE && *s != 0 && draw != DRAW_NONE)
{ {
render_ui_add_char(curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.'); render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
curx += ui_get_char_width('.'); curx += ui_get_char_width('.');
render_ui_add_char(curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.'); render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
curx += ui_get_char_width('.'); curx += ui_get_char_width('.');
render_ui_add_char(curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.'); render_container_add_char(container, curx, cury, lineheight, render_get_ui_aspect(), fgcolor, ui_font, '.');
curx += ui_get_char_width('.'); curx += ui_get_char_width('.');
} }
@ -692,13 +692,13 @@ void ui_draw_text_full(const char *origs, float x, float y, float origwrapwidth,
message with a box around it message with a box around it
-------------------------------------------------*/ -------------------------------------------------*/
void ui_draw_text_box(const char *text, int justify, float xpos, float ypos, rgb_t backcolor) void ui_draw_text_box(render_container *container, const char *text, int justify, float xpos, float ypos, rgb_t backcolor)
{ {
float target_width, target_height; float target_width, target_height;
float target_x, target_y; float target_x, target_y;
/* compute the multi-line target width/height */ /* compute the multi-line target width/height */
ui_draw_text_full(text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER, ui_draw_text_full(container, text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER,
justify, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height); justify, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER) if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER)
target_height = floor((1.0f - 2.0f * UI_BOX_TB_BORDER) / ui_get_line_height()) * ui_get_line_height(); target_height = floor((1.0f - 2.0f * UI_BOX_TB_BORDER) / ui_get_line_height()) * ui_get_line_height();
@ -718,11 +718,11 @@ void ui_draw_text_box(const char *text, int justify, float xpos, float ypos, rgb
target_y = 1.0f - UI_BOX_TB_BORDER - target_height; target_y = 1.0f - UI_BOX_TB_BORDER - target_height;
/* add a box around that */ /* add a box around that */
ui_draw_outlined_box(target_x - UI_BOX_LR_BORDER, ui_draw_outlined_box(container, target_x - UI_BOX_LR_BORDER,
target_y - UI_BOX_TB_BORDER, target_y - UI_BOX_TB_BORDER,
target_x + target_width + UI_BOX_LR_BORDER, target_x + target_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER, backcolor); target_y + target_height + UI_BOX_TB_BORDER, backcolor);
ui_draw_text_full(text, target_x, target_y, target_width, ui_draw_text_full(container, text, target_x, target_y, target_width,
justify, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); justify, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
} }
@ -1080,9 +1080,9 @@ astring &game_info_astring(running_machine *machine, astring &string)
messagebox_text string but handles no input messagebox_text string but handles no input
-------------------------------------------------*/ -------------------------------------------------*/
static UINT32 handler_messagebox(running_machine *machine, UINT32 state) static UINT32 handler_messagebox(running_machine *machine, render_container *container, UINT32 state)
{ {
ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); ui_draw_text_box(container, messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
return 0; return 0;
} }
@ -1092,10 +1092,10 @@ static UINT32 handler_messagebox(running_machine *machine, UINT32 state)
messagebox_text string and waits for an OK messagebox_text string and waits for an OK
-------------------------------------------------*/ -------------------------------------------------*/
static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state) static UINT32 handler_messagebox_ok(running_machine *machine, render_container *container, UINT32 state)
{ {
/* draw a standard message window */ /* draw a standard message window */
ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); ui_draw_text_box(container, messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* an 'O' or left joystick kicks us to the next state */ /* an 'O' or left joystick kicks us to the next state */
if (state == 0 && (input_code_pressed_once(machine, KEYCODE_O) || ui_input_pressed(machine, IPT_UI_LEFT))) if (state == 0 && (input_code_pressed_once(machine, KEYCODE_O) || ui_input_pressed(machine, IPT_UI_LEFT)))
@ -1122,10 +1122,10 @@ static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state)
any keypress any keypress
-------------------------------------------------*/ -------------------------------------------------*/
static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state) static UINT32 handler_messagebox_anykey(running_machine *machine, render_container *container, UINT32 state)
{ {
/* draw a standard message window */ /* draw a standard message window */
ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); ui_draw_text_box(container, messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* if the user cancels, exit out completely */ /* if the user cancels, exit out completely */
if (ui_input_pressed(machine, IPT_UI_CANCEL)) if (ui_input_pressed(machine, IPT_UI_CANCEL))
@ -1147,14 +1147,14 @@ static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state)
of the standard keypresses of the standard keypresses
-------------------------------------------------*/ -------------------------------------------------*/
static UINT32 handler_ingame(running_machine *machine, UINT32 state) static UINT32 handler_ingame(running_machine *machine, render_container *container, UINT32 state)
{ {
int is_paused = mame_is_paused(machine); int is_paused = mame_is_paused(machine);
/* first draw the FPS counter */ /* first draw the FPS counter */
if (showfps || osd_ticks() < showfps_end) if (showfps || osd_ticks() < showfps_end)
{ {
ui_draw_text_full(video_get_speed_text(machine), 0.0f, 0.0f, 1.0f, ui_draw_text_full(container, video_get_speed_text(machine), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
} }
else else
@ -1165,7 +1165,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
{ {
astring profilertext; astring profilertext;
profiler_get_text(machine, profilertext); profiler_get_text(machine, profilertext);
ui_draw_text_full(profilertext, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); ui_draw_text_full(container, profilertext, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
} }
/* if we're single-stepping, pause now */ /* if we're single-stepping, pause now */
@ -1312,7 +1312,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
specifying a game to save or load specifying a game to save or load
-------------------------------------------------*/ -------------------------------------------------*/
static UINT32 handler_load_save(running_machine *machine, UINT32 state) static UINT32 handler_load_save(running_machine *machine, render_container *container, UINT32 state)
{ {
char filename[20]; char filename[20];
input_code code; input_code code;
@ -1324,9 +1324,9 @@ static UINT32 handler_load_save(running_machine *machine, UINT32 state)
/* okay, we're waiting for a key to select a slot; display a message */ /* okay, we're waiting for a key to select a slot; display a message */
if (state == LOADSAVE_SAVE) if (state == LOADSAVE_SAVE)
ui_draw_message_window("Select position to save to"); ui_draw_message_window(container, "Select position to save to");
else else
ui_draw_message_window("Select position to load from"); ui_draw_message_window(container, "Select position to load from");
/* check for cancel key */ /* check for cancel key */
if (ui_input_pressed(machine, IPT_UI_CANCEL)) if (ui_input_pressed(machine, IPT_UI_CANCEL))

View File

@ -112,7 +112,7 @@ struct _slider_state
MACROS MACROS
***************************************************************************/ ***************************************************************************/
#define ui_draw_message_window(text) ui_draw_text_box(text, JUSTIFY_LEFT, 0.5f, 0.5f, UI_BACKGROUND_COLOR) #define ui_draw_message_window(c, text) ui_draw_text_box(c, text, JUSTIFY_LEFT, 0.5f, 0.5f, UI_BACKGROUND_COLOR)
@ -130,7 +130,7 @@ int ui_display_startup_screens(running_machine *machine, int first_time, int sho
void ui_set_startup_text(running_machine *machine, const char *text, int force); void ui_set_startup_text(running_machine *machine, const char *text, int force);
/* once-per-frame update and render */ /* once-per-frame update and render */
void ui_update_and_render(running_machine *machine); void ui_update_and_render(running_machine *machine, render_container *container);
/* returns the current UI font */ /* returns the current UI font */
render_font *ui_get_font(void); render_font *ui_get_font(void);
@ -143,16 +143,16 @@ float ui_get_char_width(unicode_char ch);
float ui_get_string_width(const char *s); float ui_get_string_width(const char *s);
/* draw an outlined box filled with a given color */ /* draw an outlined box filled with a given color */
void ui_draw_outlined_box(float x0, float y0, float x1, float y1, rgb_t backcolor); void ui_draw_outlined_box(render_container *container, float x0, float y0, float x1, float y1, rgb_t backcolor);
/* simple text draw at the given coordinates */ /* simple text draw at the given coordinates */
void ui_draw_text(const char *buf, float x, float y); void ui_draw_text(render_container *container, const char *buf, float x, float y);
/* full-on text draw with all the options */ /* full-on text draw with all the options */
void ui_draw_text_full(const char *origs, float x, float y, float wrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight); void ui_draw_text_full(render_container *container, const char *origs, float x, float y, float wrapwidth, int justify, int wrap, int draw, rgb_t fgcolor, rgb_t bgcolor, float *totalwidth, float *totalheight);
/* draw a multi-line message with a box around it */ /* draw a multi-line message with a box around it */
void ui_draw_text_box(const char *text, int justify, float xpos, float ypos, rgb_t backcolor); void ui_draw_text_box(render_container *container, const char *text, int justify, float xpos, float ypos, rgb_t backcolor);
/* display a temporary message at the bottom of the screen */ /* display a temporary message at the bottom of the screen */
void CLIB_DECL ui_popup_time(int seconds, const char *text, ...) ATTR_PRINTF(2,3); void CLIB_DECL ui_popup_time(int seconds, const char *text, ...) ATTR_PRINTF(2,3);

View File

@ -80,18 +80,18 @@ static void ui_gfx_exit(running_machine *machine);
/* palette handling */ /* palette handling */
static void palette_handle_keys(running_machine *machine, ui_gfx_state *state); static void palette_handle_keys(running_machine *machine, ui_gfx_state *state);
static void palette_handler(running_machine *machine, ui_gfx_state *state); static void palette_handler(running_machine *machine, render_container *container, ui_gfx_state *state);
/* graphics set handling */ /* graphics set handling */
static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells); static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells);
static void gfxset_draw_item(running_machine *machine, const gfx_element *gfx, int index, bitmap_t *bitmap, int dstx, int dsty, int color, int rotate); static void gfxset_draw_item(running_machine *machine, const gfx_element *gfx, int index, bitmap_t *bitmap, int dstx, int dsty, int color, int rotate);
static void gfxset_update_bitmap(running_machine *machine, ui_gfx_state *state, int xcells, int ycells, gfx_element *gfx); static void gfxset_update_bitmap(running_machine *machine, ui_gfx_state *state, int xcells, int ycells, gfx_element *gfx);
static void gfxset_handler(running_machine *machine, ui_gfx_state *state); static void gfxset_handler(running_machine *machine, render_container *container, ui_gfx_state *state);
/* tilemap handling */ /* tilemap handling */
static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight); static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight);
static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, int width, int height); static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, int width, int height);
static void tilemap_handler(running_machine *machine, ui_gfx_state *state); static void tilemap_handler(running_machine *machine, render_container *container, ui_gfx_state *state);
@ -151,7 +151,7 @@ static void ui_gfx_exit(running_machine *machine)
ui_gfx_ui_handler - primary UI handler ui_gfx_ui_handler - primary UI handler
-------------------------------------------------*/ -------------------------------------------------*/
UINT32 ui_gfx_ui_handler(running_machine *machine, UINT32 uistate) UINT32 ui_gfx_ui_handler(running_machine *machine, render_container *container, UINT32 uistate)
{ {
ui_gfx_state *state = &ui_gfx; ui_gfx_state *state = &ui_gfx;
@ -171,7 +171,7 @@ again:
/* if we have a palette, display it */ /* if we have a palette, display it */
if (machine->config->total_colors > 0) if (machine->config->total_colors > 0)
{ {
palette_handler(machine, state); palette_handler(machine, container, state);
break; break;
} }
@ -182,7 +182,7 @@ again:
/* if we have graphics sets, display them */ /* if we have graphics sets, display them */
if (machine->gfx[0] != NULL) if (machine->gfx[0] != NULL)
{ {
gfxset_handler(machine, state); gfxset_handler(machine, container, state);
break; break;
} }
@ -193,7 +193,7 @@ again:
/* if we have tilemaps, display them */ /* if we have tilemaps, display them */
if (tilemap_count(machine) > 0) if (tilemap_count(machine) > 0)
{ {
tilemap_handler(machine, state); tilemap_handler(machine, container, state);
break; break;
} }
@ -234,7 +234,7 @@ cancel:
viewer viewer
-------------------------------------------------*/ -------------------------------------------------*/
static void palette_handler(running_machine *machine, ui_gfx_state *state) static void palette_handler(running_machine *machine, render_container *container, ui_gfx_state *state)
{ {
int total = state->palette.which ? colortable_palette_get_size(machine->colortable) : machine->config->total_colors; int total = state->palette.which ? colortable_palette_get_size(machine->colortable) : machine->config->total_colors;
const char *title = state->palette.which ? "COLORTABLE" : "PALETTE"; const char *title = state->palette.which ? "COLORTABLE" : "PALETTE";
@ -276,14 +276,14 @@ static void palette_handler(running_machine *machine, ui_gfx_state *state)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
/* go ahead and draw the outer box now */ /* go ahead and draw the outer box now */
ui_draw_outlined_box(boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); ui_draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
/* draw the title */ /* draw the title */
x0 = 0.5f - 0.5f * titlewidth; x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight; y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++) for (x = 0; title[x] != 0; x++)
{ {
render_ui_add_char(x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]); render_container_add_char(container, x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]);
x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]); x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]);
} }
@ -297,12 +297,12 @@ static void palette_handler(running_machine *machine, ui_gfx_state *state)
{ {
x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth;
y0 = boxbounds.y0 + 2.0f * chheight; y0 = boxbounds.y0 + 2.0f * chheight;
render_ui_add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, "0123456789ABCDEF"[x & 0xf]); render_container_add_char(container, x0 + 0.5f * (cellwidth - chwidth), y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, "0123456789ABCDEF"[x & 0xf]);
/* if we're skipping, draw a point between the character and the box to indicate which */ /* if we're skipping, draw a point between the character and the box to indicate which */
/* one it's referring to */ /* one it's referring to */
if (skip != 0) if (skip != 0)
render_ui_add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_point(container, x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
/* draw the side column headers */ /* draw the side column headers */
@ -319,14 +319,14 @@ static void palette_handler(running_machine *machine, ui_gfx_state *state)
x0 = boxbounds.x0 + 5.5f * chwidth; x0 = boxbounds.x0 + 5.5f * chwidth;
y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight;
if (skip != 0) if (skip != 0)
render_ui_add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_point(container, 0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the row header */ /* draw the row header */
sprintf(buffer, "%5X", state->palette.offset + y * state->palette.count); sprintf(buffer, "%5X", state->palette.offset + y * state->palette.count);
for (x = 4; x >= 0; x--) for (x = 4; x >= 0; x--)
{ {
x0 -= render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), buffer[x]); x0 -= render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), buffer[x]);
render_ui_add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, buffer[x]); render_container_add_char(container, x0, y0 + 0.5f * (cellheight - chheight), chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, buffer[x]);
} }
} }
@ -338,7 +338,7 @@ static void palette_handler(running_machine *machine, ui_gfx_state *state)
if (index < total) if (index < total)
{ {
pen_t pen = state->palette.which ? colortable_palette_get_color(machine->colortable, index) : raw_color[index]; pen_t pen = state->palette.which ? colortable_palette_get_color(machine->colortable, index) : raw_color[index];
render_ui_add_rect(cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight, render_container_add_rect(container, cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight,
cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight, cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight,
0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); 0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
@ -422,7 +422,7 @@ static void palette_handle_keys(running_machine *machine, ui_gfx_state *state)
viewer viewer
-------------------------------------------------*/ -------------------------------------------------*/
static void gfxset_handler(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();
int set = state->gfxset.set; int set = state->gfxset.set;
@ -519,14 +519,14 @@ static void gfxset_handler(running_machine *machine, ui_gfx_state *state)
x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth));
/* go ahead and draw the outer box now */ /* go ahead and draw the outer box now */
ui_draw_outlined_box(boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); ui_draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
/* draw the title */ /* draw the title */
x0 = 0.5f - 0.5f * titlewidth; x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight; y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++) for (x = 0; title[x] != 0; x++)
{ {
render_ui_add_char(x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]); render_container_add_char(container, x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]);
x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]); x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]);
} }
@ -536,12 +536,12 @@ static void gfxset_handler(running_machine *machine, ui_gfx_state *state)
{ {
x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth;
y0 = boxbounds.y0 + 2.0f * chheight; y0 = boxbounds.y0 + 2.0f * chheight;
render_ui_add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, "0123456789ABCDEF"[x & 0xf]); render_container_add_char(container, x0 + 0.5f * (cellwidth - chwidth), y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, "0123456789ABCDEF"[x & 0xf]);
/* if we're skipping, draw a point between the character and the box to indicate which */ /* if we're skipping, draw a point between the character and the box to indicate which */
/* one it's referring to */ /* one it's referring to */
if (skip != 0) if (skip != 0)
render_ui_add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_point(container, x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
/* draw the side column headers */ /* draw the side column headers */
@ -558,14 +558,14 @@ static void gfxset_handler(running_machine *machine, ui_gfx_state *state)
x0 = boxbounds.x0 + 5.5f * chwidth; x0 = boxbounds.x0 + 5.5f * chwidth;
y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight;
if (skip != 0) if (skip != 0)
render_ui_add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_point(container, 0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the row header */ /* draw the row header */
sprintf(buffer, "%5X", state->gfxset.offset[set] + y * xcells); sprintf(buffer, "%5X", state->gfxset.offset[set] + y * xcells);
for (x = 4; x >= 0; x--) for (x = 4; x >= 0; x--)
{ {
x0 -= render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), buffer[x]); x0 -= render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), buffer[x]);
render_ui_add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, buffer[x]); render_container_add_char(container, x0, y0 + 0.5f * (cellheight - chheight), chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, buffer[x]);
} }
} }
@ -573,7 +573,7 @@ static void gfxset_handler(running_machine *machine, ui_gfx_state *state)
gfxset_update_bitmap(machine, state, xcells, ycells, gfx); gfxset_update_bitmap(machine, state, xcells, ycells, gfx);
/* add the final quad */ /* add the final quad */
render_ui_add_quad(boxbounds.x0 + 6.0f * chwidth, boxbounds.y0 + 3.5f * chheight, render_container_add_quad(container, boxbounds.x0 + 6.0f * chwidth, boxbounds.y0 + 3.5f * chheight,
boxbounds.x0 + 6.0f * chwidth + (float)cellboxwidth / (float)targwidth, boxbounds.x0 + 6.0f * chwidth + (float)cellboxwidth / (float)targwidth,
boxbounds.y0 + 3.5f * chheight + (float)cellboxheight / (float)targheight, boxbounds.y0 + 3.5f * chheight + (float)cellboxheight / (float)targheight,
ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
@ -839,7 +839,7 @@ static void gfxset_draw_item(running_machine *machine, const gfx_element *gfx, i
viewer viewer
-------------------------------------------------*/ -------------------------------------------------*/
static void tilemap_handler(running_machine *machine, ui_gfx_state *state) 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();
float chwidth, chheight; float chwidth, chheight;
@ -919,14 +919,14 @@ static void tilemap_handler(running_machine *machine, ui_gfx_state *state)
} }
/* go ahead and draw the outer box now */ /* go ahead and draw the outer box now */
ui_draw_outlined_box(boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); ui_draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR);
/* draw the title */ /* draw the title */
x0 = 0.5f - 0.5f * titlewidth; x0 = 0.5f - 0.5f * titlewidth;
y0 = boxbounds.y0 + 0.5f * chheight; y0 = boxbounds.y0 + 0.5f * chheight;
for (x = 0; title[x] != 0; x++) for (x = 0; title[x] != 0; x++)
{ {
render_ui_add_char(x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]); render_container_add_char(container, x0, y0, chheight, render_get_ui_aspect(), ARGB_WHITE, ui_font, title[x]);
x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]); x0 += render_font_get_char_width(ui_font, chheight, render_get_ui_aspect(), title[x]);
} }
@ -934,7 +934,7 @@ static void tilemap_handler(running_machine *machine, ui_gfx_state *state)
tilemap_update_bitmap(machine, state, mapboxwidth / pixelscale, mapboxheight / pixelscale); tilemap_update_bitmap(machine, state, mapboxwidth / pixelscale, mapboxheight / pixelscale);
/* add the final quad */ /* add the final quad */
render_ui_add_quad(mapboxbounds.x0, mapboxbounds.y0, render_container_add_quad(container, mapboxbounds.x0, mapboxbounds.y0,
mapboxbounds.x1, mapboxbounds.y1, mapboxbounds.x1, mapboxbounds.y1,
ARGB_WHITE, state->texture, ARGB_WHITE, state->texture,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate));

View File

@ -24,7 +24,7 @@
void ui_gfx_init(running_machine *machine); void ui_gfx_init(running_machine *machine);
/* master handler */ /* master handler */
UINT32 ui_gfx_ui_handler(running_machine *machine, UINT32 state); UINT32 ui_gfx_ui_handler(running_machine *machine, render_container *container, UINT32 state);
#endif /* __UIGFX_H__ */ #endif /* __UIGFX_H__ */

View File

@ -117,6 +117,7 @@ struct _ui_menu_item
struct _ui_menu struct _ui_menu
{ {
running_machine * machine; /* machine we are attached to */ running_machine * machine; /* machine we are attached to */
render_container * container; /* render_container we render to */
ui_menu_handler_func handler; /* handler callback */ ui_menu_handler_func handler; /* handler callback */
void * parameter; /* parameter */ void * parameter; /* parameter */
ui_menu_event event; /* the UI event that occurred */ ui_menu_event event; /* the UI event that occurred */
@ -302,7 +303,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
/* menu helpers */ /* menu helpers */
static void menu_render_triangle(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param); static void menu_render_triangle(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param);
static void menu_settings_custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); static void menu_settings_custom_render_one(render_container *container, float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask);
static void menu_settings_custom_render(running_machine *machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2); static void menu_settings_custom_render(running_machine *machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
@ -431,7 +432,7 @@ static void ui_menu_exit(running_machine *machine)
ui_menu_alloc - allocate a new menu ui_menu_alloc - allocate a new menu
-------------------------------------------------*/ -------------------------------------------------*/
ui_menu *ui_menu_alloc(running_machine *machine, ui_menu_handler_func handler, void *parameter) ui_menu *ui_menu_alloc(running_machine *machine, render_container *container, ui_menu_handler_func handler, void *parameter)
{ {
ui_menu *menu; ui_menu *menu;
@ -440,6 +441,7 @@ ui_menu *ui_menu_alloc(running_machine *machine, ui_menu_handler_func handler, v
/* initialize the state */ /* initialize the state */
menu->machine = machine; menu->machine = machine;
menu->container = container;
menu->handler = handler; menu->handler = handler;
menu->parameter = parameter; menu->parameter = parameter;
@ -808,7 +810,7 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
x2 = visible_left + visible_width + UI_BOX_LR_BORDER; x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER; y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
if (!customonly) if (!customonly)
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR); ui_draw_outlined_box(menu->container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
/* determine the first visible line based on the current selection */ /* determine the first visible line based on the current selection */
top_line = menu->selected - visible_lines / 2; top_line = menu->selected - visible_lines / 2;
@ -828,7 +830,7 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
{ {
mouse_target = ui_input_find_mouse(machine, &mouse_target_x, &mouse_target_y, &mouse_button); mouse_target = ui_input_find_mouse(machine, &mouse_target_x, &mouse_target_y, &mouse_button);
if (mouse_target != NULL) if (mouse_target != NULL)
if (render_target_map_point_container(mouse_target, mouse_target_x, mouse_target_y, render_container_get_ui(), &mouse_x, &mouse_y)) if (render_target_map_point_container(mouse_target, mouse_target_x, mouse_target_y, menu->container, &mouse_x, &mouse_y))
mouse_hit = TRUE; mouse_hit = TRUE;
} }
@ -874,13 +876,14 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
/* if we have some background hilighting to do, add a quad behind everything else */ /* if we have some background hilighting to do, add a quad behind everything else */
if (bgcolor != UI_TEXT_BG_COLOR) if (bgcolor != UI_TEXT_BG_COLOR)
render_ui_add_quad(line_x0, line_y0, line_x1, line_y1, bgcolor, hilight_texture, render_container_add_quad(menu->container, line_x0, line_y0, line_x1, line_y1, bgcolor, hilight_texture,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
/* if we're on the top line, display the up arrow */ /* if we're on the top line, display the up arrow */
if (linenum == 0 && top_line != 0) if (linenum == 0 && top_line != 0)
{ {
render_ui_add_quad( 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, render_container_add_quad( menu->container,
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y + 0.25f * line_height, line_y + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y + 0.75f * line_height, line_y + 0.75f * line_height,
@ -894,7 +897,8 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
/* if we're on the bottom line, display the down arrow */ /* if we're on the bottom line, display the down arrow */
else if (linenum == visible_lines - 1 && itemnum != menu->numitems - 1) else if (linenum == visible_lines - 1 && itemnum != menu->numitems - 1)
{ {
render_ui_add_quad( 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, render_container_add_quad( menu->container,
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y + 0.25f * line_height, line_y + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y + 0.75f * line_height, line_y + 0.75f * line_height,
@ -907,11 +911,11 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
/* if we're just a divider, draw a line */ /* if we're just a divider, draw a line */
else if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0) else if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0)
render_ui_add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(menu->container, visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* if we don't have a subitem, just draw the string centered */ /* if we don't have a subitem, just draw the string centered */
else if (item->subtext == NULL) else if (item->subtext == NULL)
ui_draw_text_full(itemtext, effective_left, line_y, effective_width, ui_draw_text_full(menu->container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, NULL, NULL); JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, NULL, NULL);
/* otherwise, draw the item on the left and the subitem text on the right */ /* otherwise, draw the item on the left and the subitem text on the right */
@ -922,7 +926,7 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
float item_width, subitem_width; float item_width, subitem_width;
/* draw the left-side text */ /* draw the left-side text */
ui_draw_text_full(itemtext, effective_left, line_y, effective_width, ui_draw_text_full(menu->container, itemtext, effective_left, line_y, effective_width,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, NULL); JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, NULL);
/* give 2 spaces worth of padding */ /* give 2 spaces worth of padding */
@ -937,13 +941,14 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
} }
/* draw the subitem right-justified */ /* draw the subitem right-justified */
ui_draw_text_full(subitem_text, effective_left + item_width, line_y, effective_width - item_width, ui_draw_text_full(menu->container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, NULL); JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, NULL);
/* apply arrows */ /* apply arrows */
if (itemnum == menu->selected && (item->flags & MENU_FLAG_LEFT_ARROW)) if (itemnum == menu->selected && (item->flags & MENU_FLAG_LEFT_ARROW))
{ {
render_ui_add_quad( effective_left + effective_width - subitem_width - gutter_width, render_container_add_quad( menu->container,
effective_left + effective_width - subitem_width - gutter_width,
line_y + 0.1f * line_height, line_y + 0.1f * line_height,
effective_left + effective_width - subitem_width - gutter_width + lr_arrow_width, effective_left + effective_width - subitem_width - gutter_width + lr_arrow_width,
line_y + 0.9f * line_height, line_y + 0.9f * line_height,
@ -953,7 +958,8 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
} }
if (itemnum == menu->selected && (item->flags & MENU_FLAG_RIGHT_ARROW)) if (itemnum == menu->selected && (item->flags & MENU_FLAG_RIGHT_ARROW))
{ {
render_ui_add_quad( effective_left + effective_width + gutter_width - lr_arrow_width, render_container_add_quad( menu->container,
effective_left + effective_width + gutter_width - lr_arrow_width,
line_y + 0.1f * line_height, line_y + 0.1f * line_height,
effective_left + effective_width + gutter_width, effective_left + effective_width + gutter_width,
line_y + 0.9f * line_height, line_y + 0.9f * line_height,
@ -975,7 +981,7 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
float target_x, target_y; float target_x, target_y;
/* compute the multi-line target width/height */ /* compute the multi-line target width/height */
ui_draw_text_full(item->subtext, 0, 0, visible_width * 0.75f, ui_draw_text_full(menu->container, item->subtext, 0, 0, visible_width * 0.75f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height); JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
/* determine the target location */ /* determine the target location */
@ -985,11 +991,11 @@ static void ui_menu_draw(running_machine *machine, ui_menu *menu, int customonly
target_y = line_y - target_height - UI_BOX_TB_BORDER; target_y = line_y - target_height - UI_BOX_TB_BORDER;
/* add a box around that */ /* add a box around that */
ui_draw_outlined_box(target_x - UI_BOX_LR_BORDER, ui_draw_outlined_box(menu->container, target_x - UI_BOX_LR_BORDER,
target_y - UI_BOX_TB_BORDER, target_y - UI_BOX_TB_BORDER,
target_x + target_width + UI_BOX_LR_BORDER, target_x + target_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR); target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR);
ui_draw_text_full(item->subtext, target_x, target_y, target_width, ui_draw_text_full(menu->container, item->subtext, target_x, target_y, target_width,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL); JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL);
} }
@ -1022,7 +1028,7 @@ static void ui_menu_draw_text_box(ui_menu *menu)
float target_x, target_y; float target_x, target_y;
/* compute the multi-line target width/height */ /* compute the multi-line target width/height */
ui_draw_text_full(text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width, ui_draw_text_full(menu->container, text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width,
JUSTIFY_LEFT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height); JUSTIFY_LEFT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);
target_height += 2.0f * line_height; target_height += 2.0f * line_height;
if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER) if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER)
@ -1047,22 +1053,23 @@ static void ui_menu_draw_text_box(ui_menu *menu)
target_y = 1.0f - UI_BOX_TB_BORDER - target_height; target_y = 1.0f - UI_BOX_TB_BORDER - target_height;
/* add a box around that */ /* add a box around that */
ui_draw_outlined_box(target_x - UI_BOX_LR_BORDER - gutter_width, ui_draw_outlined_box(menu->container, target_x - UI_BOX_LR_BORDER - gutter_width,
target_y - UI_BOX_TB_BORDER, target_y - UI_BOX_TB_BORDER,
target_x + target_width + gutter_width + UI_BOX_LR_BORDER, target_x + target_width + gutter_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER, (menu->item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); target_y + target_height + UI_BOX_TB_BORDER, (menu->item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR);
ui_draw_text_full(text, target_x, target_y, target_width, ui_draw_text_full(menu->container, text, target_x, target_y, target_width,
JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
/* draw the "return to prior menu" text with a hilight behind it */ /* draw the "return to prior menu" text with a hilight behind it */
render_ui_add_quad( target_x + 0.5f * UI_LINE_WIDTH, render_container_add_quad(menu->container,
target_x + 0.5f * UI_LINE_WIDTH,
target_y + target_height - line_height, target_y + target_height - line_height,
target_x + target_width - 0.5f * UI_LINE_WIDTH, target_x + target_width - 0.5f * UI_LINE_WIDTH,
target_y + target_height, target_y + target_height,
UI_SELECTED_BG_COLOR, UI_SELECTED_BG_COLOR,
hilight_texture, hilight_texture,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
ui_draw_text_full(backtext, target_x, target_y + target_height - line_height, target_width, ui_draw_text_full(menu->container, backtext, target_x, target_y + target_height - line_height, target_width,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL); JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL);
/* artificially set the hover to the last item so a double-click exits */ /* artificially set the hover to the last item so a double-click exits */
@ -1337,11 +1344,11 @@ void ui_menu_stack_pop(running_machine *machine)
and calls the menu handler and calls the menu handler
-------------------------------------------------*/ -------------------------------------------------*/
UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state) UINT32 ui_menu_ui_handler(running_machine *machine, render_container *container, UINT32 state)
{ {
/* if we have no menus stacked up, start with the main menu */ /* if we have no menus stacked up, start with the main menu */
if (menu_stack == NULL) if (menu_stack == NULL)
ui_menu_stack_push(ui_menu_alloc(machine, menu_main, NULL)); ui_menu_stack_push(ui_menu_alloc(machine, container, menu_main, NULL));
/* update the menu state */ /* update the menu state */
if (menu_stack != NULL) if (menu_stack != NULL)
@ -1367,16 +1374,16 @@ UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state)
standard menu handler standard menu handler
-------------------------------------------------*/ -------------------------------------------------*/
UINT32 ui_slider_ui_handler(running_machine *machine, UINT32 state) UINT32 ui_slider_ui_handler(running_machine *machine, render_container *container, UINT32 state)
{ {
UINT32 result; UINT32 result;
/* if this is the first call, push the sliders menu */ /* if this is the first call, push the sliders menu */
if (state) if (state)
ui_menu_stack_push(ui_menu_alloc(machine, menu_sliders, (void *)1)); ui_menu_stack_push(ui_menu_alloc(machine, container, menu_sliders, (void *)1));
/* handle standard menus */ /* handle standard menus */
result = ui_menu_ui_handler(machine, state); result = ui_menu_ui_handler(machine, container, state);
/* if we are cancelled, pop the sliders menu */ /* if we are cancelled, pop the sliders menu */
if (result == UI_HANDLER_CANCEL) if (result == UI_HANDLER_CANCEL)
@ -1391,7 +1398,7 @@ UINT32 ui_slider_ui_handler(running_machine *machine, UINT32 state)
select menu to be visible and inescapable select menu to be visible and inescapable
-------------------------------------------------*/ -------------------------------------------------*/
void ui_menu_force_game_select(running_machine *machine) void ui_menu_force_game_select(running_machine *machine, render_container *container)
{ {
char *gamename = (char *)options_get_string(mame_options(), OPTION_GAMENAME); char *gamename = (char *)options_get_string(mame_options(), OPTION_GAMENAME);
@ -1399,8 +1406,8 @@ void ui_menu_force_game_select(running_machine *machine)
ui_menu_stack_reset(machine); ui_menu_stack_reset(machine);
/* add the quit entry followed by the game select entry */ /* add the quit entry followed by the game select entry */
ui_menu_stack_push(ui_menu_alloc(machine, menu_quit_game, NULL)); ui_menu_stack_push(ui_menu_alloc(machine, container, menu_quit_game, NULL));
ui_menu_stack_push(ui_menu_alloc(machine, menu_select_game, gamename)); ui_menu_stack_push(ui_menu_alloc(machine, container, menu_select_game, gamename));
/* force the menus on */ /* force the menus on */
ui_show_menu(); ui_show_menu();
@ -1448,7 +1455,7 @@ static void menu_main(running_machine *machine, ui_menu *menu, void *parameter,
/* process the menu */ /* process the menu */
event = ui_menu_process(machine, menu, 0); event = ui_menu_process(machine, menu, 0);
if (event != NULL && event->iptkey == IPT_UI_SELECT) if (event != NULL && event->iptkey == IPT_UI_SELECT)
ui_menu_stack_push(ui_menu_alloc(machine, (ui_menu_handler_func)event->itemref, NULL)); ui_menu_stack_push(ui_menu_alloc(machine, menu->container, (ui_menu_handler_func)event->itemref, NULL));
} }
@ -1545,7 +1552,7 @@ static void menu_input_groups(running_machine *machine, ui_menu *menu, void *par
/* process the menu */ /* process the menu */
event = ui_menu_process(machine, menu, 0); event = ui_menu_process(machine, menu, 0);
if (event != NULL && event->iptkey == IPT_UI_SELECT) if (event != NULL && event->iptkey == IPT_UI_SELECT)
ui_menu_stack_push(ui_menu_alloc(machine, menu_input_general, event->itemref)); ui_menu_stack_push(ui_menu_alloc(machine, menu->container, menu_input_general, event->itemref));
} }
@ -2101,7 +2108,7 @@ static void menu_settings_custom_render(running_machine *machine, ui_menu *menu,
y2 = y1 + bottom; y2 = y1 + bottom;
/* draw extra menu area */ /* draw extra menu area */
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR); ui_draw_outlined_box(menu->container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
y1 += (float)DIP_SWITCH_SPACING; y1 += (float)DIP_SWITCH_SPACING;
/* iterate over DIP switches */ /* iterate over DIP switches */
@ -2117,7 +2124,7 @@ static void menu_settings_custom_render(running_machine *machine, ui_menu *menu,
selectedmask |= 1 << (diploc->swnum - 1); selectedmask |= 1 << (diploc->swnum - 1);
/* draw one switch */ /* draw one switch */
menu_settings_custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask); menu_settings_custom_render_one(menu->container, x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT); y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
} }
} }
@ -2128,7 +2135,7 @@ static void menu_settings_custom_render(running_machine *machine, ui_menu *menu,
DIP switch DIP switch
-------------------------------------------------*/ -------------------------------------------------*/
static void menu_settings_custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) static void menu_settings_custom_render_one(render_container *container, float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask)
{ {
float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * render_get_ui_aspect(); float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * render_get_ui_aspect();
float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * render_get_ui_aspect(); float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * render_get_ui_aspect();
@ -2143,7 +2150,8 @@ static void menu_settings_custom_render_one(float x1, float y1, float x2, float
x1 += (x2 - x1 - numtoggles * switch_field_width) / 2; x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
/* draw the dip switch name */ /* draw the dip switch name */
ui_draw_text_full( dip->name, ui_draw_text_full( container,
dip->name,
0, 0,
y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2, y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2,
x1 - ui_get_string_width(" "), x1 - ui_get_string_width(" "),
@ -2166,7 +2174,7 @@ static void menu_settings_custom_render_one(float x1, float y1, float x2, float
float innerx1; float innerx1;
/* first outline the switch */ /* first outline the switch */
ui_draw_outlined_box(x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); ui_draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
/* compute x1/x2 for the inner filled in switch */ /* compute x1/x2 for the inner filled in switch */
innerx1 = x1 + (switch_field_width - switch_width) / 2; innerx1 = x1 + (switch_field_width - switch_width) / 2;
@ -2175,13 +2183,13 @@ static void menu_settings_custom_render_one(float x1, float y1, float x2, float
if (dip->mask & (1 << toggle)) if (dip->mask & (1 << toggle))
{ {
float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
render_ui_add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT, render_container_add_rect(container, innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT,
(selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR, (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
else else
{ {
render_ui_add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT, render_container_add_rect(container, innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT,
UI_UNAVAILABLE_COLOR, UI_UNAVAILABLE_COLOR,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
@ -2865,11 +2873,11 @@ static void menu_sliders_custom_render(running_machine *machine, ui_menu *menu,
x2 = 1.0f - UI_BOX_LR_BORDER; x2 = 1.0f - UI_BOX_LR_BORDER;
/* draw extra menu area */ /* draw extra menu area */
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR); ui_draw_outlined_box(menu->container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
y1 += UI_BOX_TB_BORDER; y1 += UI_BOX_TB_BORDER;
/* determine the text height */ /* determine the text height */
ui_draw_text_full(tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, ui_draw_text_full(menu->container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height); JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height);
/* draw the thermometer */ /* draw the thermometer */
@ -2885,18 +2893,18 @@ static void menu_sliders_custom_render(running_machine *machine, ui_menu *menu,
current_x = bar_left + bar_width * percentage; current_x = bar_left + bar_width * percentage;
/* fill in the percentage */ /* fill in the percentage */
render_ui_add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_rect(menu->container, bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the top and bottom lines */ /* draw the top and bottom lines */
render_ui_add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(menu->container, bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(menu->container, bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw default marker */ /* draw default marker */
render_ui_add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(menu->container, default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
render_ui_add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); render_container_add_line(menu->container, default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the actual text */ /* draw the actual text */
ui_draw_text_full(tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, ui_draw_text_full(menu->container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height); JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height);
} }
} }
@ -2918,7 +2926,7 @@ static void menu_video_targets(running_machine *machine, ui_menu *menu, void *pa
/* process the menu */ /* process the menu */
event = ui_menu_process(machine, menu, 0); event = ui_menu_process(machine, menu, 0);
if (event != NULL && event->iptkey == IPT_UI_SELECT) if (event != NULL && event->iptkey == IPT_UI_SELECT)
ui_menu_stack_push(ui_menu_alloc(machine, menu_video_options, event->itemref)); ui_menu_stack_push(ui_menu_alloc(machine, menu->container, menu_video_options, event->itemref));
} }
@ -2978,9 +2986,9 @@ static void menu_video_options(running_machine *machine, ui_menu *menu, void *pa
if (target == render_get_ui_target()) if (target == render_get_ui_target())
{ {
render_container_user_settings settings; render_container_user_settings settings;
render_container_get_user_settings(render_container_get_ui(), &settings); render_container_get_user_settings(menu->container, &settings);
settings.orientation = orientation_add(delta ^ ROT180, settings.orientation); settings.orientation = orientation_add(delta ^ ROT180, settings.orientation);
render_container_set_user_settings(render_container_get_ui(), &settings); render_container_set_user_settings(menu->container, &settings);
} }
changed = TRUE; changed = TRUE;
} }
@ -3392,7 +3400,7 @@ static void menu_select_game(running_machine *machine, ui_menu *menu, void *para
/* special case for configure inputs */ /* special case for configure inputs */
if ((FPTR)driver == 1) if ((FPTR)driver == 1)
ui_menu_stack_push(ui_menu_alloc(menu->machine, menu_input_groups, NULL)); ui_menu_stack_push(ui_menu_alloc(menu->machine, menu->container, menu_input_groups, NULL));
/* anything else is a driver */ /* anything else is a driver */
else else
@ -3427,7 +3435,7 @@ static void menu_select_game(running_machine *machine, ui_menu *menu, void *para
else if (event->iptkey == IPT_UI_CANCEL && menustate->search[0] != 0) else if (event->iptkey == IPT_UI_CANCEL && menustate->search[0] != 0)
{ {
/* since we have already been popped, we must recreate ourself from scratch */ /* since we have already been popped, we must recreate ourself from scratch */
ui_menu_stack_push(ui_menu_alloc(menu->machine, menu_select_game, NULL)); ui_menu_stack_push(ui_menu_alloc(menu->machine, menu->container, menu_select_game, NULL));
} }
/* typed characters append to the buffer */ /* typed characters append to the buffer */
@ -3455,7 +3463,8 @@ static void menu_select_game(running_machine *machine, ui_menu *menu, void *para
/* if we're in an error state, overlay an error message */ /* if we're in an error state, overlay an error message */
if (menustate->error) if (menustate->error)
ui_draw_text_box("The selected game is missing one or more required ROM or CHD images. " ui_draw_text_box(menu->container,
"The selected game is missing one or more required ROM or CHD images. "
"Please select a different game.\n\nPress any key to continue.", "Please select a different game.\n\nPress any key to continue.",
JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR); JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR);
} }
@ -3621,7 +3630,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
sprintf(&tempbuf[0][0], "Type name or select: (random)"); sprintf(&tempbuf[0][0], "Type name or select: (random)");
/* get the size of the text */ /* get the size of the text */
ui_draw_text_full(&tempbuf[0][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, ui_draw_text_full(menu->container, &tempbuf[0][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(width, origx2 - origx1); maxwidth = MAX(width, origx2 - origx1);
@ -3633,7 +3642,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
y2 = origy1 - UI_BOX_TB_BORDER; y2 = origy1 - UI_BOX_TB_BORDER;
/* draw a box */ /* draw a box */
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR); ui_draw_outlined_box(menu->container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
/* take off the borders */ /* take off the borders */
x1 += UI_BOX_LR_BORDER; x1 += UI_BOX_LR_BORDER;
@ -3642,7 +3651,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
y2 -= UI_BOX_TB_BORDER; y2 -= UI_BOX_TB_BORDER;
/* draw the text within it */ /* draw the text within it */
ui_draw_text_full(&tempbuf[0][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, ui_draw_text_full(menu->container, &tempbuf[0][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
/* determine the text to render below */ /* determine the text to render below */
@ -3709,7 +3718,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
maxwidth = origx2 - origx1; maxwidth = origx2 - origx1;
for (line = 0; line < 4; line++) for (line = 0; line < 4; line++)
{ {
ui_draw_text_full(&tempbuf[line][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, ui_draw_text_full(menu->container, &tempbuf[line][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
@ -3729,7 +3738,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
color = UI_YELLOW_COLOR; color = UI_YELLOW_COLOR;
if (driver != NULL && (driver->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION)) != 0) if (driver != NULL && (driver->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION)) != 0)
color = UI_RED_COLOR; color = UI_RED_COLOR;
ui_draw_outlined_box(x1, y1, x2, y2, color); ui_draw_outlined_box(menu->container, x1, y1, x2, y2, color);
/* take off the borders */ /* take off the borders */
x1 += UI_BOX_LR_BORDER; x1 += UI_BOX_LR_BORDER;
@ -3740,7 +3749,7 @@ static void menu_select_game_custom_render(running_machine *machine, ui_menu *me
/* draw all lines */ /* draw all lines */
for (line = 0; line < 4; line++) for (line = 0; line < 4; line++)
{ {
ui_draw_text_full(&tempbuf[line][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, ui_draw_text_full(menu->container, &tempbuf[line][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
y1 += ui_get_line_height(); y1 += ui_get_line_height();
} }

View File

@ -14,6 +14,7 @@
#ifndef __UIMENU_H__ #ifndef __UIMENU_H__
#define __UIMENU_H__ #define __UIMENU_H__
#include "render.h"
/*************************************************************************** /***************************************************************************
@ -87,7 +88,7 @@ void ui_menu_init(running_machine *machine);
/* ----- core menu management ----- */ /* ----- core menu management ----- */
/* allocate a new menu */ /* allocate a new menu */
ui_menu *ui_menu_alloc(running_machine *machine, ui_menu_handler_func handler, void *parameter); ui_menu *ui_menu_alloc(running_machine *machine, render_container *container, ui_menu_handler_func handler, void *parameter);
/* free a menu */ /* free a menu */
void ui_menu_free(ui_menu *menu); void ui_menu_free(ui_menu *menu);
@ -140,13 +141,13 @@ void ui_menu_stack_pop(running_machine *machine);
/* ----- UI system interaction ----- */ /* ----- UI system interaction ----- */
/* master handler */ /* master handler */
UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state); UINT32 ui_menu_ui_handler(running_machine *machine, render_container *container, UINT32 state);
/* slider handler */ /* slider handler */
UINT32 ui_slider_ui_handler(running_machine *machine, UINT32 state); UINT32 ui_slider_ui_handler(running_machine *machine, render_container *container, UINT32 state);
/* force game select menu */ /* force game select menu */
void ui_menu_force_game_select(running_machine *machine); void ui_menu_force_game_select(running_machine *machine, render_container *container);
int ui_menu_is_force_game_select(void); int ui_menu_is_force_game_select(void);

View File

@ -1299,7 +1299,7 @@ void video_frame_update(running_machine *machine, int debug)
} }
/* draw the user interface */ /* draw the user interface */
ui_update_and_render(machine); ui_update_and_render(machine, render_container_get_ui());
/* if we're throttling, synchronize before rendering */ /* if we're throttling, synchronize before rendering */
if (!debug && !skipped_it && effective_throttle(machine)) if (!debug && !skipped_it && effective_throttle(machine))

View File

@ -823,7 +823,7 @@ void deco16_print_debug_info(running_machine *machine, bitmap_t *bitmap)
sprintf(&buf[strlen(buf)],"%04X",deco16_priority); sprintf(&buf[strlen(buf)],"%04X",deco16_priority);
ui_draw_text(buf,60,40); ui_draw_text(render_container_get_ui(), buf,60,40);
} }
/*****************************************************************************************/ /*****************************************************************************************/

View File

@ -905,7 +905,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
if (input_code_pressed(machine, KEYCODE_Z)) /* Display some info on each sprite */ if (input_code_pressed(machine, KEYCODE_Z)) /* Display some info on each sprite */
{ char buf[30]; { char buf[30];
sprintf(buf, "%02X",/*(s2[2] & ~0x3ff)>>8*/mode>>8); sprintf(buf, "%02X",/*(s2[2] & ~0x3ff)>>8*/mode>>8);
ui_draw_text(buf, sx, sy); ui_draw_text(render_container_get_ui(), buf, sx, sy);
} }
#endif #endif
@ -1085,7 +1085,7 @@ static void gdfs_draw_zooming_sprites(running_machine *machine, bitmap_t *bitmap
{ {
char buf[10]; char buf[10];
sprintf(buf, "%X",size); sprintf(buf, "%X",size);
ui_draw_text(buf, sx / 0x10000, sy / 0x10000); ui_draw_text(render_container_get_ui(), buf, sx / 0x10000, sy / 0x10000);
} }
#endif #endif
} /* single-sprites */ } /* single-sprites */

View File

@ -480,7 +480,7 @@ static void print_debug_info(bitmap_t *bitmap)
l[3]=f3_line_ram[0x15e0]&0xffff; l[3]=f3_line_ram[0x15e0]&0xffff;
bufptr += sprintf(bufptr,"5000: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]); bufptr += sprintf(bufptr,"5000: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
ui_draw_text(buf, 60, 40); ui_draw_text(render_container_get_ui(), buf, 60, 40);
} }
/******************************************************************************/ /******************************************************************************/