UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { UINT32 flags = PRIMFLAG_ANTIALIAS(machine().options().antialias() ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | PRIMFLAG_VECTOR(1); const rectangle &visarea = screen.visible_area(); float xscale = 1.0f / (65536 * visarea.width()); float yscale = 1.0f / (65536 * visarea.height()); float xoffs = (float)visarea.min_x; float yoffs = (float)visarea.min_y; point *curpoint; int lastx = 0; int lasty = 0; curpoint = m_vector_list.get(); screen.container().empty(); screen.container().add_rect(0.0f, 0.0f, 1.0f, 1.0f, rgb_t(0xff,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_VECTORBUF(1)); for (int i = 0; i < m_vector_index; i++) { render_bounds coords; float intensity = (float)curpoint->intensity / 255.0f; float intensity_weight = normalized_sigmoid(intensity, vector_options::s_beam_intensity_weight); // check for static intensity float beam_width = m_min_intensity == m_max_intensity ? vector_options::s_beam_width_min : vector_options::s_beam_width_min + intensity_weight * (vector_options::s_beam_width_max - vector_options::s_beam_width_min); // normalize width beam_width *= 1.0f / (float)VECTOR_WIDTH_DENOM; coords.x0 = ((float)lastx - xoffs) * xscale; coords.y0 = ((float)lasty - yoffs) * yscale; coords.x1 = ((float)curpoint->x - xoffs) * xscale; coords.y1 = ((float)curpoint->y - yoffs) * yscale; if (curpoint->intensity != 0) { screen.container().add_line( coords.x0, coords.y0, coords.x1, coords.y1, beam_width, (curpoint->intensity << 24) | (curpoint->col & 0xffffff), flags); } lastx = curpoint->x; lasty = curpoint->y; curpoint++; } return 0; }
void render_crosshair::draw(render_container &container, u8 fade) { // add a quad assuming a 4:3 screen (this is not perfect) container.add_quad(m_x - 0.03f, m_y - 0.04f, m_x + 0.03f, m_y + 0.04f, rgb_t(0xc0, fade, fade, fade), m_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); }
void ui_menu::draw_text_box() { const char *text = item[0].text; const char *backtext = item[1].text; float line_height = ui_get_line_height(machine()); float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); float gutter_width = lr_arrow_width; float target_width, target_height, prior_width; float target_x, target_y; /* compute the multi-line target width/height */ ui_draw_text_full(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); target_height += 2.0f * line_height; if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER) target_height = floor((1.0f - 2.0f * UI_BOX_TB_BORDER) / line_height) * line_height; /* maximum against "return to prior menu" text */ prior_width = ui_get_string_width(machine(), backtext) + 2.0f * gutter_width; target_width = MAX(target_width, prior_width); /* determine the target location */ target_x = 0.5f - 0.5f * target_width; target_y = 0.5f - 0.5f * target_height; /* make sure we stay on-screen */ if (target_x < UI_BOX_LR_BORDER + gutter_width) target_x = UI_BOX_LR_BORDER + gutter_width; if (target_x + target_width + gutter_width + UI_BOX_LR_BORDER > 1.0f) target_x = 1.0f - UI_BOX_LR_BORDER - gutter_width - target_width; if (target_y < UI_BOX_TB_BORDER) target_y = UI_BOX_TB_BORDER; if (target_y + target_height + UI_BOX_TB_BORDER > 1.0f) target_y = 1.0f - UI_BOX_TB_BORDER - target_height; /* add a box around that */ ui_draw_outlined_box(container, target_x - UI_BOX_LR_BORDER - gutter_width, target_y - UI_BOX_TB_BORDER, target_x + target_width + gutter_width + UI_BOX_LR_BORDER, target_y + target_height + UI_BOX_TB_BORDER, (item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); ui_draw_text_full(container, text, target_x, target_y, target_width, 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 */ container->add_quad( target_x + 0.5f * UI_LINE_WIDTH, target_y + target_height - line_height, target_x + target_width - 0.5f * UI_LINE_WIDTH, target_y + target_height, UI_SELECTED_BG_COLOR, hilight_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); ui_draw_text_full(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); /* artificially set the hover to the last item so a double-click exits */ hover = numitems - 1; }
static void dview_draw_box(DView *dv, int rtype, int x, int y, int w, int h, rgb_t col) { rectangle r; dview_get_rect(dv, rtype, &r); dv->container->add_rect(NX(dv, x + r.min_x), NY(dv, y + r.min_y), NX(dv, x + r.min_x + w), NY(dv, y + r.min_y + h), col, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); }
void ui_menu::draw_arrow(render_container *container, float x0, float y0, float x1, float y1, rgb_t fgcolor, UINT32 orientation) { container->add_quad( x0, y0, x1, y1, fgcolor, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(orientation)); }
void crosshair_manager::render(screen_device &screen) { int player; for (player = 0; player < MAX_PLAYERS; player++) /* draw if visible and the right screen */ if (m_visible[player] && ((m_screen[player] == &screen) || (m_screen[player] == CROSSHAIR_SCREEN_ALL))) { /* add a quad assuming a 4:3 screen (this is not perfect) */ screen.container().add_quad(m_x[player] - 0.03f, m_y[player] - 0.04f, m_x[player] + 0.03f, m_y[player] + 0.04f, rgb_t(0xc0, m_fade, m_fade, m_fade), m_texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } }
void crosshair_render(screen_device &screen) { int player; for (player = 0; player < MAX_PLAYERS; player++) /* draw if visible and the right screen */ if (global.visible[player] && ((global.screen[player] == &screen) || (global.screen[player] == CROSSHAIR_SCREEN_ALL))) { /* add a quad assuming a 4:3 screen (this is not perfect) */ screen.container().add_quad(global.x[player] - 0.03f, global.y[player] - 0.04f, global.x[player] + 0.03f, global.y[player] + 0.04f, MAKE_ARGB(0xc0, global.fade, global.fade, global.fade), global.texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } }
void ui_menu::highlight(render_container *container, float x0, float y0, float x1, float y1, rgb_t bgcolor) { container->add_quad(x0, y0, x1, y1, bgcolor, hilight_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); }
void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { const slider_state *curslider = (const slider_state *)selectedref; if (curslider != nullptr) { float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x; float line_height = mame_machine_manager::instance()->ui().get_line_height(); float percentage, default_percentage; std::string tempstring; float text_height; INT32 curval; /* determine the current value and text */ curval = (*curslider->update)(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE); /* compute the current and default percentages */ percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval); default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval); /* assemble the text */ tempstring.insert(0, " ").insert(0, curslider->description); /* move us to the bottom of the screen, and expand to full width */ y2 = 1.0f - UI_BOX_TB_BORDER; y1 = y2 - bottom; x1 = UI_BOX_LR_BORDER; x2 = 1.0f - UI_BOX_LR_BORDER; /* draw extra menu area */ mame_machine_manager::instance()->ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); y1 += UI_BOX_TB_BORDER; /* determine the text height */ mame_machine_manager::instance()->ui().draw_text_full(container, tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, nullptr, &text_height); /* draw the thermometer */ bar_left = x1 + UI_BOX_LR_BORDER; bar_area_top = y1; bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER; bar_area_height = line_height; /* compute positions */ bar_top = bar_area_top + 0.125f * bar_area_height; bar_bottom = bar_area_top + 0.875f * bar_area_height; default_x = bar_left + bar_width * default_percentage; current_x = bar_left + bar_width * percentage; /* fill in the percentage */ container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); /* draw the top and bottom lines */ container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); /* draw default marker */ container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); container->add_line(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 */ mame_machine_manager::instance()->ui().draw_text_full(container, tempstring.c_str(), 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, nullptr, &text_height); } }
static VIDEO_UPDATE( alg ) { /* composite the video */ if (!video_skip_this_frame()) { mame_bitmap *vidbitmap; rectangle fixedvis = Machine->screen[screen].visarea; fixedvis.max_x++; fixedvis.max_y++; /* first lay down the video data */ laserdisc_get_video(discinfo, &vidbitmap); if (video_texture == NULL) video_texture = render_texture_alloc(vidbitmap, NULL, 0, TEXFORMAT_YUY16, NULL, NULL); else render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); /* then overlay the Amiga video */ if (overlay_texture == NULL) overlay_texture = render_texture_alloc(tmpbitmap, &fixedvis, 0, TEXFORMAT_PALETTEA16, NULL, NULL); else render_texture_set_bitmap(overlay_texture, tmpbitmap, &fixedvis, 0, TEXFORMAT_PALETTEA16); /* add both quads to the screen */ render_screen_add_quad(0, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), video_texture, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); render_screen_add_quad(0, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), overlay_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_SCREENTEX(1)); } /* display disc information */ if (discinfo != NULL) popmessage("%s", laserdisc_describe_state(discinfo)); return 0; }
void video_frame_update(void) { int skipped_it = video_skip_this_frame(); int paused = mame_is_paused(Machine); int phase = mame_get_phase(Machine); int livemask; int scrnum; /* only render sound and video if we're in the running phase */ if (phase == MAME_PHASE_RUNNING) { /* update sound */ sound_frame_update(); /* finish updating the screens */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) if (Machine->drv->screen[scrnum].tag != NULL) video_screen_update_partial(scrnum, Machine->screen[scrnum].visarea.max_y); /* now add the quads for all the screens */ livemask = render_get_live_screens_mask(); for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) { if (livemask & (1 << scrnum)) { internal_screen_info *screen = &scrinfo[scrnum]; /* only update if empty and not a vector game; otherwise assume the driver did it directly */ if (render_container_is_empty(render_container_get_screen(scrnum)) && !(Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)) { mame_bitmap *bitmap = screen->bitmap[screen->curbitmap]; if (!skipping_this_frame && screen->changed) { rectangle fixedvis = Machine->screen[scrnum].visarea; fixedvis.max_x++; fixedvis.max_y++; render_texture_set_bitmap(screen->texture, bitmap, &fixedvis, Machine->drv->screen[scrnum].palette_base, screen->format); screen->curbitmap = 1 - screen->curbitmap; } render_screen_add_quad(scrnum, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), screen->texture, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); } } } /* update our movie recording state */ if (!paused) movie_record_frame(0); /* reset the screen changed flags */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) scrinfo[scrnum].changed = 0; } /* draw any crosshairs */ crosshair_render(); /* draw the user interface */ ui_update_and_render(); /* call the OSD to update */ skipping_this_frame = osd_update(mame_timer_get_time()); /* empty the containers */ for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++) if (Machine->drv->screen[scrnum].tag != NULL) render_container_empty(render_container_get_screen(scrnum)); /* update FPS */ recompute_fps(skipped_it); /* call the end-of-frame callback */ if (phase == MAME_PHASE_RUNNING) { /* reset partial updates if we're paused or if the debugger is active */ if (paused || mame_debug_is_active()) video_reset_partial_updates(); /* otherwise, call the video EOF callback */ else if (Machine->drv->video_eof != NULL) { profiler_mark(PROFILER_VIDEO); (*Machine->drv->video_eof)(Machine); profiler_mark(PROFILER_END); } } }
static void gfxset_handler(mame_ui_manager &mui, render_container &container, ui_gfx_state &state) { render_font *ui_font = mui.get_font(); int dev = state.gfxset.devindex; int set = state.gfxset.set; ui_gfx_info &info = state.gfxdev[dev]; device_gfx_interface &interface = *info.interface; gfx_element &gfx = *interface.gfx(set); float fullwidth, fullheight; float cellwidth, cellheight; float chwidth, chheight; float titlewidth; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int cellboxwidth, cellboxheight; int targwidth = mui.machine().render().ui_target().width(); int targheight = mui.machine().render().ui_target().height(); int cellxpix, cellypix; int xcells, ycells; int pixelscale = 0; int x, y, skip; // add a half character padding for the box chheight = mui.get_line_height(); chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; // the character cell box bounds starts a half character in from the box cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; // add space on the left for 5 characters of text, plus a half character of padding cellboxbounds.x0 += 5.5f * chwidth; // add space on the top for a title, a half line of padding, a header, and another half line cellboxbounds.y0 += 3.0f * chheight; // convert back to pixels cellboxwidth = (cellboxbounds.x1 - cellboxbounds.x0) * (float)targwidth; cellboxheight = (cellboxbounds.y1 - cellboxbounds.y0) * (float)targheight; // compute the number of source pixels in a cell cellxpix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.height() : gfx.width()); cellypix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.width() : gfx.height()); // compute the largest pixel scale factor that still fits xcells = info.columns[set]; while (xcells > 1) { pixelscale = (cellboxwidth / xcells) / cellxpix; if (pixelscale != 0) break; xcells--; } info.columns[set] = xcells; // worst case, we need a pixel scale of 1 pixelscale = std::max(1, pixelscale); // in the Y direction, we just display as many as we can ycells = cellboxheight / (pixelscale * cellypix); // now determine the actual cellbox size cellboxwidth = std::min(cellboxwidth, xcells * pixelscale * cellxpix); cellboxheight = std::min(cellboxheight, ycells * pixelscale * cellypix); // compute the size of a single cell at this pixel scale factor, as well as the aspect ratio cellwidth = (cellboxwidth / (float)xcells) / (float)targwidth; cellheight = (cellboxheight / (float)ycells) / (float)targheight; //cellaspect = cellwidth / cellheight; // working from the new width/height, recompute the boxbounds fullwidth = (float)cellboxwidth / (float)targwidth + 6.5f * chwidth; fullheight = (float)cellboxheight / (float)targheight + 4.0f * chheight; // recompute boxbounds from this boxbounds.x0 = (1.0f - fullwidth) * 0.5f; boxbounds.x1 = boxbounds.x0 + fullwidth; boxbounds.y0 = (1.0f - fullheight) * 0.5f; boxbounds.y1 = boxbounds.y0 + fullheight; // recompute cellboxbounds cellboxbounds.x0 = boxbounds.x0 + 6.0f * chwidth; cellboxbounds.x1 = cellboxbounds.x0 + (float)cellboxwidth / (float)targwidth; cellboxbounds.y0 = boxbounds.y0 + 3.5f * chheight; cellboxbounds.y1 = cellboxbounds.y0 + (float)cellboxheight / (float)targheight; // figure out the title std::ostringstream title_buf; util::stream_format(title_buf, "'%s' %d/%d", interface.device().tag(), set, info.setcount - 1); // if the mouse pointer is over a pixel in a tile, add some info about the tile and pixel bool found_pixel = false; int32_t mouse_target_x, mouse_target_y; float mouse_x, mouse_y; bool mouse_button; render_target *mouse_target = mui.machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); if (mouse_target != nullptr && mouse_target->map_point_container(mouse_target_x, mouse_target_y, container, mouse_x, mouse_y) && cellboxbounds.x0 <= mouse_x && cellboxbounds.x1 > mouse_x && cellboxbounds.y0 <= mouse_y && cellboxbounds.y1 > mouse_y) { int code = info.offset[set] + int((mouse_x - cellboxbounds.x0) / cellwidth) + int((mouse_y - cellboxbounds.y0) / cellheight) * xcells; int xpixel = int((mouse_x - cellboxbounds.x0) / (cellwidth / cellxpix)) % cellxpix; int ypixel = int((mouse_y - cellboxbounds.y0) / (cellheight / cellypix)) % cellypix; if (code < gfx.elements() && xpixel < (cellxpix - 1) && ypixel < (cellypix - 1)) { found_pixel = true; if (info.rotate[set] & ORIENTATION_FLIP_X) xpixel = (cellxpix - 2) - xpixel; if (info.rotate[set] & ORIENTATION_FLIP_Y) ypixel = (cellypix - 2) - ypixel; if (info.rotate[set] & ORIENTATION_SWAP_XY) std::swap(xpixel, ypixel); uint8_t pixdata = gfx.get_data(code)[xpixel + ypixel * gfx.rowbytes()]; util::stream_format(title_buf, " #%X:%X @ %d,%d = %X", code, info.color[set], xpixel, ypixel, gfx.colorbase() + info.color[set] * gfx.granularity() + pixdata); } } if (!found_pixel) util::stream_format(title_buf, " %dx%d COLOR %X/%X", gfx.width(), gfx.height(), info.color[set], info.color_count[set]); // expand the outer box to fit the title const std::string title = title_buf.str(); titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title.c_str()); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (auto ch : title) { container.add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, ch); x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), ch); } // draw the top column headers skip = (int)(chwidth / cellwidth); for (x = 0; x < xcells; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, "0123456789ABCDEF"[x & 0xf]); // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to if (skip != 0) container.add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } // draw the side column headers skip = (int)(chheight / cellheight); for (y = 0; y < ycells; y += 1 + skip) // only display if there is data to show if (info.offset[set] + y * xcells < gfx.elements()) { char buffer[10]; // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container.add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header sprintf(buffer, "%5X", info.offset[set] + y * xcells); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, mui.machine().render().ui_aspect(), buffer[x]); container.add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, buffer[x]); } } // update the bitmap gfxset_update_bitmap(mui.machine(), state, xcells, ycells, gfx); // add the final quad container.add_quad(cellboxbounds.x0, cellboxbounds.y0, cellboxbounds.x1, cellboxbounds.y1, rgb_t::white(), state.texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // handle keyboard navigation before drawing gfxset_handle_keys(mui.machine(), state, xcells, ycells); }
void input_viewer::render_dips() { render_container* ui = &(machine().render().ui_container()); ioport_port* port; ioport_field* bit; int dip_num = 0; float height = machine().ui().get_line_height(); int x; // determine number of DIP switches to display /* loop over all input ports */ for (port = machine().ioport().first_port(); port != NULL; port = port->next()) { /* loop over all bitfields for this port */ for (bit = port->first_field(); bit != NULL; bit = bit->next()) { if (bit->type() == IPT_DIPSWITCH) { dip_num++; } } } ui->add_quad(0.0f,1.0f-(float)(dip_num*height),1.0f,1.0f,BGCOL,NULL,PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); x = dip_num; /* loop over all input ports */ for (port = machine().ioport().first_port(); port != NULL; port = port->next()) { /* loop over all bitfields for this port */ for (bit = port->first_field(); bit != NULL; bit = bit->next()) { if (bit->type() == IPT_DIPSWITCH) { char txt[512]; const char* dip; const char* value = "INVALID"; const char* def = "INVALID"; ioport_value portdata; // scan the list of settings looking for a match on the current value if(bit->first_setting() != NULL) { dip = bit->name(); portdata = machine().ioport().get_defvalue(port); for (ioport_setting *setting = bit->first_setting(); setting != NULL; setting = setting->next()) if (setting->enabled()) { if (setting->value() == (portdata & bit->mask())) value = setting->name(); if (setting->value() == (bit->defvalue() & bit->mask())) def = setting->name(); } sprintf(txt,"%s : %s [%s]",dip,value,def); machine().ui().draw_text_full(ui,txt,0.0f,1.0f - (float)(height * x),1.0f,JUSTIFY_LEFT,WRAP_NEVER,DRAW_OPAQUE,COL_WHITE,0,NULL,NULL); x--; } } } } }
void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) { float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect(); float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect(); int numtoggles, toggle; float switch_toggle_gap; float y1_off, y1_on; /* determine the number of toggles in the DIP */ numtoggles = 32 - count_leading_zeros(dip->mask); /* center based on the number of switches */ x1 += (x2 - x1 - numtoggles * switch_field_width) / 2; /* draw the dip switch name */ machine().ui().draw_text_full( container, dip->name, 0, y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2, x1 - machine().ui().get_string_width(" "), JUSTIFY_RIGHT, WRAP_NEVER, DRAW_NORMAL, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA), NULL , NULL); /* compute top and bottom for on and off positions */ switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2; y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap; y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap; /* iterate over toggles */ for (toggle = 0; toggle < numtoggles; toggle++) { float innerx1; /* first outline the switch */ machine().ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); /* compute x1/x2 for the inner filled in switch */ innerx1 = x1 + (switch_field_width - switch_width) / 2; /* see if the switch is actually used */ if (dip->mask & (1 << toggle)) { float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; container->add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT, (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else { container->add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT, UI_UNAVAILABLE_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } /* advance to the next switch */ x1 += switch_field_width; } }
static void tilemap_handler(mame_ui_manager &mui, render_container &container, ui_gfx_state &state) { render_font *ui_font = mui.get_font(); float chwidth, chheight; render_bounds mapboxbounds; render_bounds boxbounds; int targwidth = mui.machine().render().ui_target().width(); int targheight = mui.machine().render().ui_target().height(); float titlewidth; float x0, y0; int mapboxwidth, mapboxheight; // get the size of the tilemap itself tilemap_t *tilemap = mui.machine().tilemap().find(state.tilemap.which); uint32_t mapwidth = tilemap->width(); uint32_t mapheight = tilemap->height(); if (state.tilemap.rotate & ORIENTATION_SWAP_XY) std::swap(mapwidth, mapheight); // add a half character padding for the box chheight = mui.get_line_height(); chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; // the tilemap box bounds starts a half character in from the box mapboxbounds = boxbounds; mapboxbounds.x0 += 0.5f * chwidth; mapboxbounds.x1 -= 0.5f * chwidth; mapboxbounds.y0 += 0.5f * chheight; mapboxbounds.y1 -= 0.5f * chheight; // add space on the top for a title and a half line of padding mapboxbounds.y0 += 1.5f * chheight; // convert back to pixels mapboxwidth = (mapboxbounds.x1 - mapboxbounds.x0) * (float)targwidth; mapboxheight = (mapboxbounds.y1 - mapboxbounds.y0) * (float)targheight; // determine the maximum integral scaling factor int pixelscale = state.tilemap.zoom; if (pixelscale == 0) { int maxxscale, maxyscale; for (maxxscale = 1; mapwidth * (maxxscale + 1) < mapboxwidth; maxxscale++) { } for (maxyscale = 1; mapheight * (maxyscale + 1) < mapboxheight; maxyscale++) { } pixelscale = std::min(maxxscale, maxyscale); } // recompute the final box size mapboxwidth = std::min(mapboxwidth, int(mapwidth * pixelscale)); mapboxheight = std::min(mapboxheight, int(mapheight * pixelscale)); // recompute the bounds, centered within the existing bounds mapboxbounds.x0 += 0.5f * ((mapboxbounds.x1 - mapboxbounds.x0) - (float)mapboxwidth / (float)targwidth); mapboxbounds.x1 = mapboxbounds.x0 + (float)mapboxwidth / (float)targwidth; mapboxbounds.y0 += 0.5f * ((mapboxbounds.y1 - mapboxbounds.y0) - (float)mapboxheight / (float)targheight); mapboxbounds.y1 = mapboxbounds.y0 + (float)mapboxheight / (float)targheight; // now recompute the outer box against this new info boxbounds.x0 = mapboxbounds.x0 - 0.5f * chwidth; boxbounds.x1 = mapboxbounds.x1 + 0.5f * chwidth; boxbounds.y0 = mapboxbounds.y0 - 2.0f * chheight; boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight; // figure out the title std::ostringstream title_buf; util::stream_format(title_buf, "TILEMAP %d/%d", state.tilemap.which + 1, mui.machine().tilemap().count()); // if the mouse pointer is over a tile, add some info about its coordinates and color int32_t mouse_target_x, mouse_target_y; float mouse_x, mouse_y; bool mouse_button; render_target *mouse_target = mui.machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); if (mouse_target != nullptr && mouse_target->map_point_container(mouse_target_x, mouse_target_y, container, mouse_x, mouse_y) && mapboxbounds.x0 <= mouse_x && mapboxbounds.x1 > mouse_x && mapboxbounds.y0 <= mouse_y && mapboxbounds.y1 > mouse_y) { int xpixel = (mouse_x - mapboxbounds.x0) * targwidth; int ypixel = (mouse_y - mapboxbounds.y0) * targheight; if (state.tilemap.rotate & ORIENTATION_FLIP_X) xpixel = (mapboxwidth - 1) - xpixel; if (state.tilemap.rotate & ORIENTATION_FLIP_Y) ypixel = (mapboxheight - 1) - ypixel; if (state.tilemap.rotate & ORIENTATION_SWAP_XY) std::swap(xpixel, ypixel); uint32_t col = ((xpixel / pixelscale + state.tilemap.xoffs) / tilemap->tilewidth()) % tilemap->cols(); uint32_t row = ((ypixel / pixelscale + state.tilemap.yoffs) / tilemap->tileheight()) % tilemap->rows(); uint8_t gfxnum; uint32_t code, color; tilemap->get_info_debug(col, row, gfxnum, code, color); util::stream_format(title_buf, " @ %d,%d = GFX%d #%X:%X", col * tilemap->tilewidth(), row * tilemap->tileheight(), int(gfxnum), code, color); } else util::stream_format(title_buf, " %dx%d OFFS %d,%d", tilemap->width(), tilemap->height(), state.tilemap.xoffs, state.tilemap.yoffs); if (state.tilemap.flags != TILEMAP_DRAW_ALL_CATEGORIES) util::stream_format(title_buf, " CAT %d", state.tilemap.flags); // expand the outer box to fit the title const std::string title = title_buf.str(); titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title.c_str()); if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) { boxbounds.x0 = 0.5f - 0.5f * (titlewidth + chwidth); boxbounds.x1 = boxbounds.x0 + titlewidth + chwidth; } // go ahead and draw the outer box now mui.draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (auto ch : title) { container.add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, ch); x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), ch); } // update the bitmap tilemap_update_bitmap(mui.machine(), state, mapboxwidth / pixelscale, mapboxheight / pixelscale); // add the final quad container.add_quad(mapboxbounds.x0, mapboxbounds.y0, mapboxbounds.x1, mapboxbounds.y1, rgb_t::white(), state.texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state.tilemap.rotate)); // handle keyboard input tilemap_handle_keys(mui.machine(), state, mapboxwidth, mapboxheight); }
void menu_dats_view::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float maxwidth = origx2 - origx1; float width; std::string driver = (m_issoft == true) ? m_swinfo->longname : m_driver->description; ui().draw_text_full(container(), driver.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(maxwidth, width); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - ui().get_line_height(); // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; ui().draw_text_full(container(), driver.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); maxwidth = 0; for (auto & elem : m_items_list) { ui().draw_text_full(container(), elem.label.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); maxwidth += width; } float space = (1.0f - maxwidth) / (m_items_list.size() * 2); // compute our bounds x1 -= UI_BOX_LR_BORDER; x2 += UI_BOX_LR_BORDER; y1 = y2 + UI_BOX_TB_BORDER; y2 += ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders y1 += UI_BOX_TB_BORDER; // draw the text within it int x = 0; for (auto & elem : m_items_list) { x1 += space; rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR; rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; ui().draw_text_full(container(), elem.label.c_str(), x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NONE, fcolor, bcolor, &width, nullptr); if (bcolor != UI_TEXT_BG_COLOR) ui().draw_textured_box(container(), x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); ui().draw_text_full(container(), elem.label.c_str(), x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fcolor, bcolor, &width, nullptr); x1 += width + space; ++x; } // bottom std::string revision; revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision); ui().draw_text_full(container(), revision.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(origx2 - origx1, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), revision.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); }
void menu_dats_view::draw(uint32_t flags) { auto line_height = ui().get_line_height(); auto ud_arrow_width = line_height * machine().render().ui_aspect(); auto gutter_width = 0.52f * line_height * machine().render().ui_aspect(); mouse_x = -1, mouse_y = -1; float visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER; float visible_left = (1.0f - visible_width) * 0.5f; draw_background(); hover = item.size() + 1; visible_items = item.size() - 2; float extra_height = 2.0f * line_height; float visible_extra_menu_height = customtop + custombottom + extra_height; // locate mouse mouse_hit = false; mouse_button = false; mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); if (mouse_target != nullptr) if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y)) mouse_hit = true; // account for extra space at the top and bottom float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; m_visible_lines = int(std::trunc(visible_main_menu_height / line_height)); visible_main_menu_height = float(m_visible_lines) * line_height; // compute top/left of inner menu area by centering float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; // if the menu is at the bottom of the extra, adjust visible_top += customtop; // compute left box size float x1 = visible_left; float y1 = visible_top - UI_BOX_TB_BORDER; float x2 = x1 + visible_width; float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height; float line = visible_top + float(m_visible_lines) * line_height; ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); m_visible_lines = (std::min)(visible_items, m_visible_lines); top_line = (std::max)(0, top_line); if (top_line + m_visible_lines >= visible_items) top_line = visible_items - m_visible_lines; // determine effective positions taking into account the hilighting arrows float effective_width = visible_width - 2.0f * gutter_width; float effective_left = visible_left + gutter_width; int const n_loop = (std::min)(visible_items, m_visible_lines); for (int linenum = 0; linenum < n_loop; linenum++) { float line_y = visible_top + (float)linenum * line_height; int itemnum = top_line + linenum; const menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text.c_str(); rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line_y; float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float line_y1 = line_y + line_height; // if we're on the top line, display the up arrow if (linenum == 0 && top_line != 0) { draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0); if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_UP; } } // if we're on the bottom line, display the down arrow else if (linenum == m_visible_lines - 1 && itemnum != visible_items - 1) { draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y); if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_DOWN; } } // draw dats text else if (pitem.subtext.empty()) { ui().draw_text_full(container(), itemtext, effective_left, line_y, effective_width, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); } } for (size_t count = visible_items; count < item.size(); count++) { const menu_item &pitem = item[count]; const char *itemtext = pitem.text.c_str(); float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line; float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float line_y1 = line + line_height; rgb_t fgcolor = UI_SELECTED_COLOR; rgb_t bgcolor = UI_SELECTED_BG_COLOR; if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = count; if (pitem.type == menu_item_type::SEPARATOR) container().add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height, UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); else { highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); ui().draw_text_full(container(), itemtext, effective_left, line, effective_width, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); } line += line_height; } // if there is something special to add, do it by calling the virtual method custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items); }
UINT32 laserdisc_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { // handle the overlay if present screen_bitmap &overbitmap = m_overbitmap[m_overindex]; if (overbitmap.valid() && (!m_overupdate_ind16.isnull() || !m_overupdate_rgb32.isnull())) { // scale the cliprect to the overlay size rectangle clip(m_overclip); clip.min_y = cliprect.min_y * overbitmap.height() / bitmap.height(); if (cliprect.min_y == screen.visible_area().min_y) clip.min_y = MIN(clip.min_y, m_overclip.min_y); clip.max_y = (cliprect.max_y + 1) * overbitmap.height() / bitmap.height() - 1; // call the update callback if (!m_overupdate_ind16.isnull()) m_overupdate_ind16(screen, overbitmap.as_ind16(), clip); else m_overupdate_rgb32(screen, overbitmap.as_rgb32(), clip); } // if this is the last update, do the rendering if (cliprect.max_y == screen.visible_area().max_y) { // update the texture with the overlay contents if (overbitmap.valid()) m_overtex->set_bitmap(overbitmap, m_overclip, overbitmap.texformat()); // get the laserdisc video bitmap_yuy16 &vidbitmap = get_video(); m_videotex->set_bitmap(vidbitmap, vidbitmap.cliprect(), TEXFORMAT_YUY16); // reset the screen contents screen.container().empty(); // add the video texture if (m_videoenable) screen.container().add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t(0xff,0xff,0xff,0xff), m_videotex, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); // add the overlay if (m_overenable && overbitmap.valid()) { float x0 = 0.5f - 0.5f * m_overscalex + m_overposx; float y0 = 0.5f - 0.5f * m_overscaley + m_overposy; float x1 = x0 + m_overscalex; float y1 = y0 + m_overscaley; screen.container().add_quad(x0, y0, x1, y1, rgb_t(0xff,0xff,0xff,0xff), m_overtex, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_SCREENTEX(1)); } // swap to the next bitmap m_overindex = (m_overindex + 1) % ARRAY_LENGTH(m_overbitmap); } return 0; }
static VIDEO_UPDATE( cliff ) { /* update the TMS9928A video */ video_update_tms9928a( machine, screen, bitmap, cliprect ); if (discinfo != NULL) { mame_bitmap *vidbitmap; rectangle fixedvis = *TMS9928A_get_visarea(); fixedvis.max_x++; fixedvis.max_y++; laserdisc_get_video(discinfo, &vidbitmap); /* first lay down the video data */ if (video_texture == NULL) video_texture = render_texture_alloc(NULL, NULL); if (vidbitmap != last_video_bitmap) render_texture_set_bitmap(video_texture, vidbitmap, NULL, 0, TEXFORMAT_YUY16); last_video_bitmap = vidbitmap; /* then overlay the TMS9928A video */ if (overlay_texture == NULL) overlay_texture = render_texture_alloc(NULL, NULL); render_texture_set_bitmap(overlay_texture, bitmap, &fixedvis, 0, TEXFORMAT_PALETTEA16); /* add both quads to the screen */ render_container_empty(render_container_get_screen(screen)); render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), video_texture, PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), overlay_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_SCREENTEX(1)); } /* display disc information */ if (discinfo != NULL) popmessage("%s", laserdisc_describe_state(discinfo)); return 0; }
void ui_menu::draw(bool customonly) { float line_height = machine().ui().get_line_height(); float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); float ud_arrow_width = line_height * machine().render().ui_aspect(); float gutter_width = lr_arrow_width * 1.3f; float x1, y1, x2, y2; float effective_width, effective_left; float visible_width, visible_main_menu_height; float visible_extra_menu_height; float visible_top, visible_left; int selected_subitem_too_big = FALSE; int visible_lines; int top_line; int itemnum, linenum; bool mouse_hit, mouse_button; render_target *mouse_target; INT32 mouse_target_x, mouse_target_y; float mouse_x = -1, mouse_y = -1; // compute the width and height of the full menu visible_width = 0; visible_main_menu_height = 0; for (itemnum = 0; itemnum < numitems; itemnum++) { const ui_menu_item &pitem = item[itemnum]; float total_width; // compute width of left hand side total_width = gutter_width + machine().ui().get_string_width(pitem.text) + gutter_width; // add in width of right hand side if (pitem.subtext) total_width += 2.0f * gutter_width + machine().ui().get_string_width(pitem.subtext); // track the maximum if (total_width > visible_width) visible_width = total_width; // track the height as well visible_main_menu_height += line_height; } // account for extra space at the top and bottom visible_extra_menu_height = customtop + custombottom; // add a little bit of slop for rounding visible_width += 0.01f; visible_main_menu_height += 0.01f; // if we are too wide or too tall, clamp it down if (visible_width + 2.0f * UI_BOX_LR_BORDER > 1.0f) visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER; // if the menu and extra menu won't fit, take away part of the regular menu, it will scroll if (visible_main_menu_height + visible_extra_menu_height + 2.0f * UI_BOX_TB_BORDER > 1.0f) visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; visible_lines = floor(visible_main_menu_height / line_height); visible_main_menu_height = (float)visible_lines * line_height; // compute top/left of inner menu area by centering visible_left = (1.0f - visible_width) * 0.5f; visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; // if the menu is at the bottom of the extra, adjust visible_top += customtop; // first add us a box x1 = visible_left - UI_BOX_LR_BORDER; y1 = visible_top - UI_BOX_TB_BORDER; x2 = visible_left + visible_width + UI_BOX_LR_BORDER; y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER; if (!customonly) machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); // determine the first visible line based on the current selection top_line = selected - visible_lines / 2; if (top_line < 0) top_line = 0; if (top_line + visible_lines >= numitems) top_line = numitems - visible_lines; // determine effective positions taking into account the hilighting arrows effective_width = visible_width - 2.0f * gutter_width; effective_left = visible_left + gutter_width; // locate mouse mouse_hit = false; mouse_button = false; if (!customonly) { mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button); if (mouse_target != nullptr) if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y)) mouse_hit = true; } // loop over visible lines hover = numitems + 1; if (!customonly) for (linenum = 0; linenum < visible_lines; linenum++) { float line_y = visible_top + (float)linenum * line_height; itemnum = top_line + linenum; const ui_menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; rgb_t fgcolor2 = UI_SUBITEM_COLOR; rgb_t fgcolor3 = UI_CLONE_COLOR; float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line_y; float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float line_y1 = line_y + line_height; // set the hover if this is our item if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) hover = itemnum; // if we're selected, draw with a different background if (itemnum == selected) { fgcolor = UI_SELECTED_COLOR; bgcolor = UI_SELECTED_BG_COLOR; fgcolor2 = UI_SELECTED_COLOR; fgcolor3 = UI_SELECTED_COLOR; } // else if the mouse is over this item, draw with a different background else if (itemnum == hover) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; fgcolor2 = UI_MOUSEOVER_COLOR; fgcolor3 = UI_MOUSEOVER_COLOR; } // if we have some background hilighting to do, add a quad behind everything else if (bgcolor != UI_TEXT_BG_COLOR) highlight(container, line_x0, line_y0, line_x1, line_y1, bgcolor); // if we're on the top line, display the up arrow if (linenum == 0 && top_line != 0) { draw_arrow( container, 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0); if (hover == itemnum) hover = -2; } // if we're on the bottom line, display the down arrow else if (linenum == visible_lines - 1 && itemnum != numitems - 1) { draw_arrow( container, 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y); if (hover == itemnum) hover = -1; } // if we're just a divider, draw a line else if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0) container->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)); // if we don't have a subitem, just draw the string centered else if (pitem.subtext == nullptr) machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr); // otherwise, draw the item on the left and the subitem text on the right else { int subitem_invert = pitem.flags & MENU_FLAG_INVERT; const char *subitem_text = pitem.subtext; float item_width, subitem_width; // draw the left-side text machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, nullptr); // give 2 spaces worth of padding item_width += 2.0f * gutter_width; // if the subitem doesn't fit here, display dots if (machine().ui().get_string_width(subitem_text) > effective_width - item_width) { subitem_text = "..."; if (itemnum == selected) selected_subitem_too_big = TRUE; } // draw the subitem right-justified machine().ui().draw_text_full(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, nullptr); // apply arrows if (itemnum == selected && (pitem.flags & MENU_FLAG_LEFT_ARROW)) { draw_arrow( container, effective_left + effective_width - subitem_width - gutter_width, line_y + 0.1f * line_height, effective_left + effective_width - subitem_width - gutter_width + lr_arrow_width, line_y + 0.9f * line_height, fgcolor, ROT90 ^ ORIENTATION_FLIP_X); } if (itemnum == selected && (pitem.flags & MENU_FLAG_RIGHT_ARROW)) { draw_arrow( container, effective_left + effective_width + gutter_width - lr_arrow_width, line_y + 0.1f * line_height, effective_left + effective_width + gutter_width, line_y + 0.9f * line_height, fgcolor, ROT90); } } } // if the selected subitem is too big, display it in a separate offset box if (selected_subitem_too_big) { const ui_menu_item &pitem = item[selected]; int subitem_invert = pitem.flags & MENU_FLAG_INVERT; linenum = selected - top_line; float line_y = visible_top + (float)linenum * line_height; float target_width, target_height; float target_x, target_y; // compute the multi-line target width/height machine().ui().draw_text_full(container, pitem.subtext, 0, 0, visible_width * 0.75f, JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height); // determine the target location target_x = visible_left + visible_width - target_width - UI_BOX_LR_BORDER; target_y = line_y + line_height + UI_BOX_TB_BORDER; if (target_y + target_height + UI_BOX_TB_BORDER > visible_main_menu_height) target_y = line_y - target_height - UI_BOX_TB_BORDER; // add a box around that machine().ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER, target_y - UI_BOX_TB_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); machine().ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width, JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); } // if there is something special to add, do it by calling the virtual method custom_render((selected >= 0 && selected < numitems) ? item[selected].ref : nullptr, customtop, custombottom, x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != numitems); }
static void gfxset_handler(running_machine &machine, render_container *container, ui_gfx_state *state) { render_font *ui_font = ui_get_font(machine); int set = state->gfxset.set; gfx_element *gfx = machine.gfx[set]; float fullwidth, fullheight; float cellwidth, cellheight; float chwidth, chheight; float titlewidth; //float cellaspect; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int cellboxwidth, cellboxheight; int targwidth = machine.render().ui_target().width(); int targheight = machine.render().ui_target().height(); int cellxpix, cellypix; int xcells, ycells; int pixelscale = 0; int x, y, skip; char title[100]; /* add a half character padding for the box */ chheight = ui_get_line_height(machine); chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; /* the character cell box bounds starts a half character in from the box */ cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; /* add space on the left for 5 characters of text, plus a half character of padding */ cellboxbounds.x0 += 5.5f * chwidth; /* add space on the top for a title, a half line of padding, a header, and another half line */ cellboxbounds.y0 += 3.0f * chheight; /* convert back to pixels */ cellboxwidth = (cellboxbounds.x1 - cellboxbounds.x0) * (float)targwidth; cellboxheight = (cellboxbounds.y1 - cellboxbounds.y0) * (float)targheight; /* compute the number of source pixels in a cell */ cellxpix = 1 + ((state->gfxset.rotate[state->gfxset.set] & ORIENTATION_SWAP_XY) ? gfx->height() : gfx->width()); cellypix = 1 + ((state->gfxset.rotate[state->gfxset.set] & ORIENTATION_SWAP_XY) ? gfx->width() : gfx->height()); /* compute the largest pixel scale factor that still fits */ xcells = state->gfxset.count[set]; while (xcells > 1) { pixelscale = (cellboxwidth / xcells) / cellxpix; if (pixelscale != 0) break; xcells--; } /* worst case, we need a pixel scale of 1 */ pixelscale = MAX(1, pixelscale); /* in the Y direction, we just display as many as we can */ ycells = cellboxheight / (pixelscale * cellypix); /* now determine the actual cellbox size */ cellboxwidth = MIN(cellboxwidth, xcells * pixelscale * cellxpix); cellboxheight = MIN(cellboxheight, ycells * pixelscale * cellypix); /* compute the size of a single cell at this pixel scale factor, as well as the aspect ratio */ cellwidth = (cellboxwidth / (float)xcells) / (float)targwidth; cellheight = (cellboxheight / (float)ycells) / (float)targheight; //cellaspect = cellwidth / cellheight; /* working from the new width/height, recompute the boxbounds */ fullwidth = (float)cellboxwidth / (float)targwidth + 6.5f * chwidth; fullheight = (float)cellboxheight / (float)targheight + 4.0f * chheight; /* recompute boxbounds from this */ boxbounds.x0 = (1.0f - fullwidth) * 0.5f; boxbounds.x1 = boxbounds.x0 + fullwidth; boxbounds.y0 = (1.0f - fullheight) * 0.5f; boxbounds.y1 = boxbounds.y0 + fullheight; /* figure out the title and expand the outer box to fit */ for (x = 0; x < MAX_GFX_ELEMENTS && machine.gfx[x] != NULL; x++) ; sprintf(title, "GFX %d/%d %dx%d COLOR %X", state->gfxset.set, x - 1, gfx->width(), gfx->height(), state->gfxset.color[set]); titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); /* go ahead and draw the outer box now */ ui_draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); /* draw the title */ x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (x = 0; title[x] != 0; x++) { container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]); x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]); } /* draw the top column headers */ skip = (int)(chwidth / cellwidth); for (x = 0; x < xcells; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, machine.render().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 */ /* one it's referring to */ if (skip != 0) container->add_point(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 */ skip = (int)(chheight / cellheight); for (y = 0; y < ycells; y += 1 + skip) /* only display if there is data to show */ if (state->gfxset.offset[set] + y * xcells < gfx->elements()) { char buffer[10]; /* if we're skipping, draw a point between the character and the box to indicate which */ /* one it's referring to */ x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container->add_point(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 */ sprintf(buffer, "%5X", state->gfxset.offset[set] + y * xcells); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, machine.render().ui_aspect(), buffer[x]); container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, buffer[x]); } } /* update the bitmap */ gfxset_update_bitmap(machine, state, xcells, ycells, gfx); /* add the final quad */ container->add_quad(boxbounds.x0 + 6.0f * chwidth, boxbounds.y0 + 3.5f * chheight, boxbounds.x0 + 6.0f * chwidth + (float)cellboxwidth / (float)targwidth, boxbounds.y0 + 3.5f * chheight + (float)cellboxheight / (float)targheight, ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); /* handle keyboard navigation before drawing */ gfxset_handle_keys(machine, state, xcells, ycells); }
void input_viewer::render_input() { int port = 0; char txt[6]; float height = machine().ui().get_line_height(); if(m_player < 1 || m_player > 8) return; // invalid player if(machine().input().code_pressed(KEYCODE_DEL)) { render_dips(); return; } render_container* ui = &(machine().render().ui_container()); machine().render().ui_container().add_quad(0.0f,1.0f-(float)(inptype[m_layout].lines*height),1.0f,1.0f,BGCOL,NULL,PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); while(inptype[m_layout].inp[port].port != -1) { strcpy(txt,inptype[m_layout].inp[port].text); if(inptype[m_layout].inp[port].playerspecific == 0) { if(input_port_used(inptype[m_layout].inp[port].port,0) != 0) { int col = inptype[m_layout].inp[port].colour; machine().ui().draw_text_full(ui,txt,(float)(inptype[m_layout].inp[port].x * CHARACTER_WIDTH),1.0f - (float)(height * inptype[m_layout].inp[port].line),1.0f,JUSTIFY_LEFT,WRAP_NEVER,DRAW_OPAQUE,col,0,NULL,NULL); } } else { if(input_port_used(inptype[m_layout].inp[port].port,m_player-1) != 0) { int col = inptype[m_layout].inp[port].colour; machine().ui().draw_text_full(ui,txt,(float)(inptype[m_layout].inp[port].x * CHARACTER_WIDTH),1.0f - (float)(height * inptype[m_layout].inp[port].line),1.0f,JUSTIFY_LEFT,WRAP_NEVER,DRAW_OPAQUE,col,0,NULL,NULL); } } port++; } }
static void palette_handler(running_machine &machine, render_container *container, ui_gfx_state &state) { palette_device *palette = state.palette.device; int total = state.palette.which ? palette->indirect_entries() : palette->entries(); const rgb_t *raw_color = palette->palette()->entry_list_raw(); render_font *ui_font = machine.ui().get_font(); float cellwidth, cellheight; float chwidth, chheight; float titlewidth; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int x, y, skip; char title[100]; // add a half character padding for the box chheight = machine.ui().get_line_height(); chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; // the character cell box bounds starts a half character in from the box cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; // add space on the left for 5 characters of text, plus a half character of padding cellboxbounds.x0 += 5.5f * chwidth; // add space on the top for a title, a half line of padding, a header, and another half line cellboxbounds.y0 += 3.0f * chheight; // figure out the title and expand the outer box to fit const char *suffix = palette->indirect_entries() == 0 ? "" : state.palette.which ? " COLORS" : " PENS"; sprintf(title, "'%s'%s", palette->tag(), suffix); titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now machine.ui().draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (x = 0; title[x] != 0; x++) { container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]); x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]); } // compute the cell size cellwidth = (cellboxbounds.x1 - cellboxbounds.x0) / (float)state.palette.columns; cellheight = (cellboxbounds.y1 - cellboxbounds.y0) / (float)state.palette.columns; // draw the top column headers skip = (int)(chwidth / cellwidth); for (x = 0; x < state.palette.columns; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, machine.render().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 // one it's referring to if (skip != 0) container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } // draw the side column headers skip = (int)(chheight / cellheight); for (y = 0; y < state.palette.columns; y += 1 + skip) // only display if there is data to show if (state.palette.offset + y * state.palette.columns < total) { char buffer[10]; // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container->add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header sprintf(buffer, "%5X", state.palette.offset + y * state.palette.columns); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, machine.render().ui_aspect(), buffer[x]); container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, buffer[x]); } } // now add the rectangles for the colors for (y = 0; y < state.palette.columns; y++) for (x = 0; x < state.palette.columns; x++) { int index = state.palette.offset + y * state.palette.columns + x; if (index < total) { pen_t pen = state.palette.which ? palette->indirect_color(index) : raw_color[index]; container->add_rect(cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight, cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight, 0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } } // handle keys palette_handle_keys(machine, state); }
void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { ui_manager &mui = machine().ui(); float maxwidth = origx2 - origx1; float width; std::string driver; if (issoft) driver = m_swinfo->longname; else driver = m_driver->description; mui.draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(origx2 - origx1, width); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - mui.get_line_height(); // draw a box mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; mui.draw_text_full(container, driver.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // take off the borders x1 -= UI_BOX_LR_BORDER; x2 += UI_BOX_LR_BORDER; y1 -= UI_BOX_TB_BORDER; maxwidth = 0; for (auto & elem : m_items_list) { mui.draw_text_full(container, elem.label.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); maxwidth += width; } float space = (1.0f - maxwidth) / (m_items_list.size() * 2); // compute our bounds y1 = y2 + UI_BOX_TB_BORDER; y2 += mui.get_line_height() + 2.0f * UI_BOX_TB_BORDER; // draw a box mui.draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it int x = 0; for (auto & elem : m_items_list) { x1 += space; rgb_t fcolor = (actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR; rgb_t bcolor = (actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; mui.draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NONE, fcolor, bcolor, &width, nullptr); if (bcolor != UI_TEXT_BG_COLOR) mui.draw_textured_box(container, x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); mui.draw_text_full(container, elem.label.c_str(), x1, y1, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NORMAL, fcolor, bcolor, &width, nullptr); x1 += width + space; ++x; } // bottom std::string revision; revision.assign(_("Revision: ")).append(m_items_list[actual].revision); mui.draw_text_full(container, revision.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(origx2 - origx1, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it mui.draw_text_full(container, revision.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); }
static void palette_handler(mame_ui_manager &mui, render_container &container, ui_gfx_state &state) { device_palette_interface *palette = state.palette.interface; palette_device *paldev = dynamic_cast<palette_device *>(&palette->device()); int total = state.palette.which ? palette->indirect_entries() : palette->entries(); const rgb_t *raw_color = palette->palette()->entry_list_raw(); render_font *ui_font = mui.get_font(); float chwidth, chheight; float titlewidth; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int x, y, skip; // add a half character padding for the box chheight = mui.get_line_height(); chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; // the character cell box bounds starts a half character in from the box cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; // add space on the left for 5 characters of text, plus a half character of padding cellboxbounds.x0 += 5.5f * chwidth; // add space on the top for a title, a half line of padding, a header, and another half line cellboxbounds.y0 += 3.0f * chheight; // compute the cell size float cellwidth = (cellboxbounds.x1 - cellboxbounds.x0) / (float)state.palette.columns; float cellheight = (cellboxbounds.y1 - cellboxbounds.y0) / (float)state.palette.columns; // figure out the title std::ostringstream title_buf; util::stream_format(title_buf, "'%s'", palette->device().tag()); if (palette->indirect_entries() > 0) title_buf << (state.palette.which ? _(" COLORS") : _(" PENS")); // if the mouse pointer is over one of our cells, add some info about the corresponding palette entry int32_t mouse_target_x, mouse_target_y; float mouse_x, mouse_y; bool mouse_button; render_target *mouse_target = mui.machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); if (mouse_target != nullptr && mouse_target->map_point_container(mouse_target_x, mouse_target_y, container, mouse_x, mouse_y) && cellboxbounds.x0 <= mouse_x && cellboxbounds.x1 > mouse_x && cellboxbounds.y0 <= mouse_y && cellboxbounds.y1 > mouse_y) { int index = state.palette.offset + int((mouse_x - cellboxbounds.x0) / cellwidth) + int((mouse_y - cellboxbounds.y0) / cellheight) * state.palette.columns; if (index < total) { util::stream_format(title_buf, " #%X", index); if (palette->indirect_entries() > 0 && !state.palette.which) util::stream_format(title_buf, " => %X", palette->pen_indirect(index)); else if (paldev != nullptr && paldev->basemem().base() != nullptr) util::stream_format(title_buf, " = %X", paldev->read_entry(index)); rgb_t col = state.palette.which ? palette->indirect_color(index) : raw_color[index]; util::stream_format(title_buf, " (R:%X G:%X B:%X)", col.r(), col.g(), col.b()); } } // expand the outer box to fit the title const std::string title = title_buf.str(); titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title.c_str()); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (auto ch : title) { container.add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, ch); x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), ch); } // draw the top column headers skip = (int)(chwidth / cellwidth); for (x = 0; x < state.palette.columns; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container.add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, "0123456789ABCDEF"[x & 0xf]); // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to if (skip != 0) container.add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } // draw the side column headers skip = (int)(chheight / cellheight); for (y = 0; y < state.palette.columns; y += 1 + skip) // only display if there is data to show if (state.palette.offset + y * state.palette.columns < total) { char buffer[10]; // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container.add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header sprintf(buffer, "%5X", state.palette.offset + y * state.palette.columns); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, mui.machine().render().ui_aspect(), buffer[x]); container.add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, mui.machine().render().ui_aspect(), rgb_t::white(), *ui_font, buffer[x]); } } // now add the rectangles for the colors for (y = 0; y < state.palette.columns; y++) for (x = 0; x < state.palette.columns; x++) { int index = state.palette.offset + y * state.palette.columns + x; if (index < total) { pen_t pen = state.palette.which ? palette->indirect_color(index) : raw_color[index]; container.add_rect(cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight, cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight, 0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } } // handle keys palette_handle_keys(mui.machine(), 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.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(machine); float cellwidth, cellheight; float chwidth, chheight; float titlewidth; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int x, y, skip; /* add a half character padding for the box */ chheight = ui_get_line_height(machine); chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; /* the character cell box bounds starts a half character in from the box */ cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; /* add space on the left for 5 characters of text, plus a half character of padding */ cellboxbounds.x0 += 5.5f * chwidth; /* add space on the top for a title, a half line of padding, a header, and another half line */ cellboxbounds.y0 += 3.0f * chheight; /* figure out the title and expand the outer box to fit */ titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); /* go ahead and draw the outer box now */ ui_draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); /* draw the title */ x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (x = 0; title[x] != 0; x++) { container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]); x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]); } /* compute the cell size */ cellwidth = (cellboxbounds.x1 - cellboxbounds.x0) / (float)state->palette.count; cellheight = (cellboxbounds.y1 - cellboxbounds.y0) / (float)state->palette.count; /* draw the top column headers */ skip = (int)(chwidth / cellwidth); for (x = 0; x < state->palette.count; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, machine.render().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 */ /* one it's referring to */ if (skip != 0) container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + cellboxbounds.y0), UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } /* draw the side column headers */ skip = (int)(chheight / cellheight); for (y = 0; y < state->palette.count; y += 1 + skip) /* only display if there is data to show */ if (state->palette.offset + y * state->palette.count < total) { char buffer[10]; /* if we're skipping, draw a point between the character and the box to indicate which */ /* one it's referring to */ x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container->add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); /* draw the row header */ sprintf(buffer, "%5X", state->palette.offset + y * state->palette.count); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, machine.render().ui_aspect(), buffer[x]); container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, buffer[x]); } } /* now add the rectangles for the colors */ for (y = 0; y < state->palette.count; y++) for (x = 0; x < state->palette.count; x++) { int index = state->palette.offset + y * state->palette.count + x; if (index < total) { pen_t pen = state->palette.which ? colortable_palette_get_color(machine.colortable, index) : raw_color[index]; container->add_rect(cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight, cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight, 0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } } /* handle keys */ palette_handle_keys(machine, state); }
static void crosshair_render(void) { float x[MAX_PLAYERS], y[MAX_PLAYERS]; input_port_entry *ipt; int portnum = -1; int player; UINT8 tscale; /* skip if not needed */ if (crosshair_visible == 0) return; /* animate via crosshair_animate */ crosshair_animate += 0x04; /* compute a color scaling factor from the current animation value */ if (crosshair_animate < 0x80) tscale = 0xa0 + (0x60 * (crosshair_animate & 0x7f) / 0x80); else tscale = 0xa0 + (0x60 * (~crosshair_animate & 0x7f) / 0x80); /* read all the lightgun values */ for (ipt = Machine->input_ports; ipt->type != IPT_END; ipt++) { /* keep track of the port number */ if (ipt->type == IPT_PORT) portnum++; /* compute the values */ if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE) { float value = (float)((readinputport(portnum) & ipt->mask) - ipt->analog.min) / (float)(ipt->analog.max - ipt->analog.min); value = (value - 0.5f) * ipt->analog.crossscale + 0.5f; value += ipt->analog.crossoffset; /* switch off the axis */ switch (ipt->analog.crossaxis) { case CROSSHAIR_AXIS_X: x[ipt->player] = value; if (ipt->analog.crossaltaxis != 0) y[ipt->player] = ipt->analog.crossaltaxis; break; case CROSSHAIR_AXIS_Y: y[ipt->player] = value; if (ipt->analog.crossaltaxis != 0) x[ipt->player] = ipt->analog.crossaltaxis; break; } } } /* draw all crosshairs */ for (player = 0; player < MAX_PLAYERS; player++) if (crosshair_visible & (1 << player)) { /* add a quad assuming a 4:3 screen (this is not perfect) */ render_screen_add_quad(0, x[player] - 0.03f, y[player] - 0.04f, x[player] + 0.03f, y[player] + 0.04f, MAKE_ARGB(0xc0, tscale, tscale, tscale), crosshair_texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } }
static void tilemap_handler(running_machine &machine, render_container *container, ui_gfx_state *state) { render_font *ui_font = ui_get_font(machine); float chwidth, chheight; render_bounds mapboxbounds; render_bounds boxbounds; int targwidth = machine.render().ui_target().width(); int targheight = machine.render().ui_target().height(); float titlewidth; float x0, y0; int mapboxwidth, mapboxheight; int maxxscale, maxyscale; UINT32 mapwidth, mapheight; int x, pixelscale; char title[100]; /* get the size of the tilemap itself */ tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which); mapwidth = tilemap->width(); mapheight = tilemap->height(); if (state->tilemap.rotate & ORIENTATION_SWAP_XY) { UINT32 temp = mapwidth; mapwidth = mapheight; mapheight = temp; } /* add a half character padding for the box */ chheight = ui_get_line_height(machine); chwidth = ui_font->char_width(chheight, machine.render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; /* the tilemap box bounds starts a half character in from the box */ mapboxbounds = boxbounds; mapboxbounds.x0 += 0.5f * chwidth; mapboxbounds.x1 -= 0.5f * chwidth; mapboxbounds.y0 += 0.5f * chheight; mapboxbounds.y1 -= 0.5f * chheight; /* add space on the top for a title and a half line of padding */ mapboxbounds.y0 += 1.5f * chheight; /* convert back to pixels */ mapboxwidth = (mapboxbounds.x1 - mapboxbounds.x0) * (float)targwidth; mapboxheight = (mapboxbounds.y1 - mapboxbounds.y0) * (float)targheight; /* determine the maximum integral scaling factor */ pixelscale = state->tilemap.zoom; if (pixelscale == 0) { for (maxxscale = 1; mapwidth * (maxxscale + 1) < mapboxwidth; maxxscale++) ; for (maxyscale = 1; mapheight * (maxyscale + 1) < mapboxheight; maxyscale++) ; pixelscale = MIN(maxxscale, maxyscale); } /* recompute the final box size */ mapboxwidth = MIN(mapboxwidth, mapwidth * pixelscale); mapboxheight = MIN(mapboxheight, mapheight * pixelscale); /* recompute the bounds, centered within the existing bounds */ mapboxbounds.x0 += 0.5f * ((mapboxbounds.x1 - mapboxbounds.x0) - (float)mapboxwidth / (float)targwidth); mapboxbounds.x1 = mapboxbounds.x0 + (float)mapboxwidth / (float)targwidth; mapboxbounds.y0 += 0.5f * ((mapboxbounds.y1 - mapboxbounds.y0) - (float)mapboxheight / (float)targheight); mapboxbounds.y1 = mapboxbounds.y0 + (float)mapboxheight / (float)targheight; /* now recompute the outer box against this new info */ boxbounds.x0 = mapboxbounds.x0 - 0.5f * chwidth; boxbounds.x1 = mapboxbounds.x1 + 0.5f * chwidth; boxbounds.y0 = mapboxbounds.y0 - 2.0f * chheight; boxbounds.y1 = mapboxbounds.y1 + 0.5f * chheight; /* figure out the title and expand the outer box to fit */ sprintf(title, "TMAP %d/%d %dx%d OFFS %d,%d", state->tilemap.which, machine.tilemap().count() - 1, mapwidth, mapheight, state->tilemap.xoffs, state->tilemap.yoffs); titlewidth = ui_font->string_width(chheight, machine.render().ui_aspect(), title); if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) { boxbounds.x0 = 0.5f - 0.5f * (titlewidth + chwidth); boxbounds.x1 = boxbounds.x0 + titlewidth + chwidth; } /* go ahead and draw the outer box now */ ui_draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); /* draw the title */ x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (x = 0; title[x] != 0; x++) { container->add_char(x0, y0, chheight, machine.render().ui_aspect(), ARGB_WHITE, *ui_font, title[x]); x0 += ui_font->char_width(chheight, machine.render().ui_aspect(), title[x]); } /* update the bitmap */ tilemap_update_bitmap(machine, state, mapboxwidth / pixelscale, mapboxheight / pixelscale); /* add the final quad */ container->add_quad(mapboxbounds.x0, mapboxbounds.y0, mapboxbounds.x1, mapboxbounds.y1, ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate)); /* handle keyboard input */ tilemap_handle_keys(machine, state, mapboxwidth, mapboxheight); }
static void gfxset_handler(mame_ui_manager &mui, render_container *container, ui_gfx_state &state) { render_font *ui_font = mui.get_font(); int dev = state.gfxset.devindex; int set = state.gfxset.set; ui_gfx_info &info = state.gfxdev[dev]; device_gfx_interface &interface = *info.interface; gfx_element &gfx = *interface.gfx(set); float fullwidth, fullheight; float cellwidth, cellheight; float chwidth, chheight; float titlewidth; //float cellaspect; float x0, y0; render_bounds cellboxbounds; render_bounds boxbounds; int cellboxwidth, cellboxheight; int targwidth = mui.machine().render().ui_target().width(); int targheight = mui.machine().render().ui_target().height(); int cellxpix, cellypix; int xcells, ycells; int pixelscale = 0; int x, y, skip; char title[100]; // add a half character padding for the box chheight = mui.get_line_height(); chwidth = ui_font->char_width(chheight, mui.machine().render().ui_aspect(), '0'); boxbounds.x0 = 0.0f + 0.5f * chwidth; boxbounds.x1 = 1.0f - 0.5f * chwidth; boxbounds.y0 = 0.0f + 0.5f * chheight; boxbounds.y1 = 1.0f - 0.5f * chheight; // the character cell box bounds starts a half character in from the box cellboxbounds = boxbounds; cellboxbounds.x0 += 0.5f * chwidth; cellboxbounds.x1 -= 0.5f * chwidth; cellboxbounds.y0 += 0.5f * chheight; cellboxbounds.y1 -= 0.5f * chheight; // add space on the left for 5 characters of text, plus a half character of padding cellboxbounds.x0 += 5.5f * chwidth; // add space on the top for a title, a half line of padding, a header, and another half line cellboxbounds.y0 += 3.0f * chheight; // convert back to pixels cellboxwidth = (cellboxbounds.x1 - cellboxbounds.x0) * (float)targwidth; cellboxheight = (cellboxbounds.y1 - cellboxbounds.y0) * (float)targheight; // compute the number of source pixels in a cell cellxpix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.height() : gfx.width()); cellypix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.width() : gfx.height()); // compute the largest pixel scale factor that still fits xcells = info.columns[set]; while (xcells > 1) { pixelscale = (cellboxwidth / xcells) / cellxpix; if (pixelscale != 0) break; xcells--; } info.columns[set] = xcells; // worst case, we need a pixel scale of 1 pixelscale = MAX(1, pixelscale); // in the Y direction, we just display as many as we can ycells = cellboxheight / (pixelscale * cellypix); // now determine the actual cellbox size cellboxwidth = MIN(cellboxwidth, xcells * pixelscale * cellxpix); cellboxheight = MIN(cellboxheight, ycells * pixelscale * cellypix); // compute the size of a single cell at this pixel scale factor, as well as the aspect ratio cellwidth = (cellboxwidth / (float)xcells) / (float)targwidth; cellheight = (cellboxheight / (float)ycells) / (float)targheight; //cellaspect = cellwidth / cellheight; // working from the new width/height, recompute the boxbounds fullwidth = (float)cellboxwidth / (float)targwidth + 6.5f * chwidth; fullheight = (float)cellboxheight / (float)targheight + 4.0f * chheight; // recompute boxbounds from this boxbounds.x0 = (1.0f - fullwidth) * 0.5f; boxbounds.x1 = boxbounds.x0 + fullwidth; boxbounds.y0 = (1.0f - fullheight) * 0.5f; boxbounds.y1 = boxbounds.y0 + fullheight; // figure out the title and expand the outer box to fit sprintf(title, "'%s' %d/%d %dx%d COLOR %X", interface.device().tag(), set, info.setcount - 1, gfx.width(), gfx.height(), info.color[set]); titlewidth = ui_font->string_width(chheight, mui.machine().render().ui_aspect(), title); x0 = 0.0f; if (boxbounds.x1 - boxbounds.x0 < titlewidth + chwidth) x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; y0 = boxbounds.y0 + 0.5f * chheight; for (x = 0; title[x] != 0; x++) { container->add_char(x0, y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, title[x]); x0 += ui_font->char_width(chheight, mui.machine().render().ui_aspect(), title[x]); } // draw the top column headers skip = (int)(chwidth / cellwidth); for (x = 0; x < xcells; x += 1 + skip) { x0 = boxbounds.x0 + 6.0f * chwidth + (float)x * cellwidth; y0 = boxbounds.y0 + 2.0f * chheight; container->add_char(x0 + 0.5f * (cellwidth - chwidth), y0, chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, "0123456789ABCDEF"[x & 0xf]); // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to if (skip != 0) container->add_point(x0 + 0.5f * cellwidth, 0.5f * (y0 + chheight + boxbounds.y0 + 3.5f * chheight), UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } // draw the side column headers skip = (int)(chheight / cellheight); for (y = 0; y < ycells; y += 1 + skip) // only display if there is data to show if (info.offset[set] + y * xcells < gfx.elements()) { char buffer[10]; // if we're skipping, draw a point between the character and the box to indicate which // one it's referring to x0 = boxbounds.x0 + 5.5f * chwidth; y0 = boxbounds.y0 + 3.5f * chheight + (float)y * cellheight; if (skip != 0) container->add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header sprintf(buffer, "%5X", info.offset[set] + y * xcells); for (x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, mui.machine().render().ui_aspect(), buffer[x]); container->add_char(x0, y0 + 0.5f * (cellheight - chheight), chheight, mui.machine().render().ui_aspect(), rgb_t::white, *ui_font, buffer[x]); } } // update the bitmap gfxset_update_bitmap(mui.machine(), state, xcells, ycells, gfx); // add the final quad container->add_quad(boxbounds.x0 + 6.0f * chwidth, boxbounds.y0 + 3.5f * chheight, boxbounds.x0 + 6.0f * chwidth + (float)cellboxwidth / (float)targwidth, boxbounds.y0 + 3.5f * chheight + (float)cellboxheight / (float)targheight, rgb_t::white, state.texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // handle keyboard navigation before drawing gfxset_handle_keys(mui.machine(), state, xcells, ycells); }