diff options
Diffstat (limited to 'src/emu/ui/datmenu.cpp')
-rw-r--r-- | src/emu/ui/datmenu.cpp | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/src/emu/ui/datmenu.cpp b/src/emu/ui/datmenu.cpp index 93c776f3e51..c623c8d1f2c 100644 --- a/src/emu/ui/datmenu.cpp +++ b/src/emu/ui/datmenu.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Dankan1890 +// copyright-holders:Maurizio Petrarota /********************************************************************* ui/datmenu.cpp @@ -22,7 +22,12 @@ // ctor / dtor //------------------------------------------------- -ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver) : ui_menu(machine, container) +ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver) + : ui_menu(machine, container) + , m_actual(0) + , m_driver((driver == nullptr) ? &machine.system() : driver) + , m_issoft(false) + { image_interface_iterator iter(machine.root_device()); for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) @@ -35,7 +40,6 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container m_parent = strensure(image->software_entry()->parentname()); } } - m_driver = (driver == nullptr) ? &machine.system() : driver; init_items(); } @@ -44,17 +48,18 @@ ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container // ctor //------------------------------------------------- -ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, ui_software_info *swinfo, const game_driver *driver) : ui_menu(machine, container) -{ - m_list = swinfo->listname; - m_short = swinfo->shortname; - m_long = swinfo->longname; - m_parent = swinfo->parentname; - m_driver = (driver == nullptr) ? &machine.system() : driver; - m_swinfo = swinfo; - - issoft = true; +ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, ui_software_info *swinfo, const game_driver *driver) + : ui_menu(machine, container) + , m_actual(0) + , m_driver((driver == nullptr) ? &machine.system() : driver) + , m_swinfo(swinfo) + , m_list(swinfo->listname) + , m_short(swinfo->shortname) + , m_long(swinfo->longname) + , m_parent(swinfo->parentname) + , m_issoft(true) +{ if (machine.datfile().has_software(m_list, m_short, m_parent)) m_items_list.emplace_back(_("Software History"), UI_HISTORY_LOAD, machine.datfile().rev_history()); if (swinfo != nullptr && !swinfo->usage.empty()) @@ -78,15 +83,15 @@ void ui_menu_dats_view::handle() const ui_menu_event *m_event = process(MENU_FLAG_UI_DATS); if (m_event != nullptr) { - if (m_event->iptkey == IPT_UI_LEFT && actual > 0) + if (m_event->iptkey == IPT_UI_LEFT && m_actual > 0) { - actual--; + m_actual--; reset(UI_MENU_RESET_SELECT_FIRST); } - if (m_event->iptkey == IPT_UI_RIGHT && actual < m_items_list.size() - 1) + if (m_event->iptkey == IPT_UI_RIGHT && m_actual < m_items_list.size() - 1) { - actual++; + m_actual++; reset(UI_MENU_RESET_SELECT_FIRST); } } @@ -98,13 +103,18 @@ void ui_menu_dats_view::handle() void ui_menu_dats_view::populate() { - machine().pause(); - (issoft == true) ? get_data_sw() : get_data(); + bool paused = machine().paused(); + if (!paused) + machine().pause(); + + (m_issoft == true) ? get_data_sw() : get_data(); item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr); customtop = 2.0f * machine().ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; custombottom = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; - machine().resume(); + + if (!paused) + machine().resume(); } //------------------------------------------------- @@ -116,7 +126,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom ui_manager &mui = machine().ui(); float maxwidth = origx2 - origx1; float width; - std::string driver = (issoft == true) ? m_swinfo->longname : m_driver->description; + std::string driver = (m_issoft == true) ? m_swinfo->longname : 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); @@ -168,25 +178,23 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom 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); + 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; + 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); + 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); + revision.assign(_("Revision: ")).append(m_items_list[m_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); @@ -206,7 +214,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom // 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); + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } //------------------------------------------------- @@ -219,7 +227,7 @@ void ui_menu_dats_view::get_data() std::vector<int> xend; std::string buffer; std::vector<std::string> m_item; - if (m_items_list[actual].option == UI_COMMAND_LOAD) + if (m_items_list[m_actual].option == UI_COMMAND_LOAD) { machine().datfile().command_sub_menu(m_driver, m_item); if (!m_item.empty()) @@ -236,7 +244,7 @@ void ui_menu_dats_view::get_data() } } else - machine().datfile().load_data_info(m_driver, buffer, m_items_list[actual].option); + machine().datfile().load_data_info(m_driver, buffer, m_items_list[m_actual].option); int totallines = machine().ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend); for (int x = 0; x < totallines; ++x) @@ -251,8 +259,7 @@ void ui_menu_dats_view::get_data_sw() std::vector<int> xstart; std::vector<int> xend; std::string buffer; - std::vector<std::string> m_item; - if (m_items_list[actual].option == 0) + if (m_items_list[m_actual].option == 0) buffer = m_swinfo->usage; else { |