diff options
author | 2017-05-04 10:44:25 -0400 | |
---|---|---|
committer | 2017-05-04 10:44:25 -0400 | |
commit | 5afc563c3abc52b5e45986de49de19f98be3e5b8 (patch) | |
tree | 8033c8d0c3d70a8259add976bd0eb3317c0e0c50 | |
parent | c9c097050b6364346ef530cd23bb576ebe185aa2 (diff) | |
parent | 4091898097df5ee2ba2aeb312d6183b3f9372772 (diff) |
Merge pull request #2072 from startaq/tilemap_category
UI: Add the ability to select different tilemap categories
-rw-r--r-- | src/emu/tilemap.cpp | 8 | ||||
-rw-r--r-- | src/emu/tilemap.h | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/viewgfx.cpp | 36 |
3 files changed, 40 insertions, 6 deletions
diff --git a/src/emu/tilemap.cpp b/src/emu/tilemap.cpp index 2e2b14f5086..d1db7ea6082 100644 --- a/src/emu/tilemap.cpp +++ b/src/emu/tilemap.cpp @@ -1457,12 +1457,16 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c // rowscroll and with fixed parameters //------------------------------------------------- -void tilemap_t::draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly) +void tilemap_t::draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly, u32 flags) { // set up for the blit, using hard-coded parameters (no priority, etc) blit_parameters blit; bitmap_ind8 dummy_priority; - configure_blit_parameters(blit, dummy_priority, dest.cliprect(), TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0, 0xff); + + // draw everything + flags |= TILEMAP_DRAW_OPAQUE; + + configure_blit_parameters(blit, dummy_priority, dest.cliprect(), flags, 0, 0xff); // compute the effective scroll positions scrollx = m_width - scrollx % m_width; diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h index 83afd4051c2..c8364f3b931 100644 --- a/src/emu/tilemap.h +++ b/src/emu/tilemap.h @@ -556,7 +556,7 @@ public: void draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); void draw_roz(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); void draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); - void draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly); + void draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly, u32 flags = TILEMAP_DRAW_ALL_CATEGORIES); // mappers // scan in row-major order with optional flipping diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp index 085f2d25d7b..53c3f409488 100644 --- a/src/frontend/mame/ui/viewgfx.cpp +++ b/src/frontend/mame/ui/viewgfx.cpp @@ -88,6 +88,7 @@ struct ui_gfx_state int yoffs; // current Y offset int zoom; // zoom factor uint8_t rotate; // current rotation (orientation) value + uint32_t flags; // render flags } tilemap; }; @@ -158,6 +159,7 @@ void ui_gfx_init(running_machine &machine) // set up the tilemap state state->tilemap.rotate = rotate; + state->tilemap.flags = TILEMAP_DRAW_ALL_CATEGORIES; } @@ -1075,7 +1077,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u // figure out the title std::ostringstream title_buf; - util::stream_format(title_buf, "TILEMAP %d/%d", state.tilemap.which, mui.machine().tilemap().count() - 1); + 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; @@ -1106,6 +1108,9 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u 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()); @@ -1191,6 +1196,31 @@ static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, i state.bitmap_dirty = true; } + // handle flags (category) + if (machine.ui_input().pressed(IPT_UI_PAGE_UP) && state.tilemap.flags != TILEMAP_DRAW_ALL_CATEGORIES) + { + if (state.tilemap.flags > 0) + { + state.tilemap.flags--; + machine.popmessage("Category = %d", state.tilemap.flags); + } + else + { + state.tilemap.flags = TILEMAP_DRAW_ALL_CATEGORIES; + machine.popmessage("Category All"); + } + state.bitmap_dirty = true; + } + if (machine.ui_input().pressed(IPT_UI_PAGE_DOWN) && (state.tilemap.flags < TILEMAP_DRAW_CATEGORY_MASK || (state.tilemap.flags == TILEMAP_DRAW_ALL_CATEGORIES))) + { + if (state.tilemap.flags == TILEMAP_DRAW_ALL_CATEGORIES) + state.tilemap.flags = 0; + else + state.tilemap.flags++; + state.bitmap_dirty = true; + machine.popmessage("Category = %d", state.tilemap.flags); + } + // handle navigation (up,down,left,right), taking orientation into account int step = 8; // this may be applied more than once if multiple directions are pressed if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1; @@ -1252,7 +1282,7 @@ static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, std::swap(width, height); // realloc the bitmap if it is too small - if (state.bitmap == nullptr || state.texture == nullptr || state.bitmap->width() != width || state.bitmap->height() != height) + if (state.bitmap_dirty || state.bitmap == nullptr || state.texture == nullptr || state.bitmap->width() != width || state.bitmap->height() != height) { // free the old stuff machine.render().texture_free(state.texture); @@ -1271,7 +1301,7 @@ static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, if (state.bitmap_dirty) { tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which); - tilemap->draw_debug(*machine.first_screen(), *state.bitmap, state.tilemap.xoffs, state.tilemap.yoffs); + tilemap->draw_debug(*machine.first_screen(), *state.bitmap, state.tilemap.xoffs, state.tilemap.yoffs, state.tilemap.flags); // reset the texture to force an update state.texture->set_bitmap(*state.bitmap, state.bitmap->cliprect(), TEXFORMAT_RGB32); |