diff options
Diffstat (limited to 'src/frontend/mame/ui/selsoft.cpp')
-rw-r--r-- | src/frontend/mame/ui/selsoft.cpp | 115 |
1 files changed, 94 insertions, 21 deletions
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index c5c32303e93..bc8d3267585 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -16,14 +16,17 @@ #include "ui/inifile.h" #include "ui/selector.h" -#include "corestr.h" #include "drivenum.h" #include "emuopts.h" +#include "fileio.h" #include "mame.h" #include "rendutil.h" #include "softlist_dev.h" #include "uiinput.h" #include "luaengine.h" + +#include "corestr.h" +#include "path.h" #include "unicode.h" #include <algorithm> @@ -84,6 +87,8 @@ public: , m_filter_type(software_filter::ALL) , m_swinfo() , m_searchlist() + , m_right_panel(menu.right_panel()) + , m_right_image(menu.right_image()) { // add start empty item m_swinfo.emplace_back(*menu.m_system.driver); @@ -218,7 +223,8 @@ public: } // sort array - std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale()); + std::locale const lcl; + std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl); auto const compare_names = [&coll] (std::string const &x, std::string const &y) -> bool { @@ -344,6 +350,11 @@ public: return m_searchlist; } + u8 right_panel() const { return m_right_panel; } + u8 right_image() const { return m_right_image; } + void set_right_panel(u8 index) { m_right_panel = index; } + void set_right_image(u8 index) { m_right_image = index; } + private: icon_cache m_icons; bool m_has_empty_start; @@ -353,6 +364,9 @@ private: std::vector<ui_software_info> m_swinfo; std::vector<search_item> m_searchlist; + u8 m_right_panel; + u8 m_right_image; + std::unique_ptr<std::thread> m_search_thread; }; @@ -371,8 +385,21 @@ menu_select_software::menu_select_software(mame_ui_manager &mui, render_containe using machine_data_cache = util::lru_cache_map<game_driver const *, std::shared_ptr<machine_data> >; auto &cached(mui.get_session_data<menu_select_software, machine_data_cache>(8)[system.driver]); - if (!cached) + if (cached) + { + // restore last right panel settings for this machine + set_right_panel(cached->right_panel()); + set_right_image(cached->right_image()); + } + else + { + // restore last right panel settings from UI options + ui_options &moptions = ui().options(); + set_right_panel(moptions.software_right_panel()); + set_right_image(moptions.software_right_image()); + cached = std::make_shared<machine_data>(*this); + } m_data = cached; m_filter_highlight = m_data->filter_type(); @@ -394,73 +421,89 @@ menu_select_software::~menu_select_software() // handle //------------------------------------------------- -void menu_select_software::handle(event const *ev) +bool menu_select_software::handle(event const *ev) { - if (m_prev_selected == nullptr) + if (m_prev_selected == nullptr && item_count() > 0) m_prev_selected = item(0).ref(); // FIXME: everything above here used run before events were processed // process the menu + bool changed = false; if (ev) { if (dismiss_error()) { // reset the error on any subsequent menu event + changed = true; } else switch (ev->iptkey) { case IPT_UI_SELECT: if ((get_focus() == focused_menu::MAIN) && ev->itemref) - inkey_select(ev); + changed = inkey_select(ev); break; case IPT_UI_LEFT: - if (ui_globals::rpanel == RP_IMAGES) + if (right_panel() == RP_IMAGES) { // Images - previous_image_view(); + changed = previous_image_view(); } - else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view > 0) + else if (right_panel() == RP_INFOS && ui_globals::cur_sw_dats_view > 0) { // Infos ui_globals::cur_sw_dats_view--; m_topline_datsview = 0; + changed = true; } break; case IPT_UI_RIGHT: - if (ui_globals::rpanel == RP_IMAGES) + if (right_panel() == RP_IMAGES) { // Images - next_image_view(); + changed = next_image_view(); } - else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view < (ui_globals::cur_sw_dats_total - 1)) + else if (right_panel() == RP_INFOS && ui_globals::cur_sw_dats_view < (ui_globals::cur_sw_dats_total - 1)) { // Infos ui_globals::cur_sw_dats_view++; m_topline_datsview = 0; + changed = true; } break; case IPT_UI_UP: if ((get_focus() == focused_menu::LEFT) && (software_filter::FIRST < m_filter_highlight)) + { --m_filter_highlight; + changed = true; + } break; case IPT_UI_DOWN: if ((get_focus() == focused_menu::LEFT) && (software_filter::LAST > m_filter_highlight)) + { ++m_filter_highlight; + changed = true; + } break; case IPT_UI_HOME: if (get_focus() == focused_menu::LEFT) + { m_filter_highlight = software_filter::FIRST; + changed = true; + } break; case IPT_UI_END: if (get_focus() == focused_menu::LEFT) + { m_filter_highlight = software_filter::LAST; + changed = true; + } break; case IPT_UI_DATS: @@ -483,12 +526,12 @@ void menu_select_software::handle(event const *ev) mfav.add_favorite_software(*swinfo); machine().popmessage(_("%s\n added to favorites list."), swinfo->longname); } - else { machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname); mfav.remove_favorite_software(*swinfo); } + changed = true; } } } @@ -497,13 +540,42 @@ void menu_select_software::handle(event const *ev) // if we're in an error state, overlay an error message draw_error_text(); + return changed; +} + +//------------------------------------------------- +// recompute_metrics +//------------------------------------------------- + +void menu_select_software::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu_select_launch::recompute_metrics(width, height, aspect); + + // configure the custom rendering + set_custom_space(4.0F * line_height() + 5.0F * tb_border(), 4.0F * line_height() + 4.0F * tb_border()); +} + +//------------------------------------------------- +// menu_deactivated +//------------------------------------------------- + +void menu_select_software::menu_deactivated() +{ + menu_select_launch::menu_deactivated(); + + // save last right panel settings + m_data->set_right_panel(right_panel()); + m_data->set_right_image(right_image()); + ui_options &mopt = ui().options(); + mopt.set_value(OPTION_SOFTWARE_RIGHT_PANEL, right_panel_config_string(), OPTION_PRIORITY_CMDLINE); + mopt.set_value(OPTION_SOFTWARE_RIGHT_IMAGE, right_image_config_string(), OPTION_PRIORITY_CMDLINE); } //------------------------------------------------- // populate //------------------------------------------------- -void menu_select_software::populate(float &customtop, float &custombottom) +void menu_select_software::populate() { for (auto &icon : m_data->icons()) // TODO: why is this here? maybe better on resize or setting change? icon.second.texture.reset(); @@ -563,15 +635,12 @@ void menu_select_software::populate(float &customtop, float &custombottom) m_displaylist[curitem].get().parentname.empty() ? 0 : FLAG_INVERT, (void *)&m_displaylist[curitem].get()); } - // configure the custom rendering - skip_main_items = 0; - customtop = 4.0f * ui().get_line_height() + 5.0f * ui().box_tb_border(); - custombottom = 4.0f * ui().get_line_height() + 4.0f * ui().box_tb_border(); + m_skip_main_items = 0; if (old_software != -1) { set_selected_index(old_software); - top_line = selected_index() - (ui_globals::visible_sw_lines / 2); + centre_selection(); } reselect_last::reset(); @@ -582,7 +651,7 @@ void menu_select_software::populate(float &customtop, float &custombottom) // handle select key event //------------------------------------------------- -void menu_select_software::inkey_select(const event *menu_event) +bool menu_select_software::inkey_select(const event *menu_event) { ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref; driver_enumerator drivlist(machine().options(), *ui_swinfo->driver); @@ -594,6 +663,7 @@ void menu_select_software::inkey_select(const event *menu_event) if (!audit_passed(sysaudit)) { set_error(reset_options::REMEMBER_REF, make_system_audit_fail_text(auditor, sysaudit)); + return true; } else if (ui_swinfo->startempty == 1) { @@ -602,6 +672,7 @@ void menu_select_software::inkey_select(const event *menu_event) reselect_last::reselect(true); launch_system(*ui_swinfo->driver, *ui_swinfo); } + return false; } else { @@ -617,11 +688,13 @@ void menu_select_software::inkey_select(const event *menu_event) reselect_last::reselect(true); launch_system(drivlist.driver(), *ui_swinfo); } + return false; } else { // otherwise, display an error set_error(reset_options::REMEMBER_REF, make_software_audit_fail_text(auditor, swaudit)); + return true; } } } @@ -703,7 +776,7 @@ void menu_select_software::make_topbox_text(std::string &line0, std::string &lin // determine the text for the header int vis_item = !m_search.empty() ? m_available_items : (m_available_items - 1); line0 = string_format(_("%1$s %2$s ( %3$d / %4$d software packages )"), emulator_info::get_appname(), bare_build_version, vis_item, m_data->swinfo().size() - 1); - line1 = string_format(_("Driver: \"%1$s\" software list "), m_system.description); + line1 = string_format(_("%1$s - select software"), m_system.description); software_filter const *const it(m_data->current_filter()); char const *const filter(it ? it->filter_text() : nullptr); |